Mercurial > repos > konradpaszkiewicz > velvetoptimiser
comparison VelvetOptimiser-2.1.7_modified/VelvetOpt/gwrap.pm @ 0:50ae1360fbbe default tip
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author | konradpaszkiewicz |
---|---|
date | Tue, 07 Jun 2011 18:07:56 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:50ae1360fbbe |
---|---|
1 # VelvetOpt::gwrap.pm | |
2 # | |
3 # Copyright 2008 Simon Gladman <simon.gladman@csiro.au> | |
4 # | |
5 # This program is free software; you can redistribute it and/or modify | |
6 # it under the terms of the GNU General Public License as published by | |
7 # the Free Software Foundation; either version 2 of the License, or | |
8 # (at your option) any later version. | |
9 # | |
10 # This program is distributed in the hope that it will be useful, | |
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 # GNU General Public License for more details. | |
14 # | |
15 # You should have received a copy of the GNU General Public License | |
16 # along with this program; if not, write to the Free Software | |
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
18 # MA 02110-1301, USA. | |
19 # | |
20 package VelvetOpt::gwrap; | |
21 | |
22 =head1 NAME | |
23 | |
24 VelvetOpt::gwrap.pm - Velvet graphing and assembly program wrapper module. | |
25 | |
26 =head1 AUTHOR | |
27 | |
28 Simon Gladman, CSIRO, 2007, 2008. | |
29 | |
30 =head1 LICENSE | |
31 | |
32 Copyright 2008 Simon Gladman <simon.gladman@csiro.au> | |
33 | |
34 This program is free software; you can redistribute it and/or modify | |
35 it under the terms of the GNU General Public License as published by | |
36 the Free Software Foundation; either version 2 of the License, or | |
37 (at your option) any later version. | |
38 | |
39 This program is distributed in the hope that it will be useful, | |
40 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
41 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
42 GNU General Public License for more details. | |
43 | |
44 You should have received a copy of the GNU General Public License | |
45 along with this program; if not, write to the Free Software | |
46 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
47 MA 02110-1301, USA. | |
48 | |
49 =head1 SYNOPSIS | |
50 | |
51 use VelvetOpt::gwrap; | |
52 use VelvetOpt::Assembly; | |
53 my $object = VelvetOpt::Assembly->new( | |
54 timestamph => "23 November 2008 15:00:00", | |
55 ass_id => "1", | |
56 versiong => "0.7.19", | |
57 pstringg => "test", | |
58 ass_dir => "/home/gla048/Desktop/newVelvetOptimiser/test" | |
59 ); | |
60 my $worked = VelvetOpt::gwrap::objectVelvetg($object); | |
61 if($worked){ | |
62 print $object->toString(); | |
63 } | |
64 else { | |
65 die "Error in velvetg..\n" . $object->toString(); | |
66 } | |
67 | |
68 =head1 DESCRIPTION | |
69 | |
70 A wrapper module to run velvetg on VelvetAssembly objects or on velvetg | |
71 parameter strings. Also contains private methods to check velvetg | |
72 parameter strings, run velvetg and return results. | |
73 | |
74 =head2 Uses | |
75 | |
76 =over 8 | |
77 | |
78 =item strict | |
79 | |
80 =item warnings | |
81 | |
82 =item Carp | |
83 | |
84 =item VelvetOpt::Assembly | |
85 | |
86 =item POSIX qw(strftime) | |
87 | |
88 =back | |
89 | |
90 =head2 Private Fields | |
91 | |
92 =over 8 | |
93 | |
94 =item interested | |
95 | |
96 STDERR printing debug message toggle. 1 for on, 0 for off. | |
97 | |
98 =back | |
99 | |
100 =head2 Methods | |
101 | |
102 =over 8 | |
103 | |
104 =item _runVelvetg | |
105 | |
106 Private method which runs velvetg with the supplied velvetg parameter string and returns velvetg output messages as a string. | |
107 | |
108 =item _checkVGString | |
109 | |
110 Private method which checks for a correctly formatted velvetg parameter string. Returns 1 or 0. | |
111 | |
112 =item objectVelvetg | |
113 | |
114 Accepts a VelvetAssembly object, looks for the velvetg parameter string it contains, checks it, sends it to _runVelvetg, collects the results and stores them in the VelvetAssembly object. | |
115 | |
116 =item stringVelvetg | |
117 | |
118 Accepts a velvetg parameter string, checks it, sends it to _runVelvetg and then collects and returns the velvetg output messages. | |
119 | |
120 =back | |
121 | |
122 =cut | |
123 | |
124 use warnings; | |
125 use strict; | |
126 use Carp; | |
127 use VelvetOpt::Assembly; | |
128 use POSIX qw(strftime); | |
129 | |
130 my $interested = 0; | |
131 | |
132 sub _runVelvetg { | |
133 my $cmdline = shift; | |
134 my $output = ""; | |
135 print STDERR "About to run velvetg!\n" if $interested; | |
136 $output = `velvetg $cmdline`; | |
137 $output .= "\nTimestamp: " . strftime("%b %e %Y %H:%M:%S", localtime) . "\n"; | |
138 return $output; | |
139 } | |
140 | |
141 sub _checkVGString { | |
142 return 1; | |
143 } | |
144 | |
145 sub objectVelvetg { | |
146 my $va = shift; | |
147 my $cmdline = $va->{pstringg}; | |
148 if(_checkVGString($cmdline)){ | |
149 $va->{velvetgout} = _runVelvetg($cmdline); | |
150 my @t = split /\n/, $va->{velvetgout}; | |
151 $t[$#t] =~ s/Timestamp:\s+//; | |
152 $va->{timestampg} = $t[$#t]; | |
153 return 1; | |
154 } | |
155 else { | |
156 $va->{velvetgout} = "Formatting errors in velvetg parameter string."; | |
157 return 0; | |
158 } | |
159 } | |
160 | |
161 sub stringVelvetg { | |
162 my $cmdline = shift; | |
163 if(_checkVGString($cmdline)){ | |
164 return _runVelvetg($cmdline); | |
165 } | |
166 else { | |
167 return "Formatting errors in velvetg parameter string."; | |
168 } | |
169 } | |
170 | |
171 1; |