...
Code Block | ||
---|---|---|
| ||
mu_sigma=$(grep "^-- mu length = [0-9]*, sigma length = [0-9]*$" preprocessing_results.txt | \ sed -E 's/-- mu length = ([0-9]+), sigma length = ([0-9]+)/\1,\2/'); \ mu=$(echo $mu_sigma | cut -d "," -f 1); \ sigma=$(echo $mu_sigma | cut -d "," -f 2); \ sed -i -E "s/mu_length=unknown1/mu_length=$mu/" svdetect.conf; \ sed -i -E "s/sigma_length=unknown2/sigma_length=$sigma/" svdetect.conf |
Note that the above is considered a '1-liner' even though it is spread across 6 lines for clarity. When \ is encountered at the end of the line the command line waits until it reaches the end of a line without finding a "\" before executing anything. As the following commands will take a few minutes each and must be completed in order, launch them in order, but read ahead as to what values in our svdetect.conf file are critical to analysis, and why we picked the values we did.
...
Expand title Critical values and their choice option value reason mu_length 2223 this is taken directly from the preprocessing perl script, it enables classification of the different discordant read mappings sigma_length 1122 Again taken from the preprocessing perl script, it enables classification of the different discordant read mappings window_size 5000 Must be set to at least 2mu + (2sigma)0.5 to enable balance classification (4540 would be minimum value in this case) step_length 2500 Documentation suggests this be 25-50% of the window size, smaller sizes enable more precise endpoint determination. strand; insert size; ordering_filtering 1 Setting each to 1 turns on such filtering, absent being listed, or being listed as 0, these tests would not run You may also consult the manual for a full description of what the commands and options inside of the svdetect.conf file.
Expand title Click here for a breakdown of what this one liner is doing First lets break this one liner down into its 6 parts:
Code Block linenumbers true mu_sigma=$(grep "^-- mu length = [0-9]*, sigma length = [0-9]*$" preprocessing_results.txt | \ sed -E 's/-- mu length = ([0-9]+), sigma length = ([0-9]+)/\1,\2/'); \ mu=$(echo $mu_sigma | cut -d "," -f 1); \ sigma=$(echo $mu_sigma | cut -d "," -f 2); \ sed -i -E "s/mu_length=unknown1/mu_length=$mu/" svdetect.conf; \ sed -i -E "s/sigma_length=unknown2/sigma_length=$sigma/" svdetect.conf
- Line 1 uses grep on the preprocessing_results.txt file looking for any line that matches "^-- mu length = [0-9]*, sigma length = [0-9]*$" and stores it in a variable mu_sigma.
- mu_sigma=$(......) stores everything between the () marks in a command line variable named mu_sigma ... you should notice that the closing ) mark is actually on line 2
- the | at the end of the line is the "pipe" command which passes the output to the next command (line in this case as we have broken the command up into parts)
- Line 2 uses the sed command to delete everything that is not a number or , and finishes storing the output in the mu_sigma variable
- sed commands can be broken down as follows: 's/find/replace/'
- in this case, find:
- -- mu length = ([0-9]+), sigma length = ([0-9]+)
- where :
- [0-9] is any number
- the + sign means find whatever is to the left 1 or more times
- and things between () should be remembered for use in the replace portion of the command
- likewise, in this case, replace:
- \1,\2/
- where
- \1 means whatever was between the first set of () marks in the find portion
- , is a literal comma
- \2 means whatever was between the sescond set of () marks in the find portion
- in this case, find:
- at the end of line 2 we now have a new variable named mu_sigma with a value of "2223,1122"
- sed commands can be broken down as follows: 's/find/replace/'
- Line 3 creates a new variable named mu and gives it the value of whatever is to the left of the first , it finds.
- echo $mu_sigma |
- pass the value of $mu_sigma to whatever is on the other side of |
- cut -d "," -f 1
- divide whatever the cut command sees at all the "," marks and then print whatever is to the left of the 1st
- at the end of line 3 we now have a variable named mu with the value "2223"
- echo $mu_sigma |
- Line 4 does the same thing as line 3 except for a variable named sigma, and takes whatever is between the 2nd comma and 3rd comma (since we only have 1 comma, its taking whatever comes after the comma)
- at the end of line 4 we now have a variable named sigma with the value "1122"
- Line 5 looks through the entire svdetect.conf file looking for a line that matches mu_length=unknown1 and replaces all that text with mu_length=$mu (except the computer knows $mu is the variable with the value 2223.
- the -i option tells the sed command to do the replacement in place meaning you are changing the contents of the file
- the "" marks tell the command line that you want to evaluate whatever is between the ""marks, in this case, the mu variable
- at the end of line 5, our svdetect.conf file line 23 now reads mu_length=2223
- Line 5 looks through the entire svdetect.conf file looking for a line that matches sigma_length=unknown2 and replaces all that text with sigma_length=$sigma (except the computer knows $sigma is the variable with the value 1122.
- the -i option tells the sed command to do the replacement in place meaning you are changing the contents of the file
- the "" marks tell the command line that you want to evaluate whatever is between the ""marks, in this case, the sigma variable
- at the end of line 5, our svdetect.conf file line 24 now reads sigma_length=1122
- Line 1 uses grep on the preprocessing_results.txt file looking for any line that matches "^-- mu length = [0-9]*, sigma length = [0-9]*$" and stores it in a variable mu_sigma.
...