FAST
view release on metacpan or search on metacpan
lib/FAST/Bio/SearchIO/erpin.pm view on Meta::CPAN
'Data' => $1}
);
} elsif ($line =~ m{^Cutoff:\s+(\S+)}xmso) {
$self->element(
{'Name' => 'Parameters_cutoff',
'Data' => $1}
);
} elsif ($line =~ m{^Database:\s+"(.*)"}xmso) {
$self->element(
{'Name' => 'ERPIN_db',
'Data' => $1}
);
} elsif ($line =~ m{^\s+(\d+)\snucleotides\sto\sbe\sprocessed\sin\s(\d+)\ssequences}xmso) {
$self->element_hash(
{'ERPIN_db-len' => $2,
'ERPIN_db-let' => $1}
);
} elsif ($line =~ m{^E-value\sat\scutoff\s\S+\sfor\s\S+\sdouble\sstrand\sdata:\s+(\S+)}xmso) {
$self->element(
{'Name' => 'Parameters_expect',
'Data' => $1}
);
} elsif ($line =~ m{^\s+(ATGC\sratios:\s+(?:\S+\s+\S+\s+\S+\s+\S+))}) {
$self->element(
{'Name' => 'Statistics_db-let',
'Data' => $1}
);
}
}
} elsif ($line =~ m{^>(\S+)\s+(.*)}xmso ) {
my ($id, $desc) = ($1, $2);
chomp $desc;
# desc line is repeated for each strand, so must check
# prior to starting a new hit
if (!$lasthit || $id ne $lasthit) {
if ($self->within_element('hit') ) {
$self->element_hash({
'Hit_signif' => $lasteval,
'Hit_score' => $lastscore,
'Hit_bits' => $lastscore
});
$self->end_element({'Name' => 'Hit'});
}
$self->start_element({'Name' => 'Hit'});
my ($gi, $acc, $ver) = $self->_get_seq_identifiers($id);
$self->element_hash({
'Hit_id' => $id,
'Hit_gi' => $gi,
'Hit_accession' => $ver ? "$acc.$ver" :
$acc ? $acc : $id,
'Hit_def' => $desc
});
}
$lasthit = $id;
} elsif ( (index($line, 'FW') == 0) || (index($line, 'RC') == 0)) {
my ($str, $hn, $pos, $score, $eval) = split ' ', $line;
if ($minscore < $score) {
$self->start_element({'Name' => 'Hsp'});
my ($start, $end) = split m{\.\.}, $pos, 2;
($start, $end) = ($end, $start) if ($str eq 'RC');
$line = $self->_readline;
chomp $line;
$self->element_hash({
'Hsp_stranded' => 'HIT',
'Hsp_hit-from' => $start,
'Hsp_hit-to' => $end,
'Hsp_score' => $score,
'Hsp_bit-score' => $score,
'Hsp_evalue' => $eval,
'Hsp_query-from' => 1,
'Hsp_query-to' => length($line),
'Hsp_align-len' => length($line),
'Hsp_hseq' =>$line
});
$self->end_element({'Name' => 'Hsp'});
$lastscore = $score if (!$lastscore || $lastscore < $score);
$lasteval = $eval if (!$lasteval || $lasteval > $eval);
}
} else {
#$self->debug("Dropped data: $line");
}
}
if ($seentop) {
if ($self->within_element('hit')) {
$self->element_hash({
'Hit_signif' => $lasteval,
'Hit_score' => $lastscore,
'Hit_bits' => $lastscore
});
$self->end_element({'Name' => 'Hit'});
}
$self->end_element({'Name' => 'Result'});
}
return $self->end_document();
}
=head2 start_element
Title : start_element
Usage : $eventgenerator->start_element
Function: Handles a start element event
Returns : none
Args : hashref with at least 2 keys 'Data' and 'Name'
=cut
sub start_element {
my ( $self, $data ) = @_;
# we currently don't care about attributes
my $nm = $data->{'Name'};
my $type = $MODEMAP{$nm};
if ($type) {
if ( $self->_eventHandler->will_handle($type) ) {
my $func = sprintf( "start_%s", lc $type );
$self->_eventHandler->$func( $data->{'Attributes'} );
}
unshift @{ $self->{'_elements'} }, $type;
}
( run in 0.623 second using v1.01-cache-2.11-cpan-71847e10f99 )