X BOL wishing you a very and Happy New year

Alternative content

Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Perl script to extract sequence by Ids from multifasta file !

#!/usr/bin/perl -w use strict; my $idsfile = "$ARGV[0]"; my $seqfile = "$ARGV[1]"; my %ids = (); open FILE, $idsfile; while(<FILE>) { chomp; $ids{$_} += 1; } close FILE; local $/ = "\n>"; # read by FASTA record open FASTA, $seqfile; while (<FASTA>) { chomp; my $seq = $_; my ($id) = $seq =~ /^>*(\S+)/; # parse ID as first word in FASTA header if (exists($ids{$id})) { $seq =~ s/^>*.+\n//; # remove FASTA header $seq =~ s/\n//g; # remove endlines print ">$id\n$seq\n"; } } close FASTA;