comparison vkmz.py @ 5:04079c34452a draft

planemo upload for repository https://github.com/HegemanLab/VKMZ commit 3e37abe007f126480b9b748ad5322755445ac95b-dirty
author eslerm
date Thu, 31 May 2018 12:06:20 -0400
parents b02af8eb8e6e
children 35b984684450
comparison
equal deleted inserted replaced
4:1c2fe3a17065 5:04079c34452a
33 inputSubparser.add_argument('--error', '-e', nargs='?', type=float, required=True, help='Mass error of mass spectrometer in PPM') 33 inputSubparser.add_argument('--error', '-e', nargs='?', type=float, required=True, help='Mass error of mass spectrometer in PPM')
34 inputSubparser.add_argument('--database', '-d', nargs='?', default='databases/bmrb-light.tsv', help='Select database.') 34 inputSubparser.add_argument('--database', '-d', nargs='?', default='databases/bmrb-light.tsv', help='Select database.')
35 inputSubparser.add_argument('--directory', nargs='?', default='', type=str, help='Define directory of tool.') 35 inputSubparser.add_argument('--directory', nargs='?', default='', type=str, help='Define directory of tool.')
36 inputSubparser.add_argument('--polarity', '-p', choices=['positive','negative'], help='Force polarity mode. Ignore variables in input file.') 36 inputSubparser.add_argument('--polarity', '-p', choices=['positive','negative'], help='Force polarity mode. Ignore variables in input file.')
37 inputSubparser.add_argument('--no-adjustment', '-na', action='store_true', help='Use flag to turn off polarity based mass adjustment. This flag should always be used if reprocessing data generated by VKMZ.') 37 inputSubparser.add_argument('--no-adjustment', '-na', action='store_true', help='Use flag to turn off polarity based mass adjustment. This flag should always be used if reprocessing data generated by VKMZ.')
38 inputSubparser.add_argument('--multiprocessing', '-m', action='store_true', help='Use flag to turn on multiprocessing.') 38 inputSubparser.add_argument('--unique', '-u', action='store_true', help='Set flag to only output features which have a single match.')
39 inputSubparser.add_argument('--multiprocessing', '-m', action='store_true', help='Set flag to turn on multiprocessing.')
39 inputSubparser.add_argument('--plottype', '-t', nargs='?', default='scatter-2d', choices=['scatter-2d', 'scatter-3d'], help='Select plot type.') 40 inputSubparser.add_argument('--plottype', '-t', nargs='?', default='scatter-2d', choices=['scatter-2d', 'scatter-3d'], help='Select plot type.')
40 inputSubparser.add_argument('--size', '-s', nargs='?', default=5, type=int, help='Set maxium size of plot symbols.') 41 inputSubparser.add_argument('--size', '-s', nargs='?', default=5, type=int, help='Set maxium size of plot symbols.')
41 inputSubparser.add_argument('--size-algorithm', '-a', nargs='?', default=0, type=int, choices=[0,1], help="Symbol size algorithm selector. Algorithm 0 sets all symbols to the maxium size. Algorithm 2 determines a features symbol size by it's log intensity.") 42 inputSubparser.add_argument('--size-algorithm', '-a', nargs='?', default=0, type=int, choices=[0,1], help="Symbol size algorithm selector. Algorithm 0 sets all symbols to the maxium size. Algorithm 2 determines a features symbol size by it's log intensity.")
42 args = parser.parse_args() 43 args = parser.parse_args()
43 44
45 46
46 # read inputs, arguments and define globals 47 # read inputs, arguments and define globals
47 vkError = getattr(args, "error") 48 vkError = getattr(args, "error")
48 49
49 vkPolarity = getattr(args, "polarity") 50 vkPolarity = getattr(args, "polarity")
51
52 vkUnique = getattr(args, "unique")
50 53
51 vkMultiprocessing = getattr(args, "multiprocessing") 54 vkMultiprocessing = getattr(args, "multiprocessing")
52 55
53 vkNoAdjustment = getattr(args, "no_adjustment") 56 vkNoAdjustment = getattr(args, "no_adjustment")
54 57
101 uncertainty = mass * vkError / 1e6 104 uncertainty = mass * vkError / 1e6
102 prediction = predict(mass, uncertainty, 0, vkMaxIndex) 105 prediction = predict(mass, uncertainty, 0, vkMaxIndex)
103 if prediction != -1: 106 if prediction != -1:
104 feature[2] = mass 107 feature[2] = mass
105 predictions = predictNeighbors(mass, uncertainty, prediction) 108 predictions = predictNeighbors(mass, uncertainty, prediction)
109 if vkUnique and len(predictions) > 1:
110 return
106 feature.append(predictions) # feature[5] 111 feature.append(predictions) # feature[5]
107 predictionClosest = predictions[0] 112 predictionClosest = predictions[0]
108 formula = predictionClosest[1] 113 formula = predictionClosest[1]
109 formulaList = re.findall('[A-Z][a-z]?|[0-9]+', formula) 114 formulaList = re.findall('[A-Z][a-z]?|[0-9]+', formula)
110 formulaDictionary = {'C':0,'H':0,'O':0,'N':0} 115 formulaDictionary = {'C':0,'H':0,'O':0,'N':0}