SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate consensus sequence with Samtools mpileup? Heisman Bioinformatics 4 10-28-2013 04:57 PM
Blast 2 multifasta files one against the other Kawaccino Bioinformatics 5 06-06-2013 10:56 PM
Generate consensus sequence with samtools mpileup Lilith-Elina Bioinformatics 0 04-08-2013 01:38 AM
Generate consensus sequence from BAM alignment Adam Witney General 2 09-14-2011 02:49 AM
Help needed to generate Consensus from alignment sarbashis Illumina/Solexa 0 08-10-2011 09:58 PM

Reply
 
Thread Tools
Old 11-11-2013, 12:59 PM   #1
Antony03
Member
 
Location: Canada, Quebec

Join Date: Apr 2012
Posts: 53
Default Generate consensus from MultiFasta

Hi,

I have a multifasta like:

>sequence1
ATCGATCATCG
>sequence2
ATCGATNNTCG
>sequence3
ATCGATCATCG

All sequences are the same, except there are some N. I want to make a consensus with the N if there are.

Do you know I can do this?
Thanks!
Antony03 is offline   Reply With Quote
Old 11-13-2013, 04:30 PM   #2
Antony03
Member
 
Location: Canada, Quebec

Join Date: Apr 2012
Posts: 53
Default

A little up!

Please
Antony03 is offline   Reply With Quote
Old 11-13-2013, 06:43 PM   #3
gringer
David Eccles (gringer)
 
Location: Wellington, New Zealand

Join Date: May 2011
Posts: 838
Default

here's my rough 5-minute attempt:
Code:
#!/usr/bin/perl
use warnings;
use strict;
my @sequence = ();
while(<>){
  if(!/^>/){
    chomp;
    my @bases = split(//,$_);
    for(my $i = 0; $i < @bases; $i++){
      if($bases[$i] eq "N"){
        $sequence[$i] = "N";
      } elsif($sequence[$i] ne "N") {
        $sequence[$i] = $bases[$i];
      }
    }
  }
}

print(">consensus\n".join("",@sequence)."\n");
[may not compile, will probably contain bugs, will probably be very slow]
gringer is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 08:37 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO