comparison cpt_genbank2circosk.pl @ 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 #!/usr/bin/perl
2 #
3 # Code written by Eric Rasche
4 # mailto:rasche.eric@yandex.ru
5 # tel:404.692.2048
6 # http://eric.rasche.co.uk
7 # for
8 # Center for Phage Technology
9 #
10
11 use strict;
12 use warnings;
13
14 use CPT::GalaxyGetOpt;
15 use Data::Dumper;
16
17 my $ggo = CPT::GalaxyGetOpt->new();
18 my %colors = map { $_ => $_ } qw(red orange yellow green blue gray black white);
19 my %intensity = map { $_ => $_ } qw (vvvvl vvvl vvl vl vd vvd vvvd vvvvd);
20
21 my $options = $ggo->getOptions(
22 'options' => [
23 [
24 'file',
25 'Input file',
26 {
27 required => 1,
28 validate => 'File/Input',
29 file_format => ['genbank', 'embl', 'txt'],
30 }
31 ],
32 [
33 'chromosome' => 'Name for the
34 chromosome inside Circos',
35 {
36 required => 1,
37 validate => 'String'
38 }
39 ],
40 [
41 'color' => 'Color to use for Circos plot',
42 {
43 required => 1,
44 validate => 'Option',
45 options => \%colors,
46 }
47 ],
48 [
49 'intensity' => 'Circos color intensity. ',
50 {
51 validate => 'Option',
52 options => \%intensity,
53 }
54 ],
55 ],
56 'outputs' => [
57 [
58 'circosk',
59 'Circos Karyotype File',
60 {
61 validate => 'File/Output',
62 required => 1,
63 default => 'karyotype',
64 data_format => 'text/plain',
65 default_format => 'TXT'
66 }
67 ],
68 ],
69 'defaults' => [
70 'appname' => 'Genbank2CircosK',
71 'appid' => 'Genbank2CircosK',
72 'appvers' => '1.94',
73 'appdesc' =>
74 'Convert genbank files to Circos Karyotype configuration files',
75 ],
76 'tests' => [
77 {
78 test_name => "Default",
79 params => {
80 'file' => 'test-data/inputs/multi.gbk',
81 'chromosome' => 'test',
82 'color' => 'red',
83 'intensity' => 'vvvl',
84 },
85 outputs => {
86 'circosk' => ['karyotype.txt', 'test-data/outputs/circosk.conf'],
87 }
88 },
89 ],
90 );
91
92 use CPT::Bio;
93 my $bio = CPT::Bio->new();
94
95 my @results;
96 my $c = 0;
97 my $seqio = $bio->requestCopyIO( file => $options->{file} );
98
99 while(my $seqobj = $seqio->next_seq()){
100 foreach my $feat ( $seqobj->get_SeqFeatures () ) {
101
102 #band test 12 CDS__test_1gbk 5715 6335 red]
103 next if ( $feat->primary_tag ne 'CDS' );
104 my $id = $bio->_getIdentifier($feat);
105 $id =~ s/\s+/_/g;
106 push(
107 @results,
108 join(
109 ' ',
110 (
111 'band',
112 $options->{'chromosome'},
113 $c++,
114 $id,
115 $feat->start,
116 $feat->end,
117 (defined $options->{'intensity'} ? $options->{'intensity'} : '') . $options->{'color'}
118 )
119 )
120 );
121 }
122 }
123
124 my $z = join( "\n", @results );
125
126 use CPT::OutputFiles;
127 my $output = CPT::OutputFiles->new(
128 name => 'circosk',
129 GGO => $ggo,
130 );
131 $output->CRR(data => $z);