Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
mb, a BLAST output file looks like this;Gene: blahblah Query: FDVKHGAHJKHBHXYJTJGHCJHZGJHJJFVJKFG
Here is my attempt below which just doesn't run (p.s i realise that this could be easily achieved using bioperl but i dont want to use that). Error messages especially don't like it when i mention $end_annotation and $start_annotation!! thanks.Query= 8 (545 letters) Database: /ebi/cgg/one/nrdb-filtered/nrdb.filtered 905,591 sequences; 283,075,510 total letters Searching..................................................done Sco +re E Sequences producing significant alignments: (bi +ts) Value /:swiss|P75505|YC71_MYCPN Hypothetical lipoprotein MPN271 precu... 1 +36 2e-31 >/:swiss|P75505|YC71_MYCPN Hypothetical lipoprotein MPN271 precursor (A65_orf251a).//:pironly|S73889|S73889 probable lipoprotein A65_orf251a - Mycoplasma pneumoniae (ATCC 29342) (SGC3)//:gp|AE000055|1674262 conserved hypothetical protein, see: MPN643 [Mycoplasma pneumoniae] Length = 251 Score = 136 bits (340), Expect = 2e-31 Identities = 72/121 (59%), Positives = 88/121 (72%), Gaps = 1/121 (0% +) Frame = -3 Query: 363 KRSFYQELPLLLWFLLLGTVLSACSKVESTKSVHPVKSFKSDLKSLLKETIKQDIDLSK +T 184 K+ F FLL GT+LSAC+ +++ DL++L+KET +DIDLSK Sbjct: 3 KKKFLSRFSFSSLFLLCGTLLSACTGIQA------------DLRNLIKETTGKDIDLSK +A 50
#! /usr/local/bin/perl -w use strict; my $start_annotation; my $end_annotation; my %alignments = (); my $filename = 'strept_blastx.output'; parse_blast (\$start_annotation, \$end_annotation, \%alignments, $file +name); print $start_annotation; sub get_file_data { my ($filename) = @_; my @filedata = (); unless(open (GET_FILE_DATA, $filename)) { print STDERR "cant open file \"$filename\"\n\n"; exit; } @filedata = <GET_FILE_DATA>; close GET_FILE_DATA; return @filedata; } foreach my $key (keys %alignments) { print "$key\nxxxxxxxxx\n", $alignments{key}, "\nxxxxxxxxxx\n"; } print $end_annotation; exit; sub parse_blast { my ($start_annotation, $end_annotation, $alignments, $filename) = @_; my $blast_output_file = ''; my $alignment_section = ''; $blast_output_file = join('', get_file_data ($filename)); ($$start_annotation, $alignment_section, $$end_annotation) = ($blas +t_output_file =~/(.*^ALIGNMENTS\n)(.*)(^ Database:.*)/ms); %alignments = parse_blast_alignment ($alignment_section); } sub parse_blast_alignment { my($alignment_section) = @_; my (%alignment_hash) =(); while ($alignment_section =~ /^>.*\n(^(?!>).*\n)+/gm) { my ($value) = $&; my ($key) = (split(/\|/, $value)) [1]; $alignment_hash{$key} = $value; } return %alignment_hash; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: parsing BLAST output
by Hofmator (Curate) on May 31, 2002 at 13:10 UTC | |
|
Re: parsing BLAST output
by marvell (Pilgrim) on May 31, 2002 at 11:05 UTC | |
|
Re: parsing BLAST output
by indapa (Monk) on May 31, 2002 at 18:01 UTC | |
|
Re: parsing BLAST output
by mrbbking (Hermit) on May 31, 2002 at 12:34 UTC |