Fetching Fasta: Difference between revisions
Jump to navigation
Jump to search
m New page: * Fetching Fasta as separate components <pre> #!/usr/bin/perl -w #---------------------------- # Description # Remmoves the new line if exists in multifasta ignoring the sequence identifi... |
mNo edit summary |
||
| Line 1: | Line 1: | ||
* Fetching Fasta as separate components | * Fetching Fasta as separate components | ||
< | <source lang=perl> | ||
#!/usr/bin/perl -w | #!/usr/bin/perl -w | ||
| Line 43: | Line 43: | ||
`rm tempfile`; | `rm tempfile`; | ||
#END | #END | ||
</ | </source> | ||
Revision as of 18:03, 1 January 2010
- Fetching Fasta as separate components
#!/usr/bin/perl -w
#----------------------------
# Description
# Remmoves the new line if exists in multifasta ignoring the sequence identifier
# Usage: Type infilename and Capture the output
#--------------------------------
# Use of functions
use strict;
use Bio::SeqIO;
# Variables
my $argcount = @ARGV;
if ($argcount !=1 ) {die "\n\t ->Usage: Type infile!\n\n";}
my ($infile,$outfile) = @ARGV;
my @seq;
# Function
chomp($infile);
my $input = `cat $infile`;
$input =~ s/[\"|(|)|:]//g;
$input =~ s/Note //g;
$input =~ s/[ ]+/_/g;
open(TEMP, ">tempfile");
print TEMP $input;
close TEMP;
my $in = Bio::SeqIO->new(-file => "tempfile", -format => 'Fasta');
my $identifier;
my $sequence;
while ( my $seq = $in->next_seq() ) {
$identifier = $seq->id;
$sequence = $seq->seq;
print ">$identifier\n$sequence\n";
}
`rm tempfile`;
#END