| 1 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | Bio::FeatureIO::gff - read/write GFF feature files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | my $feature; #get a Bio::SeqFeature::Annotated somehow | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | my $featureOut = Bio::FeatureIO->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | -format => 'gff', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | -version => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | -fh => \*STDOUT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | -validate_terms => 1, #boolean. validate ontology terms online? default 0 (false). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | $featureOut->write_feature($feature); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | Currently implemented: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | version read? write? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | GFF 1 N N | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | GFF 2 N N | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | GFF 2.5 (GTF) N Y | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | GFF 3 Y Y | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | http://bioperl.org/wiki/Mailing_list - About the mailing lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | =head2 Support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | of the bugs and their resolution. Bug reports can be submitted via | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | the web: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | http://bugzilla.open-bio.org/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | Allen Day, <allenday@ucla.edu> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | Steffen Grossmann, <grossman@molgen.mpg.de> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | Scott Cain, <cain@cshl.edu> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | Rob Edwards <rob@salmonella.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # Let the code begin... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | package Bio::FeatureIO::gff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | $Bio::FeatureIO::gff::AUTHORITY = 'cpan:BIOPERLML'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | $Bio::FeatureIO::gff::VERSION = '1.6.905'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | #these are alphabetical, keep them that way. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | ▶ | use Bio::Annotation::DBLink; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | use Bio::Annotation::OntologyTerm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | ▶ | use Bio::Annotation::SimpleValue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | ▶ | use Bio::Annotation::Target; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | ▶ | use Bio::FeatureIO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | ▶ | use Bio::Ontology::OntologyStore; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 4 | ▶ | use Bio::OntologyIO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 4 | ▶ | use Bio::SeqFeature::Annotated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 4 | ▶ | use Bio::SeqIO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | ▶ | use URI::Escape; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 4 | ▶ | use base qw(Bio::FeatureIO); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 4 | ▶ | use constant DEFAULT_VERSION => 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 4 | my $RESERVED_TAGS = "ID|Name|Alias|Parent|Target|Gap|Derives_from|Note|Dbxref|dbxref|Ontology_term|Index|CRUD"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 7 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=7 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | my($self,%arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | $self->SUPER::_initialize(%arg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | ▶ | $self->version( $arg{-version} || DEFAULT_VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$arg{'-version'} || 3
MC/DC0%0/1
$arg{'-version'} || 3
$arg{'-version'}
Truth table50%1/2
A
A= $arg{'-version'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 7 | ▶ | $self->validate($arg{-validate_terms} || 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$arg{'-validate_terms'} || 0
MC/DC0%0/1
$arg{'-validate_terms'} || 0
$arg{'-validate_terms'}
Truth table50%1/2
A
A= $arg{'-validate_terms'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 7 | ▶ | if ($arg{-file} =~ /^>.*/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $self->_print("##gff-version " . $self->version() . "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 7 | my $directive; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 7 | ▶ | while(($directive = $self->_readline()) && ($directive =~ /^##/) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$directive = $self->_readline and $directive =~ /^##/
MC/DC50%1/2
$directive = $self->_readline and $directive =~ /^##/
$directive = $self->_readline
$directive =~ /^##/
Truth table66%2/3
A and B
A= $directive = $self->_readlineB= $directive =~ /^##/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 12 | $self->_handle_directive($directive); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 7 | $self->_pushback($directive); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | #need to validate against SOFA, no SO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 7 | ▶ | if ($self->validate) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->so( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | Bio::Ontology::OntologyStore->get_ontology('Sequence Ontology Feature Annotation') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | =head2 next_feature() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | Usage : my $feature = $featureio->next_feature(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | Function: reads a feature record from a GFF stream and returns it as an object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | Returns : a Bio::SeqFeature::Annotated object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | Args : N/A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 68 | ▶ | sub next_feature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_feature: called CC=11 SCAR=24.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 68 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 68 | my $gff_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 68 | my($f) = $self->_buffer_feature(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 68 | ▶ | if($f){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | return $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 67 | ▶ | return if $self->fasta_mode(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # be graceful about empty lines or comments, and make sure we return undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # if the input is consumed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 65 | ▶ | while(($gff_string = $self->_readline()) && defined($gff_string)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$gff_string = $self->_readline and defined $gff_string
MC/DC0%0/2
$gff_string = $self->_readline and defined $gff_string
$gff_string = $self->_readline
defined $gff_string
Truth table33%1/3
A and B
A= $gff_string = $self->_readlineB= defined $gff_string
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 68 | ▶ | next if $gff_string =~ /^\s*$/; #skip blank lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 68 | ▶ | next if $gff_string =~ /^\#[^#]/; #skip comments, but not directives | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 65 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 65 | ▶ | return unless $gff_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # looks like we went into FASTA mode without a directive. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 65 | ▶ | if($gff_string =~ /^>/){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | my $pos = tell($self->_fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # TODO: SeqIO::fasta uses _fh directly, whereas _pushback uses an in-memory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # buffer; this completely breaks with piped data, so fix for files and punt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # on the rest for now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | if ($pos >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | seek($self->_fh, -length($gff_string), 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $self->warn("In-line parsing of FASTA not yet supported"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $self->_pushback($gff_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | $self->fasta_mode(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # got a directive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | elsif($gff_string =~ /^##/){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 6 | $self->_handle_directive($gff_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 6 | return $self->_buffer_feature(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # got a feature | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 57 | return $self->_handle_feature($gff_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | =head2 next_feature_group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | Title : next_feature_group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | Usage : @feature_group = $stream->next_feature_group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | Function: Reads the next feature_group from $stream and returns it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | Feature groups in GFF3 files are separated by '###' directives. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | features in a group might form a hierarchical structure. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | complete hierarchy of features is returned, i.e. the returned array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | represents only the top-level features. Lower-level features can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | be accessed using the 'get_SeqFeatures' method recursively. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | Example : # getting the complete hierarchy of features in a GFF3 file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | my @toplevel_features; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | while (my @fg = $stream->next_feature_group) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | push(@toplevel_features, @fg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | Returns : an array of Bio::SeqFeature::Annotated objects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | Args : none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 5 | ▶ | sub next_feature_group { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_feature_group: called CC=10 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 5 | my $feat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | my %seen_ids; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 5 | my @all_feats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | my @toplevel_feats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | $self->{group_not_done} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 5 | ▶ | while ($self->{group_not_done} && ($feat = $self->next_feature()) && defined($feat)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->{"group_not_done"} and $feat = $self->next_feature and defined $feat
$self->{"group_not_done"} and $feat = $self->next_feature
MC/DC33%1/3
$self->{"group_not_done"} and $feat = $self->next_feature and defined $feat
$self->{"group_not_done"}
$feat = $self->next_feature
defined $feat
Truth table50%2/4
A and B and C
A= $self->{"group_not_done"}B= $feat = $self->next_featureC= defined $feat
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | # we start by collecting all features in the group and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # memorizing those which have an ID attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 30 | my $anno_ID = $feat->get_Annotations('ID'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 30 | ▶ | if(ref($anno_ID)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 6 | my $attr_ID = $anno_ID->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | $self->throw("Oops! ID $attr_ID exists more than once in your file!") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 6 | ▶ | if (exists($seen_ids{$attr_ID})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 6 | $seen_ids{$attr_ID} = $feat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 30 | push(@all_feats, $feat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # assemble the top-level features | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 5 | foreach $feat (@all_feats) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 30 | my @parents = $feat->get_Annotations('Parent'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 30 | ▶ | if (@parents) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 24 | foreach my $parent (@parents) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 24 | my $parent_id = $parent->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 24 | ▶ | $self->throw("Parent with ID $parent_id not found!") unless (exists($seen_ids{$parent_id})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 24 | $seen_ids{$parent_id}->add_SeqFeature($feat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 6 | push(@toplevel_feats, $feat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 5 | return @toplevel_feats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | =head2 next_seq() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | access the FASTA section (if any) at the end of the GFF stream. note that this method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | will return undef if not all features in the stream have been handled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 17 | ▶ | sub next_seq() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_seq: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 17 | ▶ | return unless $self->fasta_mode(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | #first time next_seq has been called. initialize Bio::SeqIO instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 12 | ▶ | if(!$self->seqio){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 6 | $self->seqio( Bio::SeqIO->new(-format => 'fasta', -fh => $self->_fh()) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 12 | return $self->seqio->next_seq(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | =head2 write_feature() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | Usage : $featureio->write_feature( Bio::SeqFeature::Annotated->new(...) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | Function: writes a feature in GFF format. the GFF version used is governed by the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | '-version' argument passed to Bio::FeatureIO->new(), and defaults to GFF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | version 3. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | Returns : ###FIXME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | Args : a Bio::SeqFeature::Annotated object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub write_feature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_feature: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my($self,$feature) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if (!$feature) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $self->throw("gff.pm cannot write_feature unless you give a feature to write.\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | $self->throw("only Bio::SeqFeature::Annotated objects are writeable") unless $feature->isa('Bio::SeqFeature::Annotated'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | if($self->version == 1){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | return $self->_write_feature_1($feature); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } elsif($self->version == 2){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | return $self->_write_feature_2($feature); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } elsif($self->version == 2.5){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | return $self->_write_feature_25($feature); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } elsif($self->version == 3){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return $self->_write_feature_3($feature); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $self->throw(sprintf("don't know how to write GFF version %s",$self->version)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | ################################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | =head1 ACCESSORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | =head2 fasta_mode() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | Usage : $obj->fasta_mode($newval) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | Function: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | Example : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | Returns : value of fasta_mode (a scalar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | Side effect when setting: rewind the file handle a little bit to get the last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | carriage return that was swallowed when the previous line was processed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 91 | ▶ | sub fasta_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fasta_mode: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 91 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 91 | ▶ | $self->{'fasta_mode'} = $val if defined($val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 91 | ▶ | if ($val && $val == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$val and $val == 1
MC/DC50%1/2
$val and $val == 1
$val
$val == 1
Truth table66%2/3
A and B
A= $valB= $val == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # seek $self->_fh(), -1, 1; #rewind 1 byte to get the previous line's \n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 7 | $self->_pushback("\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 91 | return $self->{'fasta_mode'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | =head2 seqio() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | Usage : $obj->seqio($newval) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | Function: holds a Bio::SeqIO instance for handling the GFF3 ##FASTA section. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | Returns : value of seqio (a scalar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 30 | ▶ | sub seqio { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seqio: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 30 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 30 | ▶ | $self->{'seqio'} = $val if defined($val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 30 | return $self->{'seqio'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | =head2 sequence_region() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | Function: ###FIXME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | Returns : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | Args : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 1 | ▶ | sub sequence_region { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sequence_region: called CC=4 SCAR=18.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | my ($self,$k,$v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 1 | ▶ | if(defined($k) && defined($v)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $k and defined $v
MC/DC0%0/2
defined $k and defined $v
defined $k
defined $v
Truth table33%1/3
A and B
A= defined $kB= defined $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | $self->{'sequence_region'}{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | return $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | elsif(defined($k)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | return $self->{'sequence_region'}{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | =head2 so() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | Usage : $obj->so($newval) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | Function: holds a Sequence Ontology instance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | Returns : value of so (a scalar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | sub so { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
so: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | ###FIXME validate $val object's type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $self->{so} = $val if defined($val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | return $self->{so}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | =head2 validate() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | Usage : $obj->validate($newval) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | Function: true if encountered ontology terms in next_feature() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | mode should be validated. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | Returns : value of validate (a scalar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 80 | ▶ | sub validate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 80 | my($self,$val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 80 | ▶ | $self->{'validate'} = $val if defined($val); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 80 | return $self->{'validate'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | =head2 version() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | Usage : $obj->version($newval) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | Function: version of GFF to read/write. valid values are 1, 2, 2.5, and 3. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | Returns : value of version (a scalar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 7 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=4 SCAR=17.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 7 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 7 | my %valid = map {$_=>1} (1, 2, 2.5, 3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 7 | ▶ | if(defined $val && $valid{$val}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $val and $valid{$val}
MC/DC0%0/2
defined $val and $valid{$val}
defined $val
$valid{$val}
Truth table33%1/3
A and B
A= defined $valB= $valid{$val}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 7 | return $self->{'version'} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | elsif(defined($val)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $self->throw('invalid version. valid versions: '.join(' ', sort keys %valid)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | return $self->{'version'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ################################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | =head1 INTERNAL METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | =head2 _buffer_feature() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | Usage : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | Function: ###FIXME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | Returns : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | Args : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 75 | ▶ | sub _buffer_feature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_buffer_feature: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 75 | my ($self,$f) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 75 | ▶ | if ( $f ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | push @{ $self->{'buffer'} }, $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | return $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | elsif ( $self->{'buffer'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 2 | return shift @{ $self->{'buffer'} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 72 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | =head1 _handle_directive() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | this method is called for lines beginning with '##'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 18 | ▶ | sub _handle_directive { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_directive: called CC=13 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 18 | my($self,$directive_string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 18 | $directive_string =~ s/^##//; #remove escape | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 18 | my($directive,@arg) = split /\s+/, $directive_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 18 | ▶ | if($directive eq 'gff-version'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 6 | my $version = $arg[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 6 | ▶ | if($version != 3){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $self->throw("this is not a gff version 3 document, it is version '$version'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | elsif($directive eq 'sequence-region'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | # RAE: Sequence regions are in the format sequence-region seqid start end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # for these we want to store the seqid, start, and end. Then when we validate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # we want to make sure that the features are within the seqid/start/end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | ▶ | $self->throw('Both start and end for sequence region should be defined') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$arg[1] and $arg[2]
MC/DC0%0/2
$arg[1] and $arg[2]
$arg[1]
$arg[2]
Truth table33%1/3
A and B
A= $arg[1]B= $arg[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | unless $arg[1] && $arg[2]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 1 | my $fta = Bio::Annotation::OntologyTerm->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | $fta->name( 'region'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | my $f = Bio::SeqFeature::Annotated->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | $f->seq_id( $arg[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 1 | $f->start( $arg[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 1 | $f->end( $arg[2] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 1 | $f->strand(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 1 | $f->type( $fta ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | #cache this in sequence_region(), we may need it for validation later. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 1 | $self->sequence_region($f->seq_id => $f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | #NOTE: is this the right thing to do -- treat this as a feature? -allenday | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | #buffer it to be returned by next_feature() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1 | $self->_buffer_feature($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | elsif($directive eq 'feature-ontology'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 1 | $self->warn("'##$directive' directive handling not yet implemented"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | elsif($directive eq 'attribute-ontology'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 1 | $self->warn("'##$directive' directive handling not yet implemented"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | elsif($directive eq 'source-ontology'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 1 | $self->warn("'##$directive' directive handling not yet implemented"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ▶ | elsif($directive eq 'FASTA' or $directive =~ /^>/){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$directive eq "FASTA" or $directive =~ /^>/
MC/DC50%1/2
$directive eq "FASTA" or $directive =~ /^>/
$directive eq "FASTA"
$directive =~ /^>/
Truth table66%2/3
A or B
A= $directive eq "FASTA"B= $directive =~ /^>/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | #next_seq() will take care of this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 5 | $self->fasta_mode(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | elsif($directive eq '#'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | #all forward references resolved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 3 | $self->{group_not_done} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | elsif($directive eq 'organism') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my $organism = $arg[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | $self->organism($organism); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $self->throw("don't know what do do with directive: '##".$directive."'"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | =head1 _handle_feature() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | this method is called for each line not beginning with '#'. it parses the line and returns a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | Bio::SeqFeature::Annotated object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 57 | ▶ | sub _handle_feature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_feature: called CC=54 SCAR=56.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 57 | my($self,$feature_string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 57 | my $feat = Bio::SeqFeature::Annotated->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 57 | my($seq,$source,$type,$start,$end,$score,$strand,$phase,$attribute_string) = split /\t/, $feature_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 57 | $feat->seq_id($seq); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 57 | $feat->source_tag($source); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 57 | ▶ | $feat->start($start) unless $start eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 57 | ▶ | $feat->end($end) unless $end eq '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 57 | ▶ | $feat->strand($strand eq '+' ? 1 : $strand eq '-' ? -1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 57 | $feat->score($score); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 57 | $feat->phase($phase); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 57 | my $fta = Bio::Annotation::OntologyTerm->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 57 | ▶ | if($self->validate()){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # RAE Added a couple of validations based on the GFF3 spec at http://song.sourceforge.net/gff3.shtml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # 1. Validate the id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | if ($seq =~ /[^a-zA-Z0-9\.\-\:\^\*\$\@\!\+\_\?]/) { # I just escaped everything. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | $self->throw("Validation Error: seqid ($seq) contains characters that are not [a-zA-Z0-9.:^*\$\@!+_?\-] and not escaped"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | if ($seq =~ /\s/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $self->throw("Validation Error: seqid ($seq) contains unescaped whitespace") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # NOTE i think we're handling this in as a directive, and this test may be removed -allenday | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if ($seq =~ /^>/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $self->throw("Validation Error: seqid ($seq) begins with a >") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | # 2. Validate the starts and stops. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # these need to be within the region's bounds, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | # also start <= end. bail out if either is not true. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | if ($start > $end) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $self->throw("Validation Error: start ($start) must be less than or equal to end in $seq"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $region = $self->sequence_region($seq); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # NOTE: we can only validate against sequence-region that are declared in the file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | # if i reference some region from elsewhere, can't validate. if we want to be really strict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | # we should bail out here. -allenday | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | if ( defined($region) && $start < $region->start() || $end > $region->end() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $region and $start < $region->start or $end > $region->end
defined $region and $start < $region->start
MC/DC0%0/3
defined $region and $start < $region->start or $end > $region->end
defined $region
$start < $region->start
$end > $region->end
Truth table0%0/5
A and B or C
A= defined $regionB= $start < $region->startC= $end > $region->end
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $self->throw("Validation Error: sequence location ($seq from $start to $end) does not appear to lie within a defined sequence-region") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | # 3. Validate the strand. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | # In the unvalidated version +=1 and -=-1. Everything else is 0. We just need to warn when it is not [+-.?] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | $self->throw("Validation Error: strand is not one of [+-.?] at $seq") if ($strand =~ /^[^\+\-\.\?]$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | # 4. Validate the phase to be one of [.012] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | $self->throw("Validation Error: phase is not one of [.012] at $seq") if ($phase =~ /^[^\.012]$/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $feature_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | if($type =~ /^\D+:\d+$/){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | #looks like an identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ($feature_type) = $self->so->find_terms(-identifier => $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | #looks like a name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ($feature_type) = $self->so->find_terms(-name => $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | if(!$feature_type){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | $self->throw("Validation Error: couldn't find ontology term for '$type'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | $fta->term($feature_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 57 | ▶ | if($type =~ /^\D+:\d+$/){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | #looks like an identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | $fta->identifier($type) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 57 | $fta->name($type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 57 | $feat->type($fta); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 57 | my %attr = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 57 | chomp $attribute_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 57 | ▶ | unless ( $attribute_string eq '.' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 57 | my @attributes = split ';', $attribute_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 57 | foreach my $attribute (@attributes){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 93 | my($key,$values) = split '=', $attribute; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | # remove leading and trailing quotes from values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 93 | $values =~ s/^["']//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 93 | $values =~ s/["']$//; #' terminate the quote for emacs | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 93 | my @values = map{uri_unescape($_)} split ',', $values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | #minor hack to allow for multiple instances of the same tag | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 93 | ▶ | if ($attr{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 3 | my @tmparray = @{$attr{$key}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 3 | push @tmparray, @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 3 | $attr{$key} = [@tmparray]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 90 | $attr{$key} = [@values]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | #Handle Dbxref attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 57 | ▶ | if($attr{Dbxref} or $attr{dbxref}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$attr{"Dbxref"} or $attr{"dbxref"}
MC/DC50%1/2
$attr{"Dbxref"} or $attr{"dbxref"}
$attr{"Dbxref"}
$attr{"dbxref"}
Truth table66%2/3
A or B
A= $attr{"Dbxref"}B= $attr{"dbxref"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 8 | foreach my $value (@{ $attr{Dbxref} }, @{ $attr{dbxref} }){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 71 | my $a = Bio::Annotation::DBLink->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 71 | my($db,$accession) = $value =~ /^(.+?):(.+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 71 | ▶ | if(!$db or !$accession){ #dbxref malformed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$db and $accession
MC/DC0%0/2
$db and $accession
$db
$accession
Truth table33%1/3
A and B
A= $dbB= $accession
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | $self->throw("Error in line:\n$feature_string\nDbxref value '$value' did not conform to GFF3 specification"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 71 | $a->database($db); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 71 | $a->primary_id($accession); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 71 | $feat->add_Annotation('Dbxref',$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | #Handle Ontology_term attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 57 | ▶ | if($attr{Ontology_term}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 3 | foreach my $id (@{ $attr{Ontology_term} }){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 9 | my $a = Bio::Annotation::OntologyTerm->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 9 | ▶ | if($self->validate()){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | my $ont_name = Bio::Ontology::OntologyStore->guess_ontology($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | my $ont = Bio::Ontology::OntologyStore->get_ontology($ont_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my($term) = $ont->find_terms(-identifier => $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $a->term($term); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 9 | $a->identifier($id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 9 | $feat->add_Annotation('Ontology_term',$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | #Handle Gap attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 57 | ▶ | if($attr{Gap}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 3 | for my $value (@{ $attr{Gap} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 3 | my $a = Bio::Annotation::SimpleValue->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 3 | $a->value($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 3 | $feat->add_Annotation('Gap',$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | #Handle Target attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 57 | ▶ | if($attr{Target}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 3 | my $target_collection = Bio::Annotation::Collection->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 3 | foreach my $target_string (@{ $attr{Target} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | #only replace + for space if + has been used in place of it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | #that is, + could also mean plus strand, and we don't want | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | #to accidentally remove it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | #presumably you can't use + for space and + for strand in the same string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 3 | ▶ | $target_string =~ s/\+/ /g unless $target_string =~ / /; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 3 | my ($t_id,$tstart,$tend,$strand,$extra) = split /\s+/, $target_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 3 | ▶ | if (!$tend || $extra) { # too much or too little stuff in the string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $tend or $extra
MC/DC0%0/2
not $tend or $extra
not $tend
$extra
Truth table33%1/3
not(A) or B
A= not $tendB= $extra
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | $self->throw("The value in the Target string, $target_string, does not conform to the GFF3 specification"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 3 | my $a = Bio::Annotation::Target->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | -target_id => $t_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | -start => $tstart, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | -end => $tend, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 3 | ▶ | if ($strand && $strand eq '+') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$strand and $strand eq "+"
MC/DC0%0/2
$strand and $strand eq "+"
$strand
$strand eq "+"
Truth table33%1/3
A and B
A= $strandB= $strand eq "+"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | $strand = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | ▶ | } elsif ($strand && $strand eq '-') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$strand and $strand eq "-"
MC/DC0%0/2
$strand and $strand eq "-"
$strand
$strand eq "-"
Truth table33%1/3
A and B
A= $strandB= $strand eq "-"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | $strand = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 3 | $strand = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 3 | ▶ | $a->strand($strand) if $strand; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 3 | $feat->add_Annotation('Target',$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | #Handle ID attribute. May only have one ID, throw error otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 57 | ▶ | if($attr{ID}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 11 | ▶ | if(scalar( @{ $attr{ID} } ) > 1){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $self->throw("Error in line:\n$feature_string\nA feature may have at most one ID value"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | #ID's must be unique in the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 11 | ▶ | if ($self->{'allIDs'}->{${$attr{ID}}[0]} && $self->validate()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"allIDs"}{do {
$attr{"ID"}
}->[0]} and $self->validate
MC/DC0%0/2
$self->{"allIDs"}{do {
$attr{"ID"}
}->[0]} and $self->validate
$self->{"allIDs"}{do {
$attr{"ID"}
}->[0]}
$self->validate
Truth table33%1/3
A and B
A= $self->{"allIDs"}{do {
$attr{"ID"}
}->[0]}B= $self->validate
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $self->throw("Validation Error: The ID ${$attr{ID}}[0] occurs more than once in the file, but should be unique"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 11 | $self->{'allIDs'}->{${$attr{ID}}[0]} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 11 | my $a = Bio::Annotation::SimpleValue->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 11 | $a->value( @{ $attr{ID} }[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 11 | $feat->add_Annotation('ID',$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | #Handle Name attribute. May only have one Name, throw error otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 57 | ▶ | if($attr{Name}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | if(scalar( @{ $attr{Name} } ) > 1){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | $self->throw("Error in line:\n$feature_string\nA feature may have at most one Name value"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | my $a = Bio::Annotation::SimpleValue->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | $a->value( @{ $attr{Name} }[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $feat->add_Annotation('Name',$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 57 | foreach my $other_canonical (qw(Alias Parent Note Derives_from Index CRUD)){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 342 | ▶ | if($attr{$other_canonical}){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 62 | foreach my $value (@{ $attr{$other_canonical} }){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 62 | my $a = Bio::Annotation::SimpleValue->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 62 | $a->value($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 62 | $feat->add_Annotation($other_canonical,$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 57 | my @non_reserved_tags = grep {/^[a-z]/} keys %attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 57 | foreach my $non_reserved_tag (@non_reserved_tags) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 8 | ▶ | next if ($non_reserved_tag eq 'dbxref'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | foreach my $value (@{ $attr{$non_reserved_tag} }){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | $feat = $self->_handle_non_reserved_tag($feat,$non_reserved_tag,$value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | my @illegal_tags = grep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 90 | {!/($RESERVED_TAGS)/} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 57 | grep {/^[A-Z]/} keys %attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 57 | ▶ | if (@illegal_tags > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | my $tags = join(", ", @illegal_tags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | $self->throw("The following tag(s) are illegal and are causing this parser to die: $tags"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 57 | return $feat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | =head2 _handle_non_reserved_tag() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | Usage : $self->_handle_non_reserved_tag($feature,$tag,$value) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | Function: Deal with non-reserved word tags in the ninth column | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | Returns : An updated Bio::SeqFeature::Annotated object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | Args : A Bio::SeqFeature::Annotated and a tag/value pair | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | Note that this method can be overridden in a subclass to provide | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | special handling of non-reserved word tags. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | sub _handle_non_reserved_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_non_reserved_tag: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | my ($feat,$tag,$value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | # to customize through subclassing and overriding: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | #if ($tag eq 'someTagOfInterest') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | # do something different | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | # else { do what is below | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | my $a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | if ($tag eq 'comment') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | $a = Bio::Annotation::Comment->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | $a = Bio::Annotation::SimpleValue->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | $a->value($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | $feat->add_Annotation($tag,$a); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | return $feat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | =head2 organism | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | Gets/sets the organims from the organism directive | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | ▶ | sub organism { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
organism: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | ▶ | my $organism = shift if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | return $self->{'organism'} = $organism if defined($organism); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | return $self->{'organism'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | =head1 _write_feature_1() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | write a feature in GFF v1 format. currently not implemented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | sub _write_feature_1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_feature_1: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my($self,$feature) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | $self->throw(sprintf("write_feature unimplemented for GFF version %s",$self->version)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | =head1 _write_feature_2() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | write a feature in GFF v2 format. currently not implemented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | sub _write_feature_2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_feature_2: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my($self,$feature) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | $self->throw(sprintf("write_feature unimplemented for GFF version %s",$self->version)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | =head1 _write_feature_25() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | write a feature in GFF v2.5 (aka GTF) format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | sub _write_feature_25 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_feature_25: not called CC=23 SCAR=63.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | my($self,$feature,$group) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | #the top-level feature is an aggregate of all subfeatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | my ($transcript_id, $gene_id) = (($feature->get_Annotations('transcript_id'))[0], ($feature->get_Annotations('gene_id'))[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | if(!defined($group)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | $group = ($feature->get_Annotations('ID'))[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | $transcript_id ||= $group; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$transcript_id ||= $group
MC/DC0%0/2
$transcript_id ||= $group
$transcript_id
$group
Truth table0%0/3
A ||= B
A= $transcript_idB= $group
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | $gene_id ||= $group; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$gene_id ||= $group
MC/DC0%0/2
$gene_id ||= $group
$gene_id
$group
Truth table0%0/3
A ||= B
A= $gene_idB= $group
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | my $seq = ref($feature->seq_id) ? $feature->seq_id->value : $feature->seq_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | my $source = $feature->source->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | my $type = $feature->type->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | $type = 'EXON' if $type eq 'exon'; #a GTF peculiarity, incosistent with the sequence ontology. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | ▶ | my $min = $feature->start || '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->start || '.'
MC/DC0%0/1
$feature->start || '.'
$feature->start
Truth table0%0/2
A
A= $feature->start
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | ▶ | my $max = $feature->end || '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->end || '.'
MC/DC0%0/1
$feature->end || '.'
$feature->end
Truth table0%0/2
A
A= $feature->end
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | ▶ | my $strand = $feature->strand == 1 ? '+' : $feature->strand == -1 ? '-' : '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | my $score = defined($feature->score) ? (ref($feature->score) ? $feature->score->value : $feature->score) : '.'; # score is optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | my $frame = defined($feature->frame) ? (ref($feature->frame) ? $feature->frame->value : $feature->frame) : (ref($feature->phase) ? $feature->phase->value : $feature->phase); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | #these are the only valid types in a GTF document | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | if($type eq 'EXON' or $type eq 'CDS' or $type eq 'start_codon' or $type eq 'stop_codon'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$type eq "EXON" or $type eq "CDS" or $type eq "start_codon" or $type eq "stop_codon"
$type eq "EXON" or $type eq "CDS" or $type eq "start_codon"
$type eq "EXON" or $type eq "CDS"
MC/DC0%0/4
$type eq "EXON" or $type eq "CDS" or $type eq "start_codon" or $type eq "stop_codon"
$type eq "EXON"
$type eq "CDS"
$type eq "start_codon"
$type eq "stop_codon"
Truth table0%0/5
A or B or C or D
A= $type eq "EXON"B= $type eq "CDS"C= $type eq "start_codon"D= $type eq "stop_codon"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | my $attr = sprintf('gene_id "%s"; transcript_id "%s";',$gene_id ? $gene_id->value : '',$transcript_id ? $transcript_id->value : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | my $outstring = sprintf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | $seq,$source,$type,$min,$max,$score,$strand,$frame eq '.' ? 0 : $frame,$attr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | $self->_print($outstring); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | foreach my $subfeat ($feature->get_SeqFeatures){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | $self->_write_feature_25($subfeat,$group); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | =head1 _write_feature_3() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | write a feature in GFF v3 format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | ▶ | sub _write_feature_3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_feature_3: not called CC=23 SCAR=63.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | my($self,$feature) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | ▶ | my $seq = ref($feature->seq_id) ? $feature->seq_id->value : $feature->seq_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | my $source; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | ▶ | if ($feature->source()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | $source = $feature->source->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | $source = $feature->source() || "unknownsource"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->source || 'unknownsource'
MC/DC0%0/1
$feature->source || 'unknownsource'
$feature->source
Truth table0%0/2
A
A= $feature->source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | my $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | ▶ | if ($feature->type()) { $type = $feature->type->name; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | else { $type = "region"; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | ▶ | my $min = $feature->start || '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->start || '.'
MC/DC0%0/1
$feature->start || '.'
$feature->start
Truth table0%0/2
A
A= $feature->start
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | my $max = $feature->end || '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->end || '.'
MC/DC0%0/1
$feature->end || '.'
$feature->end
Truth table0%0/2
A
A= $feature->end
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | my $strand = $feature->strand == 1 ? '+' : $feature->strand == -1 ? '-' : '.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | ▶ | my $score = defined($feature->score) ? (ref($feature->score) ? $feature->score->value : $feature->score) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | ▶ | my $phase = defined($feature->phase) ? (ref($feature->phase) ? $feature->phase->value : $feature->phase) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my @attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | if(my @v = ($feature->get_Annotations('Name'))){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | my $vstring = join ',', map {uri_escape($_->value)} @v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | push @attr, "Name=$vstring"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | if(my @v = ($feature->get_Annotations('ID'))){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | my $vstring = join ',', map {uri_escape($_->value)} @v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | push @attr, "ID=$vstring"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | ▶ | $self->throw('GFF3 features may have at most one ID, feature with these IDs is invalid:\n'.$vstring) if scalar(@v) > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | ▶ | if(my @v = ($feature->get_Annotations('Parent'))){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | my $vstring = join ',', map {uri_escape($_->value)} @v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | push @attr, "Parent=$vstring"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | ▶ | if(my @v = ($feature->get_Annotations('dblink'))){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | my $vstring = join ',', map {uri_escape($_->database .':'. $_->primary_id)} @v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | push @attr, "Dbxref=$vstring"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | ▶ | if(my @v = ($feature->get_Annotations('ontology_term'))){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | my $vstring = join ',', map {uri_escape($_->identifier)} @v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | push @attr, "Ontology_term=$vstring"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | if(my @v = ($feature->get_Annotations('comment'))){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | my $vstring = join ',', map {uri_escape($_->text)} @v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | push @attr, "Note=$vstring"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | ▶ | if(my @v = ($feature->get_Annotations('Target'))){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | my %strand_map = ( 1=>'+', 0=>'', -1=>'-', '+' => '+', '-' => '-' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | my $vstring = join ',', map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | ▶ | uri_escape($_->target_id).' '.$_->start.' '.$_->end.(defined $_->strand ? ' '.$strand_map{$_->strand} : '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } @v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | push @attr, "Target=$vstring"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | my $attr = join ';', @attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | my $outstring = sprintf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | $seq,$source,$type,$min,$max,$score,$strand,$phase,$attr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | $self->_print($outstring); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | foreach my $subfeat ($feature->get_SeqFeatures){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | $self->_write_feature_3($subfeat); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||