Commit 26c844be authored by mirandaa's avatar mirandaa
Browse files

changed to positional arguments

parent 4166d8c1
...@@ -20,16 +20,15 @@ def getArgs(): ...@@ -20,16 +20,15 @@ def getArgs():
"MS1 Adduct (optional)", "MS1 Adduct (optional)",
"Specify adduct type, this is optional for ranged formulas") "Specify adduct type, this is optional for ranged formulas")
ms1_optgroup.add_argument('adduct_ms1', metavar='Chemical Formula for MS1 Adduct' , help = 'for example H' ms1_optgroup.add_argument('--adduct_ms1', metavar='Chemical Formula for MS1 Adduct' , help = 'for example H'
, nargs = '?', default='') , default='')
ms2_optgroup = parser.add_argument_group( ms2_optgroup = parser.add_argument_group(
"Fragments (optional)", "Fragments (optional)",
"Specify the chemical formulas of fragments, if applicable.") "Specify the chemical formulas of fragments, if applicable.")
ms2_optgroup.add_argument('formula_ms2', metavar='Chemical Formulas fragments' , help = 'seperated by comma if there are multiple' ms2_optgroup.add_argument('--formula_ms2', metavar='Chemical Formulas fragments' , help = 'seperated by comma if there are multiple'
, nargs = '?', default='') , default='')
args = parser.parse_args() args = parser.parse_args()
return args return args
...@@ -117,7 +116,12 @@ def main(): ...@@ -117,7 +116,12 @@ def main():
cc = txt2dict(args.formula_ms1) cc = txt2dict(args.formula_ms1)
af = txt2dict(args.adduct_ms1) #get chemical composition of adduct af = txt2dict(args.adduct_ms1) #get chemical composition of adduct
res = addDicts(cc,af, ms) res = addDicts(cc,af, ms)
# if args.formula_ms2 != '': frags_txt=[]
if args.formula_ms2 != '':
frags = args.formula_ms2.split(',')
frags_txt = [f.strip() for f in frags]
frags_dict = [txt2dict(f) for f in frags_txt]
dbes = [res2dbe(d) for d in frags_dict]
such = makeSuch(res) such = makeSuch(res)
ec = res2String(res) ec = res2String(res)
...@@ -126,6 +130,9 @@ def main(): ...@@ -126,6 +130,9 @@ def main():
line1 = f'#Identify {args.compound}#' line1 = f'#Identify {args.compound}#'
line2 = f'QUERYNAME = {args.compound};' line2 = f'QUERYNAME = {args.compound};'
line3 = f"DEFINE pr = '{ec}' WITH DBR = ({dbe_low},{dbe_high}), CHG = {ms}1;" line3 = f"DEFINE pr = '{ec}' WITH DBR = ({dbe_low},{dbe_high}), CHG = {ms}1;"
for frag in frags_txt:
do something here
line4 = f'IDENTIFY\n\tpr in MS1{ms}' line4 = f'IDENTIFY\n\tpr in MS1{ms}'
line5 = f'SUCHTHAT\n\t{such}(pr.chemsc[H]) AND \n\tisOdd(pr.chemsc[db]*2)' line5 = f'SUCHTHAT\n\t{such}(pr.chemsc[H]) AND \n\tisOdd(pr.chemsc[db]*2)'
line6 = f'REPORT\n\tPRM = pr.mass;\n\tEC = pr.chemsc;\n\tCLASS = "{args.compound}" % "()";\n\tQSERR = "%2.2f" % "(pr.errppm)";\n\tQS = pr.intensity;;' line6 = f'REPORT\n\tPRM = pr.mass;\n\tEC = pr.chemsc;\n\tCLASS = "{args.compound}" % "()";\n\tQSERR = "%2.2f" % "(pr.errppm)";\n\tQS = pr.intensity;;'
...@@ -141,6 +148,6 @@ def main(): ...@@ -141,6 +148,6 @@ def main():
f.write(line6 + '\n') f.write(line6 + '\n')
if __name__ == "__main__": if __name__ == "__main__":
# main() main()
args = getArgs() # args = getArgs()
print(vars(args)) # print(vars(args))
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment