comparison lib/CPT/BioData.pm @ 1:8691c1c61a8e draft default tip

planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
author cpt
date Mon, 05 Jun 2023 02:48:47 +0000
parents
children
comparison
equal deleted inserted replaced
0:54c7a3ea81e2 1:8691c1c61a8e
1 package CPT::BioData;
2 use Moose;
3 use strict;
4 use warnings;
5 use autodie;
6
7 has 'dummy_var' => (isa => 'Str', is => 'ro');
8
9 my %genbank_feature_tags = (
10 "locus_tag" => 1,
11 "gene" => 1,
12 "product" => 1,
13 "allele" => 1,
14 "anticodon" => 1,
15 "artificial_location" => 1,
16 "bio_material" => 1,
17 "bound_moiety" => 1,
18 "cell_line" => 1,
19 "cell_type" => 1,
20 "chromosome" => 1,
21 "citation" => 1,
22 "clone" => 1,
23 "clone_lib" => 1,
24 "codon_start" => 1,
25 "collected_by" => 1,
26 "collection_date" => 1,
27 "compare" => 1,
28 "country" => 1,
29 "cultivar" => 1,
30 "culture_collection" => 1,
31 "db_xref" => 1,
32 "dev_stage" => 1,
33 "direction" => 1,
34 "EC_number" => 1,
35 "ecotype" => 1,
36 "environmental_sample" => 1,
37 "estimated_length" => 1,
38 "exception" => 1,
39 "experiment" => 1,
40 "focus" => 1,
41 "frequency" => 1,
42 "function" => 1,
43 "gap_type" => 1,
44 "gene_synonym" => 1,
45 "germline" => 1,
46 "haplogroup" => 1,
47 "haplotype" => 1,
48 "host" => 1,
49 "identified_by" => 1,
50 "inference" => 1,
51 "isolate" => 1,
52 "isolation_source" => 1,
53 "lab_host" => 1,
54 "lat_lon" => 1,
55 "linkage_evidence" => 1,
56 "macronuclear" => 1,
57 "map" => 1,
58 "mating_type" => 1,
59 "mobile_element_type" => 1,
60 "mod_base" => 1,
61 "mol_type" => 1,
62 "ncRNA_class" => 1,
63 "note" => 1,
64 "number" => 1,
65 "old_locus_tag" => 1,
66 "operon" => 1,
67 "organelle" => 1,
68 "organism" => 1,
69 "partial" => 1,
70 "PCR_conditions" => 1,
71 "PCR_primers" => 1,
72 "phenotype" => 1,
73 "plasmid" => 1,
74 "pop_variant" => 1,
75 "protein_id" => 1,
76 "proviral" => 1,
77 "pseudo" => 1,
78 "rearranged" => 1,
79 "replace" => 1,
80 "ribosomal_slippage" => 1,
81 "rpt_family" => 1,
82 "rpt_type" => 1,
83 "rpt_unit_range" => 1,
84 "rpt_unit_seq" => 1,
85 "satellite" => 1,
86 "segment" => 1,
87 "serotype" => 1,
88 "serovar" => 1,
89 "sex" => 1,
90 "specimen_voucher" => 1,
91 "standard_name" => 1,
92 "strain" => 1,
93 "sub_clone" => 1,
94 "sub_species" => 1,
95 "sub_strain" => 1,
96 "tag_peptide" => 1,
97 "tissue_lib" => 1,
98 "tissue_type" => 1,
99 "transgenic" => 1,
100 "translation" => 1,
101 "transl_except" => 1,
102 "transl_table" => 1,
103 "trans_splicing" => 1,
104 "variety" => 1,
105 );
106 my %artemis_colours = (
107 0 => 'rgb(255,255,255)',
108 1 => 'rgb(100,100,100)',
109 2 => 'rgb(255,0,0)',
110 3 => 'rgb(0,255,0)',
111 4 => 'rgb(0,0,255)',
112 5 => 'rgb(0,255,255)',
113 6 => 'rgb(255,0,255)',
114 7 => 'rgb(255,255,0)',
115 8 => 'rgb(152,251,152)',
116 9 => 'rgb(135,206,250)',
117 10 => 'rgb(255,165,0)',
118 11 => 'rgb(200,150,100)',
119 12 => 'rgb(255,200,200)',
120 13 => 'rgb(170,170,170)',
121 14 => 'rgb(0,0,0)',
122 15 => 'rgb(255,63,63)',
123 16 => 'rgb(255,127,127)',
124 17 => 'rgb(255,191,191)',
125 );
126
127 sub artemis_colour_decode{
128 my ($self, $idx) = @_;
129 return $artemis_colours{$idx};
130 }
131
132 my %table321 = (
133 'Gly' => 'G', 'Pro' => 'P',
134 'Ala' => 'A',
135 'Val' => 'V',
136 'Leu' => 'L',
137 'Ile' => 'I',
138 'Met' => 'M',
139 'Cys' => 'C',
140 'Phe' => 'F',
141 'Tyr' => 'Y',
142 'Trp' => 'W',
143 'His' => 'H',
144 'Lys' => 'K',
145 'Arg' => 'R',
146 'Gln' => 'Q',
147 'Asn' => 'N',
148 'Glu' => 'E',
149 'Asp' => 'D',
150 'Ser' => 'S',
151 'Thr' => 'T',
152 'XXX' => 'X',
153 'End' => '*',
154 'Stop' => '*'
155 );
156
157 sub decode321{
158 my ($self, $three) = @_;
159 return $table321{$three};
160 }
161
162
163 sub get321Table {
164 my ($self) = @_;
165 return \%table321;
166 }
167
168
169 sub getTranslationTable {
170 my ($self, $table_id) = @_;
171 require Bio::Tools::CodonTable;
172 my $table = Bio::Tools::CodonTable->new( -id => (defined $table_id? $table_id: 1) );
173 my %result;
174 my @codons = qw(A C T G);
175 foreach my $i (@codons) {
176 foreach my $j (@codons) {
177 foreach my $k (@codons) {
178 $result{"$i$j$k"} = $table->translate("$i$j$k");
179 }
180 }
181 }
182 if(defined($table_id) && $table_id == 11){
183 $result{TGA} = '*';
184 $result{TAA} = '#';
185 $result{TAG} = '+';
186 }
187 return \%result;
188 }
189
190
191
192 sub isValidTag {
193 my ( $self, $tag ) = @_;
194 return $genbank_feature_tags{$tag};
195 }
196
197 no Moose;
198 1;
199
200 __END__
201
202 =pod
203
204 =encoding UTF-8
205
206 =head1 NAME
207
208 CPT::BioData
209
210 =head1 VERSION
211
212 version 1.99.4
213
214 =head2 get321Table
215
216 $bio->get321Table();
217
218 Convenience function which returns a codon translation table (3 letter ID to 1 letter code)
219
220 =head2 getTranslationTable
221
222 $bio->getTranslationTable();
223
224 Convenience function which returns a hash translated according to Bio::Tools::CodonTable
225
226 This is done for speed reasons. CodonTable is very slow and we require better performance
227
228 =head2 isValidTag
229
230 if($cptbio->isValidTag('locus_tag')) { ... }
231
232 Will validate a GBK feature tag
233
234 =head1 AUTHOR
235
236 Eric Rasche <rasche.eric@yandex.ru>
237
238 =head1 COPYRIGHT AND LICENSE
239
240 This software is Copyright (c) 2014 by Eric Rasche.
241
242 This is free software, licensed under:
243
244 The GNU General Public License, Version 3, June 2007
245
246 =cut