comparison variant_effect_predictor/Bio/EnsEMBL/Utils/VegaCuration/Translation.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1 =head1 LICENSE
2
3 Copyright (c) 1999-2012 The European Bioinformatics Institute and
4 Genome Research Limited. All rights reserved.
5 This software is distributed under a modified Apache license.
6 For license details, please see
7 http://www.ensembl.org/info/about/code_licence.html
8 =head1 CONTACT
9 Please email comments or questions to the public Ensembl
10 developers list at <dev@ensembl.org>.
11 Questions may also be sent to the Ensembl help desk at
12 <helpdesk@ensembl.org>.
13
14 =cut
15 =head1 NAME
16 =head1 SYNOPSIS
17 =head1 DESCRIPTION
18 =head1 METHODS
19 =cut
20
21 package Bio::EnsEMBL::Utils::VegaCuration::Translation;
22 use strict;
23 use warnings;
24 use vars qw(@ISA);
25 use Data::Dumper;
26 use Bio::EnsEMBL::Utils::VegaCuration::Transcript;
27 @ISA = qw(Bio::EnsEMBL::Utils::VegaCuration::Transcript);
28
29 =head2 check_CDS_start_end_remarks
30
31 Args : B::E::Transcript
32 Example : my $results = $support->check_CDS_end_remarks($transcript)
33 Description: identifies incorrect 'CDS end...' transcript remarks in a
34 otter-derived Vega database
35 Returntype : hashref
36
37 =cut
38
39 sub check_CDS_start_end_remarks {
40 my $self = shift;
41 my $trans = shift;
42 # info for checking
43 my @remarks = @{$trans->get_all_Attributes('remark')};
44 my $coding_end = $trans->cdna_coding_end;
45 my $coding_start = $trans->cdna_coding_start;
46 my $trans_end = $trans->length;
47 my $trans_seq = $trans->seq->seq;
48 my $stop_codon = substr($trans_seq, $coding_end-3, 3);
49 my $start_codon = substr($trans_seq, $coding_start-1, 3);
50 #hashref to return results
51 my $results;
52
53 #extra CDS end not found remarks
54 if (grep {$_->value eq 'CDS end not found'} @remarks) {
55 if ( ($coding_end != $trans_end)
56 && ( grep {$_ eq $stop_codon} qw(TGA TAA TAG) ) ) {
57 $results->{'END_EXTRA'} = 1;
58 }
59 }
60 #missing CDS end not found remark
61 if ( $coding_end == $trans_end ) {
62 if (! grep {$_->value eq 'CDS end not found'} @remarks) {
63 if (grep {$_ eq $stop_codon} qw(TGA TAA TAG)) {
64 $results->{'END_MISSING_2'} = 1;
65 }
66 else {
67 $results->{'END_MISSING_1'} = $stop_codon;
68 }
69 }
70 }
71 #extra CDS start not found remark
72 if (grep {$_->value eq 'CDS start not found'} @remarks) {
73 if ( ($coding_start != 1)
74 && ($start_codon eq 'ATG') ) {
75 $results->{'START_EXTRA'} = 1;
76 }
77 }
78 #missing CDS start not found remark
79 if ( $coding_start == 1) {
80 if ( ! grep {$_->value eq 'CDS start not found'} @remarks) {
81 if ($start_codon eq 'ATG') {
82 $results->{'START_MISSING_2'} = 1;
83 } else {
84 $results->{'START_MISSING_1'} = $start_codon;
85 }
86 }
87 }
88 return $results;
89 }
90
91 =head2 check_CDS_start_end_remarks_loutre
92
93 Args : B::E::Transcript
94 Example : my $results = $support->check_CDS_end_remarks($transcript)
95 Description: identifies incorrect 'CDS end...' transcript attribs in a loutre
96 of a loutre-derived Vega database.
97 Returntype : hashref
98
99 =cut
100
101 sub check_CDS_start_end_remarks_loutre {
102 my $self = shift;
103 my $trans = shift;
104
105 # info for checking
106 my @stops = qw(TGA TAA TAG);
107 my %attributes;
108 foreach my $attribute (@{$trans->get_all_Attributes()}) {
109 push @{$attributes{$attribute->code}}, $attribute;
110 }
111 # warn $trans->stable_id;
112 # warn Data::Dumper::Dumper(\%attributes);
113 my $coding_end = $trans->cdna_coding_end;
114 my $coding_start = $trans->cdna_coding_start;
115 my $trans_end = $trans->length;
116 my $trans_seq = $trans->seq->seq;
117 my $stop_codon_offset = 3 + $trans->translation->end_Exon->end_phase;
118 my $initial_exon_phase = $trans->translation->start_Exon->phase;
119 my $stop_codon = substr($trans_seq, $coding_end-3, 3);
120 my $start_codon = substr($trans_seq, $coding_start-1, 3);
121
122 my $start_codon_incorrect = 1;
123 if ($start_codon eq 'ATG' ) {
124 $start_codon_incorrect = 0;
125 }
126 elsif ($start_codon eq 'CTG') {
127 foreach my $attrib (@{$attributes{'remark'}}) {
128 if ($attrib->value =~ /non[- ]ATG start/) {
129 $start_codon_incorrect = 0;
130 }
131 }
132 }
133
134 # warn "$start_codon -- $initial_exon_phase -- $coding_start -- $start_codon_incorrect";
135
136 #hashref to return results
137 my $results;
138
139 #extra CDS end not found remarks
140 if ($attributes{'cds_end_NF'}) {
141 if ( ($attributes{'cds_end_NF'}->[0]->value == 1)
142 && ($coding_end != $trans_end)
143 && ( grep {$_ eq $stop_codon} @stops) ) {
144 # warn $trans->stable_id.": $coding_end--$trans_end--$stop_codon";
145 # warn $trans->translation->end_Exon->end_phase;
146 $results->{'END_EXTRA'} = $stop_codon;
147 }
148 }
149 #missing CDS end not found remark
150 if ( $coding_end == $trans_end ) {
151 if ($attributes{'cds_end_NF'}) {
152 if ($attributes{'cds_end_NF'}->[0]->value == 0 ) {
153 if (! grep {$_ eq $stop_codon} @stops) {
154 # warn $trans->translation->end_Exon->end_phase;
155 $results->{'END_MISSING'}{'WRONG'} = $stop_codon;
156 }
157 }
158 }
159 elsif (! grep {$_ eq $stop_codon} @stops) {
160 $results->{'END_MISSING'}{'ABSENT'} = $stop_codon;
161 }
162 }
163 #extra CDS start not found remark
164 if ( $attributes{'cds_start_NF'}) {
165 if ( ($attributes{'cds_start_NF'}->[0]->value == 1 )
166 && (! $start_codon_incorrect)) {
167 unless ( ($coding_start == 1) && ( $initial_exon_phase > 0)) {
168 $results->{'START_EXTRA'} = $start_codon;
169 }
170 }
171 }
172 #missing CDS start not found remark
173 if ( $coding_start == 1) {
174 if ( $attributes{'cds_start_NF'} ) {
175 if ( $attributes{'cds_start_NF'}->[0]->value == 0 ) {
176 if ($start_codon_incorrect) {
177 $results->{'START_MISSING'}{'ABSENT'} = $start_codon;
178 }
179 elsif ($initial_exon_phase > 0) {
180 $results->{'START_MISSING'}{'INITIAL_PHASE'} = $initial_exon_phase;
181 }
182 }
183 }
184 elsif ($start_codon ne 'ATG') {
185 $results->{'START_MISSING'}{'ABSENT'} = $start_codon;
186 }
187
188 }
189 return $results;
190 }
191
192 =head2 get_havana_seleno_comments
193
194 Args : none
195 Example : my $results = $support->get_havana_seleno_comments
196 Description: parses the HEREDOC containing Havana comments in this module
197 Returntype : hashref
198
199 =cut
200
201 sub get_havana_seleno_comments {
202 my $seen_translations;
203 while (<DATA>) {
204 next if /^\s+$/ or /#+/;
205 my ($obj,$comment) = split /=/;
206 $obj =~ s/^\s+|\s+$//g;
207 $comment =~ s/^\s+|\s+$//g;
208 # We add the origin as now "seen" can come from a number of places, and have
209 # a number of consequences in different cases, not just discounted Secs from this method. -- ds23
210 $seen_translations->{$obj} = [ $comment,"notsec-havana" ];
211 }
212 return $seen_translations;
213 }
214
215 sub check_for_stops {
216 my $support = shift;
217 my ($gene,$seen_transcripts,$log_object) = @_;
218 my $transcripts;
219 my $has_log_object=defined($log_object);
220 if($has_log_object){
221 my @help = $log_object->species_params->get_trans($gene->stable_id);
222 $transcripts=\@help;
223 }else{
224 $log_object=$support;
225 $transcripts=$gene->get_all_Transcripts;
226 }
227
228 my $gname = $gene->get_all_Attributes('name')->[0]->value;
229 my $gsi = $gene->stable_id;
230 my $scodon = 'TGA';
231 my $mod_date = $support->date_format( $gene->modified_date,'%d/%m/%y' );
232 my $hidden_remak_ttributes;
233 TRANS:
234 foreach my $trans (@$transcripts) {
235 my $tsi = $trans->stable_id;
236 my $tID = $trans->dbID;
237 my $tname = $trans->get_all_Attributes('name')->[0]->value;
238 if($has_log_object){
239 $hidden_remak_ttributes=$log_object->species_params->get_attributes->{$tsi}->{'hidden_remark'};
240 }else{
241 $hidden_remak_ttributes=$trans->get_all_Attributes('hidden_remark');
242 }
243 foreach my $rem (@$hidden_remak_ttributes) {
244 if ($rem->value =~ /not_for_Vega/) {
245 #$support->log_verbose("Skipping transcript $tname ($tsi) since 'not_for_Vega'\n",1);
246 $log_object->_save_log('log_verbose', '', $gsi, '', $tsi, '', "Skipping transcript $tname ($tsi) since 'not_for_Vega'");
247 next TRANS;
248 }
249 }
250
251 # go no further if there is a ribosomal framshift attribute
252 foreach my $attrib (@{$trans->get_all_Attributes('_rib_frameshift')}) {
253 if ($attrib->value) {
254 $log_object->_save_log('log', '', $gsi, '', $tsi, '', "Skipping $tsi ($tname) since it has a ribosomal frameshift attribute");
255 next TRANS;
256 }
257 }
258
259 #$support->log_verbose("Studying transcript $tsi ($tname, $tID)\n",1);
260 $log_object->_save_log('log_verbose', '', $gsi, '', $tsi, '', "Studying transcript $tsi ($tname, $tID)");
261 my $peptide;
262
263 # go no further if the transcript doesn't translate or if there are no stops
264 next TRANS unless ($peptide = $trans->translate);
265 my $pseq = $peptide->seq;
266 my $orig_seq = $pseq;
267 # (translate method trims stops from sequence end)
268
269 next TRANS unless ($pseq =~ /\*/);
270 # warn sprintf("Stop codon is '%s'\n",substr($trans->translateable_seq,-3));
271 #$support->log_verbose("Stops found in $tsi ($tname)\n",1);
272 $log_object->_save_log('log_verbose', '', $gsi, '', $tsi, '', "Stops found in $tsi ($tname)");
273
274 # find out where and how many stops there are
275 my @found_stops;
276 my $mrna = $trans->translateable_seq;
277 my $offset = 0;
278 my $tstop;
279 while ($pseq =~ /^([^\*]*)\*(.*)/) {
280 my $pseq1_f = $1;
281 $pseq = $2;
282 my $seq_flag = 0;
283 $offset += length($pseq1_f) * 3;
284 my $stop = substr($mrna, $offset, 3);
285 my $aaoffset = int($offset / 3)+1;
286 push(@found_stops, [ $stop, $aaoffset ]);
287 $tstop .= "$aaoffset ";
288 $offset += 3;
289 }
290
291 # are all stops TGA...?
292 my $num_stops = scalar(@found_stops);
293 my $num_tga = 0;
294 my $positions;
295 foreach my $stop (@found_stops) {
296 $positions .= $stop->[0]."(".$stop->[1].") ";
297 if ($stop->[0] eq $scodon) {
298 $num_tga++;
299 }
300 }
301 my $source = $gene->source;
302 #...no - an internal stop codon error in the database...
303 if ($num_tga < $num_stops) {
304 if ($source eq 'havana') {
305 #$support->log_warning("INTERNAL STOPS HAVANA: Transcript $tsi ($tname) from gene $gname has non \'$scodon\' stop codons [$mod_date]:\nSequence = $orig_seq\nStops at $positions)\n\n");
306 $log_object->_save_log('log_warning', '', $gsi, 'TRANSCRIPT', $tsi, 'VQCT_internal_stop', "INTERNAL STOPS HAVANA: Transcript $tsi ($tname) from gene $gname has non \'$scodon\' stop codons [$mod_date]: Sequence = $orig_seq Stops at $positions)");
307 }
308 else {
309 #$support->log_warning("INTERNAL STOPS EXTERNAL: Transcript $tsi ($tname) from gene $gname has non \'$scodon\' stop codons[$mod_date]:\nSequence = $orig_seq\nStops at $positions)\n\n");
310 $log_object->_save_log('log_warning', '', $gsi, 'TRANSCRIPT', $tsi, 'VQCT_internal_stop', "INTERNAL STOPS EXTERNAL: Transcript $tsi ($tname) from gene $gname has non \'$scodon\' stop codons[$mod_date]: Sequence = $orig_seq Stops at $positions)");
311 }
312 }
313 #...yes - check remarks
314 else {
315 my $flag_remark = 0; # 1 if word seleno has been used
316 my $flag_remark2 = 0; # 1 if existing remark has correct numbering
317 my $alabel = 'Annotation_remark- selenocysteine ';
318 my $alabel2 = 'selenocysteine ';
319 my $annot_stops;
320 my $remarks;
321 my $att;
322 #get both hidden_remarks and remarks
323 foreach my $remark_type ('remark','hidden_remark') {
324 if($has_log_object){
325 $att=$log_object->species_params->get_attributes->{$trans->stable_id}->{$remark_type};
326 }else{
327 $att=$trans->get_all_Attributes($remark_type)
328 }
329 foreach my $attrib ( @$att) {
330 push @{$remarks->{$remark_type}}, $attrib->value;
331 }
332 }
333 #parse remarks to check syntax for location of edits
334 while (my ($attrib,$remarks)= each %$remarks) {
335 foreach my $text (@{$remarks}) {
336 if ( ($attrib eq 'remark') && ($text=~/^$alabel(.*)/) ){
337 #$support->log_warning("seleno remark for $tsi stored as Annotation_remark not hidden remark) [$mod_date]\n");
338 $log_object->_save_log('log_warning', '', $gsi, '', $tsi, 'VQCT_wrong_selC_coord', "seleno remark for $tsi stored as Annotation_remark not hidden remark) [$mod_date]");
339 $annot_stops=$1;
340 }
341 elsif ($text =~ /^$alabel2(.*)/) {
342 my $maybe = $1;
343 if($maybe =~ /^\s*\d+(\s+\d+)*\s*$/) {
344 $annot_stops=$maybe;
345 } else {
346 $log_object->_save_log('log', '', $gene->stable_id, '', $tsi, '', "Maybe annotated stop in incorrect format, maybe just a remark that happens to begin '$alabel2'".
347 " -- might need to investigate: '$alabel2$maybe' [$mod_date]");
348 }
349 }
350 }
351 }
352
353 #check the location of the annotated edits matches actual stops in the sequence
354 my @annotated_stops;
355 if ($annot_stops){
356 my $i = 0;
357 foreach my $offset (split(/\s+/, $annot_stops)) {
358 #OK if it matches a known stop
359 if (
360 defined($found_stops[$i]) && defined($found_stops[$i]->[1]) && ($found_stops[$i]->[1] == $offset)) {
361 push @annotated_stops, $offset;
362 }
363 # catch old annotations where number was in DNA not peptide coordinates
364 elsif (defined($found_stops[$i]) && defined($found_stops[$i]->[1]) && (($found_stops[$i]->[1] * 3) == $offset)) {
365 $log_object->_save_log('log_warning', '', $gene->stable_id, 'DNA', $tsi, 'VQCT_wrong_selC_coord', "DNA: Annotated stop for transcript tsi ($tname) is in DNA not peptide coordinates) [$mod_date]");
366 }
367 # catch old annotations where number off by one
368 elsif (defined($found_stops[$i]) && defined($found_stops[$i]->[1]) && (($found_stops[$i]->[1]) == $offset+1)) {
369 $log_object->_save_log('log_warning', '', $gene->stable_id, 'PEPTIDE', $tsi, 'VQCT_wrong_selC_coord', "PEPTIDE: Annotated stop for transcript $tsi ($tname) is out by one) [$mod_date]");
370 }
371 elsif (defined($offset) && ($offset=~/^\d+$/)){
372 if ($offset == length($orig_seq)+1) {
373 if($seen_transcripts->{$tsi} && $seen_transcripts->{$tsi}->[1] eq 'known-tga-stop') {
374 $log_object->_save_log('log', '', $gene->stable_id, 'TRANSCRIPT', $tsi, '', "Annotated stop for transcript $tsi ($tname) known to be a stop codon. Ok. [$mod_date]");
375 } elsif($seen_transcripts->{$tsi} && $seen_transcripts->{$tsi}->[1] eq 'known-terminal-sec') {
376 $log_object->_save_log('log', '', $gene->stable_id, 'TRANSCRIPT', $tsi, '', "Annotated stop for transcript $tsi ($tname) known to be a terminal Sec. Ok. [$mod_date]");
377 } else {
378 $log_object->_save_log('log_warning', '', $gene->stable_id, 'TRANSCRIPT', $tsi, '', "Annotated stop for transcript $tsi ($tname) \"$offset\" matches actual stop codon yet has no entry in script config to disambiguate it. Please investigate and add appropriate entry to config arrays in add_selcys.pl. [$mod_date]");
379 }
380 }
381 else {
382 $log_object->_save_log('log_warning', '', $gene->stable_id, 'TRANSCRIPT', $tsi, 'VQCT_wrong_selC_coord', "Annotated stop for transcript $tsi ($tname) \"$offset\" does not match a TGA codon) [$mod_date]");
383 push @annotated_stops, $offset;
384 }
385 }
386 $i++;
387 }
388 }
389
390 #check location of found stops matches annotated ones - any new ones are reported
391 foreach my $stop ( @found_stops ) {
392 my $pos = $stop->[1];
393 my $seq = $stop->[0];
394 unless ( grep { $pos == $_} @annotated_stops) {
395 if ($seen_transcripts->{$tsi} && $seen_transcripts->{$tsi}->[1] eq 'notsec-havana') {
396 #$support->log_verbose("Transcript $tsi ($tname) has potential selenocysteines but has been discounted by annotators:\n\t".$seen_transcripts->{$tsi}.") [$mod_date]\n");
397 $log_object->_save_log('log_verbose', '', $gene->stable_id, '', $tsi, 'VQCT_pot_selC', "Transcript $tsi ($tname) has potential selenocysteines but has been discounted by annotators: ".$seen_transcripts->{$tsi}->[0].") [$mod_date]");
398 }
399 else {
400 #$support->log("POTENTIAL SELENO ($seq) in $tsi ($tname, gene $gname) found at $pos [$mod_date]\n");
401 $log_object->_save_log('log', '', $gene->stable_id, '', $tsi, 'VQCT_pot_selC', "POTENTIAL SELENO ($seq) in $tsi ($tname, gene $gname) found at $pos [$mod_date]");
402 }
403 }
404 }
405 }
406 }
407 }
408 sub _save_log{
409 my $self=shift;
410 my $log_type = shift;
411 my $chrom_name=shift || '';
412 my $gsi=shift || '';
413 my $type=shift || '';
414 my $tsi=shift || '';
415 my $tag=shift || '';
416 my $txt=shift || '';
417 $self->$log_type($txt."\n");
418 }
419
420 #details of annotators comments
421 __DATA__
422 OTTHUMT00000144659 = FIXED- changed to transcript
423 OTTHUMT00000276377 = FIXED- changed to transcript
424 OTTHUMT00000257741 = FIXED- changed to nmd
425 OTTHUMT00000155694 = NOT_FIXED- should be nmd but external annotation but cannot be fixed
426 OTTHUMT00000155695 = NOT_FIXED- should be nmd but external annotation but cannot be fixed
427 OTTHUMT00000282573 = FIXED- changed to unprocessed pseudogene
428 OTTHUMT00000285227 = FIXED- changed start site
429 OTTHUMT00000151008 = FIXED- incorrect trimming of CDS, removed extra stop codon
430 OTTHUMT00000157999 = FIXED- changed incorrect stop
431 OTTHUMT00000150523 = FIXED- incorrect trimming of CDS
432 OTTHUMT00000150525 = FIXED- incorrect trimming of CDS
433 OTTHUMT00000150522 = FIXED- incorrect trimming of CDS
434 OTTHUMT00000150521 = FIXED- incorrect trimming of CDS
435 OTTHUMT00000246819 = FIXED- corrected frame
436 OTTHUMT00000314078 = FIXED- corrected frame
437 OTTHUMT00000080133 = FIXED- corrected frame
438 OTTHUMT00000286423 = FIXED- changed to transcript
439 OTTMUST00000055509 = FIXED- error
440 OTTMUST00000038729 = FIXED- corrected frame
441 OTTMUST00000021760 = FIXED- corrected frame
442 OTTMUST00000023057 = FIXED- corrected frame
443 OTTMUST00000015207 = FIXED- corrected frame
444 OTTMUST00000056646 = FIXED- error
445 OTTMUST00000059686 = FIXED- corrected frame
446 OTTMUST00000013426 = FIXED- corrected frame
447 OTTMUST00000044412 = FIXED- error