A test to ensure Bio::PrimarySeqI->trunc() doesn't use clone() for a Bio::Seq::RichSe...
[bioperl-live.git] / Bio / Tools / Seg.pm
bloba92d52a6bedb02fec82c76896c16113d4f4d4902
2 # BioPerl module for Bio::Tools::Seg
4 # Copyright Balamurugan Kumarasamy
5 # Totally re-written, added docs and tests -- Torsten Seemann, Sep 2006
7 # Copyright
8 # You may distribute this module under the same terms as perl itself
10 # POD documentation - main docs before the code
12 =head1 NAME
14 Bio::Tools::Seg - parse C<seg> output
16 =head1 SYNOPSIS
18 use Bio::Tools::Seg;
19 my $parser = Bio::Tools::Seg->(-file => 'seg.fasta');
20 while ( my $f = $parser->next_result ) {
21 if ($f->score < 1.5) {
22 print $f->location->to_FTstring, " is low complexity\n";
26 =head1 DESCRIPTION
28 C<seg> identifies low-complexity regions on a protein sequence.
29 It is usually part of the C<WU-BLAST> and C<InterProScan> packages.
31 The L<Bio::Tools::Seg> module will only parse the "fasta" output
32 modes of C<seg>, i.e. C<seg -l> (low complexity regions only),
33 C<seg -h> (high complexity regions only), or C<seg -a> (both low
34 and high).
36 It creates a L<Bio::SeqFeature::Generic> for each FASTA-like entry
37 found in the input file. It is up to the user to appropriately filter
38 these using the feature's score.
40 =head1 FEEDBACK
42 =head2 Mailing Lists
44 User feedback is an integral part of the evolution of this and other
45 Bioperl modules. Send your comments and suggestions preferably to
46 the Bioperl mailing list. Your participation is much appreciated.
48 bioperl-l@bioperl.org - General discussion
49 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
51 =head2 Support
53 Please direct usage questions or support issues to the mailing list:
55 I<bioperl-l@bioperl.org>
57 rather than to the module maintainer directly. Many experienced and
58 reponsive experts will be able look at the problem and quickly
59 address it. Please include a thorough description of the problem
60 with code and data examples if at all possible.
62 =head2 Reporting Bugs
64 Report bugs to the Bioperl bug tracking system to help us keep track
65 of the bugs and their resolution. Bug reports can be submitted via the
66 web:
68 https://github.com/bioperl/bioperl-live/issues
70 =head1 AUTHOR - Torsten Seemann
72 Email - torsten.seemann AT infotech.monash.edu.au
74 =head1 CONTRIBUTOR - Bala
76 Email - savikalpa@fugu-sg.org
78 =head1 APPENDIX
80 The rest of the documentation details each of the object methods.
81 Internal methods are usually preceded with a _
83 =cut
85 package Bio::Tools::Seg;
86 use strict;
88 use Bio::SeqFeature::Generic;
89 use base qw(Bio::Root::Root Bio::Root::IO);
91 =head2 new
93 Title : new
94 Usage : my $obj = Bio::Tools::Seg->new();
95 Function: Builds a new Bio::Tools::Seg object
96 Returns : Bio::Tools::Seg
97 Args : -fh/-file => $val, # for initing input, see Bio::Root::IO
99 =cut
102 sub new {
103 my($class,@args) = @_;
104 my $self = $class->SUPER::new(@args);
105 $self->_initialize_io(@args);
106 return $self;
109 =head2 next_result
111 Title : next_result
112 Usage : my $feat = $seg->next_result
113 Function: Get the next result set from parser data
114 Returns : Bio::SeqFeature::Generic
115 Args : none
117 =cut
119 sub next_result {
120 my ($self) = @_;
122 # For example in this line
123 # test_prot(214-226) complexity=2.26 (12/2.20/2.50)
124 # $1 is test_prot
125 # $2 is 214
126 # $3 is 226
127 # $4 is 2.26
129 while (my $line = $self->_readline) {
130 if ($line =~ /^\>\s*?(\S+)?\s*?\((\d+)\-(\d+)\)\s*complexity=(\S+)/) {
131 return Bio::SeqFeature::Generic->new(
132 -seq_id => $1,
133 -start => $2,
134 -end => $3,
135 -score => $4,
136 -source_tag => 'Seg',
137 -primary => 'low_complexity'