Question: Changing To Reverse Complementary Snp Nucleotides
0
gravatar for bibb77
5.6 years ago by
bibb7750
Chile
bibb7750 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.3k views
ADD COMMENTlink modified 5.6 years ago by JC7.6k • written 5.6 years ago by bibb7750
2
gravatar for JC
5.6 years ago by
JC7.6k
Mexico
JC7.6k wrote:

POL:

perl -pe 'tr/ACGT-/TGCA+/ if (/-/)' < SNP.list > SNP.for
ADD COMMENTlink written 5.6 years ago by JC7.6k
0
gravatar for Rob Syme
5.6 years ago by
Rob Syme530
Perth, Western Australia
Rob Syme530 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 5.6 years ago • written 5.6 years ago by Rob Syme530
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: 1278 users visited in the last hour