| 1 | package Bio::ToolBox::GeneTools; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp qw(carp cluck croak confess); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = '2.03'; | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | ### Export | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||
| 13 | get_exons | ||||||||||||||||||||||||||||||||||||||||||
| 14 | get_alt_exons | ||||||||||||||||||||||||||||||||||||||||||
| 15 | get_common_exons | ||||||||||||||||||||||||||||||||||||||||||
| 16 | get_uncommon_exons | ||||||||||||||||||||||||||||||||||||||||||
| 17 | get_alt_common_exons | ||||||||||||||||||||||||||||||||||||||||||
| 18 | get_introns | ||||||||||||||||||||||||||||||||||||||||||
| 19 | get_alt_introns | ||||||||||||||||||||||||||||||||||||||||||
| 20 | get_common_introns | ||||||||||||||||||||||||||||||||||||||||||
| 21 | get_uncommon_introns | ||||||||||||||||||||||||||||||||||||||||||
| 22 | get_alt_common_introns | ||||||||||||||||||||||||||||||||||||||||||
| 23 | get_transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 24 | collapse_transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 25 | get_transcript_length | ||||||||||||||||||||||||||||||||||||||||||
| 26 | is_coding | ||||||||||||||||||||||||||||||||||||||||||
| 27 | get_cds | ||||||||||||||||||||||||||||||||||||||||||
| 28 | get_cdsStart | ||||||||||||||||||||||||||||||||||||||||||
| 29 | get_cdsEnd | ||||||||||||||||||||||||||||||||||||||||||
| 30 | get_start_codon | ||||||||||||||||||||||||||||||||||||||||||
| 31 | get_stop_codon | ||||||||||||||||||||||||||||||||||||||||||
| 32 | get_transcript_cds_length | ||||||||||||||||||||||||||||||||||||||||||
| 33 | get_utrs | ||||||||||||||||||||||||||||||||||||||||||
| 34 | get_transcript_utr_length | ||||||||||||||||||||||||||||||||||||||||||
| 35 | get_5p_utrs | ||||||||||||||||||||||||||||||||||||||||||
| 36 | get_3p_utrs | ||||||||||||||||||||||||||||||||||||||||||
| 37 | get_transcript_5p_utr_length | ||||||||||||||||||||||||||||||||||||||||||
| 38 | get_transcript_3p_utr_length | ||||||||||||||||||||||||||||||||||||||||||
| 39 | gff_string | ||||||||||||||||||||||||||||||||||||||||||
| 40 | gtf_string | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ucsc_string | ||||||||||||||||||||||||||||||||||||||||||
| 42 | bed12_string | ||||||||||||||||||||||||||||||||||||||||||
| 43 | filter_transcript_support_level | ||||||||||||||||||||||||||||||||||||||||||
| 44 | filter_transcript_gencode_basic | ||||||||||||||||||||||||||||||||||||||||||
| 45 | filter_transcript_biotype | ||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||
| 48 | all => \@EXPORT_OK, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | exon => [ | ||||||||||||||||||||||||||||||||||||||||||
| 50 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 51 | get_exons | ||||||||||||||||||||||||||||||||||||||||||
| 52 | get_alt_exons | ||||||||||||||||||||||||||||||||||||||||||
| 53 | get_common_exons | ||||||||||||||||||||||||||||||||||||||||||
| 54 | get_uncommon_exons | ||||||||||||||||||||||||||||||||||||||||||
| 55 | get_alt_common_exons | ||||||||||||||||||||||||||||||||||||||||||
| 56 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 58 | intron => [ | ||||||||||||||||||||||||||||||||||||||||||
| 59 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 60 | get_introns | ||||||||||||||||||||||||||||||||||||||||||
| 61 | get_alt_introns | ||||||||||||||||||||||||||||||||||||||||||
| 62 | get_common_introns | ||||||||||||||||||||||||||||||||||||||||||
| 63 | get_uncommon_introns | ||||||||||||||||||||||||||||||||||||||||||
| 64 | get_alt_common_introns | ||||||||||||||||||||||||||||||||||||||||||
| 65 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 66 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 67 | transcript => [ | ||||||||||||||||||||||||||||||||||||||||||
| 68 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 69 | get_transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 70 | collapse_transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 71 | get_transcript_length | ||||||||||||||||||||||||||||||||||||||||||
| 72 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 73 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 74 | cds => [ | ||||||||||||||||||||||||||||||||||||||||||
| 75 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 76 | is_coding | ||||||||||||||||||||||||||||||||||||||||||
| 77 | get_cds | ||||||||||||||||||||||||||||||||||||||||||
| 78 | get_cdsStart | ||||||||||||||||||||||||||||||||||||||||||
| 79 | get_cdsEnd | ||||||||||||||||||||||||||||||||||||||||||
| 80 | get_start_codon | ||||||||||||||||||||||||||||||||||||||||||
| 81 | get_stop_codon | ||||||||||||||||||||||||||||||||||||||||||
| 82 | get_transcript_cds_length | ||||||||||||||||||||||||||||||||||||||||||
| 83 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 84 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 85 | utr => [ | ||||||||||||||||||||||||||||||||||||||||||
| 86 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 87 | get_utrs | ||||||||||||||||||||||||||||||||||||||||||
| 88 | get_5p_utrs | ||||||||||||||||||||||||||||||||||||||||||
| 89 | get_3p_utrs | ||||||||||||||||||||||||||||||||||||||||||
| 90 | get_transcript_utr_length | ||||||||||||||||||||||||||||||||||||||||||
| 91 | get_transcript_5p_utr_length | ||||||||||||||||||||||||||||||||||||||||||
| 92 | get_transcript_3p_utr_length | ||||||||||||||||||||||||||||||||||||||||||
| 93 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 94 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 95 | export => [ | ||||||||||||||||||||||||||||||||||||||||||
| 96 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 97 | gff_string | ||||||||||||||||||||||||||||||||||||||||||
| 98 | gtf_string | ||||||||||||||||||||||||||||||||||||||||||
| 99 | ucsc_string | ||||||||||||||||||||||||||||||||||||||||||
| 100 | bed12_string | ||||||||||||||||||||||||||||||||||||||||||
| 101 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 102 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 103 | filter => [ | ||||||||||||||||||||||||||||||||||||||||||
| 104 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 105 | filter_transcript_biotype | ||||||||||||||||||||||||||||||||||||||||||
| 106 | filter_transcript_gencode_basic | ||||||||||||||||||||||||||||||||||||||||||
| 107 | filter_transcript_support_level | ||||||||||||||||||||||||||||||||||||||||||
| 108 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 109 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | ######## Exon Methods | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 143 | ▶ | sub get_exons { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_exons: called CC=16 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | # initialize | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 143 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 143 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 143 | my @exons; | |||||||||||||||||||||||||||||||||||||||||
| 120 | my @cdss; | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 143 | my @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | # go through the subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 143 | foreach my $subfeat ( $transcript->get_SeqFeatures ) { | |||||||||||||||||||||||||||||||||||||||||
| 125 | 1925 | my $type = $subfeat->primary_tag; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 1925 | ▶ | if ( $type =~ /exon/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 947 | push @exons, $subfeat; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | elsif ( $type =~ m/(?: cds | utr | untranslated )/xi ) { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 978 | push @cdss, $subfeat; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | elsif ( $type =~ m/(?: rna | transcript )/xi ) { | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | push @transcripts, $subfeat; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | # check which array we'll use | ||||||||||||||||||||||||||||||||||||||||||
| 138 | # prefer to use actual exon subfeatures, but those may not be defined | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 143 | my @list; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 143 | ▶ | if (@exons) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 947 | @list = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 142 | 1638 | sort { $a->[1] <=> $b->[1] } | |||||||||||||||||||||||||||||||||||||||||
| 143 | 143 | map { [ $_, $_->start ] } @exons; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | elsif (@cdss) { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | # duplicate the CDSs as exons | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | foreach (@cdss) { | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $e = $_->duplicate; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $e->primary_tag('exon'); # reset tag | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $e->phase('.'); # no phase | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | push @list, $e; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | # make sure to merge adjacent exons | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | @list = map { $_->[0] } # must sort first | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | sort { $a->[1] <=> $b->[1] } | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | map { [ $_, $_->start ] } @list; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | for ( my $i = 0; $i < scalar @list; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ( defined( $list[ $i + 1 ] ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ( $list[ $i + 1 ]->start - $list[$i]->end <= 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | # need to merge | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $list[$i]->end( $list[ $i + 1 ]->end ); | |||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | splice( @list, $i + 1, 1 ); # remove the merged | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $i--; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | elsif (@transcripts) { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | foreach my $t (@transcripts) { | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | # there are possibly duplicates in here if there are alternate transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 175 | # should we remove them? | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my @e = get_exons($t); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | push @list, @e; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | @list = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
MC/DC0%0/2
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]
$Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
Truth table0%0/3
A || B
A= $Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]B= $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | map { [ $_, $_->start, $_->end ] } @list; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | # nothing found! | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 143 | ▶ | return wantarray ? @list : \@list; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | ▶ | sub get_alt_exons { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_alt_exons: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | my $ac_exons = get_alt_common_exons(@_); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | my @alts; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | foreach my $k ( keys %{$ac_exons} ) { | |||||||||||||||||||||||||||||||||||||||||
| 195 | 15 | ▶ | next if $k eq 'common'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 14 | ▶ | next if $k eq 'uncommon'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 13 | push @alts, @{ $ac_exons->{$k} }; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | if (@alts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | # re-sort in genomic order | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 19 | @alts = map { $_->[1] } | |||||||||||||||||||||||||||||||||||||||||
| 203 | 60 | sort { $a->[0] <=> $b->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | map { [ $_->start, $_ ] } @alts; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | return wantarray ? @alts : \@alts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | ▶ | sub get_common_exons { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_common_exons: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | my $ac_exons = get_alt_common_exons(@_); | |||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | ▶ | return wantarray ? @{ $ac_exons->{common} } : $ac_exons->{common}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | ▶ | sub get_uncommon_exons { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_uncommon_exons: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | my $ac_exons = get_alt_common_exons(@_); | |||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | ▶ | return wantarray ? @{ $ac_exons->{uncommon} } : $ac_exons->{uncommon}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | ▶ | sub get_alt_common_exons { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_alt_common_exons: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | return _get_alt_common_things( 1, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | ######## Intron Methods | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 42 | ▶ | sub get_introns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_introns: called CC=16 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 42 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 42 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | # check whether we were passed a gene object | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 42 | ▶ | if ( $transcript->primary_tag =~ /gene/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my @transcripts = get_transcripts($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my @introns; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | foreach my $t (@transcripts) { | |||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $i = get_introns($t); | |||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if ( $i and scalar( @{$i} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$i and scalar @{$i;}
MC/DC0%0/1
$i and scalar @{$i;}
$i
Truth table0%0/2
A
A= $i
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | push @introns, ($i); | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if (@introns) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | @introns = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | sort { $a->[1] <=> $b->[1] } | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | map { [ $_, $_->start ] } @introns; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | return wantarray ? @introns : \@introns; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | # find the exons and/or CDSs | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 42 | my @exons = get_exons($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 249 | 42 | ▶ | return unless @exons; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 42 | ▶ | return if ( scalar(@exons) == 1 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | # identify the last exon index position | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 42 | my $last_i = scalar(@exons) - 1; | |||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # collect introns based on strand | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 42 | my @introns; | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | # forward strand | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 42 | ▶ | if ( $transcript->strand >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | # each intron is created based on the previous exon | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # use 1-base counting for the actual name instead of 0-base | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 42 | ▶ | for ( my $i = 0; $i < $last_i; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 234 | my $e = $exons[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 234 | my $i = $e->new( | |||||||||||||||||||||||||||||||||||||||||
| 266 | -seq_id => $e->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 267 | -start => $e->end + 1, | ||||||||||||||||||||||||||||||||||||||||||
| 268 | -end => $exons[ $i + 1 ]->start - 1, # up to start of next exon | ||||||||||||||||||||||||||||||||||||||||||
| 269 | -strand => $transcript->strand, | ||||||||||||||||||||||||||||||||||||||||||
| 270 | -primary_tag => 'intron', | ||||||||||||||||||||||||||||||||||||||||||
| 271 | -source_tag => $transcript->source_tag, | ||||||||||||||||||||||||||||||||||||||||||
| 272 | -primary_id => sprintf( "%s.intron%d", $transcript->id, $i + 1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 273 | -display_name => | ||||||||||||||||||||||||||||||||||||||||||
| 274 | sprintf( "%s.intron%d", $transcript->display_name, $i + 1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 275 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 234 | push @introns, $i; | |||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | # reverse strand | ||||||||||||||||||||||||||||||||||||||||||
| 281 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 282 | # each intron is created based on the previous exon | ||||||||||||||||||||||||||||||||||||||||||
| 283 | # ordering from 5' to 3' end direction for convenience in naming | ||||||||||||||||||||||||||||||||||||||||||
| 284 | # this actually works out to be 1-base naming | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | for ( my $i = $last_i; $i > 0; $i-- ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $e = $exons[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $i = $e->new( | |||||||||||||||||||||||||||||||||||||||||
| 288 | -seq_id => $e->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 289 | -start => $exons[ $i - 1 ]->end + 1, # end of next exon | ||||||||||||||||||||||||||||||||||||||||||
| 290 | -end => $e->start - 1, | ||||||||||||||||||||||||||||||||||||||||||
| 291 | -strand => $transcript->strand, | ||||||||||||||||||||||||||||||||||||||||||
| 292 | -primary_tag => 'intron', | ||||||||||||||||||||||||||||||||||||||||||
| 293 | -source_tag => $transcript->source_tag, | ||||||||||||||||||||||||||||||||||||||||||
| 294 | -primary_id => sprintf( "%s.intron%d", $transcript->id, $i ), | ||||||||||||||||||||||||||||||||||||||||||
| 295 | -display_name => | ||||||||||||||||||||||||||||||||||||||||||
| 296 | sprintf( "%s.intron%d", $transcript->display_name, $i ), | ||||||||||||||||||||||||||||||||||||||||||
| 297 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | push @introns, $i; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | # reorder the introns based on start position | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if (@introns) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | @introns = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
MC/DC0%0/2
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]
$Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
Truth table0%0/3
A || B
A= $Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]B= $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | map { [ $_, $_->start, $_->end ] } @introns; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | # finished | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 42 | ▶ | return wantarray ? @introns : \@introns; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | ▶ | sub get_alt_introns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_alt_introns: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | my $ac_introns = get_alt_common_introns(@_); | |||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | my @alts; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | foreach my $k ( keys %{$ac_introns} ) { | |||||||||||||||||||||||||||||||||||||||||
| 317 | 15 | ▶ | next if $k eq 'common'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 14 | ▶ | next if $k eq 'uncommon'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 13 | push @alts, @{ $ac_introns->{$k} }; | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 1 | ▶ | if (@alts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | # re-sort in genomic order | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 8 | @alts = map { $_->[1] } | |||||||||||||||||||||||||||||||||||||||||
| 325 | 17 | sort { $a->[0] <=> $b->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | map { [ $_->start, $_ ] } @alts; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | ▶ | return wantarray ? @alts : \@alts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | ▶ | sub get_common_introns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_common_introns: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | my $ac_introns = get_alt_common_introns(@_); | |||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | ▶ | return wantarray ? @{ $ac_introns->{common} } : $ac_introns->{common}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | ▶ | sub get_uncommon_introns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_uncommon_introns: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | my $ac_introns = get_alt_common_introns(@_); | |||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | ▶ | return wantarray ? @{ $ac_introns->{uncommon} } : $ac_introns->{uncommon}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 3 | ▶ | sub get_alt_common_introns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_alt_common_introns: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 3 | return _get_alt_common_things( 0, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 6 | ▶ | sub _get_alt_common_things { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_alt_common_things: called CC=15 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | # internal subroutine to get either exons or introns | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 6 | my $do_exon = shift; # true for exon, false for intron | |||||||||||||||||||||||||||||||||||||||||
| 349 | 6 | my @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 6 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 6 | ▶ | if ( scalar @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | # someone passed a gene, get the transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 6 | ▶ | confess 'not a SeqFeature object!' unless ref( $_[0] ) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 6 | @transcripts = get_transcripts( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | elsif ( scalar @_ > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | # presume these are transcripts? | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | @transcripts = @_; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | # hash of transcript to things | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 6 | my %tx2things = ( | |||||||||||||||||||||||||||||||||||||||||
| 365 | common => [], | ||||||||||||||||||||||||||||||||||||||||||
| 366 | uncommon => [] | ||||||||||||||||||||||||||||||||||||||||||
| 367 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | # no transcripts provided? | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 6 | ▶ | return \%tx2things unless @transcripts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | # only one transcript provided? | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 6 | ▶ | if ( scalar @transcripts == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | # all exons are common by definition | ||||||||||||||||||||||||||||||||||||||||||
| 376 | # my $name = $transcripts[0]->display_name; | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | my @things = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | $do_exon ? get_exons( $transcripts[0] ) : get_introns( $transcripts[0] ); | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $tx2things{common} = \@things; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | return \%tx2things; | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | # get things and put them in has based on coordinates | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 6 | my %pos2things; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 6 | foreach my $t (@transcripts) { | |||||||||||||||||||||||||||||||||||||||||
| 386 | 78 | ▶ | my @things = $do_exon ? get_exons($t) : get_introns($t); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 78 | foreach my $e (@things) { | |||||||||||||||||||||||||||||||||||||||||
| 388 | 471 | my $new_e = $e->duplicate; | |||||||||||||||||||||||||||||||||||||||||
| 389 | 471 | $pos2things{ $e->start }{ $e->end }{ $t->display_name } = $new_e; | |||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 78 | $tx2things{ $t->display_name } = []; | |||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | # put things into categories based on commonality | ||||||||||||||||||||||||||||||||||||||||||
| 395 | # associate things with unique transcripts, common, or uncommon sets | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 6 | my $trx_number = scalar @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 6 | foreach my $s ( sort { $a <=> $b } keys %pos2things ) { # sort on start | |||||||||||||||||||||||||||||||||||||||||
| 398 | 126 | foreach my $e ( sort { $a <=> $b } keys %{ $pos2things{$s} } ) { # sort on stop | |||||||||||||||||||||||||||||||||||||||||
| 399 | 165 | my @names = keys %{ $pos2things{$s}{$e} }; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 165 | ▶ | if ( scalar @names == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | # only 1 thing, must be an alternate | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 81 | push @{ $tx2things{ $names[0] } }, $pos2things{$s}{$e}{ $names[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | elsif ( scalar @names == $trx_number ) { | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | # common to all transcripts, take the first one as example | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | push @{ $tx2things{common} }, $pos2things{$s}{$e}{ $names[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 411 | # common to some but not all transcripts, so uncommon | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 84 | push @{ $tx2things{uncommon} }, $pos2things{$s}{$e}{ $names[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 6 | return \%tx2things; | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | ######## Transcript Methods | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 12 | ▶ | sub get_transcripts { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_transcripts: called CC=14 SCAR=34.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 12 | my $gene = shift; | |||||||||||||||||||||||||||||||||||||||||
| 423 | 12 | ▶ | return unless $gene; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 12 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($gene) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 12 | ▶ | return $gene if ( $gene->primary_tag =~ m/rna | transcript/xi ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 12 | my @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 427 | my @exons; | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 12 | my @other; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 12 | foreach my $subf ( $gene->get_SeqFeatures ) { | |||||||||||||||||||||||||||||||||||||||||
| 430 | 145 | ▶ | if ( $subf->primary_tag =~ m/(?: rna | transcript | \bprocessed )/xi ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 145 | push @transcripts, $subf; | |||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | elsif ( $subf->primary_tag =~ m/^(?: cds | exon | \w+codon )$/xi ) { | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | push @exons, $subf; | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 437 | # wierdo subfeature types like unprocessed_pseudogene | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | push @other, $subf; | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 12 | ▶ | if ( not @transcripts and @exons ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not @transcripts and @exons
MC/DC0%0/2
not @transcripts and @exons
not @transcripts
@exons
Truth table33%1/3
not(A) and B
A= not @transcriptsB= @exons
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | # some weirdly formatted annotation files skip the transcript | ||||||||||||||||||||||||||||||||||||||||||
| 444 | # looking at you SGD | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my $transcript = $gene->new( | |||||||||||||||||||||||||||||||||||||||||
| 446 | -seq_id => $gene->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 447 | -start => $gene->start, | ||||||||||||||||||||||||||||||||||||||||||
| 448 | -end => $gene->end, | ||||||||||||||||||||||||||||||||||||||||||
| 449 | -strand => $gene->strand, | ||||||||||||||||||||||||||||||||||||||||||
| 450 | -primary_tag => 'transcript', | ||||||||||||||||||||||||||||||||||||||||||
| 451 | -source => $gene->source_tag, | ||||||||||||||||||||||||||||||||||||||||||
| 452 | -name => $gene->display_name, | ||||||||||||||||||||||||||||||||||||||||||
| 453 | -segments => \@exons, | ||||||||||||||||||||||||||||||||||||||||||
| 454 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | push @transcripts, $transcript; | |||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||
| 457 | ▶ | elsif ( not @transcripts and not @exons and @other ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
not @transcripts || @exons and @other
@transcripts || @exons
MC/DC0%0/3
not @transcripts || @exons and @other
@transcripts
@exons
@other
Truth table25%1/4
not(A || B) and C
A= @transcriptsB= @exonsC= @other
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | # well, what choice do we have? | ||||||||||||||||||||||||||||||||||||||||||
| 460 | # we can assume these are transcripts, because what else could they be? | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | @transcripts = @other; | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 145 | @transcripts = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 464 | 309 | ▶ | sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
MC/DC50%1/2
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]
$Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
Truth table66%2/3
A || B
A= $Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]B= $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | 12 | map { [ $_, $_->start, $_->length ] } @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 466 | 12 | ▶ | return wantarray ? @transcripts : \@transcripts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | ▶ | sub collapse_transcripts { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collapse_transcripts: called CC=18 SCAR=31.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | 1 | my @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 471 | 1 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 1 | my $example = $_[0]; # parent transcript seqfeature to model new transcript on | |||||||||||||||||||||||||||||||||||||||||
| 473 | 1 | ▶ | if ( scalar @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | # someone passed a gene, get the transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | @transcripts = get_transcripts( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | return unless @transcripts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | return $transcripts[0] if scalar @transcripts == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | elsif ( scalar @_ > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 1 | @transcripts = @_; | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | # get all useable exons to collapse | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | my @exons; | |||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | foreach my $t (@transcripts) { | |||||||||||||||||||||||||||||||||||||||||
| 487 | 13 | my @e = get_exons($t); | |||||||||||||||||||||||||||||||||||||||||
| 488 | 13 | push @exons, @e; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | # check that we have exons - weirdo files may just have CDS!!!???? | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | ▶ | unless (@exons) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | foreach my $t (@transcripts) { | |||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | my @e = get_cds($t); | |||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | push @exons, @e; | |||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | 1 | ▶ | return unless (@exons); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | # sort all the exons | ||||||||||||||||||||||||||||||||||||||||||
| 501 | 85 | my @sorted = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 502 | 414 | ▶ | sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
MC/DC100%2/2
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]
$Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
Truth table100%3/3
A || B
A= $Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]B= $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 1 | map { [ $_, $_->start, $_->end ] } @exons; | |||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | # build new exons from the original - don't keep cruft | ||||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | my $next = shift @sorted; | |||||||||||||||||||||||||||||||||||||||||
| 507 | 1 | my @new; | |||||||||||||||||||||||||||||||||||||||||
| 508 | 1 | $new[0] = $next->new( | |||||||||||||||||||||||||||||||||||||||||
| 509 | -seq_id => $next->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 510 | -start => $next->start, | ||||||||||||||||||||||||||||||||||||||||||
| 511 | -end => $next->end, | ||||||||||||||||||||||||||||||||||||||||||
| 512 | -strand => $next->strand, | ||||||||||||||||||||||||||||||||||||||||||
| 513 | -primary_tag => 'exon', | ||||||||||||||||||||||||||||||||||||||||||
| 514 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | # work through remaining exons, adding and merging as necessary | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 1 | ▶ | while (@sorted) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 84 | $next = shift @sorted; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 84 | my ( $ns, $ne ) = ( $next->start, $next->end ); # new start & end | |||||||||||||||||||||||||||||||||||||||||
| 520 | 84 | my ( $os, $oe ) = ( $new[-1]->start, $new[-1]->end ); # old start & end | |||||||||||||||||||||||||||||||||||||||||
| 521 | 84 | ▶ | if ( $ns == $os and $ne > $oe ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$ns == $os and $ne > $oe
MC/DC100%2/2
$ns == $os and $ne > $oe
$ns == $os
$ne > $oe
Truth table100%3/3
A and B
A= $ns == $osB= $ne > $oe
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | # same beginning, further end | ||||||||||||||||||||||||||||||||||||||||||
| 524 | 5 | $new[-1]->end($ne); | |||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | ▶ | elsif ( $ns > $os and $ns < $oe and $ne > $oe ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$ns > $os and $ns < $oe and $ne > $oe
$ns > $os and $ns < $oe
MC/DC0%0/3
$ns > $os and $ns < $oe and $ne > $oe
$ns > $os
$ns < $oe
$ne > $oe
Truth table75%3/4
A and B and C
A= $ns > $osB= $ns < $oeC= $ne > $oe
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | # overlapping start, further end | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $new[-1]->end($ne); | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | elsif ( $ns > $oe ) { | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | # completely new exon | ||||||||||||||||||||||||||||||||||||||||||
| 534 | 13 | push @new, | |||||||||||||||||||||||||||||||||||||||||
| 535 | $next->new( | ||||||||||||||||||||||||||||||||||||||||||
| 536 | -seq_id => $next->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 537 | -start => $ns, | ||||||||||||||||||||||||||||||||||||||||||
| 538 | -end => $ne, | ||||||||||||||||||||||||||||||||||||||||||
| 539 | -strand => $next->strand, | ||||||||||||||||||||||||||||||||||||||||||
| 540 | -primary_tag => 'exon', | ||||||||||||||||||||||||||||||||||||||||||
| 541 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | # all other possibilities we can skip | ||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | # return the assembled transcript | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | return $example->new( | |||||||||||||||||||||||||||||||||||||||||
| 549 | -seq_id => $example->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 550 | -start => $new[0]->start, | ||||||||||||||||||||||||||||||||||||||||||
| 551 | -end => $new[-1]->end, | ||||||||||||||||||||||||||||||||||||||||||
| 552 | -strand => $example->strand, | ||||||||||||||||||||||||||||||||||||||||||
| 553 | -primary_tag => 'transcript', | ||||||||||||||||||||||||||||||||||||||||||
| 554 | -source => $example->source_tag, | ||||||||||||||||||||||||||||||||||||||||||
| 555 | -name => $example->display_name, | ||||||||||||||||||||||||||||||||||||||||||
| 556 | -segments => \@new, | ||||||||||||||||||||||||||||||||||||||||||
| 557 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 4 | ▶ | sub get_transcript_length { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_transcript_length: called CC=6 SCAR=21.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 4 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 562 | 4 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 4 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 4 | ▶ | if ( $transcript->primary_tag =~ /gene$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | # someone passed a gene object!!!! | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my @lengths; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | foreach my $t ( get_transcripts($transcript) ) { | |||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | push @lengths, get_transcript_length($t); | |||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | # return the longest transcript length | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | return ( sort { $b <=> $a } @lengths )[0]; | |||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | 4 | my $total = 0; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 4 | foreach my $e ( get_exons($transcript) ) { | |||||||||||||||||||||||||||||||||||||||||
| 577 | 33 | $total += $e->length; | |||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | 4 | return $total; | |||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | ######## CDS Methods | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 31 | ▶ | sub is_coding { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_coding: called CC=15 SCAR=41.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 31 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 586 | 31 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 587 | 31 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | 31 | ▶ | if ( $transcript->primary_tag =~ /gene$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | # someone passed a gene, check its subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $code_potential = 0; | |||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | foreach ( $transcript->get_SeqFeatures ) { | |||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $code_potential += is_coding($_); | |||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | return $code_potential; | |||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | 31 | ▶ | return 1 if $transcript->primary_tag =~ /mrna/i; # assumption | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | 12 | ▶ | return 1 if $transcript->source =~ m/protein .? coding/xi; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 12 | ▶ | if ( $transcript->has_tag('transcript_biotype') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | # ensembl type GTFs | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my ($biotype) = $transcript->get_tag_values('transcript_biotype'); | |||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | return $biotype =~ m/protein .? coding/xi ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | elsif ( $transcript->has_tag('biotype') ) { | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | # ensembl type GFFs | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 12 | my ($biotype) = $transcript->get_tag_values('biotype'); | |||||||||||||||||||||||||||||||||||||||||
| 609 | 12 | ▶ | return $biotype =~ m/protein .? coding/xi ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 611 | elsif ( $transcript->has_tag('gene_biotype') ) { | ||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | # ensembl type GTFs | ||||||||||||||||||||||||||||||||||||||||||
| 614 | # must be careful here, gene_biotype of course pertains to gene, | ||||||||||||||||||||||||||||||||||||||||||
| 615 | # and not necessarily this particular transcript | ||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | my ($biotype) = $transcript->get_tag_values('gene_biotype'); | |||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | return 1 if $biotype =~ m/protein .? coding/xi; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | foreach ( $transcript->get_SeqFeatures ) { | |||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | # old fashioned way | ||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | return 1 if $_->primary_tag eq 'CDS'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | 106 | ▶ | sub get_cds { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cds: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 628 | 106 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 629 | 106 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | 106 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 631 | 106 | my @cds; | |||||||||||||||||||||||||||||||||||||||||
| 632 | 106 | foreach my $subfeat ( $transcript->get_SeqFeatures ) { | |||||||||||||||||||||||||||||||||||||||||
| 633 | 1475 | ▶ | push @cds, $subfeat if $subfeat->primary_tag eq 'CDS'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||
| 635 | 106 | ▶ | return unless @cds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | 565 | @cds = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 637 | 901 | sort { $a->[1] <=> $b->[1] } | |||||||||||||||||||||||||||||||||||||||||
| 638 | 91 | map { [ $_, $_->start ] } @cds; | |||||||||||||||||||||||||||||||||||||||||
| 639 | 91 | ▶ | return wantarray ? @cds : \@cds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | 22 | ▶ | sub get_cdsStart { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cdsStart: called CC=7 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 643 | 22 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 644 | 22 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | 22 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 646 | 22 | my $cds = get_cds($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 647 | 22 | ▶ | return unless $cds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 648 | 20 | ▶ | if ( $transcript->strand >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | 20 | return $cds->[0]->start; | |||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 651 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 652 | # stop codons may or may not be not included | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | my $codon = get_stop_codon($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if ($codon) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | return $codon->start < $cds->[0]->start ? $codon->start : $cds->[0]->start; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||
| 657 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | return $cds->[0]->start; | |||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 22 | ▶ | sub get_cdsEnd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cdsEnd: called CC=7 SCAR=21.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | 22 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 665 | 22 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | 22 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 667 | 22 | my $cds = get_cds($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 668 | 22 | ▶ | return unless $cds; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 669 | 20 | ▶ | if ( $transcript->strand >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 670 | 20 | my $codon = get_stop_codon($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 671 | 20 | ▶ | if ($codon) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | 20 | ▶ | return $codon->end > $cds->[-1]->end ? $codon->end : $cds->[-1]->end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||
| 674 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | return $cds->[-1]->end; | |||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||
| 678 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | return $cds->[-1]->end; | |||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | 4 | ▶ | sub get_transcript_cds_length { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_transcript_cds_length: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | 4 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 685 | 4 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | 4 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 687 | 4 | my $total = 0; | |||||||||||||||||||||||||||||||||||||||||
| 688 | 4 | foreach my $subf ( $transcript->get_SeqFeatures ) { | |||||||||||||||||||||||||||||||||||||||||
| 689 | 53 | ▶ | next unless $subf->primary_tag eq 'CDS'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 690 | 13 | $total += $subf->length; | |||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | 4 | return $total; | |||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | 13 | ▶ | sub get_start_codon { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_start_codon: called CC=8 SCAR=21.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 696 | 13 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 697 | 13 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 13 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 13 | my $start_codon; | |||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | # look for existing one | ||||||||||||||||||||||||||||||||||||||||||
| 702 | 13 | foreach my $subfeat ( $transcript->get_SeqFeatures ) { | |||||||||||||||||||||||||||||||||||||||||
| 703 | 177 | ▶ | $start_codon = $subfeat if $subfeat->primary_tag =~ m/start .? codon/xi; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | 13 | ▶ | return $start_codon if $start_codon; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | # otherwise we have to build one | ||||||||||||||||||||||||||||||||||||||||||
| 708 | 13 | my $cdss = get_cds($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 709 | 13 | ▶ | return unless $cdss; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 710 | 10 | ▶ | if ( $transcript->strand >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 10 | $start_codon = $transcript->new( | |||||||||||||||||||||||||||||||||||||||||
| 712 | -seq_id => $transcript->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 713 | -source => $transcript->source, | ||||||||||||||||||||||||||||||||||||||||||
| 714 | -primary_tag => 'start_codon', | ||||||||||||||||||||||||||||||||||||||||||
| 715 | -start => $cdss->[0]->start, | ||||||||||||||||||||||||||||||||||||||||||
| 716 | -end => $cdss->[0]->start + 2, | ||||||||||||||||||||||||||||||||||||||||||
| 717 | -strand => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 718 | -phase => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 719 | -primary_id => $transcript->primary_id . '.start_codon', | ||||||||||||||||||||||||||||||||||||||||||
| 720 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 722 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | $start_codon = $transcript->new( | |||||||||||||||||||||||||||||||||||||||||
| 724 | -seq_id => $transcript->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 725 | -source => $transcript->source, | ||||||||||||||||||||||||||||||||||||||||||
| 726 | -primary_tag => 'start_codon', | ||||||||||||||||||||||||||||||||||||||||||
| 727 | -start => $cdss->[-1]->end - 2, | ||||||||||||||||||||||||||||||||||||||||||
| 728 | -end => $cdss->[-1]->end, | ||||||||||||||||||||||||||||||||||||||||||
| 729 | -strand => -1, | ||||||||||||||||||||||||||||||||||||||||||
| 730 | -phase => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 731 | -primary_id => $transcript->primary_id . '.start_codon', | ||||||||||||||||||||||||||||||||||||||||||
| 732 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||
| 734 | 10 | return $start_codon; | |||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | 33 | ▶ | sub get_stop_codon { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_stop_codon: called CC=8 SCAR=21.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | 33 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 739 | 33 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 740 | 33 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 741 | 33 | my $stop_codon; | |||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | # look for existing one | ||||||||||||||||||||||||||||||||||||||||||
| 744 | 33 | foreach my $subfeat ( $transcript->get_SeqFeatures ) { | |||||||||||||||||||||||||||||||||||||||||
| 745 | 472 | ▶ | $stop_codon = $subfeat if $subfeat->primary_tag =~ m/stop .? codon/xi; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||
| 747 | 33 | ▶ | return $stop_codon if $stop_codon; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | # otherwise we have to build one | ||||||||||||||||||||||||||||||||||||||||||
| 750 | # this entirely presumes that the stop codon is inclusive to the last cds | ||||||||||||||||||||||||||||||||||||||||||
| 751 | # this is the case with GFF3 and UCSC tables, but not GTF | ||||||||||||||||||||||||||||||||||||||||||
| 752 | 33 | my $cdss = get_cds($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 753 | 33 | ▶ | return unless $cdss; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 754 | 30 | ▶ | if ( $transcript->strand >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 755 | 30 | $stop_codon = $transcript->new( | |||||||||||||||||||||||||||||||||||||||||
| 756 | -seq_id => $transcript->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 757 | -source => $transcript->source, | ||||||||||||||||||||||||||||||||||||||||||
| 758 | -primary_tag => 'stop_codon', | ||||||||||||||||||||||||||||||||||||||||||
| 759 | -start => $cdss->[-1]->end - 2, | ||||||||||||||||||||||||||||||||||||||||||
| 760 | -end => $cdss->[-1]->end, | ||||||||||||||||||||||||||||||||||||||||||
| 761 | -strand => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 762 | -phase => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 763 | -primary_id => $transcript->primary_id . '.stop_codon', | ||||||||||||||||||||||||||||||||||||||||||
| 764 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | $stop_codon = $transcript->new( | |||||||||||||||||||||||||||||||||||||||||
| 768 | -seq_id => $transcript->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 769 | -source => $transcript->source, | ||||||||||||||||||||||||||||||||||||||||||
| 770 | -primary_tag => 'stop_codon', | ||||||||||||||||||||||||||||||||||||||||||
| 771 | -start => $cdss->[0]->start, | ||||||||||||||||||||||||||||||||||||||||||
| 772 | -end => $cdss->[0]->start + 2, | ||||||||||||||||||||||||||||||||||||||||||
| 773 | -strand => -1, | ||||||||||||||||||||||||||||||||||||||||||
| 774 | -phase => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 775 | -primary_id => $transcript->primary_id . '.stop_codon', | ||||||||||||||||||||||||||||||||||||||||||
| 776 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||
| 778 | 30 | return $stop_codon; | |||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | 13 | ▶ | sub get_utrs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_utrs: called CC=27 SCAR=56.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 782 | 13 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 783 | 13 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 784 | 13 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | # collect the various types of subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 787 | 13 | my @exons; | |||||||||||||||||||||||||||||||||||||||||
| 788 | my @cdss; | ||||||||||||||||||||||||||||||||||||||||||
| 789 | 13 | my @utrs; | |||||||||||||||||||||||||||||||||||||||||
| 790 | 13 | my @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 791 | 13 | foreach my $subfeat ( $transcript->get_SeqFeatures ) { | |||||||||||||||||||||||||||||||||||||||||
| 792 | 224 | my $type = $subfeat->primary_tag; | |||||||||||||||||||||||||||||||||||||||||
| 793 | 224 | ▶ | if ( $type =~ /exon/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 794 | 104 | push @exons, $subfeat; | |||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||
| 796 | elsif ( $type =~ /cds/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 797 | 78 | push @cdss, $subfeat; | |||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 799 | elsif ( $type =~ m/utr | untranslated/xi ) { | ||||||||||||||||||||||||||||||||||||||||||
| 800 | 42 | push @utrs, $subfeat; | |||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||
| 802 | elsif ( $type =~ m/rna | transcript/xi ) { | ||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | push @transcripts, $subfeat; | |||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | # collect the utrs into final list | ||||||||||||||||||||||||||||||||||||||||||
| 808 | 13 | my @list; | |||||||||||||||||||||||||||||||||||||||||
| 809 | 13 | ▶ | if (@utrs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | # good, we don't have to do any work | ||||||||||||||||||||||||||||||||||||||||||
| 812 | 12 | @list = @utrs; | |||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||
| 814 | elsif (@transcripts) { | ||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | # someone must've passed us a gene | ||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | foreach my $t (@transcripts) { | |||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | my @u = get_utrs($t); | |||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | push @list, @u; | |||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||
| 822 | ▶ | elsif ( @exons and @cdss ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
@exons and @cdss
MC/DC0%0/2
@exons and @cdss
@exons
@cdss
Truth table33%1/3
A and B
A= @exonsB= @cdss
| |||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | # calculate the utrs ourselves | ||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | @exons = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | sort { $a->[1] <=> $b->[1] } | |||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | map { [ $_, $_->start ] } @exons; | |||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | @cdss = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | sort { $a->[1] <=> $b->[1] } | |||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | map { [ $_, $_->start ] } @cdss; | |||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | my $firstCDS = $cdss[0]; | |||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | my $lastCDS = $cdss[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | while (@exons) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | my $exon = shift @exons; | |||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | if ( $exon->end < $firstCDS->start ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | # whole exon is UTR | ||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my $utr = $exon->duplicate; | |||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | $utr->primary_tag( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 841 | $transcript->strand >= 0 ? 'five_prime_UTR' : 'three_prime_UTR' ); | ||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | $utr->display_name( $exon->display_name . '.utr' ); | |||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | push @list, $utr; | |||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||
| 845 | elsif ( $exon->overlaps($firstCDS) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||
| 847 | # partial UTR on left side | ||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my $pieces = $exon->subtract($firstCDS); # array ref of pieces | |||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | ▶ | next unless $pieces; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $utr = $pieces->[0]; # we will want the first one if there are two | |||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | $utr->primary_tag( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | $transcript->strand >= 0 ? 'five_prime_UTR' : 'three_prime_UTR' ); | ||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | $utr->display_name( $exon->display_name . '.utr' ); | |||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | $utr->strand( $exon->strand ); | |||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | $utr->source( $exon->strand ); | |||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | push @list, $utr; | |||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||
| 858 | ▶ | elsif ( $exon->start > $firstCDS->end and $exon->end < $lastCDS->start ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$exon->start > $firstCDS->end and $exon->end < $lastCDS->start
MC/DC0%0/2
$exon->start > $firstCDS->end and $exon->end < $lastCDS->start
$exon->start > $firstCDS->end
$exon->end < $lastCDS->start
Truth table0%0/3
A and B
A= $exon->start > $firstCDS->endB= $exon->end < $lastCDS->start
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | # CDS exon | ||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||
| 863 | elsif ( $exon->overlaps($lastCDS) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | # partial UTR | ||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | my $pieces = $exon->subtract($lastCDS); # array ref of pieces | |||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | next unless $pieces; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | my $utr = $pieces->[-1]; # we will want the second one if there are two | |||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | $utr->primary_tag( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 870 | $transcript->strand >= 0 ? 'three_prime_UTR' : 'five_prime_UTR' ); | ||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | $utr->display_name( $exon->display_name . '.utr' ); | |||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | $utr->strand( $exon->strand ); | |||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | $utr->source( $exon->strand ); | |||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | push @list, $utr; | |||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | elsif ( $exon->start > $lastCDS->end ) { | ||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||
| 878 | # whole exon is UTR | ||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | my $utr = $exon->duplicate; | |||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | $utr->primary_tag( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 881 | $transcript->strand >= 0 ? 'three_prime_UTR' : 'five_prime_UTR' ); | ||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | $utr->display_name( $exon->display_name . '.utr' ); | |||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | push @list, $utr; | |||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||
| 885 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 886 | # geometric error | ||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | croak 'FATAL: programmer geometric error!'; | |||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||
| 891 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 892 | # nothing usable found to identify UTRs | ||||||||||||||||||||||||||||||||||||||||||
| 893 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | # we have our list | ||||||||||||||||||||||||||||||||||||||||||
| 897 | 12 | ▶ | return wantarray ? @list : \@list; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||
| 900 | 2 | ▶ | sub get_transcript_utr_length { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_transcript_utr_length: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 901 | 2 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 902 | 2 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 903 | 2 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 904 | 2 | my $utrs = get_utrs($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 905 | 2 | my $total = 0; | |||||||||||||||||||||||||||||||||||||||||
| 906 | 2 | foreach my $utr ( @{$utrs} ) { | |||||||||||||||||||||||||||||||||||||||||
| 907 | 7 | $total += $utr->length; | |||||||||||||||||||||||||||||||||||||||||
| 908 | } | ||||||||||||||||||||||||||||||||||||||||||
| 909 | 2 | return $total; | |||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||
| 912 | 4 | ▶ | sub get_5p_utrs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_5p_utrs: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | 4 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 914 | 4 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 915 | 4 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||
| 917 | # get all UTRs | ||||||||||||||||||||||||||||||||||||||||||
| 918 | 4 | my $utrs = get_utrs($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 919 | 4 | ▶ | return unless scalar( @{$utrs} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | 4 | my @fivers = grep { $_->primary_tag =~ /5|five/i } @{$utrs}; | |||||||||||||||||||||||||||||||||||||||||
| 922 | 4 | ▶ | return wantarray ? @fivers : \@fivers; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | 4 | ▶ | sub get_3p_utrs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_3p_utrs: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 926 | 4 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 927 | 4 | ▶ | return unless $transcript; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 928 | 4 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($transcript) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | # get all UTRs | ||||||||||||||||||||||||||||||||||||||||||
| 931 | 4 | my $utrs = get_utrs($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 932 | 4 | ▶ | return unless scalar( @{$utrs} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||
| 934 | 4 | my @threes = grep { $_->primary_tag =~ /3|three/i } @{$utrs}; | |||||||||||||||||||||||||||||||||||||||||
| 935 | 4 | ▶ | return wantarray ? @threes : \@threes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | 2 | ▶ | sub get_transcript_5p_utr_length { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_transcript_5p_utr_length: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 939 | 2 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 940 | 2 | my $utrs = get_5p_utrs($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 941 | 2 | my $total = 0; | |||||||||||||||||||||||||||||||||||||||||
| 942 | 2 | foreach my $utr ( @{$utrs} ) { | |||||||||||||||||||||||||||||||||||||||||
| 943 | 3 | $total += $utr->length; | |||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||
| 945 | 2 | return $total; | |||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||
| 948 | 2 | ▶ | sub get_transcript_3p_utr_length { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_transcript_3p_utr_length: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 949 | 2 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 950 | 2 | my $utrs = get_3p_utrs($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 951 | 2 | my $total = 0; | |||||||||||||||||||||||||||||||||||||||||
| 952 | 2 | foreach my $utr ( @{$utrs} ) { | |||||||||||||||||||||||||||||||||||||||||
| 953 | 4 | $total += $utr->length; | |||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||
| 955 | 2 | return $total; | |||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||
| 958 | #### Export methods | ||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | sub gff_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gff_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||
| 962 | # Bio::ToolBox::SeqFeature and Bio::SeqFeature::Lite objects have this method | ||||||||||||||||||||||||||||||||||||||||||
| 963 | # otherwise this will die | ||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | return shift->gff_string(@_); | |||||||||||||||||||||||||||||||||||||||||
| 965 | } | ||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||
| 967 | 14 | ▶ | sub gtf_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gtf_string: called CC=31 SCAR=44.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 968 | 14 | my $feature = shift; | |||||||||||||||||||||||||||||||||||||||||
| 969 | 14 | ▶ | my $gene = shift || undef; # only present when recursing | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || undef
MC/DC100%1/1
shift() || undef
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 970 | 14 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($feature) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | # process a gene | ||||||||||||||||||||||||||||||||||||||||||
| 973 | 14 | ▶ | if ( $feature->primary_tag =~ /gene$/i and not defined $gene ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$feature->primary_tag =~ /gene$/i and not defined $gene
MC/DC50%1/2
$feature->primary_tag =~ /gene$/i and not defined $gene
$feature->primary_tag =~ /gene$/i
not defined $gene
Truth table66%2/3
A and not(B)
A= $feature->primary_tag =~ /gene$/iB= not defined $gene
| |||||||||||||||||||||||||||||||||||||||||||
| 974 | 1 | my $string; | |||||||||||||||||||||||||||||||||||||||||
| 975 | 1 | foreach my $t ( get_transcripts($feature) ) { | |||||||||||||||||||||||||||||||||||||||||
| 976 | 13 | $string .= gtf_string( $t, $feature ); | |||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||
| 978 | 1 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | # check that we have transcribed feature with exons | ||||||||||||||||||||||||||||||||||||||||||
| 982 | 13 | my @exons = get_exons($feature); | |||||||||||||||||||||||||||||||||||||||||
| 983 | 13 | ▶ | return unless @exons; # no exon subfeatures? must not be a transcript.... | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||
| 985 | # mandatory identifiers | ||||||||||||||||||||||||||||||||||||||||||
| 986 | 13 | my ( $gene_id, $gene_name, $gene_biotype ); | |||||||||||||||||||||||||||||||||||||||||
| 987 | 13 | ▶ | if ($gene) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 988 | 13 | ▶ | $gene_id = $gene->primary_id || $gene->display_name || q(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$gene->primary_id || $gene->display_name || ''
$gene->primary_id or $gene->display_name
MC/DC0%0/2
$gene->primary_id || $gene->display_name || ''
$gene->primary_id
$gene->display_name
Truth table33%1/3
A or B
A= $gene->primary_idB= $gene->display_name
| |||||||||||||||||||||||||||||||||||||||||||
| 989 | 13 | ▶ | $gene_name = $gene->display_name || q(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$gene->display_name || ''
MC/DC0%0/1
$gene->display_name || ''
$gene->display_name
Truth table50%1/2
A
A= $gene->display_name
| |||||||||||||||||||||||||||||||||||||||||||
| 990 | 13 | ▶ | ($gene_biotype) = | ||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$gene->get_tag_values('gene_biotype') || $gene->get_tag_values('biotype') || ''
$gene->get_tag_values("gene_biotype") or $gene->get_tag_values("biotype")
MC/DC0%0/2
$gene->get_tag_values('gene_biotype') || $gene->get_tag_values('biotype') || ''
$gene->get_tag_values("gene_biotype")
$gene->get_tag_values("biotype")
Truth table33%1/3
A or B
A= $gene->get_tag_values("gene_biotype")B= $gene->get_tag_values("biotype")
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | $gene->get_tag_values('gene_biotype') | ||||||||||||||||||||||||||||||||||||||||||
| 992 | || $gene->get_tag_values('biotype') | ||||||||||||||||||||||||||||||||||||||||||
| 993 | || q(); | ||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||
| 995 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 996 | # these attributes might still be present for transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | ($gene_id) = $feature->get_tag_values('gene_id') || q(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->get_tag_values('gene_id') || ''
MC/DC0%0/1
$feature->get_tag_values('gene_id') || ''
$feature->get_tag_values('gene_id')
Truth table0%0/2
A
A= $feature->get_tag_values('gene_id')
| |||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | ▶ | ($gene_name) = $feature->get_tag_values('gene_name') || q(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->get_tag_values('gene_name') || ''
MC/DC0%0/1
$feature->get_tag_values('gene_name') || ''
$feature->get_tag_values('gene_name')
Truth table0%0/2
A
A= $feature->get_tag_values('gene_name')
| |||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | ▶ | ($gene_biotype) = $feature->get_tag_values('gene_biotype') || q(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$feature->get_tag_values('gene_biotype') || ''
MC/DC0%0/1
$feature->get_tag_values('gene_biotype') || ''
$feature->get_tag_values('gene_biotype')
Truth table0%0/2
A
A= $feature->get_tag_values('gene_biotype')
| |||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | 13 | ▶ | my $trx_id = $feature->primary_id || $feature->display_name; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$feature->primary_id || $feature->display_name
MC/DC0%0/2
$feature->primary_id || $feature->display_name
$feature->primary_id
$feature->display_name
Truth table33%1/3
A || B
A= $feature->primary_idB= $feature->display_name
| |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 13 | my $trx_name = $feature->display_name; | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 13 | my $group = sprintf( | |||||||||||||||||||||||||||||||||||||||||
| 1004 | "gene_id \"%s\"; transcript_id \"%s\"; gene_name \"%s\"; transcript_name \"%s\";", | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | $gene_id, $trx_id, $gene_name, $trx_name ); | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||
| 1007 | # add additional transcript attributes that might be interesting to keep | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | 13 | ▶ | if ($gene_biotype) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | $group .= " gene_biotype \"$gene_biotype\";"; | |||||||||||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | 13 | ▶ | my ($biotype) = $feature->get_tag_values('transcript_biotype') | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$feature->get_tag_values('transcript_biotype') || $feature->get_tag_values('biotype')
MC/DC0%0/2
$feature->get_tag_values('transcript_biotype') || $feature->get_tag_values('biotype')
$feature->get_tag_values('transcript_biotype')
$feature->get_tag_values('biotype')
Truth table33%1/3
A || B
A= $feature->get_tag_values('transcript_biotype')B= $feature->get_tag_values('biotype')
| |||||||||||||||||||||||||||||||||||||||||||
| 1012 | || $feature->get_tag_values('biotype'); | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | 13 | ▶ | if ($biotype) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1014 | 13 | $group .= " transcript_biotype \"$biotype\";"; | |||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | 13 | my ($tsl) = $feature->get_tag_values('transcript_support_level'); | |||||||||||||||||||||||||||||||||||||||||
| 1017 | 13 | ▶ | if ($tsl) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | $group .= " transcript_support_level \"$tsl\";"; | |||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | 13 | my $tag = $feature->get_tag_values('tag'); | |||||||||||||||||||||||||||||||||||||||||
| 1021 | 13 | ▶ | if ($tag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | ▶ | if ( ref($tag) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | foreach my $t ( @{$tag} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | $group .= " tag \"$t\";"; | |||||||||||||||||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | $group .= " tag \"$tag\";"; | |||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||
| 1032 | # skip transcript as it is technically not part of the GTF standard.... | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||
| 1034 | # convert exon subfeatures collected above | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | 13 | my $string; | |||||||||||||||||||||||||||||||||||||||||
| 1036 | 13 | my @cds = get_cds($feature); | |||||||||||||||||||||||||||||||||||||||||
| 1037 | 13 | push @cds, get_stop_codon($feature); | |||||||||||||||||||||||||||||||||||||||||
| 1038 | 13 | push @cds, get_start_codon($feature); | |||||||||||||||||||||||||||||||||||||||||
| 1039 | 171 | @exons = map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||
| 1040 | 473 | ▶ | sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
MC/DC100%2/2
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1] || $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
$Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]
$Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
Truth table100%3/3
A || B
A= $Bio::ToolBox::GeneTools::a->[1] <=> $Bio::ToolBox::GeneTools::b->[1]B= $Bio::ToolBox::GeneTools::a->[2] <=> $Bio::ToolBox::GeneTools::b->[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 1041 | 13 | map { [ $_, $_->start, $_->end ] } ( @exons, @cds ); | |||||||||||||||||||||||||||||||||||||||||
| 1042 | 13 | foreach my $subf (@exons) { | |||||||||||||||||||||||||||||||||||||||||
| 1043 | 171 | ▶ | $string .= join( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition50%2/4
$subf->seq_id || '.'
$subf->source_tag || '.'
MC/DC0%0/1
$subf->seq_id || '.'
$subf->seq_id
MC/DC0%0/1
$subf->source_tag || '.'
$subf->source_tag
Truth table50%1/2
A
A= $subf->seq_id
Truth table50%1/2
A
A= $subf->source_tag
| |||||||||||||||||||||||||||||||||||||||||||
| 1044 | "\t", | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | $subf->seq_id || '.', | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | $subf->source_tag || '.', | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | $subf->primary_tag, | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | $subf->start, | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | $subf->end, | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | defined $subf->score ? $subf->score : '.', | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | $subf->strand < 0 ? '-' : '+', | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | defined $subf->phase ? $subf->phase : '.', | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | "$group\n" | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | # finished | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | 13 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||
| 1063 | 2 | ▶ | sub ucsc_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ucsc_string: called CC=9 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1064 | 2 | my $feature = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1065 | 2 | ▶ | my $use_id = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 2 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($feature) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1067 | 2 | my @ucsc_list; | |||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||
| 1069 | # process according to type | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | 2 | ▶ | if ( $feature->primary_tag =~ /gene$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||
| 1072 | # a gene object, we will need to process it's transcript subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | 2 | foreach my $transcript ( get_transcripts($feature) ) { | |||||||||||||||||||||||||||||||||||||||||
| 1074 | 26 | my $ucsc = _process_ucsc_transcript( $transcript, $feature, $use_id ); | |||||||||||||||||||||||||||||||||||||||||
| 1075 | 26 | ▶ | push @ucsc_list, $ucsc if $ucsc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1076 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | elsif ( $feature->primary_tag =~ m/rna | transcript/xi ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||
| 1080 | # some sort of RNA transcript | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | my $ucsc = _process_ucsc_transcript( $feature, undef, $use_id ); | |||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | ▶ | push @ucsc_list, $ucsc if $ucsc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1086 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||
| 1088 | # return strings | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | 2 | my $string; | |||||||||||||||||||||||||||||||||||||||||
| 1090 | 2 | foreach my $ucsc (@ucsc_list) { | |||||||||||||||||||||||||||||||||||||||||
| 1091 | $string .= sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | "%s\t%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%s\t%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | $ucsc->{'name2'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | $ucsc->{'name'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | $ucsc->{'chr'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1096 | $ucsc->{'strand'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | $ucsc->{'txStart'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | $ucsc->{'txEnd'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1099 | $ucsc->{'cdsStart'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | $ucsc->{'cdsEnd'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | $ucsc->{'exonCount'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | 26 | join( ',', @{ $ucsc->{'exonStarts'} } ) . ',', | |||||||||||||||||||||||||||||||||||||||||
| 1103 | 26 | join( ',', @{ $ucsc->{'exonEnds'} } ) . ',', | |||||||||||||||||||||||||||||||||||||||||
| 1104 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1106 | 2 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 1107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||
| 1109 | 2 | ▶ | sub bed12_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bed12_string: called CC=10 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1110 | 2 | my $feature = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1111 | 2 | ▶ | my $use_id = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1112 | 2 | ▶ | confess 'FATAL: not a SeqFeature object!' unless ref($feature) =~ /seqfeature/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1113 | 2 | my @ucsc_list; | |||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | # process according to type | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | 2 | ▶ | if ( $feature->primary_tag =~ /gene$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||
| 1118 | # a gene object, we will need to process it's transcript subfeatures | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | foreach my $transcript ( get_transcripts($feature) ) { | |||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | my $ucsc = _process_ucsc_transcript( $transcript, $feature, $use_id ); | |||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | ▶ | push @ucsc_list, $ucsc if $ucsc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | elsif ( $feature->primary_tag =~ m/rna | transcript/xi ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||
| 1126 | # some sort of RNA transcript | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | 2 | my $ucsc = _process_ucsc_transcript( $feature, undef, $use_id ); | |||||||||||||||||||||||||||||||||||||||||
| 1128 | 2 | ▶ | push @ucsc_list, $ucsc if $ucsc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||
| 1134 | # return strings | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | 2 | my $string; | |||||||||||||||||||||||||||||||||||||||||
| 1136 | 2 | foreach my $ucsc (@ucsc_list) { | |||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||
| 1138 | # exon sizes | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | 2 | my @sizes; | |||||||||||||||||||||||||||||||||||||||||
| 1140 | 2 | ▶ | for ( my $i = 0; $i < scalar( @{ $ucsc->{'exonStarts'} } ); $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1141 | 10 | push @sizes, $ucsc->{'exonEnds'}->[$i] - $ucsc->{'exonStarts'}->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 1142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1143 | $string .= sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | "%s\t%d\t%d\t%s\t%s\t%s\t%d\t%d\t%d\t%d\t%s\t%s\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1145 | $ucsc->{'chr'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | $ucsc->{'txStart'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | $ucsc->{'txEnd'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | $ucsc->{'name'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | $ucsc->{'score'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | $ucsc->{'strand'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | $ucsc->{'cdsStart'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | $ucsc->{'cdsEnd'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | $ucsc->{'exonCount'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | join( ',', @sizes ), | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | 2 | join( ',', map { $_ - $ucsc->{'txStart'} } @{ $ucsc->{'exonStarts'} } ), | |||||||||||||||||||||||||||||||||||||||||
| 1157 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | 2 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 1160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||
| 1162 | #### filter methods | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | ▶ | sub filter_transcript_support_level { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_transcript_support_level: not called CC=25 SCAR=64.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | my $gene = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | ▶ | return unless $gene; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | ▶ | my $min_tsl = shift || 'best'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'best'
MC/DC0%0/1
shift() || 'best'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | my @list = qw(1 2 3 4 5 NA Missing); | |||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||
| 1170 | # get transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0 | my @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | ▶ | if ( ref($gene) =~ /seqfeature/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1173 | 0 | @transcripts = get_transcripts($gene); | |||||||||||||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1175 | elsif ( ref($gene) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | @transcripts = @{$gene}; | |||||||||||||||||||||||||||||||||||||||||
| 1177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | return unless @transcripts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||
| 1183 | # categorize transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | my %results = map { $_ => [] } @list; | |||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | foreach my $t (@transcripts) { | |||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | my ($tsl) = $t->get_tag_values('transcript_support_level'); | |||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||
| 1188 | # the value may be just a number, or may have additional text | ||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | ▶ | if ( $tsl =~ /^([12345])/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | push @{ $results{$1} }, $t; | |||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | elsif ( $tsl =~ /^NA/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | push @{ $results{NA} }, $t; | |||||||||||||||||||||||||||||||||||||||||
| 1194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | push @{ $results{Missing} }, $t; | |||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||
| 1200 | # take appropriate transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | my @keepers; | |||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | ▶ | if ( $min_tsl eq 'best' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||
| 1204 | # progress through all levels and keep only the highest set | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | foreach my $tsl (@list) { | |||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | ▶ | if ( scalar @{ $results{$tsl} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | @keepers = @{ $results{$tsl} }; | |||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1212 | elsif ( $min_tsl =~ /^best(\d)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | # progress through all levels and take all up to specified max | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | my $max = $1; | |||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | foreach my $tsl ( 1 .. 5 ) { | |||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | ▶ | if ( scalar @{ $results{$tsl} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | ▶ | if ( $tsl <= $max ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | push @keepers, @{ $results{$tsl} }; | |||||||||||||||||||||||||||||||||||||||||
| 1220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | ▶ | elsif ( not @keepers and $tsl > $max ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not @keepers and $tsl > $max
MC/DC0%0/2
not @keepers and $tsl > $max
not @keepers
$tsl > $max
Truth table0%0/3
not(A) and B
A= not @keepersB= $tsl > $max
| |||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||
| 1223 | # go ahead and take it if we have no other option | ||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | push @keepers, @{ $results{$tsl} }; | |||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||
| 1229 | # still take the NA and Missing if nothing else | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | ▶ | if ( scalar @keepers == 0 and scalar @{ $results{'NA'} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
scalar @keepers == 0 and scalar @{$results{"NA"};}
MC/DC0%0/1
scalar @keepers == 0 and scalar @{$results{"NA"};}
scalar @keepers == 0
Truth table0%0/2
A
A= scalar @keepers == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | @keepers = @{ $results{'NA'} }; | |||||||||||||||||||||||||||||||||||||||||
| 1232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | elsif ( scalar @keepers == 0 and scalar @{ $results{'Missing'} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
scalar @keepers == 0 and scalar @{$results{"Missing"};}
MC/DC0%0/1
scalar @keepers == 0 and scalar @{$results{"Missing"};}
scalar @keepers == 0
Truth table0%0/2
A
A= scalar @keepers == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | @keepers = @{ $results{'Missing'} }; | |||||||||||||||||||||||||||||||||||||||||
| 1235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | elsif ( $min_tsl =~ /^\d$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||
| 1239 | # take only the specified level | ||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | @keepers = @{ $results{$min_tsl} }; | |||||||||||||||||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | elsif ( $min_tsl eq 'NA' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||
| 1244 | # take only the NA guys | ||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | @keepers = @{ $results{'NA'} }; | |||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | confess | |||||||||||||||||||||||||||||||||||||||||
| 1249 | "FATAL: unrecognized minimum TSL value '$min_tsl' Check the documentation!"; | ||||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | ▶ | @keepers = @{ $results{'Missing'} } unless @keepers; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||
| 1253 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | return _return_filtered_transcripts( $gene, \@keepers ); | |||||||||||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | ▶ | sub filter_transcript_gencode_basic { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_transcript_gencode_basic: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1258 | 0 | my $gene = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | ▶ | return unless $gene; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||
| 1261 | # get transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | my @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 1263 | 0 | ▶ | if ( ref($gene) =~ /seqfeature/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1264 | 0 | @transcripts = get_transcripts($gene); | |||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1266 | elsif ( ref($gene) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | @transcripts = @{$gene}; | |||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1270 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | ▶ | return unless @transcripts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||
| 1274 | # take appropriate transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | my @keepers; | |||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | foreach my $t (@transcripts) { | |||||||||||||||||||||||||||||||||||||||||
| 1277 | 0 | my $tag = $t->get_tag_values('tag'); | |||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | ▶ | if ( ref($tag) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | foreach ( @{$tag} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1280 | 0 | ▶ | if ( $_ eq 'basic' or $_ eq 'gencode_basic' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ eq "basic" or $_ eq "gencode_basic"
MC/DC0%0/2
$_ eq "basic" or $_ eq "gencode_basic"
$_ eq "basic"
$_ eq "gencode_basic"
Truth table0%0/3
A or B
A= $_ eq "basic"B= $_ eq "gencode_basic"
| |||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | push @keepers, $t; | |||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 1283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1286 | ▶ | elsif ( $tag and $tag eq 'basic' or $_ eq 'gencode_basic' ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$tag and $tag eq "basic" or $_ eq "gencode_basic"
$tag and $tag eq "basic"
MC/DC0%0/3
$tag and $tag eq "basic" or $_ eq "gencode_basic"
$tag
$tag eq "basic"
$_ eq "gencode_basic"
Truth table0%0/5
A and B or C
A= $tagB= $tag eq "basic"C= $_ eq "gencode_basic"
| |||||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | push @keepers, $t; | |||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||
| 1291 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 1292 | 0 | return _return_filtered_transcripts( $gene, \@keepers ); | |||||||||||||||||||||||||||||||||||||||||
| 1293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||
| 1295 | 1 | ▶ | sub filter_transcript_biotype { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_transcript_biotype: called CC=11 SCAR=28.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1296 | 1 | my $gene = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1297 | 1 | ▶ | return unless $gene; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1298 | 1 | my $check = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1299 | 1 | ▶ | confess 'FATAL: no biotype value to check provided!' unless $check; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||
| 1301 | # get transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 1302 | 1 | my @transcripts; | |||||||||||||||||||||||||||||||||||||||||
| 1303 | 1 | ▶ | if ( ref($gene) =~ /seqfeature/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1304 | 1 | @transcripts = get_transcripts($gene); | |||||||||||||||||||||||||||||||||||||||||
| 1305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1306 | elsif ( ref($gene) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | 0 | @transcripts = @{$gene}; | |||||||||||||||||||||||||||||||||||||||||
| 1308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1309 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | 1 | ▶ | return unless @transcripts; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||
| 1314 | # take appropriate transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 1315 | 1 | my @keepers; | |||||||||||||||||||||||||||||||||||||||||
| 1316 | 1 | foreach my $t (@transcripts) { | |||||||||||||||||||||||||||||||||||||||||
| 1317 | 13 | ▶ | my ($value) = $t->get_tag_values('transcript_biotype') | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$t->get_tag_values('transcript_biotype') || $t->get_tag_values('biotype')
MC/DC0%0/2
$t->get_tag_values('transcript_biotype') || $t->get_tag_values('biotype')
$t->get_tag_values('transcript_biotype')
$t->get_tag_values('biotype')
Truth table33%1/3
A || B
A= $t->get_tag_values('transcript_biotype')B= $t->get_tag_values('biotype')
| |||||||||||||||||||||||||||||||||||||||||||
| 1318 | || $t->get_tag_values('biotype'); | ||||||||||||||||||||||||||||||||||||||||||
| 1319 | 13 | ▶ | $value ||= $t->primary_tag; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$value ||= $t->primary_tag
MC/DC0%0/2
$value ||= $t->primary_tag
$value
$t->primary_tag
Truth table33%1/3
A ||= B
A= $valueB= $t->primary_tag
| |||||||||||||||||||||||||||||||||||||||||||
| 1320 | 13 | ▶ | if ( $value and $value =~ /$check/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$value and $value =~ /$check/i
MC/DC50%1/2
$value and $value =~ /$check/i
$value
$value =~ /$check/i
Truth table66%2/3
A and B
A= $valueB= $value =~ /$check/i
| |||||||||||||||||||||||||||||||||||||||||||
| 1321 | 2 | push @keepers, $t; | |||||||||||||||||||||||||||||||||||||||||
| 1322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||
| 1325 | # return | ||||||||||||||||||||||||||||||||||||||||||
| 1326 | 1 | return _return_filtered_transcripts( $gene, \@keepers ); | |||||||||||||||||||||||||||||||||||||||||
| 1327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||
| 1329 | #### internal methods | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||
| 1331 | 28 | ▶ | sub _process_ucsc_transcript { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_ucsc_transcript: called CC=14 SCAR=27.7
| |||||||||||||||||||||||||||||||||||||||||||
| 1332 | 28 | my $transcript = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1333 | 28 | ▶ | my $gene = shift || undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || undef
MC/DC100%1/1
shift() || undef
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1334 | 28 | ▶ | my $use_id = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||
| 1336 | # initialize ucsc hash | ||||||||||||||||||||||||||||||||||||||||||
| 1337 | 28 | ▶ | my $ucsc = { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition40%2/5
$transcript->display_name or $transcript->primary_id
$transcript->score || 1000
MC/DC0%0/2
$transcript->display_name or $transcript->primary_id
$transcript->display_name
$transcript->primary_id
MC/DC0%0/1
$transcript->score || 1000
$transcript->score
Truth table33%1/3
A or B
A= $transcript->display_nameB= $transcript->primary_id
Truth table50%1/2
A
A= $transcript->score
| |||||||||||||||||||||||||||||||||||||||||||
| 1338 | 'name' => $use_id ? $transcript->primary_id : $transcript->display_name | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | || $transcript->primary_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1340 | 'name2' => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1341 | 'chr' => $transcript->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1342 | 'strand' => $transcript->strand < 0 ? '-' : '+', | ||||||||||||||||||||||||||||||||||||||||||
| 1343 | 'txStart' => $transcript->start - 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1344 | 'txEnd' => $transcript->end, | ||||||||||||||||||||||||||||||||||||||||||
| 1345 | 'cdsStart' => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1346 | 'cdsEnd' => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 1347 | 'exonCount' => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | 'exonStarts' => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1349 | 'exonEnds' => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1350 | 'score' => $transcript->score || 1000, | ||||||||||||||||||||||||||||||||||||||||||
| 1351 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||
| 1353 | # determine gene name | ||||||||||||||||||||||||||||||||||||||||||
| 1354 | 28 | ▶ | if ($gene) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1355 | |||||||||||||||||||||||||||||||||||||||||||
| 1356 | # use provided gene name | ||||||||||||||||||||||||||||||||||||||||||
| 1357 | 26 | ▶ | $ucsc->{'name2'} = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$gene->display_name or $gene->primary_id
MC/DC0%0/2
$gene->display_name or $gene->primary_id
$gene->display_name
$gene->primary_id
Truth table33%1/3
A or B
A= $gene->display_nameB= $gene->primary_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1358 | $use_id ? $gene->primary_id : $gene->display_name || $gene->primary_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1360 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1361 | # reuse the name | ||||||||||||||||||||||||||||||||||||||||||
| 1362 | 2 | $ucsc->{'name2'} = $ucsc->{'name'}; | |||||||||||||||||||||||||||||||||||||||||
| 1363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||||||||||||||||
| 1365 | # record CDS points | ||||||||||||||||||||||||||||||||||||||||||
| 1366 | 28 | ▶ | if ( is_coding($transcript) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1367 | 18 | my $start = get_cdsStart($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 1368 | 18 | my $stop = get_cdsEnd($transcript); | |||||||||||||||||||||||||||||||||||||||||
| 1369 | 18 | ▶ | if ( $start and $stop ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$start and $stop
MC/DC0%0/2
$start and $stop
$start
$stop
Truth table33%1/3
A and B
A= $startB= $stop
| |||||||||||||||||||||||||||||||||||||||||||
| 1370 | 18 | $ucsc->{cdsStart} = $start - 1; | |||||||||||||||||||||||||||||||||||||||||
| 1371 | 18 | $ucsc->{cdsEnd} = $stop; | |||||||||||||||||||||||||||||||||||||||||
| 1372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1373 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1374 | # if we don't have cds start/stop, then assign to transcript end | ||||||||||||||||||||||||||||||||||||||||||
| 1375 | # as if it is a noncoding transcript, regardless of primary_tag | ||||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | $ucsc->{cdsStart} = $transcript->end; | |||||||||||||||||||||||||||||||||||||||||
| 1377 | 0 | $ucsc->{cdsEnd} = $transcript->end; | |||||||||||||||||||||||||||||||||||||||||
| 1378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1380 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1381 | # non-coding transcript sets the cds points to the transcript end | ||||||||||||||||||||||||||||||||||||||||||
| 1382 | 10 | $ucsc->{cdsStart} = $transcript->end; | |||||||||||||||||||||||||||||||||||||||||
| 1383 | 10 | $ucsc->{cdsEnd} = $transcript->end; | |||||||||||||||||||||||||||||||||||||||||
| 1384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||
| 1386 | # record the exons | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | 28 | foreach my $exon ( get_exons($transcript) ) { | |||||||||||||||||||||||||||||||||||||||||
| 1388 | 180 | push @{ $ucsc->{'exonStarts'} }, $exon->start - 1; | |||||||||||||||||||||||||||||||||||||||||
| 1389 | 180 | push @{ $ucsc->{'exonEnds'} }, $exon->end; | |||||||||||||||||||||||||||||||||||||||||
| 1390 | 180 | $ucsc->{'exonCount'} += 1; | |||||||||||||||||||||||||||||||||||||||||
| 1391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||
| 1393 | 28 | return $ucsc; | |||||||||||||||||||||||||||||||||||||||||
| 1394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||
| 1396 | 1 | ▶ | sub _return_filtered_transcripts { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_return_filtered_transcripts: called CC=4 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1397 | 1 | my ( $gene, $keepers ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||
| 1399 | 1 | ▶ | if ( ref($gene) =~ /seqfeature/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||
| 1401 | # first check if we were only given a transcript | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | 1 | ▶ | if ( $gene->primary_tag =~ /transcript | rna/xi ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||
| 1404 | # we must have been given a single transcript to check, so return it | ||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | ▶ | $keepers->[0] ||= undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$keepers->[0] ||= undef
MC/DC0%0/1
$keepers->[0] ||= undef
$keepers->[0]
Truth table0%0/2
A
A= $keepers->[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | return $keepers->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1408 | |||||||||||||||||||||||||||||||||||||||||||
| 1409 | # we can't delete subfeatures, so we're forced to create a new | ||||||||||||||||||||||||||||||||||||||||||
| 1410 | # parent gene and reattach the filtered transcripts | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | 1 | my %attributes = $gene->attributes; | |||||||||||||||||||||||||||||||||||||||||
| 1412 | 1 | return $gene->new( | |||||||||||||||||||||||||||||||||||||||||
| 1413 | -seq_id => $gene->seq_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | -start => $gene->start, | ||||||||||||||||||||||||||||||||||||||||||
| 1415 | -end => $gene->end, | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | -strand => $gene->strand, | ||||||||||||||||||||||||||||||||||||||||||
| 1417 | -primary_tag => $gene->primary_tag, | ||||||||||||||||||||||||||||||||||||||||||
| 1418 | -source => $gene->source_tag, | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | -name => $gene->display_name, | ||||||||||||||||||||||||||||||||||||||||||
| 1420 | -id => $gene->primary_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1421 | -attributes => \%attributes, | ||||||||||||||||||||||||||||||||||||||||||
| 1422 | -segments => $keepers, | ||||||||||||||||||||||||||||||||||||||||||
| 1423 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1425 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1426 | 0 | return $keepers; | |||||||||||||||||||||||||||||||||||||||||
| 1427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||
| 1430 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||
| 1432 | __END__ | ||||||||||||||||||||||||||||||||||||||||||