Hello everyone,

I got a few flanking sequences around a bunch of SNPs. Since they were export from biomart, the variant allele was like a _:

    >2|28804|28804|rs544393009|dbSNP|C/T
      TGCAT_TCAGC
    >2|29358|29358|rs943169482|dbSNP|G/GAAAA
      CCCAA_AAGCC
    >2|28396|28396|rs781239227|dbSNP|T/C
      AATGC_CTTGG

Can some experts help me to replace the _ in each fasta sequence with its header description? That is each fasta input will be turned in 2 or 3 flanking sequence:

    >2|28804|28804|rs544393009|dbSNP|C
      TGCATCTCAGC
    >2|28804|28804|rs544393009|dbSNP|T
      TGCATTTCAGC
And that is what I am desperately seeking for!!!

Thanks in advance! 





This was somewhat difficult and posed a challenge. Originally I started with just `sed` and `awk` but it got very complex with them.

Nevertheless, if the format of your input file is *VERY* consistent, the following should work (assuming your input is in *snps.txt*):

    paste <(cut -f1 -d_ snps.txt  | sed 's/\/[ATGC]* / /g') <(sed 's/[0-9XY]*|[0-9]*|[0-9]*|rs[0-9]*|dbSNP|//g' snps.txt | sed 's/\/[ATGC]* [ATGC]*_[ATGC]*//g') <(cut -f2 -d_ snps.txt) -d ""

    2|28804|28804|rs544393009|dbSNP|C TGCATCTCAGC
    2|29358|29358|rs943169482|dbSNP|G CCCAAGAAGCC
    2|28396|28396|rs781239227|dbSNP|T AATGCTCTTGG

...or, to break it down a bit:

    sed 's/[0-9XY]*|[0-9]*|[0-9]*|rs[0-9]*|dbSNP|//g' snps.txt | sed 's/\/[ATGC]* [ATGC]*_[ATGC]*//g' > RefAlleles.list
    paste <(cut -f1 -d_ snps.txt  | sed 's/\/[ATGC]* / /g') <(cat RefAlleles.list) <(cut -f2 -d_ snps.txt) -d ""


