| 1 | # Let the code begin... | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package Bio::AlignIO::Handler::GenericAlignHandler; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | $Bio::AlignIO::Handler::GenericAlignHandler::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Bio::Annotation::Collection; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Bio::Annotation::Comment; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Bio::Annotation::SimpleValue; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Bio::Annotation::Target; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Bio::Annotation::DBLink; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Bio::Annotation::Reference; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Bio::SimpleAlign; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use base qw(Bio::Root::Root Bio::HandlerBaseI); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | # only stockholm is defined for now... | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my %HANDLERS = ( | |||||||||||||||||||||||||||||||||||||||||
| 21 | # stockholm has sequence and alignment specific annotation; this | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 'stockholm' => { | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 'CONSENSUS_META' => \&_generic_consensus_meta, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 'SEQUENCE' => \&_generic_metaseq, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 'NAMED_META' => \&_generic_metaseq, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 'ACCESSION' => \&_generic_store, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 'ALPHABET' => \&_generic_store, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 'ID' => \&_generic_store, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 'DESCRIPTION' => \&_generic_store, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 'REFERENCE' => \&_generic_reference, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 'DBLINK' => \&_stockholm_target, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 'DATABASE_COMMENT' => \&_generic_comment, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 'ALIGNMENT_COMMENT' => \&_generic_comment, | ||||||||||||||||||||||||||||||||||||||||||
| 34 | '_DEFAULT_' => \&_generic_simplevalue | ||||||||||||||||||||||||||||||||||||||||||
| 35 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my ($format, $verbose) = $self->_rearrange([qw(FORMAT VERBOSE)], @args); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $self->throw("Must define alignment record format") if !$format; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | $verbose && $self->verbose($verbose); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $self->format($format); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $self->handler_methods(); | |||||||||||||||||||||||||||||||||||||||||
| 46 | # if we intend at a later point we can add a Builder | ||||||||||||||||||||||||||||||||||||||||||
| 47 | #$builder && $self->alignbuilder($builder); | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub handler_methods { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler_methods: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (!($self->{'handlers'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | $self->throw("No handlers defined for alignment format ",$self->format) | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | unless exists $HANDLERS{$self->format}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $self->{'handlers'} = $HANDLERS{$self->format}; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return ($self->{'handlers'}); | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub data_handler { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data_handler: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my $nm = $data->{NAME} || $self->throw("No name tag defined!"); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data->{'NAME'} || $self->throw('No name tag defined!')
MC/DC0%0/2
$data->{'NAME'} || $self->throw('No name tag defined!')
$data->{'NAME'}
$self->throw('No name tag defined!')
Truth table0%0/3
A || B
A= $data->{'NAME'}B= $self->throw('No name tag defined!')
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | # this should handle data on the fly w/o caching; any caching should be | ||||||||||||||||||||||||||||||||||||||||||
| 65 | # done in the driver! | ||||||||||||||||||||||||||||||||||||||||||
| 66 | my $method = (exists $self->{'handlers'}->{$nm}) ? ($self->{'handlers'}->{$nm}) : | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | (exists $self->{'handlers'}->{'_DEFAULT_'}) ? ($self->{'handlers'}->{'_DEFAULT_'}) : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | undef; | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if (!$method) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->debug("No handler defined for $nm\n"); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 72 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $self->$method($data); | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub reset_parameters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_parameters: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $self->{'_params'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $self->{'_nse_cache'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->{'_features'} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | sub format { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $format = lc shift; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | $self->throw("Format $format not supported") unless exists $HANDLERS{$format}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->{'_alignformat'} = $format; | |||||||||||||||||||||||||||||||||||||||||
| 89 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return $self->{'_alignformat'}; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub get_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_params: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my ($self, @ids) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $data; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if (scalar(@ids)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | for my $id (@ids) { | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if (!index($id, '-')==0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $id = '-'.$id ; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $data->{$id} = $self->{'_params'}->{$id} if (exists $self->{'_params'}->{$id}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $data ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$data ||= {}
MC/DC0%0/1
$data ||= {}
$data
Truth table0%0/2
A
A= $data
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $data = $self->{'_params'}; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub set_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_params: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | shift->throw('Not implemented yet!'); | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub build_alignment { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_alignment: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my %init; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $self->process_seqs; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $param = $self->get_params; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if (defined $param->{-seqs}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return Bio::SimpleAlign->new(%$param, -source => $self->format); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub annotation_collection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
annotation_collection: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my ($self, $coll) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ($coll) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $self->throw("Must have Bio::AnnotationCollectionI ". | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $coll and $coll->isa("Bio::AnnotationCollectionI")
MC/DC0%0/2
ref $coll and $coll->isa("Bio::AnnotationCollectionI")
ref $coll
$coll->isa("Bio::AnnotationCollectionI")
Truth table0%0/3
A and B
A= ref $collB= $coll->isa("Bio::AnnotationCollectionI")
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | "when explicitly setting annotation_collection()") | ||||||||||||||||||||||||||||||||||||||||||
| 130 | unless (ref($coll) && $coll->isa('Bio::AnnotationCollectionI')); | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->{'_params'}->{'-annotation'} = $coll; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } elsif (!exists($self->{'_params'}->{'-annotation'})) { | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $self->{'_params'}->{'-annotation'} = Bio::Annotation::Collection->new() | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | return $self->{'_params'}->{'-annotation'}; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | sub seq_annotation_collection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seq_annotation_collection: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my ($self, $coll) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ($coll) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | $self->throw("Must have Bio::AnnotationCollectionI ". | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $coll and $coll->isa("Bio::AnnotationCollectionI")
MC/DC0%0/2
ref $coll and $coll->isa("Bio::AnnotationCollectionI")
ref $coll
$coll->isa("Bio::AnnotationCollectionI")
Truth table0%0/3
A and B
A= ref $collB= $coll->isa("Bio::AnnotationCollectionI")
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | "when explicitly setting seq_annotation_collection()") | ||||||||||||||||||||||||||||||||||||||||||
| 143 | unless (ref($coll) && $coll->isa('Bio::AnnotationCollectionI')); | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $self->{'_params'}->{'-seq_annotation'} = $coll; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } elsif (!exists($self->{'_params'}->{'-seq_annotation'})) { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $self->{'_params'}->{'-seq_annotation'} = Bio::Annotation::Collection->new() | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return $self->{'_params'}->{'-seq_annotation'}; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub process_seqs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_seqs: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $data = $self->get_params(qw(-seqs -seq_class -consensus_meta)); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | my $class = $data->{-seq_class} || 'Bio::LocatableSeq'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$data->{'-seq_class'} || 'Bio::LocatableSeq'
MC/DC0%0/1
$data->{'-seq_class'} || 'Bio::LocatableSeq'
$data->{'-seq_class'}
Truth table0%0/2
A
A= $data->{'-seq_class'}
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | # cache classes loaded already | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if (!exists($self->{'_loaded_modules'}->{$class})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $self->_load_module($class); | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $self->{'_loaded_modules'}->{$class}++; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | # process any meta sequence data | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if ( $data->{-consensus_meta} && !UNIVERSAL::isa($data->{-consensus_meta},'Bio::Seq::Meta')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$data->{"-consensus_meta"} and not UNIVERSAL::isa($data->{"-consensus_meta"}, "Bio::Seq::Meta")
MC/DC0%0/2
$data->{"-consensus_meta"} and not UNIVERSAL::isa($data->{"-consensus_meta"}, "Bio::Seq::Meta")
$data->{"-consensus_meta"}
not UNIVERSAL::isa($data->{"-consensus_meta"}, "Bio::Seq::Meta")
Truth table0%0/3
A and not(B)
A= $data->{"-consensus_meta"}B= not UNIVERSAL::isa($data->{"-consensus_meta"}, "Bio::Seq::Meta")
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $ref = $data->{-consensus_meta}; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if (!exists($self->{'_loaded_modules'}->{'Bio::Seq::Meta'})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->_load_module('Bio::Seq::Meta'); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->{'_loaded_modules'}->{'Bio::Seq::Meta'}++; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $ms = Bio::Seq::Meta->new(); | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | for my $tag (sort keys %{$ref}) { | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $ms->named_meta($tag, $ref->{$tag}); | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $self->{'_params'}->{'-consensus_meta'} = $ms; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # this should always be an array ref! | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | for my $seq (@{$data->{-seqs}}) { | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | next if (UNIVERSAL::isa($seq,'Bio::LocatableI')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | # process anything else | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | $self->_from_nse($seq) if $seq->{NSE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if (UNIVERSAL::isa($seq,'HASH')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my %param; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | for my $p (keys %$seq) { | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | $param{'-'.lc $p} = $seq->{$p} if exists $seq->{$p}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | my $ls = $class->new(%param); | |||||||||||||||||||||||||||||||||||||||||
| 185 | # a little switcheroo to attach the sequence | ||||||||||||||||||||||||||||||||||||||||||
| 186 | # (though using it to get seq() doesn't work correctly yet!) | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if (defined $seq->{NSE} && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $seq->{"NSE"} and exists $self->{"_features"} and exists $self->{"_features"}{$seq->{"NSE"}}
defined $seq->{"NSE"} and exists $self->{"_features"}
MC/DC0%0/3
defined $seq->{"NSE"} and exists $self->{"_features"} and exists $self->{"_features"}{$seq->{"NSE"}}
defined $seq->{"NSE"}
exists $self->{"_features"}
exists $self->{"_features"}{$seq->{"NSE"}}
Truth table0%0/4
A and B and C
A= defined $seq->{"NSE"}B= exists $self->{"_features"}C= exists $self->{"_features"}{$seq->{"NSE"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | exists $self->{'_features'} && | ||||||||||||||||||||||||||||||||||||||||||
| 189 | exists $self->{'_features'}->{ $seq->{NSE} }) { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | for my $feat (@{ $self->{'_features'}->{ $seq->{NSE} } }) { | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | push @{ $self->{'_params'}->{'-features'} }, $feat; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $feat->attach_seq($ls); | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $seq = $ls; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | ####################### SEQUENCE HANDLERS ####################### | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | # any sequence data for a Bio::Seq::Meta | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub _generic_metaseq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic_metaseq: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | return unless $data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | $self->throw("No alignment position passed") if !exists($data->{BLOCK_LINE}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | $self->throw("Alignment position must be an index greater than 0") if $data->{BLOCK_LINE} < 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self->{'_params'}->{'-seq_class'} = 'Bio::Seq::Meta'; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $index = $data->{BLOCK_LINE} - 1; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if (my $nse = $self->{'_params'}->{'-seqs'}->[$index]->{NSE}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $self->throw("NSE in passed data doesn't match stored data in same position: $nse") unless $nse eq $data->{NSE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->{'_params'}->{'-seqs'}->[$index]->{NSE} = $data->{NSE}; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ($data->{NAME} eq 'SEQUENCE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $self->{'_params'}->{'-seqs'}->[$index]->{SEQ} .= $data->{DATA}; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } elsif ($data->{NAME} eq 'NAMED_META') { | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $self->{'_params'}->{'-seqs'}->[$index]->{NAMED_META}->{$data->{META_TAG}} .= $data->{DATA}; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub _generic_consensus_meta { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic_consensus_meta: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | return unless $data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if ($data->{NAME} eq 'CONSENSUS_META') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $self->{'_params'}->{'-consensus_meta'}->{$data->{META_TAG}} .= $data->{DATA}; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | # any sequence data for a Bio::LocatableSeq | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub _generic_locatableseq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic_locatableseq: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | return unless $data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | $self->throw("No alignment position passed") if !exists($data->{BLOCK_LINE}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | $self->throw("Alignment position must be an index greater than 0") if $data->{BLOCK_LINE} < 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $index = $data->{BLOCK_LINE} - 1; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if (my $nse = $self->{'_params'}->{'-seqs'}->[$index]->{NSE}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | $self->throw("NSE in passed data doesn't match stored data in same position: $nse") if $nse ne $data->{NSE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->{'_params'}->{'-seqs'}->[$index]->{NSE} = $data->{NSE}; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ($data->{NAME} eq 'SEQUENCE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->{'_params'}->{'-seqs'}->[$index]->{SEQ} .= $data->{DATA}; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | ####################### RAW DATA HANDLERS ####################### | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | # store by data name (ACCESSION, ID, etc), which can be mapped to the | ||||||||||||||||||||||||||||||||||||||||||
| 250 | # appropriate alignment or sequence parameter | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub _generic_store { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic_store: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | return unless $data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if ($data->{ALIGNMENT}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->{'_params'}->{'-'.lc $data->{NAME}} = $data->{DATA}; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 257 | $self->{'_params'}->{'-seq_'.lc $data->{NAME}}->{$data->{NSE}} = $data->{DATA} | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub _generic_reference { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic_reference: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 263 | my $ref = Bio::Annotation::Reference->new(-title => $data->{TITLE}, | ||||||||||||||||||||||||||||||||||||||||||
| 264 | -authors => $data->{AUTHORS}, | ||||||||||||||||||||||||||||||||||||||||||
| 265 | -pubmed => $data->{PUBMED}, | ||||||||||||||||||||||||||||||||||||||||||
| 266 | -location => $data->{JOURNAL}, | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | -tagname => lc $data->{NAME}); | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $self->annotation_collection->add_Annotation($ref); | |||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub _generic_simplevalue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic_simplevalue: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 273 | my $sv = Bio::Annotation::SimpleValue->new(-value => $data->{DATA}, | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | -tagname => lc $data->{NAME}); | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $self->annotation_collection->add_Annotation($sv); | |||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub _generic_comment { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic_comment: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 280 | my $comment = Bio::Annotation::Comment->new(-type => lc $data->{NAME}, | ||||||||||||||||||||||||||||||||||||||||||
| 281 | -text => $data->{DATA}, | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | -tagname => lc $data->{NAME}); | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->annotation_collection->add_Annotation($comment); | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | # Some DBLinks in Stockholm format are unique, so a unique handler for them | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | sub _stockholm_target { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stockholm_target: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 289 | # process database info | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $self->_from_stk_dblink($data); | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my $comment; | |||||||||||||||||||||||||||||||||||||||||
| 292 | # Bio::Annotation::Target is now a DBLink, but has additional (RangeI) | ||||||||||||||||||||||||||||||||||||||||||
| 293 | # capabilities (for PDB data) | ||||||||||||||||||||||||||||||||||||||||||
| 294 | my $dblink = Bio::Annotation::Target->new( | ||||||||||||||||||||||||||||||||||||||||||
| 295 | -database => $data->{DBLINK_DB}, | ||||||||||||||||||||||||||||||||||||||||||
| 296 | -primary_id => $data->{DBLINK_ACC}, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | -optional_id => $data->{DBLINK_OPT}, | ||||||||||||||||||||||||||||||||||||||||||
| 298 | -start => $data->{DBLINK_START}, | ||||||||||||||||||||||||||||||||||||||||||
| 299 | -end => $data->{DBLINK_END}, | ||||||||||||||||||||||||||||||||||||||||||
| 300 | -strand => $data->{DBLINK_STRAND}, | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | -comment => $comment, | |||||||||||||||||||||||||||||||||||||||||
| 302 | -tagname => 'dblink', | ||||||||||||||||||||||||||||||||||||||||||
| 303 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ($data->{ALIGNMENT}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | # Alignment-specific DBLinks | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $self->annotation_collection->add_Annotation($dblink); | |||||||||||||||||||||||||||||||||||||||||
| 307 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 308 | # Sequence-specific DBLinks | ||||||||||||||||||||||||||||||||||||||||||
| 309 | # These should come with identifying information of some sort | ||||||||||||||||||||||||||||||||||||||||||
| 310 | # (ID/START/END/STRAND). Make into a SeqFeature (SimpleAlign is | ||||||||||||||||||||||||||||||||||||||||||
| 311 | # FeatureHolderI) spanning the length acc. to the NSE. Add the DBLink as | ||||||||||||||||||||||||||||||||||||||||||
| 312 | # Annotation specific to that SeqFeature, store in an internal hash by | ||||||||||||||||||||||||||||||||||||||||||
| 313 | # NSE so we can tie the LocatableSeq to the proper Features | ||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $self->_from_nse($data) if $data->{NSE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | $self->throw("Must supply an sequence DISPLAY_ID or NSE for sequence-related | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | DBLinks") unless $data->{ACCESSION_NUMBER} || $data->{DISPLAY_ID}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$data->{"ACCESSION_NUMBER"} or $data->{"DISPLAY_ID"}
MC/DC0%0/2
$data->{"ACCESSION_NUMBER"} or $data->{"DISPLAY_ID"}
$data->{"ACCESSION_NUMBER"}
$data->{"DISPLAY_ID"}
Truth table0%0/3
A or B
A= $data->{"ACCESSION_NUMBER"}B= $data->{"DISPLAY_ID"}
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | my $sf = Bio::SeqFeature::Generic->new(-seq_id => $data->{DISPLAY_ID}, | ||||||||||||||||||||||||||||||||||||||||||
| 318 | -accession_number => $data->{ACCESSION_NUMBER}, | ||||||||||||||||||||||||||||||||||||||||||
| 319 | -start => $data->{START}, | ||||||||||||||||||||||||||||||||||||||||||
| 320 | -end => $data->{END}, | ||||||||||||||||||||||||||||||||||||||||||
| 321 | -strand => $data->{STRAND} | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $sf->annotation->add_Annotation($dblink); | |||||||||||||||||||||||||||||||||||||||||
| 324 | # index by NSE | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | push @{ $self->{'_features'}->{ $data->{NSE} } }, $sf; | |||||||||||||||||||||||||||||||||||||||||
| 326 | #$self->seq_annotation_collection->add_Annotation($dblink); | ||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | ####################### HELPER METHODS ####################### | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | # returns ACCESSION VERSION START END STRAND ALPHABET | ||||||||||||||||||||||||||||||||||||||||||
| 333 | # cached for multiple lookups, should reset in between uses | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | sub _from_nse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_from_nse: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | return unless my $nse = $data->{NSE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | $data->{ALPHABET} = $self->get_params('-alphabet')->{'-alphabet'} || 'protein'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_params('-alphabet')->{'-alphabet'} || 'protein'
MC/DC0%0/1
$self->get_params('-alphabet')->{'-alphabet'} || 'protein'
$self->get_params('-alphabet')->{'-alphabet'}
Truth table0%0/2
A
A= $self->get_params('-alphabet')->{'-alphabet'}
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | # grab any accessions if present, switch out with ACCESSION from NSE | ||||||||||||||||||||||||||||||||||||||||||
| 339 | # (move that to primary_id) | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $new_acc; | |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if (exists $self->{'_params'}->{'-seq_accession'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $new_acc = $self->{'_params'}->{'-seq_accession'}->{$data->{NSE}}; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | if ($nse =~ m{(\S+?)(?:\.(\d+))?/(\d+)-(\d+)}xmso) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | my $strand = $data->{ALPHABET} eq 'dna' || $data->{ALPHABET} eq 'rna' ? 1 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$data->{"ALPHABET"} eq "dna" or $data->{"ALPHABET"} eq "rna"
MC/DC0%0/2
$data->{"ALPHABET"} eq "dna" or $data->{"ALPHABET"} eq "rna"
$data->{"ALPHABET"} eq "dna"
$data->{"ALPHABET"} eq "rna"
Truth table0%0/3
A or B
A= $data->{"ALPHABET"} eq "dna"B= $data->{"ALPHABET"} eq "rna"
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my ($start, $end) = ($3, $4); | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if ($start > $end) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ($start, $end, $strand) = ($end, $start, -1); | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | $data->{ACCESSION_NUMBER} = $new_acc || $1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$new_acc || $1
MC/DC0%0/2
$new_acc || $1
$new_acc
$1
Truth table0%0/3
A || B
A= $new_accB= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $data->{DISPLAY_ID} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $data->{VERSION} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | $data->{START} = $start; | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $data->{END} = $end; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $data->{STRAND} = $strand; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 357 | # we can parse for version here if needed | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $data->{DISPLAY_ID} = $data->{NSE}; | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | # this will probably be split up into subhandlers based on Record/DB | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | sub _from_stk_dblink { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_from_stk_dblink: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | return unless my $raw = $data->{DATA}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my @rawdata = split(m{\s*;\s*}, $raw); | |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my %dblink_data; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if ($rawdata[0] eq 'PDB') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | # fix for older Stockholm PDB range format | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | if (scalar(@rawdata) == 3 && $rawdata[2] =~ m{-}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @rawdata == 3 and $rawdata[2] =~ /-/
MC/DC0%0/2
scalar @rawdata == 3 and $rawdata[2] =~ /-/
scalar @rawdata == 3
$rawdata[2] =~ /-/
Truth table0%0/3
A and B
A= scalar @rawdata == 3B= $rawdata[2] =~ /-/
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | @rawdata[2,3] = split('-',$rawdata[2],2); | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | $self->throw("Not standard PDB form: ".$data->{DATA}) if scalar(@rawdata) != 4; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my ($main, $chain) = split(m{\s+}, $rawdata[1]); | |||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | %dblink_data = ( | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$chain || ''
MC/DC0%0/1
$chain || ''
$chain
Truth table0%0/2
A
A= $chain
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | DBLINK_DB => $rawdata[0], | ||||||||||||||||||||||||||||||||||||||||||
| 377 | DBLINK_ACC => $main, | ||||||||||||||||||||||||||||||||||||||||||
| 378 | DBLINK_OPT => $chain || '', | ||||||||||||||||||||||||||||||||||||||||||
| 379 | DBLINK_START => $rawdata[2], | ||||||||||||||||||||||||||||||||||||||||||
| 380 | DBLINK_END => $rawdata[3] | ||||||||||||||||||||||||||||||||||||||||||
| 381 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 382 | } elsif ($rawdata[0] eq 'SCOP') { | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | $self->throw("Not standard SCOP form: ".$data->{DATA}) if scalar(@rawdata) != 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | %dblink_data = ( | |||||||||||||||||||||||||||||||||||||||||
| 385 | DBLINK_DB => $rawdata[0], | ||||||||||||||||||||||||||||||||||||||||||
| 386 | DBLINK_ACC => $rawdata[1], | ||||||||||||||||||||||||||||||||||||||||||
| 387 | DBLINK_OPT => $rawdata[2], | ||||||||||||||||||||||||||||||||||||||||||
| 388 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 389 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | $self->warn("Some data missed: ".$data->{DATA}) if scalar(@rawdata) > 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | %dblink_data = ( | |||||||||||||||||||||||||||||||||||||||||
| 392 | DBLINK_DB => $rawdata[0], | ||||||||||||||||||||||||||||||||||||||||||
| 393 | DBLINK_ACC => $rawdata[1], | ||||||||||||||||||||||||||||||||||||||||||
| 394 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | while (my ($k, $v) = each %dblink_data) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | $data->{$k} = $v if $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | __END__ | ||||||||||||||||||||||||||||||||||||||||||