| 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 | http://bugzilla.open-bio.org/ | ||||||||||||||||||
| 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 | 3 | ▶ | BEGIN { | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 82 | 3 | $Bio::FeatureIO::vecscreen_simple::AUTHORITY = 'cpan:BIOPERLML'; | |||||||||||||||||
| 83 | } | ||||||||||||||||||
| 84 | 3 | $Bio::FeatureIO::vecscreen_simple::VERSION = '1.6.905'; | |||||||||||||||||
| 85 | 3 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 86 | 3 | ▶ | use base qw(Bio::FeatureIO); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 87 | 3 | ▶ | use Bio::SeqFeature::Generic; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | =head2 _initialize | ||||||||||||||||||
| 90 | |||||||||||||||||||
| 91 | Title : _initialize | ||||||||||||||||||
| 92 | Function: Reading? parses the header of the input | ||||||||||||||||||
| 93 | Writing? | ||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | =cut | ||||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | 1 | ▶ | sub _initialize { | ||||||||||||||||
|
Subroutine
_initialize: called CC=2 SCAR=7.2
| |||||||||||||||||||
| 98 | 1 | my($self,%arg) = @_; | |||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | 1 | $self->SUPER::_initialize(%arg); | |||||||||||||||||
| 101 | |||||||||||||||||||
| 102 | 1 | ▶ | if ($self->mode eq 'r') { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 103 | 1 | $self->{parse_state}->{seqname} = ''; | |||||||||||||||||
| 104 | 1 | $self->{parse_state}->{matchtype} = ''; | |||||||||||||||||
| 105 | } | ||||||||||||||||||
| 106 | else { | ||||||||||||||||||
| 107 | 0 | $self->throw('vecscreen_simple feature writing not implemented'); | |||||||||||||||||
| 108 | } | ||||||||||||||||||
| 109 | } | ||||||||||||||||||
| 110 | |||||||||||||||||||
| 111 | =head2 next_feature | ||||||||||||||||||
| 112 | |||||||||||||||||||
| 113 | Title : next_feature | ||||||||||||||||||
| 114 | Usage : $io->next_feature() | ||||||||||||||||||
| 115 | Function: read the next feature from the vecscreen output file | ||||||||||||||||||
| 116 | Args : none | ||||||||||||||||||
| 117 | Returns : Bio::SeqFeatureI object | ||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | =cut | ||||||||||||||||||
| 120 | |||||||||||||||||||
| 121 | 15 | ▶ | sub next_feature { | ||||||||||||||||
|
Subroutine
next_feature: called CC=10 SCAR=23.4
Pod
documented
| |||||||||||||||||||
| 122 | 15 | my $self = shift; | |||||||||||||||||
| 123 | 15 | ▶ | return unless $self->mode eq 'r'; # returns if can't read next_feature when we're in write mode | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | 15 | ▶ | while ( my $line = $self->_readline() ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 126 | 42 | chomp $line; | |||||||||||||||||
| 127 | 42 | ▶ | if ( $line =~ /^>Vector (\S+)/ ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 128 | 7 | $self->{parse_state}{seqname} = $1; | |||||||||||||||||
| 129 | } elsif ( $line =~ /^\s*WARNING/ ) { | ||||||||||||||||||
| 130 | 0 | $self->warn("$self->{parse_state}{seqname}: vecscreen says: $line\n"); | |||||||||||||||||
| 131 | } elsif ( $line =~ /\S/ ) { | ||||||||||||||||||
| 132 | |||||||||||||||||||
| 133 | $self->{parse_state}{seqname} | ||||||||||||||||||
| 134 | 28 | ▶ | or $self->throw("Unexpected line in vecscreen output '$line'"); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 135 | |||||||||||||||||||
| 136 | #if it's not a vector line, it should be either a match type or | ||||||||||||||||||
| 137 | #a coordinates line | ||||||||||||||||||
| 138 | 28 | my $lcline = lc $line; | |||||||||||||||||
| 139 | |||||||||||||||||||
| 140 | 28 | ▶ | if ( $line =~ /^(\d+)\s+(\d+)\s*$/ ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 141 | 14 | my ($s,$e) = ($1,$2); | |||||||||||||||||
| 142 | |||||||||||||||||||
| 143 | 14 | my $matchtype = $self->{parse_state}{matchtype}; | |||||||||||||||||
| 144 | 14 | $matchtype =~ s/\s/_/g; #replace whitespace with underscores for the primary tag | |||||||||||||||||
| 145 | return Bio::SeqFeature::Generic->new( -start => $s, | ||||||||||||||||||
| 146 | -end => $e, | ||||||||||||||||||
| 147 | -primary => $matchtype, | ||||||||||||||||||
| 148 | -seq_id => $self->{parse_state}{seqname}, | ||||||||||||||||||
| 149 | 14 | ); | |||||||||||||||||
| 150 | } elsif ( $lcline eq 'no hits found' ) { | ||||||||||||||||||
| 151 | 2 | $self->{parse_state}{seqname} = ''; | |||||||||||||||||
| 152 | } elsif ( grep $lcline eq $_, 'strong match', 'moderate match', 'weak match', 'suspect origin') { | ||||||||||||||||||
| 153 | 12 | $self->{parse_state}{matchtype} = $lcline; | |||||||||||||||||
| 154 | } else { | ||||||||||||||||||
| 155 | 0 | $self->throw("Parse error. Expected a match type or coordinate line but got '$line'"); | |||||||||||||||||
| 156 | } | ||||||||||||||||||
| 157 | } else { | ||||||||||||||||||
| 158 | #blank line, ignore it and reset parser | ||||||||||||||||||
| 159 | |||||||||||||||||||
| 160 | 7 | $self->{parse_state}{seqname} = ''; #< a line with whitespace | |||||||||||||||||
| 161 | #indicates a boundary | ||||||||||||||||||
| 162 | #between output for | ||||||||||||||||||
| 163 | #different sequences | ||||||||||||||||||
| 164 | 7 | $self->{parse_state}{matchtype} = ''; | |||||||||||||||||
| 165 | } | ||||||||||||||||||
| 166 | } | ||||||||||||||||||
| 167 | |||||||||||||||||||
| 168 | 1 | return; | |||||||||||||||||
| 169 | } | ||||||||||||||||||
| 170 | |||||||||||||||||||
| 171 | =head2 write_feature (NOT IMPLEMENTED) | ||||||||||||||||||
| 172 | |||||||||||||||||||
| 173 | Title : write_feature | ||||||||||||||||||
| 174 | Usage : $io->write_feature($feature) | ||||||||||||||||||
| 175 | Function: write a Bio::SeqFeatureI object in vecscreen -f 3 format | ||||||||||||||||||
| 176 | Example : | ||||||||||||||||||
| 177 | Args : Bio::SeqFeatureI object | ||||||||||||||||||
| 178 | Returns : | ||||||||||||||||||
| 179 | |||||||||||||||||||
| 180 | =cut | ||||||||||||||||||
| 181 | |||||||||||||||||||
| 182 | 0 | ▶ | sub write_feature { | ||||||||||||||||
|
Subroutine
write_feature: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 183 | 0 | shift->throw_not_implemented; | |||||||||||||||||
| 184 | } | ||||||||||||||||||
| 185 | |||||||||||||||||||
| 186 | |||||||||||||||||||
| 187 | ### | ||||||||||||||||||
| 188 | 3 | 1;#do not remove | |||||||||||||||||
| 189 | ### | ||||||||||||||||||