[Bio] / FigMetagenomeTools / separatemultifasta.pl Repository:
ViewVC logotype

Annotation of /FigMetagenomeTools/separatemultifasta.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (view) (download) (as text)

1 : olson 1.1 #!/usr/bin/perl -w
2 :    
3 :     # rewritten with BioPerl
4 :    
5 :     use strict;
6 :     use Bio::SeqIO;
7 :    
8 :     my $file=shift || die "$0 <fasta file>";
9 :     my $dir=$file.".files";
10 :     if (-e $dir) {die "$dir already exists. Not overwriting"}
11 :     else {mkdir $dir, 0755}
12 :    
13 :     my %seen;
14 :     my $sio=Bio::SeqIO->new(-file=>$file, -format=>"fasta");
15 :     while (my $seq=$sio->next_seq)
16 :     {
17 :     my $id=$seq->id;
18 :     $id =~ s/\s+/_/g;
19 :     while ($seen{$id}) {print "$id already written, "; $id.="1"; print " now trying $id\n"}
20 :     my $fout=Bio::SeqIO->new(-file=>">$dir/$id.fasta", -format=>"fasta");
21 :     $seen{$id}=1;
22 :     $fout->write_seq($seq);
23 :     }
24 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3