comparison bih4bloodexposome.pl @ 0:94eeed7f737f draft default tip

planemo upload commit 399d2714dd85043f2ed8bdeff05bb1ccd4c5dd29
author fgiacomoni
date Fri, 27 Nov 2020 10:06:35 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:94eeed7f737f
1 #!c:\Perl\bin\perl.exe -w
2
3 =head1 NAME
4
5 bih4bloodexposome.pl - Utility to detect potential contaminants in your peak list based on BloodExposome database
6
7 =head1 USAGE
8
9
10 =head1 SYNOPSIS
11
12 =head1 DESCRIPTION
13
14 =over 4
15
16 =item B<function01>
17
18 =item B<function02>
19
20 =back
21
22 =head1 AUTHOR
23
24 Prenom Nom E<lt>franck.giacomoni@inrae.frE<gt>
25
26 =head1 SUPPORT
27
28 You can find documentation for this module with the perldoc command.
29
30 perldoc bih4bloodexposome.pl
31
32 =head1 LICENSE
33
34 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
35
36 =head1 VERSION
37
38 version 0.1.0 : 2020/01/21
39
40 version 2 : ??
41
42 =cut
43 #=============================================================================
44 # Included modules and versions
45 #=============================================================================
46 ## Perl modules
47 use strict ;
48 use warnings ;
49 use diagnostics ;
50 use Carp qw (cluck croak carp) ;
51
52 use Data::Dumper ;
53 use Getopt::Long ;
54 use File::Basename ;
55 use FindBin ; ## Allows you to locate the directory of original perl script
56
57 ## Specific Perl Modules (PFEM)
58 use lib $FindBin::Bin ;
59 my $binPath = $FindBin::Bin ;
60
61 ## Dedicate Perl Modules (Home made...)
62 use Metabolomics::Fragment::Annotation qw( :all ) ;
63 use Metabolomics::Banks qw( :all ) ;
64 use Metabolomics::Banks::BloodExposome qw( :all ) ;
65 use Metabolomics::Utils qw( :all ) ;
66
67 ## Initialized values
68 my $ProgramName = basename($0) ;
69 my $OptionHelp = undef ;
70 my $VERBOSE = undef ;
71
72 my ($inputFile, $mzCol, $asHeader, $ppmError, $mode ) = (undef, undef, undef, undef, undef, undef, undef ) ;
73 my ($outputTabular, $outputXls, $outputHTML, $outputFull) = (undef, undef, undef, undef) ;
74
75 my $QueryMode = undef ; # depending of the input data the query mode can be ION|NEUTRAL
76
77 #=============================================================================
78 # Manage EXCEPTIONS
79 #=============================================================================
80 &GetOptions ( "h|help" => \$OptionHelp, # HELP
81 "v|verbose=i" => \$VERBOSE, # Level of verbose (0 to 2)
82 "i|input=s" => \$inputFile, # Input file containing a peak list (mz)
83 "mzCol=i" => \$mzCol, # Column in CSV file for MZ
84 "header=i" => \$asHeader, # CSV file as header (1=true, 0=false)
85 "ppmError=f" => \$ppmError, # ppm error
86 "m|mode=s" => \$mode, # indicate the ionisation mode (POS|NEG|NEUTRAL)
87 "outputTab=s" => \$outputTabular, # output file in tabular format
88 "outputXls=s" => \$outputXls, # output file in Xls format
89 "outputHtml=s" => \$outputHTML, # output file in html format
90 "outputFull=s" => \$outputFull, # output file in full format
91
92 ) ;
93
94 ## if you put the option -help or -h function help is started
95 if ( defined($OptionHelp) ){ &help ; }
96
97 #=============================================================================
98 # MAIN SCRIPT
99 #=============================================================================
100
101 if ($VERBOSE == 3) {
102 print "The $ProgramName program is launched as:\n";
103 print "./$ProgramName " ;
104 print "--h " if (defined $OptionHelp) ;
105 print "--input $inputFile " if (defined $inputFile) ;
106 print "--mzCol $mzCol " if (defined $mzCol) ;
107 print "--header $asHeader " if (defined $asHeader) ;
108 print "--ppmError $ppmError " if (defined $ppmError) ;
109 print "--mode $mode " if (defined $mode) ;
110 # print "--outputXls $outputXls " if (defined $outputXls) ;
111 print "--outputTab $outputTabular " if (defined $outputTabular) ;
112 # print "--outputHtml $outputHTML " if (defined $outputHTML) ;
113 print "--outputFull $outputFull " if (defined $outputFull) ;
114 print "with verbose $VERBOSE" ;
115 print "\n" ;
116 }
117
118 ## Get conf
119 my ( $oCONF, $oTEMPLATE) = ( undef, undef ) ;
120 foreach my $conf ( <$binPath/*.cfg> ) { $oCONF = Metabolomics::Utils->utilsAsConf($conf) ; }
121
122 foreach my $template ( <$binPath/_template.tabular> ) { $oTEMPLATE = $template ; }
123
124 #print Dumper $oCONF ;
125
126
127 if ( ( defined $inputFile ) and ( $inputFile ne "" ) and ( -e $inputFile ) ) {
128
129 # create a empty bank object
130 my $oBank = Metabolomics::Banks::BloodExposome->new() ;
131
132 # get contaminants bank
133 my ($validedMode, $totalEntryNum) = (undef, 0, 0) ;
134
135 $oBank->getMetabolitesFromSource() ;
136
137 if ( ( defined $mode ) and ( ( $mode eq 'POSITIVE' ) | ( $mode eq 'NEGATIVE' ) | ( $mode eq 'NEUTRAL' ) ) ) {
138 $validedMode = $mode ;
139 }
140 else {
141 croak "[ERROR] Your ionisation mode is not defined or is different to POSITIVE or NEGATIVE\n"
142 }
143
144 # build the query object
145 $totalEntryNum = $oBank->buildTheoPeakBankFromEntries($validedMode) ;
146
147 # get experimental masses
148 if ( (defined $mzCol) and (defined $asHeader) ) {
149 $oBank->parsingMsFragments($inputFile, $asHeader, $mzCol) ;
150 }
151
152 ## Analysis :
153 my $oAnalysis = Metabolomics::Fragment::Annotation->new($oBank) ;
154
155 # print Dumper $oAnalysis ;
156
157 # Compare peaklists:
158 $oAnalysis->compareExpMzToTheoMzList('PPM', $ppmError) ;
159
160 # print Dumper $oBank ;
161
162
163
164 # complete initial input tabular file
165 if ( (defined $outputFull) and (defined $inputFile) ) {
166 my $tabularfile = $oAnalysis->writeFullTabularWithPeakBankObject($inputFile, $oTEMPLATE, $outputFull)
167 }
168 # write a simple tabular output
169 if ( (defined $outputTabular) and (defined $inputFile) ) {
170 my $tabularfile = $oAnalysis->writeTabularWithPeakBankObject($oTEMPLATE, $outputTabular) ;
171 }
172 }
173 else {
174 croak "Input file is not defined or is not exist.\n" ;
175 }
176
177
178
179
180
181 #====================================================================================
182 # Help subroutine called with -h option
183 # number of arguments : 0
184 # Argument(s) :
185 # Return : 1
186 #====================================================================================
187 sub help {
188
189
190 print STDERR <<EOF ;
191 ### $ProgramName ###
192 #
193 # AUTHOR: Franck Giacomoni
194 # VERSION: 1.0
195 # CREATED: 2019/08/21
196 # LAST MODIF:
197 # PURPOSE: This program annotates any known or hypothetical metabolites (peak matching) from ms analysis with BloodExposome database
198 # USAGE: $ProgramName or $ProgramName --input *.tabular --mzCol INT --header INT --ppmError 5 --mode POSITIVE|NEGATIVE|NEUTRAL --outputTab outTab.tabular --outputFull outFull.tabular --verbose 3
199 EOF
200 exit(1) ;
201 }
202
203 ## END of script - F Giacomoni
204
205 __END__