• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Ensembl / ensembl-variation / #608922749

30 Aug 2023 04:16PM UTC coverage: 83.169%. First build
#608922749

Pull #1029

travis-ci

Pull Request #1029: Fetch multiple SV by name list

30 of 30 new or added lines in 2 files covered. (100.0%)

22453 of 26997 relevant lines covered (83.17%)

1436.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.0
/modules/Bio/EnsEMBL/Variation/Pipeline/TranscriptFileAdaptor.pm
1
=head1 LICENSE
2

3
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
4
Copyright [2016-2025] EMBL-European Bioinformatics Institute
5

6
Licensed under the Apache License, Version 2.0 (the "License");
7
you may not use this file except in compliance with the License.
8
You may obtain a copy of the License at
9

10
     http://www.apache.org/licenses/LICENSE-2.0
11

12
Unless required by applicable law or agreed to in writing, software
13
distributed under the License is distributed on an "AS IS" BASIS,
14
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
See the License for the specific language governing permissions and
16
limitations under the License.
17

18
=cut
19

20

21
=head1 CONTACT
22

23
 Please email comments or questions to the public Ensembl
24
 developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
25

26
 Questions may also be sent to the Ensembl help desk at
27
 <http://www.ensembl.org/Help/Contact>.
28

29
=cut
30
package Bio::EnsEMBL::Variation::Pipeline::TranscriptFileAdaptor;
31

32
use strict;
1✔
33

34
use Digest::MD5 qw(md5_hex);
1✔
35

36
sub new {
37
    my $class = shift;
×
38

39
    my %args = @_;
×
40

41
    my $self = bless {}, $class;
×
42

43
    if ($args{fasta_file}) {
×
44
        $self->{fasta_file} = $args{fasta_file};
×
45
    }
46
    
47
    if ($args{transcripts}) {
×
48
        $self->_dump_translations($args{transcripts});
×
49
    }
50
    
51
    return $self;
×
52
}
53

54
sub get_translation_seq {
55
    my ($self, $translation_md5) = @_;
×
56

57
    my $fasta = $self->get_translation_fasta($translation_md5);
×
58

59
    $fasta =~ s/>.*\n//m;
×
60
    $fasta =~ s/\s//mg;
×
61

62
    return $fasta;
×
63
}
64

65
sub get_translation_fasta {
66
    my ($self, $translation_md5) = @_;
×
67
    
68
    my $file = $self->{fasta_file};
×
69
    
70
    my $fasta = `samtools faidx $file $translation_md5`;
×
71

72
    return $fasta;
×
73
}
74

75
sub get_all_translation_md5s {
76
    my $self = shift;
×
77

78
    my $fasta = $self->{fasta_file};
×
79

80
    my @ids = map {/>(.+)\n/; $1} `grep '>' $fasta`;
×
81

82
    return \@ids;
×
83
}
84

85
sub _dump_translations {
86

87
    my ($self, $transcripts) = @_;
×
88

89
    # dump the translations out to the FASTA file
90

91
    my $fasta = $self->{fasta_file};
×
92

93
    open my $FASTA, ">$fasta" or die "Failed to open $fasta for writing";
×
94

95
    # get rid of any existing index file
96

97
    if (-e "$fasta.fai") {
×
98
        unlink "$fasta.fai" or die "Failed to delete fasta index file";
×
99
    }
100

101
    my %seen_md5;
×
102

103
    for my $transcript (@$transcripts) {
×
104

105
        my $tl = $transcript->translation;
×
106
    
107
        next unless $tl;
×
108

109
        my $protein = $tl->seq;
×
110

111
        my $md5 = md5_hex($protein);
×
112

113
        next if $seen_md5{$md5}++;
×
114

115
        $protein =~ s/(.{80})/$1\n/g;
×
116

117
        # get rid of any trailing newline
118
        chomp $protein;
×
119

120
        print $FASTA ">$md5\n$protein\n";
×
121
    }
122

123
    close $FASTA;
×
124

125
    # index the file
126

127
    `samtools faidx $fasta`;
×
128
}
129
 
130

131
1;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc