Thanks. I don't know if I'm missing something but I applied your code to my input and it doesn't result like the given output file.
• 0 views
•
link
Hello everyone, I would like to change allele codes to the reverse complement, this is the file that I have, is composed of Allele 1, Allele2 and Strand Orientation:
A T +
T T +
A T -
C T -
G G -
G C +
A G -
I need to flip only the ones oriented to the minus strand, so the result would be like this:
A T +
T T +
T A +
G A +
C C +
G C +
T C +
The file is tab separated and has arround 580k SNPs, I will really appreciate if you can help me with some nice awk/perl or any code to do that :)
POL:
perl -pe 'tr/ACGT-/TGCA+/ if (/-/)' < SNP.list > SNP.for
sed 's/\(.\)\t\(.\)\t\-$/\2\t\1\t+/' < input.txt
Thanks. I don't know if I'm missing something but I applied your code to my input and it doesn't result like the given output file.
Maybe some awk:
BEGIN{OFS="\t"}
function complement (nuc) {
switch (nuc) {
case /[aA]/:
return "T"
case /[tT]/:
return "A"
case /[cC]/:
return "G"
case /[gG]/:
return "C"
default:
return "N"
}
}
$3 != "-" {print $1, $2, $3}
$3 == "-" {print complement($1), complement($2), "+"}
Saved to a file complement_alleles.awk and run with:
awk -f complement_alleles.awk < input.txt
Log in to answer this question.