~ubuntu-branches/ubuntu/trusty/bioperl/trusty

« back to all changes in this revision

Viewing changes to Bio/FeatureIO/vecscreen_simple.pm

  • Committer: Package Import Robot
  • Author(s): Charles Plessy
  • Date: 2013-09-22 13:39:48 UTC
  • mfrom: (3.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20130922133948-c6z62zegjyp7ztou
Tags: 1.6.922-1
* New upstream release.
* Replaces and Breaks grinder (<< 0.5.3-3~) because of overlaping contents.
  Closes: #722910
* Stop Replacing and Breaking bioperl ( << 1.6.9 ): not needed anymore. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
=pod
2
 
 
3
 
=head1 NAME
4
 
 
5
 
Bio::FeatureIO::vecscreen_simple - read/write features from NCBI vecscreen -f 3
6
 
output
7
 
 
8
 
=head1 SYNOPSIS
9
 
 
10
 
    # read features 
11
 
    my $fin = Bio::FeatureIO->new(-file=>'vecscreen.out',
12
 
                                  -format=>'vecscreen_simple');
13
 
    my @vec_regions;
14
 
    while (my $f = $fin->next_feature) {
15
 
      push @vec_regions, $f;
16
 
    }
17
 
    
18
 
    # write features NOT IMPLEMENTED
19
 
 
20
 
=head1 DESCRIPTION
21
 
 
22
 
vecscreen is a system for quickly identifying segments of a nucleic
23
 
acid sequence that may be of vector origin.  NCBI developed vecscreen
24
 
to minimize the incidence and impact of vector contamination in public
25
 
sequence databases.  GenBank Annotation Staff use vecscreen to verify
26
 
that sequences submitted for inclusion in the database are free from
27
 
contaminating vector sequence. Any sequence can be screened for vector
28
 
contamination using vecscreen.
29
 
 
30
 
This module provides parsing for vecscreen '-f 3' output, described in
31
 
the vecscreen documentation as 'Text list, no alignments'
32
 
 
33
 
=head1 FEEDBACK
34
 
 
35
 
=head2 Mailing Lists
36
 
 
37
 
User feedback is an integral part of the evolution of this and other
38
 
Bioperl modules. Send your comments and suggestions preferably to
39
 
the Bioperl mailing list.  Your participation is much appreciated.
40
 
 
41
 
 bioperl-l@bioperl.org                  - General discussion
42
 
 http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
43
 
 
44
 
=head2 Support 
45
 
 
46
 
Please direct usage questions or support issues to the mailing list:
47
 
 
48
 
I<bioperl-l@bioperl.org>
49
 
 
50
 
rather than to the module maintainer directly. Many experienced and 
51
 
reponsive experts will be able look at the problem and quickly 
52
 
address it. Please include a thorough description of the problem 
53
 
with code and data examples if at all possible.
54
 
 
55
 
=head2 Reporting Bugs
56
 
 
57
 
Report bugs to the Bioperl bug tracking system to help us keep track
58
 
of the bugs and their resolution. Bug reports can be submitted via
59
 
the web:
60
 
 
61
 
 https://redmine.open-bio.org/projects/bioperl/
62
 
 
63
 
=head1 AUTHOR - Robert Buels
64
 
 
65
 
Email rmb32 AT cornell.edu
66
 
 
67
 
=head1 CONTRIBUTORS
68
 
 
69
 
Based on ptt.pm by Torsten Seeman
70
 
 
71
 
=head1 APPENDIX
72
 
 
73
 
The rest of the documentation details each of the object methods.
74
 
Internal methods are usually preceded with a _
75
 
 
76
 
=cut
77
 
 
78
 
# Let the code begin...
79
 
 
80
 
package Bio::FeatureIO::vecscreen_simple;
81
 
 
82
 
use strict;
83
 
use base qw(Bio::FeatureIO);
84
 
use Bio::SeqFeature::Generic;
85
 
 
86
 
=head2 _initialize
87
 
 
88
 
Title   : _initialize
89
 
Function: Reading? parses the header of the input
90
 
          Writing? 
91
 
 
92
 
=cut
93
 
 
94
 
sub _initialize {
95
 
 my($self,%arg) = @_;
96
 
 
97
 
 $self->SUPER::_initialize(%arg);
98
 
 
99
 
 if ($self->mode eq 'r') {
100
 
   $self->{parse_state}->{seqname}   = '';
101
 
   $self->{parse_state}->{matchtype} = '';
102
 
 }
103
 
 else {
104
 
   $self->throw('vecscreen_simple feature writing not implemented');
105
 
 }
106
 
}
107
 
 
108
 
=head2 next_feature
109
 
 
110
 
  Title   : next_feature
111
 
  Usage   : $io->next_feature()
112
 
  Function: read the next feature from the vecscreen output file
113
 
  Args    : none
114
 
  Returns : Bio::SeqFeatureI object
115
 
 
116
 
=cut
117
 
 
118
 
sub next_feature {
119
 
 my $self = shift;
120
 
 return unless $self->mode eq 'r'; # returns if can't read next_feature when we're in write mode
121
 
 
122
 
 while ( my $line = $self->_readline() ) {
123
 
   chomp $line;
124
 
   if ( $line =~ /^>Vector (\S+)/ ) {
125
 
     $self->{parse_state}{seqname} = $1;
126
 
   } elsif ( $line =~ /^\s*WARNING/ ) {
127
 
     $self->warn("$self->{parse_state}{seqname}: vecscreen says: $line\n");
128
 
   } elsif ( $line =~ /\S/ ) {
129
 
 
130
 
     $self->{parse_state}{seqname}
131
 
        or $self->throw("Unexpected line in vecscreen output '$line'");
132
 
 
133
 
     #if it's not a vector line, it should be either a match type or
134
 
     #a coordinates line
135
 
     my $lcline = lc $line;
136
 
 
137
 
     if ( $line =~ /^(\d+)\s+(\d+)\s*$/ ) {
138
 
        my ($s,$e) = ($1,$2);
139
 
 
140
 
        my $matchtype = $self->{parse_state}{matchtype};
141
 
        $matchtype =~ s/\s/_/g; #replace whitespace with underscores for the primary tag
142
 
        return Bio::SeqFeature::Generic->new( -start    => $s,
143
 
                                              -end      => $e,
144
 
                                              -primary  => $matchtype,
145
 
                                              -seq_id   => $self->{parse_state}{seqname},
146
 
                                            );
147
 
     } elsif ( $lcline eq 'no hits found' ) {
148
 
        $self->{parse_state}{seqname} = '';
149
 
     } elsif ( grep $lcline eq $_, 'strong match', 'moderate match', 'weak match', 'suspect origin') {
150
 
        $self->{parse_state}{matchtype} = $lcline;
151
 
     } else {
152
 
        $self->throw("Parse error.  Expected a match type or coordinate line but got '$line'");
153
 
     }
154
 
   } else {
155
 
     #blank line, ignore it and reset parser
156
 
 
157
 
     $self->{parse_state}{seqname} = ''; #< a line with whitespace
158
 
     #indicates a boundary
159
 
     #between output for
160
 
     #different sequences
161
 
     $self->{parse_state}{matchtype} = '';
162
 
   }
163
 
 }
164
 
 
165
 
 return;
166
 
}
167
 
 
168
 
=head2 write_feature (NOT IMPLEMENTED)
169
 
 
170
 
  Title   : write_feature
171
 
  Usage   : $io->write_feature($feature)
172
 
  Function: write a Bio::SeqFeatureI object in vecscreen -f 3 format
173
 
  Example :
174
 
  Args    : Bio::SeqFeatureI object
175
 
  Returns :
176
 
 
177
 
=cut
178
 
 
179
 
sub write_feature {
180
 
 shift->throw_not_implemented;
181
 
}
182
 
 
183
 
 
184
 
###
185
 
1;#do not remove
186
 
###