This looks like a multi-fasta file holding DNA or protein sequence data (with sequence ID after the >). I use one of the following two ways to get this info into an array before piping into blast or other sequence manipulations.
The first is a loop from some hand-me-down code that works quite well (but any comments etc on optimization etc v. welcome...)
open( FASTAFILE, $ARGV[0] );
while (<FASTAFILE>) {
if ( /^>/ && $seqflag == 1 ) {
push ( @sequences, $fasta );
$fasta = "";
$fasta = $_;
}
elsif (/^>/) {
$fasta = $_;
$seqflag = 1;
}
else {
$fasta .= $_;
}
}
push ( @sequences, $fasta );
#then iterate @sequences to run over BLAST
The other (better?) way is the very nice
Bioperl modules that have methods that specifically handle multifasta flat files. Also check out
EMBOSS, a sequence analysis suite that interfaces with BioPerl...EMBOSS + BioPerl makes life sooo much easier...
From the
bioperl tutorial...
# script 1: create the index
use Bio::Index::Fasta; # using fasta file format
$Index_File_Name = shift;
$inx = Bio::Index::Fasta->new(
-filename => $Index_File_Name,
-write_flag => 1);
$inx->make_index(@ARGV);
# script 2: retrieve some files
use Bio::Index::Fasta;
$Index_File_Name = shift;
$inx = Bio::Index::Fasta->new($Index_File_Name);
foreach $id (@ARGV) {
$seq = $inx->fetch($id); # Returns Bio::Seq object
# do something with the sequence
}
Hope this helps,
tandemrepeat
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.