1 | package ali_dnapro; |
---|
2 | |
---|
3 | # meant to be used from inside macros |
---|
4 | # see ../../HELP_SOURCE/source/macro.hlp@ali_dnapro |
---|
5 | |
---|
6 | use strict; |
---|
7 | use warnings; |
---|
8 | |
---|
9 | use lib "$ENV{'ARBHOME'}/lib/"; |
---|
10 | use ARB; |
---|
11 | |
---|
12 | BEGIN { |
---|
13 | use Exporter (); |
---|
14 | our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,%EXPORT_TAGS); |
---|
15 | $VERSION = 1.00; |
---|
16 | @ISA = qw(Exporter); |
---|
17 | @EXPORT = qw( |
---|
18 | &get_dnapro_alignments |
---|
19 | ); |
---|
20 | %EXPORT_TAGS = qw(); |
---|
21 | @EXPORT_OK = qw(); |
---|
22 | } |
---|
23 | |
---|
24 | sub caps($); |
---|
25 | sub caps($) { |
---|
26 | my ($reg) = @_; |
---|
27 | if ($reg =~ /\|/) { |
---|
28 | return join('|', map { |
---|
29 | die if /\|/; |
---|
30 | caps($_); |
---|
31 | } split(/\|/,$reg)); |
---|
32 | } |
---|
33 | return uc(substr($reg,0,1)).substr($reg,1); |
---|
34 | } |
---|
35 | |
---|
36 | sub mod_name($$$) { |
---|
37 | my ($name,$old,$new) = @_; |
---|
38 | if ($name =~ /$old/) { return $`.$new.$'; } |
---|
39 | $old = caps($old); |
---|
40 | $new = caps($new); |
---|
41 | if ($name =~ /$old/) { return $`.$new.$'; } |
---|
42 | $old = uc($old); |
---|
43 | $new = uc($new); |
---|
44 | if ($name =~ /$old/) { return $`.$new.$'; } |
---|
45 | return undef; |
---|
46 | } |
---|
47 | |
---|
48 | sub cant_decide($) { |
---|
49 | my ($ali_selected) = @_; |
---|
50 | die "can't decide whether '$ali_selected' is a protein or a DNA alignment.\nPlease select an alignment with 'pro' OR 'dna' in name."; |
---|
51 | } |
---|
52 | |
---|
53 | sub get_dnapro_alignments($) { |
---|
54 | my ($gb_main) = @_; |
---|
55 | |
---|
56 | my $ali_selected = BIO::remote_read_awar($gb_main,'ARB_NT','presets/use'); |
---|
57 | if ((not defined $ali_selected) or ($ali_selected =~ /\?/)) { |
---|
58 | die "Please select a valid alignment"; |
---|
59 | } |
---|
60 | |
---|
61 | my $ali_dna = mod_name($ali_selected,'protein|prot|pro', 'dna'); |
---|
62 | my $ali_pro = mod_name($ali_selected,'dna', 'pro'); |
---|
63 | |
---|
64 | if (defined $ali_pro) { |
---|
65 | if (defined $ali_dna) { cant_decide($ali_selected); } |
---|
66 | $ali_dna = $ali_selected; |
---|
67 | } |
---|
68 | else { |
---|
69 | if (not defined $ali_dna) { cant_decide($ali_selected); } |
---|
70 | $ali_pro = $ali_selected; |
---|
71 | } |
---|
72 | |
---|
73 | return ($ali_dna,$ali_pro); |
---|
74 | } |
---|
75 | |
---|
76 | # ---------------------------------------- |
---|
77 | # cleanup (if needed) |
---|
78 | END { } |
---|
79 | |
---|
80 | 1; # module initialization is ok |
---|