Fetching Fasta: Difference between revisions

From RAJ INFO
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
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
* Fetching Fasta as separate components
* Fetching Fasta as separate components
<pre>
<source lang=perl>
#!/usr/bin/perl -w
#!/usr/bin/perl -w


Line 43: Line 43:
`rm tempfile`;
`rm tempfile`;
#END
#END
</pre>
</source>
[[Category:Bioinformatics]]

Latest revision as of 18:49, 3 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