| 1 | package Bio::Gonzales::Seq::Filter; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | our ( @EXPORT, @EXPORT_OK, %EXPORT_TAGS ); | |||||||||||||||||||||||||||
| 12 | 1 | our $VERSION = '0.062'; # VERSION | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | @EXPORT = qw(); | |||||||||||||||||||||||||||
| 15 | 1 | %EXPORT_TAGS = (); | |||||||||||||||||||||||||||
| 16 | 1 | @EXPORT_OK = qw(clean_peptide_seq clean_dna_seq clean_rna_seq clean_pep_seq); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | sub clean_pep_seq { | ||||||||||||||||||||||||||||
| 19 | 1 | ▶ | my ( $seqs, $config ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
clean_pep_seq: called CC=15 SCAR=35.0
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | $seqs = [$seqs] if ( blessed($seqs) && $seqs->isa('Bio::Gonzales::Seq') ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($seqs) and $seqs->isa("Bio::Gonzales::Seq")
MC/DC0%0/2
builtin::blessed($seqs) and $seqs->isa("Bio::Gonzales::Seq")
builtin::blessed($seqs)
$seqs->isa("Bio::Gonzales::Seq")
Truth table33%1/3
A and B
A= builtin::blessed($seqs)B= $seqs->isa("Bio::Gonzales::Seq")
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | confess "please supply the sequences as an arrayref" unless ( ref $seqs eq 'ARRAY' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | confess "config format not readable" if ( $config && ref $config ne 'HASH' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$config and ref $config ne "HASH"
MC/DC0%0/2
$config and ref $config ne "HASH"
$config
ref $config ne "HASH"
Truth table33%1/3
A and B
A= $configB= ref $config ne "HASH"
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | for my $s (@$seqs) { | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1 | my $seq = $s->seq; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1 | ▶ | $seq =~ tr/*//d if ( !exists( $config->{terminal} ) || $config->{terminal} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $config->{"terminal"} or $config->{"terminal"}
MC/DC0%0/2
not exists $config->{"terminal"} or $config->{"terminal"}
not exists $config->{"terminal"}
$config->{"terminal"}
Truth table33%1/3
not(A) or B
A= not exists $config->{"terminal"}B= $config->{"terminal"}
| |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | $seq =~ s/\*$// if ( !exists( $config->{end_terminal} ) || $config->{end_termninal} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $config->{"end_terminal"} or $config->{"end_termninal"}
MC/DC0%0/2
not exists $config->{"end_terminal"} or $config->{"end_termninal"}
not exists $config->{"end_terminal"}
$config->{"end_termninal"}
Truth table33%1/3
not(A) or B
A= not exists $config->{"end_terminal"}B= $config->{"end_termninal"}
| |||||||||||||||||||||||||||||
| 31 | $seq =~ s/[^*SFTNKYEVZQMCLAOWXPBHDIRGsftnkyevzqmclaowxpbhdirg]/X/g | ||||||||||||||||||||||||||||
| 32 | 1 | ▶ | if ( !exists( $config->{uncommon_aa} ) || $config->{uncommon_aa} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $config->{"uncommon_aa"} or $config->{"uncommon_aa"}
MC/DC0%0/2
not exists $config->{"uncommon_aa"} or $config->{"uncommon_aa"}
not exists $config->{"uncommon_aa"}
$config->{"uncommon_aa"}
Truth table33%1/3
not(A) or B
A= not exists $config->{"uncommon_aa"}B= $config->{"uncommon_aa"}
| |||||||||||||||||||||||||||||
| 33 | 1 | $s->seq($seq); | |||||||||||||||||||||||||||
| 34 | 1 | ▶ | $s->desc('') if ( !exists( $config->{no_desc} ) || $config->{no_desc} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $config->{"no_desc"} or $config->{"no_desc"}
MC/DC0%0/2
not exists $config->{"no_desc"} or $config->{"no_desc"}
not exists $config->{"no_desc"}
$config->{"no_desc"}
Truth table33%1/3
not(A) or B
A= not exists $config->{"no_desc"}B= $config->{"no_desc"}
| |||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 1 | return $seqs; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | sub clean_peptide_seq { return clean_pep_seq(@_); } | ||||||||||||||||||||||||||
|
Subroutine
clean_peptide_seq: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | sub clean_rna_seq { | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my ( $seqs, $config ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
clean_rna_seq: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $seqs = [$seqs] if ( blessed($seqs) && $seqs->isa('Bio::Gonzales::Seq') ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($seqs) and $seqs->isa("Bio::Gonzales::Seq")
MC/DC0%0/2
builtin::blessed($seqs) and $seqs->isa("Bio::Gonzales::Seq")
builtin::blessed($seqs)
$seqs->isa("Bio::Gonzales::Seq")
Truth table0%0/3
A and B
A= builtin::blessed($seqs)B= $seqs->isa("Bio::Gonzales::Seq")
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | confess "please supply the sequences as an arrayref" unless ( ref $seqs eq 'ARRAY' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | confess "config format not readable" if ( $config && ref $config ne 'HASH' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$config and ref $config ne "HASH"
MC/DC0%0/2
$config and ref $config ne "HASH"
$config
ref $config ne "HASH"
Truth table0%0/3
A and B
A= $configB= ref $config ne "HASH"
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | for my $s (@$seqs) { | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | my $seq = $s->seq; | |||||||||||||||||||||||||||
| 51 | 0 | $seq =~ y/Tt/Uu/; | |||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ( $config->{intermediate_ambi} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | $seq =~ y/AGCUNagcun/N/c; | |||||||||||||||||||||||||||
| 54 | } else { | ||||||||||||||||||||||||||||
| 55 | 0 | $seq =~ y/agcunkmryswhbvdAGCUNKMRYSWHBVD/N/c; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 0 | $s->seq($seq); | |||||||||||||||||||||||||||
| 58 | 0 | ▶ | $s->desc('') if ( !exists( $config->{no_desc} ) || $config->{no_desc} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $config->{"no_desc"} or $config->{"no_desc"}
MC/DC0%0/2
not exists $config->{"no_desc"} or $config->{"no_desc"}
not exists $config->{"no_desc"}
$config->{"no_desc"}
Truth table0%0/3
not(A) or B
A= not exists $config->{"no_desc"}B= $config->{"no_desc"}
| |||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 0 | return $seqs; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub clean_dna_seq { | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my ( $seqs, $config ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
clean_dna_seq: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $seqs = [$seqs] if ( blessed($seqs) && $seqs->isa('Bio::Gonzales::Seq') ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($seqs) and $seqs->isa("Bio::Gonzales::Seq")
MC/DC0%0/2
builtin::blessed($seqs) and $seqs->isa("Bio::Gonzales::Seq")
builtin::blessed($seqs)
$seqs->isa("Bio::Gonzales::Seq")
Truth table0%0/3
A and B
A= builtin::blessed($seqs)B= $seqs->isa("Bio::Gonzales::Seq")
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | confess "please supply the sequences as an arrayref" unless ( ref $seqs eq 'ARRAY' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | confess "config format not readable" if ( $config && ref $config ne 'HASH' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$config and ref $config ne "HASH"
MC/DC0%0/2
$config and ref $config ne "HASH"
$config
ref $config ne "HASH"
Truth table0%0/3
A and B
A= $configB= ref $config ne "HASH"
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | for my $s (@$seqs) { | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | my $seq = $s->seq; | |||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( $config->{intermediate_ambi} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | $seq =~ y/AGCTNagctn/N/c; | |||||||||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||||||||
| 77 | 0 | $seq =~ y/agctnkmryswhbvdAGCTNKMRYSWHBVD/N/c; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | 0 | $s->seq($seq); | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | $s->desc('') if ( !exists( $config->{no_desc} ) || $config->{no_desc} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $config->{"no_desc"} or $config->{"no_desc"}
MC/DC0%0/2
not exists $config->{"no_desc"} or $config->{"no_desc"}
not exists $config->{"no_desc"}
$config->{"no_desc"}
Truth table0%0/3
not(A) or B
A= not exists $config->{"no_desc"}B= $config->{"no_desc"}
| |||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | 0 | return $seqs; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 1 | 1; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | __END__ | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head1 NAME | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Bio::Gonzales::Seq::Filter - filter sequence data | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | use Bio::Gonzales::Seq::Filter qw(clean_pep_seq clean_dna_seq clean_rna_seq); | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 SUBROUTINES | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =over 4 | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =item B<< $seqs = clean_dna_seq(\@seqs!, \%config) >> | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Do some cleaning, substitute invalid nucleotides with N, remove the | ||||||||||||||||||||||||||||
| 107 | description of the sequence objects. | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | C<clean_dna_seq> leaves the sequence object description untouched if | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | %config = ( no_desc => 0 ); | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =item B<< $seqs = clean_pep_seq(\@seqs!, \%config) >> | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =item B<< $seqs = clean_rna_seq(\@seqs!, \%config) >> | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =back | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | jw bargsten, C<< <jwb at cpan dot org> >> | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =cut | ||||||||||||||||||||||||||||