| 1 | # $Id$ | ||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||
| 3 | # BioPerl module for Bio::Tools::Mdust | ||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||
| 5 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||
| 7 | # Cared for by Donald Jackson, donald.jackson@bms.com | ||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||
| 9 | # Copyright Donald Jackson | ||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||
| 11 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||
| 17 | Mdust - Perl extension for Mdust nucleotide filtering | ||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||
| 21 | use Bio::Tools::Run::Mdust; | ||||||||||||||||||||||||||||||||||||||
| 22 | my $mdust = Bio::Tools::Run::Mdust->new(); | ||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | $mdust->run($bio_seq_object); | ||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||
| 28 | Perl wrapper for the nucleic acid complexity filtering program | ||||||||||||||||||||||||||||||||||||||
| 29 | B<mdust> as available from TIGR via | ||||||||||||||||||||||||||||||||||||||
| 30 | L<http://www.tigr.org/tdb/tgi/software/>. Takes a Bio::SeqI or | ||||||||||||||||||||||||||||||||||||||
| 31 | Bio::PrimarySeqI object of type DNA as input. | ||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||
| 33 | If a Bio::Seq::RichSeqI is passed then the low-complexity regions will | ||||||||||||||||||||||||||||||||||||||
| 34 | be added to the feature table of the target object as | ||||||||||||||||||||||||||||||||||||||
| 35 | Bio::SeqFeature::Generic items with primary tag = 'Excluded' . | ||||||||||||||||||||||||||||||||||||||
| 36 | Otherwise a new target object will be returned with low-complexity | ||||||||||||||||||||||||||||||||||||||
| 37 | regions masked (by N's or other character as specified by maskchar()). | ||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||
| 39 | The mdust executable must be in a directory specified with either the | ||||||||||||||||||||||||||||||||||||||
| 40 | PATH or MDUSTDIR environment variable. | ||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||
| 42 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||
| 44 | L<mdust>, | ||||||||||||||||||||||||||||||||||||||
| 45 | L<Bio::PrimarySeq>, | ||||||||||||||||||||||||||||||||||||||
| 46 | L<Bio::Seq::RichSeq>, | ||||||||||||||||||||||||||||||||||||||
| 47 | L<Bio::SeqFeature::Generic> | ||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||||
| 54 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||||||||||||
| 55 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||
| 57 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||||
| 58 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||
| 60 | =head2 Support | ||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||
| 62 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||
| 64 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||
| 66 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||||
| 67 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||||
| 68 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||||
| 69 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||
| 71 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||||
| 74 | of the bugs and their resolution. Bug reports can be submitted via | ||||||||||||||||||||||||||||||||||||||
| 75 | the web: | ||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||
| 77 | http://redmine.open-bio.org/projects/bioperl/ | ||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||
| 79 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||
| 81 | Donald Jackson (donald.jackson@bms.com) | ||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||
| 83 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||
| 85 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||||||||
| 86 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||
| 88 | =cut | ||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||
| 91 | package Bio::Tools::Run::Mdust; | ||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||
| 93 | 1 | require 5.005_62; | |||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | use Bio::SeqIO; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | use Bio::SeqFeature::Generic; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | use Bio::Root::Root; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 99 | 1 | ▶ | use Bio::Root::IO; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | use Bio::Tools::Run::WrapperBase; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||
| 102 | 1 | ▶ | use vars qw($AUTOLOAD $PROGRAMNAME @ARGNAMES @MASKCHARS $VERSION @ISA); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | 1 | @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase); | |||||||||||||||||||||||||||||||||||||
| 105 | 1 | @ARGNAMES = qw(TARGET WSIZE CUTOFF MASKCHAR COORDS TMPDIR DEBUG); | |||||||||||||||||||||||||||||||||||||
| 106 | 1 | $PROGRAMNAME = 'mdust'; | |||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||
| 108 | 1 | @MASKCHARS = qw(N X L); | |||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||
| 110 | =head2 new | ||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||
| 112 | Title : new | ||||||||||||||||||||||||||||||||||||||
| 113 | Usage : my $mdust = Bio::Tools::Run::Mdust->new( -target => $target_bioseq) | ||||||||||||||||||||||||||||||||||||||
| 114 | Purpose : Create a new mdust object | ||||||||||||||||||||||||||||||||||||||
| 115 | Returns : A Bio::Seq object | ||||||||||||||||||||||||||||||||||||||
| 116 | Args : target - Bio::Seq object for masking - alphabet MUST be DNA. | ||||||||||||||||||||||||||||||||||||||
| 117 | wsize - word size for masking (default = 3) | ||||||||||||||||||||||||||||||||||||||
| 118 | cutoff - cutoff score for masking (default = 28) | ||||||||||||||||||||||||||||||||||||||
| 119 | maskchar - character for replacing masked regions (default = N) | ||||||||||||||||||||||||||||||||||||||
| 120 | coords - boolean - indicate low-complexity regions as | ||||||||||||||||||||||||||||||||||||||
| 121 | Bio::SeqFeature::Generic | ||||||||||||||||||||||||||||||||||||||
| 122 | objects with primary tag 'Excluded', | ||||||||||||||||||||||||||||||||||||||
| 123 | do not change sequence (default 0) | ||||||||||||||||||||||||||||||||||||||
| 124 | tmpdir - directory for storing temporary files | ||||||||||||||||||||||||||||||||||||||
| 125 | debug - boolean - toggle debugging output, | ||||||||||||||||||||||||||||||||||||||
| 126 | do not remove temporary files | ||||||||||||||||||||||||||||||||||||||
| 127 | Notes : All of the arguments can also be get/set with their own accessors, such as: | ||||||||||||||||||||||||||||||||||||||
| 128 | my $wsize = $mdust->wsize(); | ||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||
| 130 | When processing multiple sequences, call Bio::Tools::Run::Mdust->new() once | ||||||||||||||||||||||||||||||||||||||
| 131 | then pass each sequence as an argument to the target() or run() methods. | ||||||||||||||||||||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||
| 134 | sub new { | ||||||||||||||||||||||||||||||||||||||
| 135 | 1 | ▶ | my ($proto, @args) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | my $pkg = ref($proto) || $proto; | ||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||
| 137 | 1 | my %args; | |||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||
| 139 | 1 | my $self = { wsize => undef, | |||||||||||||||||||||||||||||||||||||
| 140 | cutoff => undef, | ||||||||||||||||||||||||||||||||||||||
| 141 | maskchar => undef, | ||||||||||||||||||||||||||||||||||||||
| 142 | coords => 0, | ||||||||||||||||||||||||||||||||||||||
| 143 | }; | ||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||
| 145 | 1 | bless ($self, $pkg); | |||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||
| 147 | 1 | @args{@ARGNAMES} = $self->_rearrange(\@ARGNAMES, @args); | |||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||
| 149 | # load target first since it requires special handling | ||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | $self->target($args{'TARGET'}) if ($args{'TARGET'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||
| 152 | # package settings | ||||||||||||||||||||||||||||||||||||||
| 153 | 1 | ▶ | $self->{'coords'} = $args{'COORDS'} if (defined $args{'COORDS'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | $self->{'tmpdir'} = $args{'TMPDIR'} || $ENV{'TMPDIR'} || $ENV{'TMP'} || '.'; | ||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
$args{'TMPDIR'} || $ENV{'TMPDIR'} || $ENV{'TMP'} || '.'
$args{"TMPDIR"} or $ENV{"TMPDIR"} or $ENV{"TMP"}
$args{"TMPDIR"} or $ENV{"TMPDIR"}
MC/DC0%0/3
$args{'TMPDIR'} || $ENV{'TMPDIR'} || $ENV{'TMP'} || '.'
$args{"TMPDIR"}
$ENV{"TMPDIR"}
$ENV{"TMP"}
Truth table25%1/4
A or B or C
A= $args{"TMPDIR"}B= $ENV{"TMPDIR"}C= $ENV{"TMP"}
| |||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||
| 156 | # mdust options | ||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | $self->{'wsize'} = $args{'WSIZE'} if (defined $args{'WSIZE'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | $self->{'cutoff'} = $args{'CUTOFF'} if (defined $args{'CUTOFF'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 159 | 1 | ▶ | $self->{'maskchar'} = $args{'MASKCHAR'} if (defined $args{'CUTOFF'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||
| 162 | # set debugging | ||||||||||||||||||||||||||||||||||||||
| 163 | 1 | $self->verbose($args{'DEBUG'}); | |||||||||||||||||||||||||||||||||||||
| 164 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||
| 167 | =head2 run | ||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||
| 169 | Title : run | ||||||||||||||||||||||||||||||||||||||
| 170 | Usage : $mdust->run(); | ||||||||||||||||||||||||||||||||||||||
| 171 | Purpose : Run mdust on the target sequence | ||||||||||||||||||||||||||||||||||||||
| 172 | Args : target (optional) - Bio::Seq object of alphabet DNA for masking | ||||||||||||||||||||||||||||||||||||||
| 173 | Returns : Bio::Seq object with masked sequence or low-complexity regions added to feature table. | ||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||
| 175 | =cut | ||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||
| 177 | sub run { | ||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my ($self, $target) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ($target) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->target($target); | |||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||
| 184 | 0 | return $self->_run_mdust; | |||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||
| 187 | sub program_dir { | ||||||||||||||||||||||||||||||||||||||
| 188 | 3 | ▶ | return Bio::Root::IO->catfile($ENV{MDUSTDIR}) if $ENV{MDUSTDIR}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
program_dir: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||
| 192 | sub program_name { | ||||||||||||||||||||||||||||||||||||||
| 193 | 6 | ▶ | return $PROGRAMNAME; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
program_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | sub _run_mdust { | ||||||||||||||||||||||||||||||||||||||
| 197 | # open a pipe to the mdust command. Pass in sequence(s?) as fasta | ||||||||||||||||||||||||||||||||||||||
| 198 | # files on STDIN, recover filtered seqs on STDOUT | ||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_mdust: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my $target = $self->target or warn "No target sequence specified\n" && return undef; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||
| 203 | # make sure program is available - doesn't seem to check | ||||||||||||||||||||||||||||||||||||||
| 204 | #my $executable = $self->executable('mdust', 1); | ||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||
| 206 | # add options | ||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $mdust_cmd = $self->program_path; | |||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $mdust_cmd .= " -w " . $self->wsize if (defined $self->wsize); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $mdust_cmd .= " -v " . $self->cutoff if (defined $self->cutoff); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | $mdust_cmd .= " -m " . $self->maskchar if (defined $self->maskchar); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $mdust_cmd .= " -c" if ($self->coords); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | print STDERR "Running mdust: $mdust_cmd\n" if ($self->debug); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $maskedfile = $self->_maskedfile; | |||||||||||||||||||||||||||||||||||||
| 214 | 0 | eval { | |||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $pid = open (MDUST, "| $mdust_cmd > $maskedfile"); # bind STDIN of mdust to filehandle | |||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||
| 217 | 0 | local $| = 1; | |||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $seqout = Bio::SeqIO->new(-fh => \*MDUST, -format => 'Fasta'); | |||||||||||||||||||||||||||||||||||||
| 219 | 0 | $seqout->write_seq($target); | |||||||||||||||||||||||||||||||||||||
| 220 | 0 | close MDUST; # need to do this to get output to flush! | |||||||||||||||||||||||||||||||||||||
| 221 | }; | ||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | $self->throw($@) if ($@); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my $rval; | |||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ($self->coords) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $self->_parse_coords($maskedfile); | |||||||||||||||||||||||||||||||||||||
| 229 | 0 | $rval = $self->target; | |||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||
| 231 | else { # replace original seq w/ masked seq | ||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $seqin = Bio::SeqIO->new(-file=>$maskedfile, -format => 'Fasta'); | |||||||||||||||||||||||||||||||||||||
| 233 | 0 | $rval = $seqin->next_seq | |||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | unlink $maskedfile unless $self->save_tempfiles; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return $rval; | |||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||
| 242 | =head2 target | ||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||
| 244 | Title : target | ||||||||||||||||||||||||||||||||||||||
| 245 | Usage : $mdust->target($bio_seq) | ||||||||||||||||||||||||||||||||||||||
| 246 | Purpose : Set/get the target (sequence to be filtered). | ||||||||||||||||||||||||||||||||||||||
| 247 | Returns : Target Bio::Seq object | ||||||||||||||||||||||||||||||||||||||
| 248 | Args : Bio::SeqI or Bio::PrimarySeqI object using the DNA alphabet (optional) | ||||||||||||||||||||||||||||||||||||||
| 249 | Note : If coordinate parsing is selected ($mdust->coords = 1) then target | ||||||||||||||||||||||||||||||||||||||
| 250 | MUST be a Bio::Seq::RichSeqI object. Passing a RichSeqI object automatically | ||||||||||||||||||||||||||||||||||||||
| 251 | turns on coordinate parsing. | ||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||
| 253 | =cut | ||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||
| 255 | sub target { | ||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | my ($self, $targobj) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
target: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||
| 258 | 1 | ▶ | if ($targobj) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 259 | 1 | return $self->_set_target($targobj); | |||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||
| 261 | else { | ||||||||||||||||||||||||||||||||||||||
| 262 | 0 | return $self->{'target'}; | |||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||
| 268 | sub _set_target { | ||||||||||||||||||||||||||||||||||||||
| 269 | 1 | ▶ | my ($self, $targobj) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_target: called CC=7 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||
| 271 | 1 | ▶ | unless ($targobj->isa('Bio::SeqI') or ($targobj->isa('Bio::PrimarySeqI'))) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$targobj->isa("Bio::SeqI") or $targobj->isa("Bio::PrimarySeqI")
MC/DC0%0/2
$targobj->isa("Bio::SeqI") or $targobj->isa("Bio::PrimarySeqI")
$targobj->isa("Bio::SeqI")
$targobj->isa("Bio::PrimarySeqI")
Truth table33%1/3
A or B
A= $targobj->isa("Bio::SeqI")B= $targobj->isa("Bio::PrimarySeqI")
| |||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $self->throw( -text => "Target must be passed as a Bio::SeqI or Bio::PrimarySeqI object", | |||||||||||||||||||||||||||||||||||||
| 273 | -class => 'Bio::Root::BadParameter', | ||||||||||||||||||||||||||||||||||||||
| 274 | -value => $targobj ); | ||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | if ($self->coords) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | unless ($targobj->isa('Bio::Seq::RichSeqI')) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $self->throw( -text => "Target must be passed as a Bio::Seq::RichSeqSeqI object when coords == 1", | |||||||||||||||||||||||||||||||||||||
| 281 | -class => 'Bio::Root::BadParameter', | ||||||||||||||||||||||||||||||||||||||
| 282 | -value => $targobj ); | ||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||
| 285 | elsif ($targobj->isa('Bio::Seq::RichSeqI')) { | ||||||||||||||||||||||||||||||||||||||
| 286 | 1 | $self->coords(1); | |||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||
| 290 | 1 | ▶ | unless ($targobj->alphabet eq 'dna') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 291 | 0 | $self->throw( -text => "Target must be a DNA sequence", | |||||||||||||||||||||||||||||||||||||
| 292 | -class => 'Bio::Root::BadParameter', | ||||||||||||||||||||||||||||||||||||||
| 293 | -value => $targobj ); | ||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||
| 296 | 1 | $self->{'target'} = $targobj; | |||||||||||||||||||||||||||||||||||||
| 297 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||
| 301 | sub _maskedfile { | ||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_maskedfile: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $tmpdir = $self->tempdir; | |||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if ($file) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $self->{'maskedfile'} = $file; | |||||||||||||||||||||||||||||||||||||
| 307 | # add some sanity chex for writability? | ||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||
| 309 | elsif (!$self->{'maskedfile'}) { | ||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ($self->{'maskedfh'},$self->{'maskedfile'}) = | |||||||||||||||||||||||||||||||||||||
| 311 | $self->io->tempfile(-dir=>$self->tempdir()); | ||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||
| 313 | 0 | return $self->{'maskedfile'}; | |||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||
| 317 | sub _parse_coords { | ||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my ($self, $file) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_coords: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $target = $self->target; | |||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | open(FILE, $file) or die "Unable to open $file: $!"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | while (<FILE>) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 322 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||
| 323 | 0 | s/\r//; | |||||||||||||||||||||||||||||||||||||
| 324 | 0 | my ($seq, $length, $mstart, $mstop) = split(/\t/); | |||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||
| 326 | # add masked region as a SeqFeature in target | ||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $masked = Bio::SeqFeature::Generic->new( -start => $mstart, | |||||||||||||||||||||||||||||||||||||
| 328 | -end => $mstop, | ||||||||||||||||||||||||||||||||||||||
| 329 | ); | ||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $masked->primary_tag('Excluded'); | |||||||||||||||||||||||||||||||||||||
| 331 | 0 | $masked->source_tag('mdust'); | |||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $target->add_SeqFeature($masked); | |||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||
| 335 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||
| 338 | =head2 maskchar | ||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||
| 340 | Title : maskchar | ||||||||||||||||||||||||||||||||||||||
| 341 | Usage : $mdust->maskchar('N') | ||||||||||||||||||||||||||||||||||||||
| 342 | Purpose : Set/get the character for masking low-complexity regions | ||||||||||||||||||||||||||||||||||||||
| 343 | Returns : True on success | ||||||||||||||||||||||||||||||||||||||
| 344 | Args : Either N (default), X or L (lower case) | ||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||
| 346 | =cut | ||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||
| 348 | sub maskchar { | ||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | my ($self, $maskchar) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
maskchar: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | return $self->{'maskchar'} unless (defined $maskchar); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | unless ( grep {$maskchar eq $_} @MASKCHARS ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $self->throw( -text => "maskchar must be one of N, X or L", | |||||||||||||||||||||||||||||||||||||
| 355 | -class => 'Bio::Root::BadParameter', | ||||||||||||||||||||||||||||||||||||||
| 356 | -value => $maskchar ); | ||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $self->{'maskchar'} = $maskchar; | |||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||
| 360 | 0 | 1; | |||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||
| 363 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||
| 364 | 1 | ▶ | my $self= shift; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||
| 365 | 1 | ▶ | unless ( $self->save_tempfiles ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 366 | 1 | $self->cleanup(); | |||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||
| 368 | 1 | $self->SUPER::DESTROY(); | |||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||
| 372 | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||
| 373 | 2 | ▶ | my ($self, $value) = @_; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||||||||||||
| 374 | 2 | my $name = $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||
| 375 | 2 | $name =~ s/.+:://; | |||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||
| 377 | 2 | ▶ | return if ($name eq 'DESTROY'); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||
| 380 | 2 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 381 | 1 | $self->{$name} = $value; | |||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||
| 384 | 2 | ▶ | unless (exists $self->{$name}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | warn "Attribute $name not defined for ", ref($self), "\n" if ($self->debug); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 386 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||
| 389 | 2 | return $self->{$name}; | |||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||
| 392 | 1 | 1; | |||||||||||||||||||||||||||||||||||||