Fetching Fasta
Jump to navigation
Jump to search
- 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