blib/lib/Bio/Glite.pm

filter: Statementstmt 24.1% 21 / 87 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 16 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 38.4% 5 / 13 Podpod 16.6% 1 / 6 totaltotal 15.9% 27 / 169 CC 28 SCAR 44.0
CC
28
Cov
15%
AUTOLOAD
156.0
load
110.0
readFile
42.0
CRAP 81.8
↑ Summary
1 #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 # This file is part of G-language Genome Analysis Environment package
3 #
4 # Copyright (C) 2001-2009 Keio University
5 #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
6 #
7 # $Id: G.pm,v 1.4 2002/07/30 17:40:56 gaou Exp $
8 #
9 # G-language GAE is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public
11 # License as published by the Free Software Foundation; either
12 # version 2 of the License, or (at your option) any later version.
13 #
14 # G-language GAE is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 # See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public
20 # License along with G-language GAE -- see the file COPYING.
21 # If not, write to the Free Software Foundation, Inc.,
22 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #
24 #END_HEADER
25 #
26 # written by Kazuharu Arakawa <gaou@sfc.keio.ac.jp> at
27 # G-language Project, Institute for Advanced Biosciences, Keio University.
28 #
29  
30 package Bio::Glite;
31  
32 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 1 require Exporter;
38  
39 1 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 1 our @EXPORT = qw(
42 COMGA_correlation COMGA_table_maker DoubleHelix Ew P2 RNAfold _blast _clustalw _codon_usage_table _fasta _formatdb aaui align_pathway alignment amino_counter amino_info annotate_with_glimmerM baseParingTest base_counter base_entropy base_individual_information_matrix base_information_content base_relative_entropy base_z_value blastall bui cai calc_pI cbi circular_map codon_compiler codon_counter codon_mva codon_usage cognitor complement consensus_z cor cumulative diffseq dinuc dist_in_cc dnawalk dote enc filter_cds_by_atg find_dif find_dnaAbox find_iteron find_king_of_gene find_ori_ter find_pattern find_tandem find_ter fop foreach_RNAfold foreach_tandem gcsi gcskew gcwin generateGMap genes_from_ori genome_map genome_map2 genome_map3 genomicskew gopac gpac grapher graphical_LTR_search icdi leading_strand least_squares_fit load load_kegg_api longest_ORF ma_filter ma_normalize ma_rfilter markov max maxdex mean median min mindex molecular_weight nucleotide_periodicity oligomer_counter oligomer_search oligomer_translation over_lapping_finder palindrome peptide_mass phx plasmid_map query_arm query_strand read_goa rep_ori_ter run_glimmerM seq2png seqinfo seqret set_essentiality set_gc3 set_goa set_gpac set_operon set_strand shuffleseq signature splitprintseq standard_deviation sum test_gpac to_fasta togoWS translate ttest variance view_cds w_value ws
43 load
44 say
45 p
46 puts
47 readFile
48 writeFile
49 );
50  
51 1 our $VERSION = '0.10';
52  
53 # Preloaded methods go here.
54  
55 1 my $prefix = 'http://rest.g-language.org/';
56 1 my $upload = $prefix . 'upload/upl.pl';
57 1 my $ua = LWP::UserAgent->new;
58  
59 0 ▶sub load {
Subroutine load: not called CC=10 SCAR=47.0
Pod documented
60 0 my $this = {};
61  
62 0 ▶ $_[0] = $ua->post($upload, 'Content_Type'=>'form-data', 'Content'=>['file'=>[$_[0]]])->content if(-e $_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if -e $_[0] 0 0 0
63  
64 0 foreach my $line (split(/\n/, $ua->get($prefix . $_[0] . '/disclose')->content)){
65 0 my ($feat, $key, $val) = split(/\t/, $line);
66 0 ▶ if(length $val){
Branch: 1 branch
BranchTrueFalseTotal
if (length $val) { } 0 0 0
67 0 $this->{$feat}->{$key} = $val;
68 }else{
69 0 $this->{$feat} = $key;
70 }
71 }
72  
73 0 foreach my $feat (keys %{$this}){
74 0 ▶ next unless($feat =~ /FEATURE/);
Branch: 1 branch
BranchTrueFalseTotal
unless $feat =~ /FEATURE/ 0 0 0
75 0 ▶ next unless ($this->{$feat}->{type} =~ /CDS|RNA/);
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{$feat}{"type"} =~ /CDS|RNA/ 0 0 0
76
77 0 ▶ $this->{$this->{$feat}->{gene}} = $this->{$feat} if(length $this->{$feat}->{gene});
Branch: 1 branch
BranchTrueFalseTotal
if length $this->{$feat}{"gene"} 0 0 0
78 0 ▶ $this->{$this->{$feat}->{locus_tag}} = $this->{$feat} if(length $this->{$feat}->{locus_tag});
Branch: 1 branch
BranchTrueFalseTotal
if length $this->{$feat}{"locus_tag"} 0 0 0
79 0 ▶ $this->{'CDS' . $this->{$feat}->{cds}} = $this->{$feat} if($this->{$feat}->{type} eq 'CDS');
Branch: 1 branch
BranchTrueFalseTotal
if $this->{$feat}{"type"} eq "CDS" 0 0 0
80 }
81  
82 0 $this->{filename} = $_[0];
83 0 print $ua->get($prefix . $_[0])->content;
84  
85 0 return bless $this;
86 }
87  
88  
89  
90 0 ▶sub AUTOLOAD{
Subroutine AUTOLOAD: not called CC=12 SCAR=50.5
91 0 our $AUTOLOAD;
92 0 my $gb = shift;
93 0 my @args = @_;
94 0 my @method = split(/::/, $AUTOLOAD);
95  
96 0 my $i = 0;
97 0 my (@new_args);
98 0 ▶ while(defined $args[$i]){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args[$i]) 0 0 0
99 0 ▶ if (substr($args[$i], 0, 1) eq '-' && substr($args[$i], 1, 1) !~ /[0-9]/){
Branch: 1 branch
BranchTrueFalseTotal
if (substr($args[$i], 0, 1) eq '-' and not substr($args[$i], 1, 1) =~ /[0-9]/) { } 0 0 0
Condition0%0/3
substr($args[$i], 0, 1) eq "-" and not substr($args[$i], 1, 1) =~ /[0-9]/
!ll&&!rl&&r
000
MC/DC0%0/2
substr($args[$i], 0, 1) eq "-" and not substr($args[$i], 1, 1) =~ /[0-9]/
substr($args[$i], 0, 1) eq "-" not substr($args[$i], 1, 1) =~ /[0-9]/
Truth table0%0/3
A and not(B)
A= substr($args[$i], 0, 1) eq "-"B= not substr($args[$i], 1, 1) =~ /[0-9]/
ABresult
0X0
100
111
100 0 ▶ if(!defined($args[$i + 1]) || substr($args[$i + 1], 0, 1) eq '-' && substr($args[$i + 1], 1, 1) !~ /[0-9]/){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $args[$i + 1] or substr($args[$i + 1], 0, 1) eq '-' and not substr($args[$i + 1], 1, 1) =~ /[0-9]/) { } 0 0 0
Condition0%0/6
not defined $args[$i + 1] or substr($args[$i + 1], 0, 1) eq "-" and not substr($args[$i + 1], 1, 1) =~ /[0-9]/
l!l&&r!l&&!r
000
substr($args[$i + 1], 0, 1) eq "-" and not substr($args[$i + 1], 1, 1) =~ /[0-9]/
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $args[$i + 1] or substr($args[$i + 1], 0, 1) eq "-" and not substr($args[$i + 1], 1, 1) =~ /[0-9]/
not defined $args[$i + 1] substr($args[$i + 1], 0, 1) eq "-" not substr($args[$i + 1], 1, 1) =~ /[0-9]/
Truth table0%0/4
not(A) or B and not(C)
A= not defined $args[$i + 1]B= substr($args[$i + 1], 0, 1) eq "-"C= not substr($args[$i + 1], 1, 1) =~ /[0-9]/
ABCresult
1XX1
0111
00X0
0100
101 0 push(@new_args, substr($args[$i], 1) . '=' . 1);
102 0 $i ++;
103 }else{
104 0 push(@new_args, substr($args[$i], 1) . '=' . $args[$i + 1]);
105 0 $i += 2;
106 }
107 }else{
108 0 push(@new_args, $args[$i]);
109 0 $i ++;
110 }
111 }
112  
113 0 my $url = $prefix . join('/', $gb->{filename}, $method[-1], @new_args);
114 0 my $request = HTTP::Request->new('GET', $url);
115 0 my $res = $ua->simple_request($request);
116 0 my $result;
117  
118 0 ▶ if($res->is_redirect){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_redirect) { } 0 0 0
119 0 $result = $res->header('Location');
120 }else{
121 0 ▶ if($res->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_success) { } 0 0 0
122 0 $result = $ua->get($url)->content;
123 }else{
124 0 ▶ if($res->status_line =~ /404/){
Branch: 1 branch
BranchTrueFalseTotal
if ($res->status_line =~ /404/) { } 0 0 0
125 0 die("no such function $method[-1]");
126 }else{
127 0 die($res->status_line);
128 }
129 }
130 }
131
132 0 ▶ if($result =~ /\n +/ || $result =~ /http/){
Branch: 1 branch
BranchTrueFalseTotal
if ($result =~ /\n +/ or $result =~ /http/) { } 0 0 0
Condition0%0/3
$result =~ /\n +/ or $result =~ /http/
l!l&&r!l&&!r
000
MC/DC0%0/2
$result =~ /\n +/ or $result =~ /http/
$result =~ /\n +/ $result =~ /http/
Truth table0%0/3
A or B
A= $result =~ /\n +/B= $result =~ /http/
ABresult
1X1
011
000
133 0 print $result, "\n";
134 }else{
135 0 return split(/\n/, $result);
136 }
137 }
138  
139 0 ▶sub DESTROY{}
Subroutine DESTROY: not called CC=1 SCAR=0.0
140  
141 0 ▶sub p{ print Dumper(@_), "\n"; }
Subroutine p: not called CC=1 SCAR=6.9
Pod undocumented
142 0 ▶sub puts{ print @_, "\n"; }
Subroutine puts: not called CC=1 SCAR=6.9
Pod undocumented
143 0 ▶sub say{ print join(',', @_), "\n"; }
Subroutine say: not called CC=1 SCAR=6.9
Pod undocumented
144  
145 0 ▶sub readFile{
Subroutine readFile: not called CC=6 SCAR=37.4
Pod undocumented
146 0 my $file = shift;
147 0 ▶ my $chomp = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
148 0 my @result;
149  
150 0 ▶ open(FILE, $file) || die($!);
Branch: 1 branch
BranchTrueFalseTotal
open FILE, $file or die $! 0 0 0
151 0 ▶ while(<FILE>){
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline FILE)) 0 0 0
152 0 ▶ chomp if($chomp);
Branch: 1 branch
BranchTrueFalseTotal
if $chomp 0 0 0
153 0 push(@result, $_);
154 }
155 0 close(FILE);
156  
157 0 ▶ if(wantarray()){
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
158 0 return @result;
159 }else{
160 0 return join('', @result);
161 }
162 }
163  
164  
165 0 ▶sub writeFile{
Subroutine writeFile: not called CC=3 SCAR=24.8
Pod undocumented
166 0 my $data = shift;
167 0 ▶ my $file = shift || "out.txt";
Condition0%0/2
shift() || 'out.txt'
l!l
00
MC/DC0%0/1
shift() || 'out.txt'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
168  
169 0 ▶ open(OUT, '>' . $file) || die($!);
Branch: 1 branch
BranchTrueFalseTotal
open OUT, '>' . $file or die $! 0 0 0
170 0 print OUT $data;
171 0 close(OUT);
172  
173 0 return $file;
174 }
175  
176  
177  
178 1 1;
179  
180 __END__
↑ Summary