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

View of /FigMetagenomeTools/separatemultifasta.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.1 - (download) (as text) (annotate)
Mon Feb 19 17:15:26 2007 UTC (13 years, 3 months ago) by olson
Branch point for: x, MAIN
Initial revision

#!/usr/bin/perl -w

# rewritten with BioPerl

use strict;
use Bio::SeqIO;

my $file=shift || die "$0 <fasta file>";
my $dir=$file.".files";
if (-e $dir) {die "$dir already exists. Not overwriting"}
else {mkdir $dir, 0755}

my %seen;
my $sio=Bio::SeqIO->new(-file=>$file, -format=>"fasta");
while (my $seq=$sio->next_seq)
 my $id=$seq->id;
 $id =~ s/\s+/_/g;
 while ($seen{$id}) {print "$id already written, "; $id.="1"; print " now trying $id\n"}
 my $fout=Bio::SeqIO->new(-file=>">$dir/$id.fasta", -format=>"fasta");

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3