forked from The-Sequence-Ontology/GAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotein_sequence
executable file
·65 lines (48 loc) · 1.42 KB
/
protein_sequence
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use FindBin;
use lib "$FindBin::RealBin/../lib";
use GAL::Annotation;
#-----------------------------------------------------------------------------
#----------------------------------- MAIN ------------------------------------
#-----------------------------------------------------------------------------
my $usage = "
Synopsis:
gal_protein_sequence feature.gff3 sequence.fasta
Description:
Pint the protein sequence of protein coding genes.
";
my ($help, $clean);
my $opt_success = GetOptions('help' => \$help,
'clean' => \$clean,
);
if (! $opt_success) {
print STDERR join ' : ', ('FATAL',
'command_line_parse_error',
'Use gal_protein_genes --help to see correct usage');
}
if ($help || !@ARGV) {
print $usage;
exit(0);
}
my ($gff3, $fasta) = @ARGV;
die $usage unless $fasta && $gff3;
my $annotation = GAL::Annotation->new($gff3,
$fasta);
my $features = $annotation->features;
my $genes = $features->search({type => 'gene'});
GENE:
while (my $gene = $genes->next) {
next GENE unless $gene->is_coding;
my $mrnas = $gene->mRNAs;
MRNA:
while (my $mrna = $mrnas->next) {
my $mrna_id = $mrna->feature_id;
my $prot_seq = $annotation->wrap_text($mrna->protein_seq);
print ">$mrna_id (protein translation)\n";
print $prot_seq;
print "\n";
}
}