line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# GeneDesign input/output libraries |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Bio::GeneDesign::IO |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Version 5.56 |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
GeneDesign is a library for the computer-assisted design of synthetic genes |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 AUTHOR |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Sarah Richardson |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Bio::GeneDesign::IO; |
24
|
|
|
|
|
|
|
require Exporter; |
25
|
|
|
|
|
|
|
|
26
|
11
|
|
|
11
|
|
5523
|
use Bio::SeqIO; |
|
11
|
|
|
|
|
286598
|
|
|
11
|
|
|
|
|
344
|
|
27
|
11
|
|
|
11
|
|
85
|
use File::Basename; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
706
|
|
28
|
11
|
|
|
11
|
|
72
|
use Digest::MD5 qw(md5_hex); |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
505
|
|
29
|
11
|
|
|
11
|
|
62
|
use POSIX qw(log10); |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
85
|
|
30
|
11
|
|
|
11
|
|
647
|
use Carp; |
|
11
|
|
|
|
|
174
|
|
|
11
|
|
|
|
|
554
|
|
31
|
|
|
|
|
|
|
|
32
|
11
|
|
|
11
|
|
117
|
use strict; |
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
283
|
|
33
|
11
|
|
|
11
|
|
68
|
use warnings; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
523
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = 5.56; |
36
|
|
|
|
|
|
|
|
37
|
11
|
|
|
11
|
|
63
|
use base qw(Exporter); |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
8944
|
|
38
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
39
|
|
|
|
|
|
|
_export_formats |
40
|
|
|
|
|
|
|
_isa_BP_format |
41
|
|
|
|
|
|
|
_import_sequences |
42
|
|
|
|
|
|
|
_import_sequences_from_string |
43
|
|
|
|
|
|
|
_split_sequences |
44
|
|
|
|
|
|
|
_export_sequences |
45
|
|
|
|
|
|
|
_long_att_fix |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our %EXPORT_TAGS = (GD=> \@EXPORT_OK); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 Functions |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 _export_formats() |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return a list of data formats that we are comfortable working with |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _export_formats |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
|
0
|
my @list = qw(genbank fasta); |
61
|
0
|
|
|
|
|
0
|
return \@list; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 _isa_BP_format() |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
is the requested format possible in bioperl |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _isa_BP_format |
71
|
|
|
|
|
|
|
{ |
72
|
0
|
|
|
0
|
|
0
|
my ($outformat) = @_; |
73
|
0
|
0
|
|
|
|
0
|
return 0 if (! $outformat); |
74
|
0
|
|
|
|
|
0
|
my $module = "Bio::SeqIO::$outformat"; |
75
|
0
|
|
|
|
|
0
|
(my $require_name = $module . ".pm") =~ s{::}{/}xg; |
76
|
|
|
|
|
|
|
my $flag = eval |
77
|
0
|
|
|
|
|
0
|
{ |
78
|
0
|
|
|
|
|
0
|
require $require_name; |
79
|
|
|
|
|
|
|
}; |
80
|
0
|
0
|
|
|
|
0
|
return 0 if (! $flag); |
81
|
0
|
|
|
|
|
0
|
return 1; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 _import_sequences |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
NO TEST |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _import_sequences |
91
|
|
|
|
|
|
|
{ |
92
|
1
|
|
|
1
|
|
3
|
my ($path) = @_; |
93
|
1
|
|
33
|
|
|
10
|
my $iterator = Bio::SeqIO->new(-file => $path) || croak("Cannot parse $path"); |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
3698
|
my ($filename, $dirs, $suffix) = fileparse($path, qr/\.[^.]*/x); |
96
|
1
|
50
|
|
|
|
8
|
$suffix = (substr $suffix, 1) if ((substr $suffix, 0, 1) eq q{.}); |
97
|
1
|
50
|
|
|
|
5
|
$suffix = 'fasta' if ($suffix eq 'fa'); |
98
|
1
|
|
|
|
|
4
|
return ($iterator, $filename, $suffix); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 _import_sequences_from_string |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
NO TEST |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _import_sequences_from_string |
108
|
|
|
|
|
|
|
{ |
109
|
0
|
|
|
0
|
|
|
my ($string) = @_; |
110
|
0
|
|
|
|
|
|
my $sid = Digest::MD5::md5_hex(time().{}.rand().$$); |
111
|
0
|
|
|
|
|
|
my $fstring = '>' . $sid . "\n" . $string . "\n"; |
112
|
0
|
|
0
|
|
|
|
my $iterator = Bio::SeqIO->new(-string => $fstring, -format => 'fasta') || croak("Cannot parse $string"); |
113
|
0
|
|
|
|
|
|
return ($iterator, $sid, 'fasta'); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 _split_sequences |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
NO TEST |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub _split_sequences |
125
|
|
|
|
|
|
|
{ |
126
|
0
|
|
|
0
|
|
|
my ($inpath, $outpath, $outformat) = @_; |
127
|
0
|
|
|
|
|
|
my ($iterator, $filename, $suffix) = _import_sequences($inpath); |
128
|
0
|
|
0
|
|
|
|
$outformat = $outformat || $suffix; |
129
|
0
|
|
|
|
|
|
while (my $obj = $iterator->next_seq()) |
130
|
|
|
|
|
|
|
{ |
131
|
0
|
|
|
|
|
|
my $id = $obj->id; |
132
|
0
|
|
|
|
|
|
$id =~ s/\s/\_/g; |
133
|
0
|
|
|
|
|
|
my $thispath = $outpath . q{/} . $id . q{.} . $outformat; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 _export_sequences |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
NO TEST |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub _export_sequences |
145
|
|
|
|
|
|
|
{ |
146
|
0
|
|
|
0
|
|
|
my ($outpath, $outformat, $seqarr) = @_; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
my ($filename, $dirs, $suffix) = fileparse($outpath, qr/\.[^.]*/x); |
149
|
0
|
0
|
|
|
|
|
$outpath .= q{.} . $outformat if (! $suffix); |
150
|
0
|
0
|
|
|
|
|
open (my $OUTFH, '>', $outpath ) || croak ("Cannot write to $outpath ($!)"); |
151
|
0
|
|
|
|
|
|
my $FOUT = Bio::SeqIO->new(-fh => $OUTFH, -format => $outformat); |
152
|
0
|
|
|
|
|
|
$FOUT->write_seq($_) foreach (@{$seqarr}); |
|
0
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
close $OUTFH; |
154
|
0
|
|
|
|
|
|
return $outpath; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 _long_att_fix |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub _long_att_fix |
162
|
|
|
|
|
|
|
{ |
163
|
0
|
|
|
0
|
|
|
my ($seqarr) = @_; |
164
|
0
|
|
|
|
|
|
foreach my $seq (@{$seqarr}) |
|
0
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
{ |
166
|
0
|
|
|
|
|
|
foreach my $feat ($seq->get_SeqFeatures) |
167
|
|
|
|
|
|
|
{ |
168
|
0
|
|
|
|
|
|
foreach my $tag ($feat->get_all_tags()) |
169
|
|
|
|
|
|
|
{ |
170
|
0
|
|
|
|
|
|
my $value = join(q{}, $feat->get_tag_values($tag)); |
171
|
0
|
|
|
|
|
|
$value =~ s/\s//xg; |
172
|
0
|
|
|
|
|
|
$feat->remove_tag($tag); |
173
|
0
|
|
|
|
|
|
$feat->add_tag_value($tag, $value); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
} |
177
|
0
|
|
|
|
|
|
return; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
__END__ |