| 1 | # Copyright Balamurugan Kumarasamy | ||||||||||
| 2 | # You may distribute this module under the same terms as perl itself | ||||||||||
| 3 | # POD documentation - main docs before the code | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Bio::Tools::Run::Seg - Object for identifying low complexity | ||||||||||
| 8 | regions in a given protein seequence. | ||||||||||
| 9 | |||||||||||
| 10 | =head1 SYNOPSIS | ||||||||||
| 11 | |||||||||||
| 12 | # Build a Seg factory | ||||||||||
| 13 | # $paramfile is the full path to the seg binary file | ||||||||||
| 14 | my @params = ('PROGRAM',$paramfile); | ||||||||||
| 15 | my $factory = Bio::Tools::Run::Seg->new($param); | ||||||||||
| 16 | |||||||||||
| 17 | # Pass the factory a Bio::Seq object | ||||||||||
| 18 | # @feats is an array of Bio::SeqFeature::Generic objects | ||||||||||
| 19 | my @feats = $factory->run($seq); | ||||||||||
| 20 | |||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||
| 22 | |||||||||||
| 23 | Seg is a program which identifies low complexity regions in proteins. | ||||||||||
| 24 | It was developed by Wootton and Federhen at NCBI. | ||||||||||
| 25 | |||||||||||
| 26 | =head1 FEEDBACK | ||||||||||
| 27 | |||||||||||
| 28 | =head2 Mailing Lists | ||||||||||
| 29 | |||||||||||
| 30 | User feedback is an integral part of the evolution of this and other | ||||||||||
| 31 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||
| 32 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||
| 33 | |||||||||||
| 34 | bioperl-l@bioperl.org - General discussion | ||||||||||
| 35 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | =head2 Support | ||||||||||
| 39 | |||||||||||
| 40 | Please direct usage questions or support issues to the mailing list: | ||||||||||
| 41 | |||||||||||
| 42 | I<bioperl-l@bioperl.org> | ||||||||||
| 43 | |||||||||||
| 44 | rather than to the module maintainer directly. Many experienced and | ||||||||||
| 45 | reponsive experts will be able look at the problem and quickly | ||||||||||
| 46 | address it. Please include a thorough description of the problem | ||||||||||
| 47 | with code and data examples if at all possible. | ||||||||||
| 48 | |||||||||||
| 49 | =head2 Reporting Bugs | ||||||||||
| 50 | |||||||||||
| 51 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||
| 52 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||
| 53 | web: | ||||||||||
| 54 | |||||||||||
| 55 | http://redmine.open-bio.org/projects/bioperl/ | ||||||||||
| 56 | |||||||||||
| 57 | =head1 AUTHOR - Bala | ||||||||||
| 58 | |||||||||||
| 59 | Email savikalpa@fugu-sg.org | ||||||||||
| 60 | |||||||||||
| 61 | =head1 APPENDIX | ||||||||||
| 62 | |||||||||||
| 63 | The rest of the documentation details each of the object | ||||||||||
| 64 | methods. Internal methods are usually preceded with a _ | ||||||||||
| 65 | |||||||||||
| 66 | =cut | ||||||||||
| 67 | |||||||||||
| 68 | package Bio::Tools::Run::Seg; | ||||||||||
| 69 | |||||||||||
| 70 | 1 | ▶ | use vars qw($AUTOLOAD @ISA $PROGRAM $PROGRAMDIR | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 71 | 1 | $PROGRAMNAME @SEG_PARAMS %OK_FIELD); | |||||||||
| 72 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 73 | 1 | ▶ | use Bio::SeqIO; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 74 | 1 | ▶ | use Bio::Root::Root; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 75 | 1 | ▶ | use Bio::Root::IO; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 76 | 1 | ▶ | use Bio::Tools::Seg; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 77 | 1 | ▶ | use Bio::Tools::Run::WrapperBase; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 78 | |||||||||||
| 79 | 1 | @ISA = qw(Bio::Root::Root Bio::Tools::Run::WrapperBase); | |||||||||
| 80 | |||||||||||
| 81 | 1 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||
| 82 | 1 | @SEG_PARAMS=qw(PROGRAM VERBOSE); | |||||||||
| 83 | 1 | foreach my $attr ( @SEG_PARAMS) | |||||||||
| 84 | 2 | { $OK_FIELD{$attr}++; } | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | =head2 program_name | ||||||||||
| 88 | |||||||||||
| 89 | Title : program_name | ||||||||||
| 90 | Usage : $factory->program_name() | ||||||||||
| 91 | Function: holds the program name | ||||||||||
| 92 | Returns: string | ||||||||||
| 93 | Args : None | ||||||||||
| 94 | |||||||||||
| 95 | =cut | ||||||||||
| 96 | |||||||||||
| 97 | 6 | ▶ | sub program_name { | ||||||||
|
Subroutine
program_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 98 | 6 | return 'seg'; | |||||||||
| 99 | } | ||||||||||
| 100 | |||||||||||
| 101 | =head2 program_dir | ||||||||||
| 102 | |||||||||||
| 103 | Title : program_dir | ||||||||||
| 104 | Usage : $factory->program_dir(@params) | ||||||||||
| 105 | Function: returns the program directory, obtained from ENV variable. | ||||||||||
| 106 | Returns : string, or undef if $SEGDIR not in ENV | ||||||||||
| 107 | Args : None | ||||||||||
| 108 | |||||||||||
| 109 | =cut | ||||||||||
| 110 | |||||||||||
| 111 | 3 | ▶ | sub program_dir { | ||||||||
|
Subroutine
program_dir: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 112 | 3 | ▶ | return Bio::Root::IO->catfile($ENV{SEGDIR}) if $ENV{SEGDIR}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | } | ||||||||||
| 114 | |||||||||||
| 115 | 0 | ▶ | sub AUTOLOAD { | ||||||||
|
Subroutine
AUTOLOAD: not called CC=3 SCAR=24.8
| |||||||||||
| 116 | 0 | my $self = shift; | |||||||||
| 117 | 0 | my $attr = $AUTOLOAD; | |||||||||
| 118 | 0 | $attr =~ s/.*:://; | |||||||||
| 119 | 0 | $attr = uc $attr; | |||||||||
| 120 | 0 | ▶ | $self->throw("Unallowed parameter: $attr !") unless $OK_FIELD{$attr}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 121 | 0 | ▶ | $self->{$attr} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 122 | 0 | return $self->{$attr}; | |||||||||
| 123 | } | ||||||||||
| 124 | |||||||||||
| 125 | =head2 new | ||||||||||
| 126 | |||||||||||
| 127 | Title : new | ||||||||||
| 128 | Usage : $rm->new(@params) | ||||||||||
| 129 | Function: creates a new Seg factory | ||||||||||
| 130 | Returns: Bio::Tools::Run::Seg | ||||||||||
| 131 | Args : | ||||||||||
| 132 | |||||||||||
| 133 | =cut | ||||||||||
| 134 | |||||||||||
| 135 | 1 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=14.8
Pod
documented
| |||||||||||
| 136 | 1 | my ($class,@args) = @_; | |||||||||
| 137 | 1 | my $self = $class->SUPER::new(@args); | |||||||||
| 138 | |||||||||||
| 139 | 1 | my ($attr, $value); | |||||||||
| 140 | 1 | ▶ | while (@args) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 141 | 0 | $attr = shift @args; | |||||||||
| 142 | 0 | $value = shift @args; | |||||||||
| 143 | 0 | ▶ | next if( $attr =~ /^-/ ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 144 | 0 | $self->$attr($value); | |||||||||
| 145 | } | ||||||||||
| 146 | 1 | return $self; | |||||||||
| 147 | } | ||||||||||
| 148 | |||||||||||
| 149 | =head2 predict_protein_features | ||||||||||
| 150 | |||||||||||
| 151 | Title : predict_protein_features() | ||||||||||
| 152 | Usage : DEPRECATED Use $obj->run($seq) instead | ||||||||||
| 153 | Function: Runs Seg and creates an array of featrues | ||||||||||
| 154 | Returns : An array of Bio::SeqFeature::Generic objects | ||||||||||
| 155 | Args : A Bio::PrimarySeqI | ||||||||||
| 156 | |||||||||||
| 157 | =cut | ||||||||||
| 158 | |||||||||||
| 159 | 0 | ▶ | sub predict_protein_features{ | ||||||||
|
Subroutine
predict_protein_features: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 160 | 0 | return shift->run(@_); | |||||||||
| 161 | } | ||||||||||
| 162 | |||||||||||
| 163 | =head2 run | ||||||||||
| 164 | |||||||||||
| 165 | Title : run | ||||||||||
| 166 | Usage : $obj->run($seq) | ||||||||||
| 167 | Function: Runs Seg and creates an array of featrues | ||||||||||
| 168 | Returns : An array of Bio::SeqFeature::Generic objects | ||||||||||
| 169 | Args : A Bio::PrimarySeqI | ||||||||||
| 170 | |||||||||||
| 171 | =cut | ||||||||||
| 172 | |||||||||||
| 173 | 0 | ▶ | sub run{ | ||||||||
|
Subroutine
run: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 174 | 0 | my ($self,$seq) = @_; | |||||||||
| 175 | 0 | my @feats; | |||||||||
| 176 | |||||||||||
| 177 | 0 | ▶ | if (ref($seq) ) { # it is an object | ||||||||
|
Branch: 1 branch
| |||||||||||
| 178 | 0 | ▶ | if (ref($seq) =~ /GLOB/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 179 | 0 | $self->throw("cannot use filehandle"); | |||||||||
| 180 | } | ||||||||||
| 181 | |||||||||||
| 182 | 0 | my $infile1 = $self->_writeSeqFile($seq); | |||||||||
| 183 | |||||||||||
| 184 | 0 | $self->_input($infile1); | |||||||||
| 185 | |||||||||||
| 186 | 0 | @feats = $self->_run(); | |||||||||
| 187 | 0 | unlink $infile1; | |||||||||
| 188 | } | ||||||||||
| 189 | else { | ||||||||||
| 190 | #The seq object is not a seq object but a file. | ||||||||||
| 191 | #Here the file does not need to be created. | ||||||||||
| 192 | |||||||||||
| 193 | 0 | $self->_input($seq); | |||||||||
| 194 | |||||||||||
| 195 | 0 | @feats = $self->_run(); | |||||||||
| 196 | |||||||||||
| 197 | } | ||||||||||
| 198 | |||||||||||
| 199 | 0 | return @feats; | |||||||||
| 200 | |||||||||||
| 201 | } | ||||||||||
| 202 | |||||||||||
| 203 | =head2 _input | ||||||||||
| 204 | |||||||||||
| 205 | Title : _input | ||||||||||
| 206 | Usage : obj->_input($seqFile) | ||||||||||
| 207 | Function: Internal (not to be used directly) | ||||||||||
| 208 | Returns : | ||||||||||
| 209 | Args : | ||||||||||
| 210 | |||||||||||
| 211 | =cut | ||||||||||
| 212 | |||||||||||
| 213 | 0 | ▶ | sub _input { | ||||||||
|
Subroutine
_input: not called CC=2 SCAR=17.9
| |||||||||||
| 214 | 0 | my ($self,$infile1) = @_; | |||||||||
| 215 | 0 | ▶ | if(defined $infile1){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 216 | |||||||||||
| 217 | 0 | $self->{'input'}=$infile1; | |||||||||
| 218 | } | ||||||||||
| 219 | 0 | return $self->{'input'}; | |||||||||
| 220 | } | ||||||||||
| 221 | |||||||||||
| 222 | =head2 _run | ||||||||||
| 223 | |||||||||||
| 224 | Title : _run | ||||||||||
| 225 | Usage : $obj->_run() | ||||||||||
| 226 | Function: Internal (not to be used directly) | ||||||||||
| 227 | Returns : An array of Bio::SeqFeature::Generic objects | ||||||||||
| 228 | Args : None | ||||||||||
| 229 | |||||||||||
| 230 | =cut | ||||||||||
| 231 | |||||||||||
| 232 | 0 | ▶ | sub _run { | ||||||||
|
Subroutine
_run: not called CC=5 SCAR=34.0
| |||||||||||
| 233 | 0 | my ($self)= @_; | |||||||||
| 234 | |||||||||||
| 235 | 0 | my ($tfh1,$outfile) = $self->io->tempfile(-dir=>$self->tempdir()); | |||||||||
| 236 | 0 | my $str =$self->executable." ".$self->_input." -l > ".$outfile; | |||||||||
| 237 | 0 | my $status = system($str); | |||||||||
| 238 | 0 | ▶ | $self->throw( "Seg call ($str) crashed: $? \n") unless $status==0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 239 | |||||||||||
| 240 | 0 | my $filehandle; | |||||||||
| 241 | 0 | ▶ | if (ref ($outfile) !~ /GLOB/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 242 | 0 | ▶ | open (SEG, "<".$outfile) or $self->throw ("Couldn't open file ".$outfile.": $!\n"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 243 | 0 | $filehandle = \*SEG; | |||||||||
| 244 | } | ||||||||||
| 245 | else { | ||||||||||
| 246 | 0 | $filehandle = $outfile; | |||||||||
| 247 | } | ||||||||||
| 248 | 0 | my $seg_parser = Bio::Tools::Seg->new(-fh=>$filehandle); | |||||||||
| 249 | |||||||||||
| 250 | 0 | my @seg_feat; | |||||||||
| 251 | |||||||||||
| 252 | 0 | ▶ | while(my $seg_feat = $seg_parser->next_result){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 253 | |||||||||||
| 254 | 0 | push @seg_feat, $seg_feat; | |||||||||
| 255 | } | ||||||||||
| 256 | # free resources | ||||||||||
| 257 | 0 | $self->cleanup(); | |||||||||
| 258 | 0 | unlink $outfile; | |||||||||
| 259 | 0 | close($tfh1); | |||||||||
| 260 | 0 | undef $tfh1; | |||||||||
| 261 | 0 | return @seg_feat; | |||||||||
| 262 | |||||||||||
| 263 | } | ||||||||||
| 264 | |||||||||||
| 265 | =head2 _writeSeqFile | ||||||||||
| 266 | |||||||||||
| 267 | Title : _writeSeqFile | ||||||||||
| 268 | Usage : obj->_writeSeqFile($seq) | ||||||||||
| 269 | Function: Internal (not to be used directly) | ||||||||||
| 270 | Returns : string - Fasta filename to which $seq was written | ||||||||||
| 271 | Args : Bio::Seq object | ||||||||||
| 272 | |||||||||||
| 273 | =cut | ||||||||||
| 274 | |||||||||||
| 275 | 0 | ▶ | sub _writeSeqFile{ | ||||||||
|
Subroutine
_writeSeqFile: not called CC=1 SCAR=6.9
| |||||||||||
| 276 | 0 | my ($self,$seq) = @_; | |||||||||
| 277 | 0 | my ($tfh,$inputfile) = $self->io->tempfile(-dir=>$self->tempdir()); | |||||||||
| 278 | 0 | my $in = Bio::SeqIO->new(-fh => $tfh , '-format' => 'Fasta'); | |||||||||
| 279 | 0 | $in->write_seq($seq); | |||||||||
| 280 | 0 | $in->close(); | |||||||||
| 281 | 0 | close($tfh); | |||||||||
| 282 | 0 | undef $tfh; | |||||||||
| 283 | 0 | return $inputfile; | |||||||||
| 284 | |||||||||||
| 285 | } | ||||||||||
| 286 | 1 | 1; | |||||||||