I have two input files (given below) and to compare each line of the File1 with each line of File2 starts with '>sample1'. If a match occurs and that matched line in the File2 contains another line or sequence of lines starting with "Chr" they have to be displayed in output file with that sample. If a match occurs and the matched line in File2 does not contain a 'Chr' line(s) it has be omitted or not taken into consideration for output file. For easy understanding, I marked the matched lines in file1 and file2 with blue color which are taken into consideration for final output. I maked the matched lines in file1 with file2 (which doesnt contain 'Chr' lines) in red color which are not taken into account for output. The final output to be selected also given below. PLS. KINDLY HELP ME FOR THE SHELL SCRIPTING OF THIS. [/COLOR
is the format of your input data. Again, I'll assume that this data is in a file, as opposed to a pipe stream.
In the shell, you'd read a file like so -
$
$ # display the content of the file. My file is called "f32", yours may be different.
$ cat f32
Chr18:4000-4010
Chr20:393939-400303
Chr30:38838-30020
$
$ # read data from input file "f32"
$ while read LINE; do echo "Oh my! I've now read this line => $LINE"; done < f32
Oh my! I've now read this line => Chr18:4000-4010
Oh my! I've now read this line => Chr20:393939-400303
Oh my! I've now read this line => Chr30:38838-30020
$
$
while read LINE;
do echo "$LINE";
samtools faidx Bos_taurusUMD3.fa "$line";
done < data1
It has to read a line like Chr8:4000-4500 from input file and that line has to be executed in a command like 'samtools faidx Bos_taurusUMD3.fa
Chr8:4000-4500'. Then I will get the sequence like this.
>Chr8:4000-4500
TAATTCGTTTTTCTTTTTTCCTCTCTGACTCATTTATTTGTACCATTCTATCTTCTAATT
CACTAATCTTATCTTCTGCCTCTGTTATTCTACTATTTGTCGCCTCCAGAGTGTTTTTGA
TCTCATTTATTGCATTATTCATTATATATTGACTCTTTTTTATGTCTTCTAGGTCCTTGT
TAAACCTTTCTTGCATCTTCTCAATCCTTGTCTCCAGGTTATTTATCTGTGATTCCATTT
TGATTTCAAGATTTTGGATCAATTTCACTATCATTATTCAGAATTCTTTATCAGGTAGAT
TCCTTATCTCTTCCTCTTTTGTTTTGTTTGGTGGGCATTTATCCTGTTCCTTTACCTGCT
GGGTATTCCTCTGTCTCTTCATCTTGTTTATATTGCTGAGTTTGGGGTGTCCTTTCTGTA
TTCTGGCAGTTTGTGGAGTTCTCTTTATTGTGGAGTTTCCTCGCTGTGTATGGGTTTGTA
CAGGTGGCTTGTCAAGGTTTC
but when I execute the shell it is displaying the output like this
Chr8:4000-4500
>
Chr10:4000-4600
>
but not displaying the sequence.but I execute the command at $ prompt like
$samtools faidx Bos_taurusUMD3.fa Chr8:4000-4500
it is running and displaying the sequence.
How to execute it in my shell by reading each line from input line, execute it in command and display the sequences.
KINDLY HELP ME