View Single Post
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