comparison spectrast_params.py @ 2:e67b0cc10377 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/spectrast commit af2d54a900c86c6b9926b87b514517c0f0f0a975-dirty
author jjohnson
date Wed, 20 Jun 2018 12:58:33 -0400
parents
children 7f02fc51bddf
comparison
equal deleted inserted replaced
1:390a3c4a7f6b 2:e67b0cc10377
1 #!/usr/bin/env python
2
3 from __future__ import print_function
4
5 import argparse
6 import re
7 import sys
8
9 search_opts = [
10 'libraryFile',
11 'databaseFile',
12 'databaseType',
13 'indexCacheAll',
14 # 'filterSelectedListFileName',
15 'precursorMzTolerance',
16 'precursorMzUseAverage',
17 'searchAllCharges',
18 'detectHomologs',
19 'fvalFractionDelta',
20 'useSp4Scoring',
21 'fvalUseDotBias',
22 'usePValue',
23 'useTierwiseOpenModSearch',
24 # 'expectedCysteineMod',
25 # 'ignoreSpectraWithUnmodCysteine',
26 # 'ignoreChargeOneLibSpectra',
27 # 'ignoreAbnormalSpectra',
28 'outputExtension',
29 'outputDirectory',
30 'hitListTopHitFvalThreshold',
31 'hitListLowerHitsFvalThreshold',
32 'hitListShowHomologs',
33 'hitListShowMaxRank',
34 'hitListOnlyTopHit',
35 'hitListExcludeNoMatch',
36 'enzymeForPepXMLOutput',
37 'printFingerprintingSummary',
38 'filterMinPeakCount',
39 'filterAllPeaksBelowMz',
40 'filterMaxIntensityBelow',
41 'filterMinMzRange',
42 'filterCountPeakIntensityThreshold',
43 'filterRemovePeakIntensityThreshold',
44 'filterMaxPeaksUsed',
45 'filterMaxDynamicRange',
46 'peakScalingMzPower',
47 'peakScalingIntensityPower',
48 'peakScalingUnassignedPeaks',
49 'peakNoBinning',
50 'peakBinningNumBinsPerMzUnit',
51 'peakBinningFractionToNeighbor',
52 'filterLibMaxPeaksUsed',
53 'filterLightIonsMzThreshold',
54 'filterITRAQReporterPeaks',
55 'filterTMTReporterPeaks',
56 # 'filterRemoveHuge515Threshold',
57 ]
58
59
60 def __main__():
61 parser = argparse.ArgumentParser(
62 description='Parse SpectraST search.params files' +
63 ' to create an updated search.params')
64 parser.add_argument(
65 'param_files', nargs='*',
66 help='A SpectraST search.params files')
67 parser.add_argument(
68 '-o', '--output',
69 help='Output file (-) for stdout')
70 args = parser.parse_args()
71
72 output_wtr = open(args.output, 'w')\
73 if args.output and args.output != '-' else sys.stdout
74
75 optpat = re.compile('^([a-z]\w+)\s*[=:]\s*([^=]+)$')
76 search_params = dict()
77
78 # Collect all search_params
79 def parse_params(param_file, fh):
80 for i, line in enumerate(fh):
81 try:
82 m = optpat.match(line.rstrip())
83 if m:
84 k, v = m.groups()
85 if k in search_opts:
86 search_params[k] = v
87 except Exception, e:
88 print('%s(%d): %s %s' % (param_file, i, line, e),
89 file=sys.stderr)
90
91 if args.param_files:
92 for param_file in args.param_files:
93 try:
94 with open(param_file, 'r') as fh:
95 parse_params(param_file, fh)
96 except Exception, e:
97 print('parse_params: %s' % e, file=sys.stderr)
98 else:
99 try:
100 parse_params('stdin', sys.stdin)
101 except Exception, e:
102 print('parse_params: %s' % e, file=sys.stderr)
103
104 # Write search_params
105 for search_opt in search_opts:
106 if search_opt in search_params:
107 print('%s = %s' % (search_opt, search_params[search_opt]), file=output_wtr)
108
109
110 if __name__ == "__main__":
111 __main__()