Mercurial > repos > marpiech > norwich_tools
annotate tools/rdock/bin/sdreport @ 0:bc03dbb6eb37 draft
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
author | marpiech |
---|---|
date | Mon, 29 Aug 2016 03:38:13 -0400 |
parents | |
children |
rev | line source |
---|---|
0
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
1 #!/usr/bin/perl |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
2 # Produces text summaries of SD records * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
3 # * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
4 # Usage: sdreport [-l] [-t] [-s<DataField>] [sdFiles] * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
5 # * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
6 # -l output data fields for each record as processed * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
7 # -t tabulate Rbt.Score.* fields for each record as processed * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
8 # -s summarise data fields for all records * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
9 # -s<DataField> summarise data fields for each unique value * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
10 # of <DataField> * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
11 # * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
12 # Note: If -l or -t are combined with -s, the listing/table is output * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
13 # within each ligand summary * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
14 # If sdFiles not given, reads from standard input * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
15 # Output is to standard output * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
16 # Default is equivalent to sdfilter -l * |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
17 #******************************************************************************* |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
18 use lib "$ENV{'RBT_ROOT'}/lib"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
19 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
20 use SDRecord; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
21 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
22 # Default field names and headings for rDock v4.00 scores |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
23 my @defaultFields = ('SCORE','SCORE.INTER','SCORE.INTRA','SCORE.RESTR','SCORE.INTER.VDW'); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
24 my @defaultHeadings = ('TOTAL','INTER','INTRA','RESTR','VDW'); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
25 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
26 # Default field names and headings for normalised scores (score / #ligand heavy atoms) |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
27 my @defaultNormFields = ('SCORE.norm','SCORE.INTER.norm','SCORE.INTRA.norm','SCORE.RESTR.norm','SCORE.heavy'); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
28 my @defaultNormHeadings = ('TOTALn','INTERn','INTRAn','RESTRn','#heavy'); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
29 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
30 # Default field names and headings for rDock v3.00 scores |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
31 my @defaultOldFields = ('Rbt.Score.Corrected','Rbt.Score.Inter','Rbt.Score.Intra','Rbt.Score.IntraMin','Rbt.Score.Restraint'); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
32 my @defaultOldHeadings = ('TOTAL','INTER','INTRA','INTRAMIN','RESTR'); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
33 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
34 my $listFormat = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
35 my $summaryFormat = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
36 my $tableFormat = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
37 my $supplierFormat = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
38 my $csvFormat = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
39 my $summaryKey = "_TITLE1"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
40 my $oldFields = 0;#If true, use old default field names for component scores |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
41 my $headings = 1;#DM 21 Nov 2000, If false, don't output headings |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
42 my @outputFields; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
43 my @outputHeadings; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
44 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
45 #Print help if no command line arguments |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
46 printHelpAndExit() if (scalar(@ARGV) == 0); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
47 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
48 #Parse command line arguments |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
49 my $nArgs = scalar(@ARGV); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
50 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
51 while (scalar(@ARGV)) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
52 my $arg = shift @ARGV; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
53 printHelpAndExit() if ($arg eq '-h'); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
54 if (index($arg,'-l')==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
55 $listFormat = 1; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
56 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
57 elsif (index($arg,'-o')==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
58 $oldFields = 1; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
59 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
60 # 7 Feb 2005 (DM) Option to report normalised aggregate scores |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
61 elsif (index($arg,'-norm')==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
62 $oldFields = 2; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
63 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
64 elsif (index($arg,'-sup')==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
65 $supplierFormat = 1; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
66 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
67 elsif (index($arg,'-s')==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
68 $summaryFormat = 1; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
69 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
70 elsif (index($arg,'-id')==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
71 $summaryKey = substr($arg,3); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
72 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
73 elsif (index($arg,'-nh')==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
74 $headings = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
75 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
76 elsif (index($arg,'-t')==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
77 $tableFormat = 1; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
78 push @outputFields, split(',',substr($arg,2)); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
79 push @outputHeadings, @outputFields; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
80 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
81 elsif (index($arg,'-c')==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
82 $csvFormat = 1; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
83 push @outputFields, split(',',substr($arg,2)); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
84 push @outputHeadings, @outputFields; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
85 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
86 else { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
87 push @files,$arg;#must be a filename |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
88 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
89 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
90 push @ARGV,@files;#put the filenames back in the arg list |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
91 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
92 #use -l if neither table format is specified |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
93 $listFormat = (!$tableFormat && !$csvFormat && !$supplierFormat); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
94 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
95 #If no output fields defined for -t or -c use the defaults (old or new) |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
96 if (scalar(@outputFields)==0) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
97 if ($oldFields == 1) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
98 @outputFields = @defaultOldFields; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
99 @outputHeadings = @defaultOldHeadings; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
100 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
101 elsif ($oldFields == 2) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
102 @outputFields = @defaultNormFields; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
103 @outputHeadings = @defaultNormHeadings; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
104 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
105 else { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
106 @outputFields = @defaultFields; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
107 @outputHeadings = @defaultHeadings; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
108 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
109 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
110 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
111 my $sdRec = new SDRecord; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
112 my %summary;#hash of SDRecord lists, indexed by user-defined summary key |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
113 my %indexByName; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
114 my %indexByNum; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
115 my $idx = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
116 my $nRec = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
117 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
118 #Column headings for tab and csv format |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
119 #DM 21 Nov 2000 - if $headings is false, then don't output the column headings |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
120 if ($tableFormat && !$summaryFormat && $headings) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
121 tabHeadings($summaryKey,@outputHeadings); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
122 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
123 if ($csvFormat && !$summaryFormat && $headings) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
124 csvHeadings($summaryKey,@outputHeadings); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
125 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
126 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
127 #read records |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
128 while ($sdRec->readRec('LINES'=>1,'DATA'=>1)) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
129 $sdRec->addData('_REC' => ++$nRec);#add record# as temp data field |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
130 if ($listFormat && !$summaryFormat) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
131 print "\n\nRECORD #$nRec\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
132 $sdRec->writeData(); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
133 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
134 if ($tableFormat && !$summaryFormat) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
135 @recList = ($sdRec); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
136 tabScores(\@recList,$summaryKey,@outputFields); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
137 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
138 elsif ($csvFormat && !$summaryFormat) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
139 @recList = ($sdRec); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
140 csvScores(\@recList,$summaryKey,@outputFields); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
141 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
142 elsif ($supplierFormat && !$summaryFormat) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
143 @recList = ($sdRec); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
144 tabulateSuppliers(\@recList,$summaryKey); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
145 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
146 #add record to summary, indexed by user field value |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
147 #keep a separate index of unique values of user field values, |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
148 #indexed by number in the order the values first appear |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
149 #In this way we can maintain the sorted order of ligands |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
150 #when we come to print out the summary |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
151 if ($summaryFormat) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
152 my $summaryValue = $sdRec->{'DATA'}->{$summaryKey}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
153 #New data field value encountered |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
154 if (!defined $indexByName{$summaryValue}) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
155 $idx++;#incr the number of unique values |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
156 #keep cross-referenced indexes (field value <-> number) |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
157 $indexByName{$summaryValue} = $idx; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
158 $indexByNum{$idx} = $summaryValue; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
159 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
160 push @{$summary{$summaryValue}},$sdRec->copy('DATA'=>1); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
161 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
162 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
163 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
164 #Print summary if required |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
165 if ($summaryFormat) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
166 print "\n===============================================================\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
167 print "SUMMARY BY $summaryKey\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
168 foreach $idx (sort {$a<=>$b} keys %indexByNum) {#numberic sort of index numbers |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
169 my $key = $indexByNum{$idx};#look up corresponding data field value |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
170 print "\n===============================================================\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
171 print "$summaryKey = $key (#$idx)\n\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
172 writeSummary($summary{$key}); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
173 if ($listFormat) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
174 print "\nIndividual records:\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
175 foreach $rec (@{$summary{$key}}) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
176 print "\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
177 $rec->writeData(); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
178 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
179 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
180 if ($tableFormat) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
181 print "\nScores:\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
182 tabHeadings($summaryKey,@outputHeadings); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
183 tabScores($summary{$key},$summaryKey,@outputFields); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
184 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
185 if ($csvFormat) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
186 print "\nScores:\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
187 csvHeadings($summaryKey,@outputHeadings); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
188 csvScores($summary{$key},$summaryKey,@outputFields); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
189 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
190 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
191 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
192 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
193 ############################################################## |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
194 # writes a summary to STDOUT for a list of SDRecords |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
195 # Input is a reference to an array of SDRecords |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
196 sub writeSummary { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
197 my $recListRef = shift; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
198 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
199 #Extract the list of data values for each fieldname into a hash array |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
200 #(key=fieldname, value=array ref) |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
201 my %fields; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
202 foreach $rec (@{$recListRef}) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
203 my ($key,$value); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
204 while ( ($key,$value) = each %{$rec->{'DATA'}}) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
205 push @{$fields{$key}},$value; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
206 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
207 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
208 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
209 #Look for constant fields and store separately |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
210 my %constFields; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
211 foreach $key (keys %fields) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
212 my @values = sort @{$fields{$key}}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
213 my $nVal = scalar(@values); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
214 if ($values[0] eq $values[$nVal -1]) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
215 $constFields{$key} = $values[0];#store the field name and the constant value |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
216 delete $fields{$key};#remove from (non-const) array |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
217 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
218 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
219 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
220 #Print constant fields |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
221 print "\nConstant fields:\n\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
222 foreach $key (sort keys %constFields) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
223 printf "%-40s%s\n",$key,$constFields{$key}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
224 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
225 #Print min and max value for non-const fields |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
226 print "\nVariable fields:\n\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
227 foreach $key (sort keys %fields) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
228 my @values = @{$fields{$key}}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
229 #Look at first value to decide whether to do text or numeric sort |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
230 if (isNaN($values[0])) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
231 @values = sort @values;#text sort |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
232 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
233 else { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
234 @values = sort {$a <=> $b} @values;#numeric sort |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
235 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
236 my $nVal = scalar(@values); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
237 printf "%-40s",$key; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
238 print "Min = $values[0]\tMax = $values[$nVal-1]\t(N = $nVal)\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
239 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
240 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
241 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
242 ############################################################## |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
243 # function isNaN equivalent to the C++, java, javascript isNaN |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
244 # From P Vaglio, ~intranet/lib/rbt_func.pl |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
245 sub isNaN { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
246 local($_) = @_; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
247 s/\s+//g; # strip white space |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
248 # match +or- beginning of line 0 or 1 time |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
249 # then any numeric 0 or more |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
250 # then a decimal point |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
251 # then any numeric 0 or more after decimal point |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
252 # then possibly an e or E then + or - then any numreci at least once |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
253 if (/^([+-]?)(\d*)(\.(\d*))?([Ee]([+-]?\d+))?$/ && (defined $2 || defined $4)) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
254 return 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
255 } else { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
256 return 1; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
257 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
258 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
259 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
260 ############################################################## |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
261 # output corresponding headings for use with tabScores |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
262 sub tabHeadings { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
263 my $summaryKey = shift; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
264 my @fieldNames = @_; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
265 printf("%-10s%-30s","REC",$summaryKey); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
266 foreach $field (@fieldNames) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
267 printf("%10s",$field); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
268 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
269 print "\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
270 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
271 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
272 ############################################################## |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
273 # tab-delimited output of named data field values |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
274 sub tabScores { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
275 my $recListRef = shift; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
276 my $summaryKey = shift; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
277 my @fieldNames = @_; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
278 foreach $rec (@{$recListRef}) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
279 printf("%03d\t%-30.30s",$rec->{'DATA'}->{'_REC'},$rec->{'DATA'}->{$summaryKey}); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
280 foreach $field (@fieldNames) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
281 my $val = $rec->{'DATA'}->{$field}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
282 if (isNaN($val)) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
283 printf("%-10.12s",$val); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
284 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
285 else { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
286 printf("%10.3f",$val); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
287 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
288 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
289 print "\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
290 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
291 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
292 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
293 ############################################################## |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
294 # output corresponding headings for use with csvScores |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
295 sub csvHeadings { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
296 my $summaryKey = shift; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
297 my @fieldNames = @_; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
298 printf("%s,%s","REC",$summaryKey); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
299 foreach $field (@fieldNames) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
300 printf(",%s",$field); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
301 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
302 print "\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
303 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
304 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
305 ############################################################## |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
306 # comma-delimited output of named data field values |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
307 sub csvScores { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
308 my $recListRef = shift; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
309 my $summaryKey = shift; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
310 my @fieldNames = @_; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
311 foreach $rec (@{$recListRef}) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
312 printf("%d,%s",$rec->{'DATA'}->{'_REC'},$rec->{'DATA'}->{$summaryKey}); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
313 foreach $field (@fieldNames) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
314 my $val = $rec->{'DATA'}->{$field}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
315 if (isNaN($val)) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
316 printf(",%s",$val); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
317 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
318 else { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
319 printf(",%.3f",$val); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
320 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
321 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
322 print "\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
323 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
324 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
325 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
326 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
327 ############################################################## |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
328 # standardised output of Catalyst supplier field |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
329 # Input is a reference to an array of SDRecords |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
330 # and a ligand identifier field to output in column 1 (def=Name) |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
331 sub tabulateSuppliers { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
332 my $recListRef = shift; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
333 my $summaryKey = shift || 'Name'; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
334 foreach $rec (@{$recListRef}) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
335 my $suppBase = $rec->{'DATAREF'}->{'Supplier'}+1; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
336 my $linesRef = $rec->{'LINES'}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
337 my $name = $rec->{'DATA'}->{$summaryKey}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
338 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
339 #Output some useful compound info |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
340 my $name = $rec->{'DATA'}->{$summaryKey}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
341 my $molFormula = $rec->{'DATA'}->{'MolFormula'}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
342 my $molWt = $rec->{'DATA'}->{'MolWt'}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
343 my $casNum = $rec->{'DATA'}->{'CAS_num'}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
344 my $mdlNum = $rec->{'DATA'}->{'MDLNUMBER'}; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
345 print "\n\n====================================================================================================\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
346 printf("%-10.10s%s\n","Name:",$name); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
347 printf("%-10.10s%s\n","Formula:",$molFormula); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
348 printf("%-10.10s%s\n","Mol.wt:",$molWt); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
349 printf("%-10.10s%s\n","CAS #:",$casNum); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
350 printf("%-10.10s%s\n","MDL #:",$mdlNum); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
351 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
352 #Get all the supplier record lines into a list |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
353 #Record is terminated by blank line |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
354 my @lines; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
355 my $nLines = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
356 for (; $$linesRef[$suppBase+$nLines] ne ""; $nLines++) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
357 push @lines,$$linesRef[$suppBase+$nLines]; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
358 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
359 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
360 #Column headings |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
361 printf("\n%-20.20s%-40.40s%-40.40s\n", |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
362 "Supplier", |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
363 "Comment", |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
364 "Price" |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
365 ); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
366 print "----------------------------------------------------------------------------------------------------\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
367 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
368 #Loop over each supplier |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
369 my $iLine = 0; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
370 for (; $iLine < $nLines; $iLine++) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
371 #collect supplier info lines |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
372 my @supplierInfo = (); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
373 for (; $lines[$iLine] ne "." && $iLine < $nLines; $iLine++) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
374 push @supplierInfo,$lines[$iLine]; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
375 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
376 #Check for incomplete record |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
377 if ($iLine == $nLines) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
378 print "** INCOMPLETE RECORD **\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
379 last; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
380 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
381 my $nSupplierInfo = scalar(@supplierInfo); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
382 my $supplier = $supplierInfo[0]; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
383 #loop over each grade |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
384 for ($iLine++; ($lines[$iLine] ne "........................") && ($iLine < $nLines); $iLine++) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
385 #collect grade info lines |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
386 my @gradeInfo = (); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
387 for (; index($lines[$iLine],"_") ne 0 && $iLine < $nLines; $iLine++) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
388 push @gradeInfo,$lines[$iLine]; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
389 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
390 #Check for incomplete record |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
391 if ($iLine == $nLines) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
392 print "** INCOMPLETE RECORD **\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
393 last; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
394 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
395 my $grade = $gradeInfo[0]; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
396 #loop over each price info line |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
397 for (; index($lines[$iLine],".") ne 0 && $iLine < $nLines; $iLine++) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
398 my @priceInfo = split(" ",$lines[$iLine]); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
399 my $price = join(" ",@priceInfo); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
400 printf("%-20.20s%-40.39s%-40.40s\n", |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
401 $supplier, |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
402 $grade, |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
403 $price); |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
404 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
405 #Check for incomplete record |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
406 if ($iLine == $nLines) { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
407 print "** INCOMPLETE RECORD **\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
408 last; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
409 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
410 last if $lines[$iLine] eq "........................"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
411 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
412 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
413 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
414 } |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
415 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
416 |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
417 ####################################################################### |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
418 sub printHelpAndExit { |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
419 print "\nProduces text summaries of SD records\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
420 print "\nUsage:\tsdreport [-l] [-t[<FieldName,FieldName...>]] [-c<FieldName,FieldName...>] [-id<IDField>] [-nh] [-o] [-s] [-sup] [sdFiles]\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
421 print "\n\t-l (list format) output all data fields for each record as processed\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
422 print "\t-t (tab format) tabulate selected fields for each record as processed\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
423 print "\t-c (csv format) comma delimited output of selected fields for each record as processed\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
424 print "\t-s (summary format) output summary statistics for each unique value of ligand ID\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
425 print "\t-sup (supplier format) tabulate supplier details (from Catalyst)\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
426 print "\t-id<IDField> data field to use as ligand ID\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
427 print "\t-nh don't output column headings in -t and -c formats\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
428 print "\t-o use old (v3.00) score field names as default columns in -t and -c formats, else use v4.00 field names\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
429 print "\t-norm use normalised score field names as default columns in -t and -c formats (normalised = score / #ligand heavy atoms)\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
430 print "\nNote:\tIf -l, -t or -c are combined with -s, the listing/table is output within each ligand summary\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
431 print "\t-sup should not be combined with other options\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
432 print "\tDefault field names for -t and -c are rDock score field names\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
433 print "\tDefault ID field name is Name\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
434 print "\n\tIf sdFiles not given, reads from standard input\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
435 print "\tOutput is to standard output\n\n"; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
436 exit; |
bc03dbb6eb37
planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff
changeset
|
437 } |