2 # -*-Perl-*- mode (for emacs)
6 bp_seqret - bioperl implementation of sequence fetch from local db (like EMBOSS seqret)
10 bp_seqret [-f/--format outputformat] [-o/--out/--outfile outfile] [-d/--db dbname] [-i/--id/-s/--seqname seqname1]
14 bp_seqret -f fasta -db db.fa -i seq1 -i seq2 > output.fas
15 bp_seqret db.fa:seq1 output.fas
16 bp_seqret db.fa:seq1 -o output.fas
17 bp_seqret -db db.fa -o output.fas seq1 seq2 seq3
18 bp_seqret -db db.fa seq1 seq2 seq3 output.fas
19 bp_seqret -db db.fa seq1 seq2 seq3 - > output.fas
21 The DB is expected to be a Fasta formatted sequence file with multiple
24 Output format is Fasta by default.
26 If no output filename is provided then output is written to STDOUT.
27 Providing '-' as the output filename will accomplish the same thing.
32 Jason Stajich jason_AT_bioperl-dot-org
48 'f|format:s' => \
$format,
49 'o|out|outfile:s' => \
$outfile,
50 's|sbegin|begin|start:s' => \
$start,
51 'e|send|end|stop:s' => \
$end,
52 'd|db|dbname:s' => \
$dbname,
53 'i|id|seqname:s' => \
@names);
57 die "need a dbname\n" unless @ARGV;
58 $dbname = shift @ARGV;
59 if( $dbname =~ s/^([^:]+):// ) {
65 my $db = Bio
::DB
::Fasta
->new($dbname, -glob => "*.{fa,fas,fsa,fasta,pep,aa,seq,cds,peps}");
71 $out = Bio
::SeqIO
->new(-format
=> $format,
72 -file
=> ">$outfile");
74 $out = Bio
::SeqIO
->new(-format
=> $format);
76 for my $nm ( @names ) {
78 if( $start || $end ) {
79 $seq = $db->seq($nm, $start => $end);
84 my ($id,$desc) = split(/\s+/,$db->header($nm),2);
85 if( $start && $end ) {
86 $id = sprintf("%s_%d-%d",$id,$start || 0,$end || 0);
89 $out->write_seq(Bio
::PrimarySeq
->new(-display_id
=> $id,
90 -description
=> $desc,
93 warn("$nm not found\n");