File: vecscreen_simple.pm

package info (click to toggle)
libbio-featureio-perl 1.6.905-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 344 kB
  • sloc: perl: 1,479; makefile: 2
file content (189 lines) | stat: -rw-r--r-- 5,023 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
=pod

=head1 NAME

Bio::FeatureIO::vecscreen_simple - read/write features from NCBI vecscreen -f 3
output

=head1 SYNOPSIS

    # read features 
    my $fin = Bio::FeatureIO->new(-file=>'vecscreen.out',
                                  -format=>'vecscreen_simple');
    my @vec_regions;
    while (my $f = $fin->next_feature) {
      push @vec_regions, $f;
    }
    
    # write features NOT IMPLEMENTED

=head1 DESCRIPTION

vecscreen is a system for quickly identifying segments of a nucleic
acid sequence that may be of vector origin.  NCBI developed vecscreen
to minimize the incidence and impact of vector contamination in public
sequence databases.  GenBank Annotation Staff use vecscreen to verify
that sequences submitted for inclusion in the database are free from
contaminating vector sequence. Any sequence can be screened for vector
contamination using vecscreen.

This module provides parsing for vecscreen '-f 3' output, described in
the vecscreen documentation as 'Text list, no alignments'

=head1 FEEDBACK

=head2 Mailing Lists

User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list.  Your participation is much appreciated.

 bioperl-l@bioperl.org                  - General discussion
 http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

=head2 Support 

Please direct usage questions or support issues to the mailing list:

I<bioperl-l@bioperl.org>

rather than to the module maintainer directly. Many experienced and 
reponsive experts will be able look at the problem and quickly 
address it. Please include a thorough description of the problem 
with code and data examples if at all possible.

=head2 Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:

 http://bugzilla.open-bio.org/

=head1 AUTHOR - Robert Buels

Email rmb32 AT cornell.edu

=head1 CONTRIBUTORS

Based on ptt.pm by Torsten Seeman

=head1 APPENDIX

The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _

=cut

# Let the code begin...

package Bio::FeatureIO::vecscreen_simple;
BEGIN {
  $Bio::FeatureIO::vecscreen_simple::AUTHORITY = 'cpan:BIOPERLML';
}
$Bio::FeatureIO::vecscreen_simple::VERSION = '1.6.905';
use strict;
use base qw(Bio::FeatureIO);
use Bio::SeqFeature::Generic;

=head2 _initialize

Title   : _initialize
Function: Reading? parses the header of the input
          Writing? 

=cut

sub _initialize {
 my($self,%arg) = @_;

 $self->SUPER::_initialize(%arg);

 if ($self->mode eq 'r') {
   $self->{parse_state}->{seqname}   = '';
   $self->{parse_state}->{matchtype} = '';
 }
 else {
   $self->throw('vecscreen_simple feature writing not implemented');
 }
}

=head2 next_feature

  Title   : next_feature
  Usage   : $io->next_feature()
  Function: read the next feature from the vecscreen output file
  Args    : none
  Returns : Bio::SeqFeatureI object

=cut

sub next_feature {
 my $self = shift;
 return unless $self->mode eq 'r'; # returns if can't read next_feature when we're in write mode

 while ( my $line = $self->_readline() ) {
   chomp $line;
   if ( $line =~ /^>Vector (\S+)/ ) {
     $self->{parse_state}{seqname} = $1;
   } elsif ( $line =~ /^\s*WARNING/ ) {
     $self->warn("$self->{parse_state}{seqname}: vecscreen says: $line\n");
   } elsif ( $line =~ /\S/ ) {

     $self->{parse_state}{seqname}
	or $self->throw("Unexpected line in vecscreen output '$line'");

     #if it's not a vector line, it should be either a match type or
     #a coordinates line
     my $lcline = lc $line;

     if ( $line =~ /^(\d+)\s+(\d+)\s*$/ ) {
	my ($s,$e) = ($1,$2);

	my $matchtype = $self->{parse_state}{matchtype};
	$matchtype =~ s/\s/_/g; #replace whitespace with underscores for the primary tag
	return Bio::SeqFeature::Generic->new( -start    => $s,
					      -end      => $e,
					      -primary  => $matchtype,
					      -seq_id   => $self->{parse_state}{seqname},
					    );
     } elsif ( $lcline eq 'no hits found' ) {
	$self->{parse_state}{seqname} = '';
     } elsif ( grep $lcline eq $_, 'strong match', 'moderate match', 'weak match', 'suspect origin') {
	$self->{parse_state}{matchtype} = $lcline;
     } else {
	$self->throw("Parse error.  Expected a match type or coordinate line but got '$line'");
     }
   } else {
     #blank line, ignore it and reset parser

     $self->{parse_state}{seqname} = ''; #< a line with whitespace
     #indicates a boundary
     #between output for
     #different sequences
     $self->{parse_state}{matchtype} = '';
   }
 }

 return;
}

=head2 write_feature (NOT IMPLEMENTED)

  Title   : write_feature
  Usage   : $io->write_feature($feature)
  Function: write a Bio::SeqFeatureI object in vecscreen -f 3 format
  Example :
  Args    : Bio::SeqFeatureI object
  Returns :

=cut

sub write_feature {
 shift->throw_not_implemented;
}


###
1;#do not remove
###