Question: Changing To Reverse Complementary Snp Nucleotides
0
gravatar for bibb77
6.2 years ago by
bibb7780
Chile
bibb7780 wrote:

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 :)

snp • 2.5k views
ADD COMMENTlink modified 6.2 years ago by JC8.7k • written 6.2 years ago by bibb7780
2
gravatar for JC
6.2 years ago by
JC8.7k
Mexico
JC8.7k wrote:

POL:

perl -pe 'tr/ACGT-/TGCA+/ if (/-/)' < SNP.list > SNP.for
ADD COMMENTlink written 6.2 years ago by JC8.7k
0
gravatar for Rob Syme
6.2 years ago by
Rob Syme540
Perth, Western Australia
Rob Syme540 wrote:

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
ADD COMMENTlink modified 6.2 years ago • written 6.2 years ago by Rob Syme540
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2017 users visited in the last hour