Commit 242e1322 authored by mirandaa's avatar mirandaa
Browse files

update layout and add fragments

parent 3ee54a2f
......@@ -2,14 +2,19 @@ import os
from chem_parser import txt2dict
from gooey import Gooey, GooeyParser
@Gooey
@Gooey(program_name="MFQL Dessert")
def getArgs():
parser = GooeyParser(description='MFQL generator v0.0.1')
parser.add_argument('compound', type=str, help='Compound name')
parser.add_argument('formula_ms1', type=str, help='Specify formula (eg h2o or C[1..20]H[4..80]O[0..1])')
parser.add_argument('adduct_ms1', type=str, help='Specify adduct type (optional for ranges)')
parser.add_argument('ms_mode', type=str, help='MS mode + (is positive?)')
parser.add_argument('mfql_dir', type=str, help='output dir for MFQL files', widget='DirChooser')
parser.add_argument('compound', metavar='Compound', help='Human reabable name for reference')
parser.add_argument('formula_ms1', metavar='Chemical Formula for MS1' , help='Specify formula (eg h2o or C[1..20]H[4..80]O[0..1])')
parser.add_argument('adduct_ms1', metavar='Chemical Formula for MS1 Adduct', help='Specify adduct type (optional for ranges)'
, nargs = '?', default='')
parser.add_argument('formula_ms2', metavar='Chemical Formula for fragments,', help='Specify fragment formula\none per line (if applicable)'
, nargs = '?')
parser.add_argument('ms_mode', metavar='Select the Mode to use', help='MS mode'
, choices=['+', '-'])
parser.add_argument('mfql_dir', metavar='Directory where to store the results', help='output dir for MFQL files'
,default='./mfql_dir/' , widget='DirChooser')
args = parser.parse_args()
return args
......@@ -62,6 +67,7 @@ def calc_dbe(cc_dict):
# from Man-XCALI-97617-Xcalibur-31-Qual-ManXCALI97617-A-EN.pdf page 189: Double Bond/Ring equevelentse
dbe = 1 + sum([cc_dict.get(e, 0)*val_minus_2[e] for e in val_minus_2.keys()])/2
return dbe
def makeSuch(res):
#test for odd/even number of hydrogens
if res['H'][0] % 2 == 0:
......@@ -80,6 +86,7 @@ def res2String(res):
else:
ec += f'{k}[{v[0]}..{v[1]}] '
return ec
def res2dbe(res):
low_res = {k:v[0] for k,v in res.items()}
high_res = {k:v[1] for k,v in res.items()}
......@@ -87,13 +94,14 @@ def res2dbe(res):
dbe_high = calc_dbe(high_res)
return (dbe_low, dbe_high)
def main():
args = getArgs()
ms = args.ms_mode
cc = txt2dict(args.formula_ms1)
af = txt2dict(args.adduct_ms1) #get chemical composition of adduct
res = addDicts(cc,af, ms)
# if args.formula_ms2 != '':
such = makeSuch(res)
ec = res2String(res)
dbe_low, dbe_high = res2dbe(res)
......
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