Dear all,
i have a blast output file and need to add a column for strand infromation (+ or -). For example,
gene1 contig2 1 69 100 169
gene2 contig20 3 53 250 200
i need to change it to
gene1 contig2 1 69 100 169 +
gene2 contig20 3 53 250 200 -
note: 100<169 +, 250>200 -
i am new in perl programming. my command is $ cat a.txt | perl -e 'while (<>){chomp; @array = split(//, $_); if ($array[4]< $array[5]){print"@array\t+\n"} else {print"@array\t-\n"} }'
The output is
g e n e - c o n t i g 2 1 6 9 1 0 0 1 6 9
g e n e - c o n t i g 2 0 3 5 3 2 5 0 2 0 0
Could anyone help to correct the errors and briefly describe it? Thank you very much!!
try: replace
@array = split(//, $_);
with@array = split(/\s/, $_);
or simply@array = split;
thank you very much for correction.