Bio-FastParsers
view release on metacpan or search on metacpan
lib/Bio/FastParsers/Blast/Table.pm view on Meta::CPAN
my $self = shift;
open my $fh, '<', $self->file; # autodie
return sub { <$fh> }; # return closure
}
## use critic
my @attrs = qw(
query_id hit_id
percent_identity hsp_length mismatches gaps
query_from query_to
hit_from hit_to
evalue bit_score
query_strand
hit_strand
query_start query_end
hit_start hit_end
); # DID try to use MOP to get HSP attrs but order was not preserved
lib/Bio/FastParsers/Blast/Table/Hsp.pm view on Meta::CPAN
is => 'ro',
isa => 'Str',
required => 1,
) for qw(query_id hit_id);
has $_ => (
is => 'ro',
isa => 'Num',
required => 1,
) for qw(
percent_identity hsp_length mismatches gaps
query_from query_to
hit_from hit_to
query_strand
hit_strand
query_start query_end
hit_start hit_end
);
has $_ => (
is => 'ro',
lib/Bio/FastParsers/Blast/Table/Hsp.pm view on Meta::CPAN
Returns the id of the query sequence.
This method does not accept any arguments.
=head2 hit_id
Returns the id of the hit (or subject) sequence.
This method does not accept any arguments.
=head2 percent_identity
Returns the identity (in percents) of the HSP.
This method does not accept any arguments.
=head2 hsp_length
Returns the length (in nt or aa) of the HSP.
This method does not accept any arguments.
=head2 mismatches
lib/Bio/FastParsers/Blast/Xml/Hsp.pm view on Meta::CPAN
return shift->query_coverage
}
sub scov {
return shift->subject_coverage
}
sub pident {
return shift->percentage_identity
}
sub ppos {
return shift->percentage_positive
}
sub query_len {
return shift->_parent->query_len
}
lib/Bio/FastParsers/Blast/Xml/Hsp.pm view on Meta::CPAN
sub subject_coverage {
my $self = shift;
return sprintf("%.1f",
100 * ( $self->hit_end - $self->hit_start + 1 ) / $self->hit_len
);
}
sub percentage_identity {
my $self = shift;
return sprintf("%.1f", 100 * ( $self->identity / $self->align_len ) );
}
sub percentage_positive {
my $self = shift;
return sprintf("%.1f", 100 * ( $self->positive / $self->align_len ) );
}
__PACKAGE__->meta->make_immutable;
1;
__END__
lib/Bio/FastParsers/Blast/Xml/Hsp.pm view on Meta::CPAN
=head2 subject_coverage
Returns the subject (hit) coverage of the HSP.
# $hsp is a Bio::FastParsers::Blast::Xml::Hsp
my $subject_coverage = $hsp->subject_coverage;
This method does not accept any arguments.
=head2 percentage_identity
Returns the percentage of identity of the HSP.
# $hsp is a Bio::FastParsers::Blast::Xml::Hsp
my $percentage_identity = $hsp->percentage_identity;
This method does not accept any arguments.
=head2 percentage_positive
Returns the percentage of positive matches of the HSP.
# $hsp is a Bio::FastParsers::Blast::Xml::Hsp
my $percentage_positive = $hsp->percentage_positive;
This method does not accept any arguments.
=head1 ALIASES
=head2 expect
Alias for C<evalue> method. For API consistency.
=head2 qcov
Alias for C<query_coverage> method. For API consistency.
=head2 scov
Alias for C<subject_coverage> method. For API consistency.
=head2 pident
Alias for C<percentage_identity> method. For API consistency.
=head2 ppos
Alias for C<percentage_positive> method. For API consistency.
=head2 query_len
Alias for C<query_len> method in Hit object. For API completeness.
=head2 hit_len
Alias for C<len> method in Hit object. For API completeness.
=head1 AUTHOR
lib/Bio/FastParsers/Uclust.pm view on Meta::CPAN
LINE:
while (my $line = <$in>) {
chomp $line;
my ($type, @fields) = split /\t/xms, $line;
# https://www.drive5.com/usearch/manual/opt_uc.html
# Field Description
# - Record type S, H, C or N (see table below).
# 0 Cluster number (0-based).
# 1 Sequence length (S, N and H) or cluster size (C).
# 2 For H records, percent identity with target.
# 3 For H records, the strand: + or - for nucleotides, . for proteins.
# 4 Not used, parsers should ignore this field. Included for backwards compatibility.
# 5 Not used, parsers should ignore this field. Included for backwards compatibility.
# 6 Compressed alignment or the symbol '=' (equals sign). The = indicates that the query is 100% identical to the target sequence (field 10).
# 7 Label of query sequence (always present).
# 8 Label of target sequence (H records only).
if ($type eq 'C') {
push @{ $members_for{ $fields[7] } }, ();
}
t/blast_table.t view on Meta::CPAN
]
);
sub check_hsps {
my $infile = shift;
my $exp_hsps_ref = shift;
my @methods = qw(
query_id hit_id
percent_identity hsp_length mismatches gaps
query_from query_to
hit_from hit_to
evalue bit_score
query_strand
hit_strand
query_start query_end
hit_start hit_end
);
ok my $report = $class->new( file => $infile ), 'Blast::Table constructor';
t/blast_table.t view on Meta::CPAN
sub check_hits {
my $infile = shift;
my $exp_hsps_ref = shift;
my $report = $class->new( file => $infile );
while ( my $exp_hsp = shift @{ $exp_hsps_ref } ) {
my $hsp = $report->next_hit;
cmp_deeply [ $hsp->query_id, $hsp->hit_id, $hsp->percent_identity + 0 ],
$exp_hsp, 'got expected next hit';
}
return;
}
sub check_queries {
my $infile = shift;
my $exp_hsps_ref = shift;
my $report = $class->new( file => $infile );
while ( my $exp_hsp = shift @{ $exp_hsps_ref } ) {
my $hsp = $report->next_query;
cmp_deeply [ $hsp->query_id, $hsp->hit_id, $hsp->percent_identity + 0 ],
$exp_hsp, 'got expected next query';
}
return;
}
# TODO: test multi-query reports
done_testing;
t/blast_xml.t view on Meta::CPAN
];
my @hsp_data = map {
$_->query_strand, $_->hit_strand,
$_->query_start, $_->query_end,
$_->hit_start, $_->hit_end,
$_->query_frame, $_->query_from, $_->query_to,
$_->hit_frame, $_->hit_from, $_->hit_to,
$_->query_len, $_->hit_len,
$_->qcov, $_->subject_coverage,
$_->pident, $_->percentage_positive
} map { $_->get_hsp(27) } $bo->get_iteration(0)->get_hit(0);
cmp_deeply \@hsp_data, $hsp_data_ref,
'got expected coordinates for hsp 27';
}
sub check_file {
my %args = @_;
( run in 0.485 second using v1.01-cache-2.11-cpan-709fd43a63f )