Commit b530527d authored by mirandaa's avatar mirandaa
Browse files

writ the file

parent e4c6d34a
......@@ -13,7 +13,6 @@
"metadata": {},
"outputs": [],
"source": [
"import pandas\n",
"#https://pypi.org/project/molmass/\n",
"from molmass import Formula"
]
......@@ -50,9 +49,6 @@
"#define MS mode\n",
"ms = input('Define MS mode (either + or -):')\n",
"\n",
"#define lipid class\n",
"lipid_class = input('Define lipid class (PL, NL, Cer, SM, PI, PG):')\n",
"\n",
"#define filename\n",
"filename = input('Define file name (no special characters):')\n",
"mfql = '.mfql'\n",
......@@ -109,15 +105,6 @@
"allelems.keys()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"allelems"
]
},
{
"cell_type": "code",
"execution_count": null,
......@@ -140,15 +127,6 @@
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"res"
]
},
{
"cell_type": "code",
"execution_count": null,
......@@ -180,7 +158,8 @@
"if res['H'] % 2 == 0:\n",
" such = 'isEven'\n",
"else:\n",
" such = 'isOdd'"
" such = 'isOdd'\n",
" "
]
},
{
......@@ -189,64 +168,66 @@
"metadata": {},
"outputs": [],
"source": [
"#generate mfql\n",
"#report adjusted to neutral lipids in pos mode\n",
"if lipid_class == 'NL' and ms == '+':\n",
" with open(filename, 'w') as f: #change name accordingly\n",
" print(f'#Identify {cn}#', file=f)\n",
" print(f'\\nQUERYNAME = {qn};', file=f)\n",
" print(f\"\\nDEFINE pr = 'C[{res['C']}] H[{res['H']}] D[{res['2H']}] N[{res['N']}] O[{res['O']}]' WITH DBR = ({dbe},{dbe}), CHG = {ms}1;\", file=f)\n",
" print(f'\\nIDENTIFY\\n\\tpr in MS1{ms}', file=f)\n",
" print(f'\\nSUCHTHAT\\n\\t{such}(pr.chemsc[H]) AND \\n\\tisOdd(pr.chemsc[db]*2)', file=f)\n",
" print(f'\\nREPORT\\n\\tPRM = pr.mass;\\n\\tEC = pr.chemsc;\\n\\tCLASS = \"{qn}\" % \"()\";\\n\\tQSERR = \"%2.2f\" % \"(pr.errppm)\";\\n\\tQS = pr.intensity;;', file=f)\n",
"\n",
"#report adjusted to DG in neg mode \n",
"if lipid_class == 'NL' and ms == '-':\n",
" with open(filename, 'w') as f: #change name accordingly\n",
" print(f'#Identify {cn}#', file=f)\n",
" print(f'\\nQUERYNAME = {qn};', file=f)\n",
" print(f\"\\nDEFINE pr = 'C[{res['C']}] H[{res['H']}] D[{res['2H']}] O[{res['O']}]' WITH DBR = ({dbe},{dbe}), CHG = {ms}1;\", file=f)\n",
" print(f'\\nIDENTIFY\\n\\tpr in MS1{ms}', file=f)\n",
" print(f'\\nSUCHTHAT\\n\\t{such}(pr.chemsc[H]) AND \\n\\tisOdd(pr.chemsc[db]*2)', file=f)\n",
" print(f'\\nREPORT\\n\\tPRM = pr.mass;\\n\\tEC = pr.chemsc;\\n\\tCLASS = \"{qn}\" % \"()\";\\n\\tQSERR = \"%2.2f\" % \"(pr.errppm)\";\\n\\tQS = pr.intensity;;', file=f)\n",
"\n",
"#report adjusted to Cer independent of mode \n",
"if lipid_class == 'Cer':\n",
" with open(filename, 'w') as f: #change name accordingly\n",
" print(f'#Identify {cn}#', file=f)\n",
" print(f'\\nQUERYNAME = {qn};', file=f)\n",
" print(f\"\\nDEFINE pr = 'C[{res['C']}] H[{res['H']}] D[{res['2H']}] N[{res['N']}] O[{res['O']}]' WITH DBR = ({dbe},{dbe}), CHG = {ms}1;\", file=f)\n",
" print(f'\\nIDENTIFY\\n\\tpr in MS1{ms}', file=f)\n",
" print(f'\\nSUCHTHAT\\n\\t{such}(pr.chemsc[H]) AND \\n\\tisOdd(pr.chemsc[db]*2)', file=f)\n",
" print(f'\\nREPORT\\n\\tPRM = pr.mass;\\n\\tEC = pr.chemsc;\\n\\tCLASS = \"{qn}\" % \"()\";\\n\\tQSERR = \"%2.2f\" % \"(pr.errppm)\";\\n\\tQS = pr.intensity;;', file=f) \n",
"\n",
"#report adjusted to SM and PLs\n",
"if lipid_class == 'PL' or lipid_class == 'SM':\n",
" with open(filename, 'w') as f: #change name accordingly\n",
" print(f'#Identify {cn}#', file=f)\n",
" print(f'\\nQUERYNAME = {qn};', file=f)\n",
" print(f\"\\nDEFINE pr = 'C[{res['C']}] H[{res['H']}] D[{res['2H']}] N[{res['N']}] O[{res['O']}] P[{res['P']}]' WITH DBR = ({dbe},{dbe}), CHG = {ms}1;\", file=f)\n",
" print(f'\\nIDENTIFY\\n\\tpr in MS1{ms}', file=f)\n",
" print(f'\\nSUCHTHAT\\n\\t{such}(pr.chemsc[H]) AND \\n\\tisOdd(pr.chemsc[db]*2)', file=f)\n",
" print(f'\\nREPORT\\n\\tPRM = pr.mass;\\n\\tEC = pr.chemsc;\\n\\tCLASS = \"{qn}\" % \"()\";\\n\\tQSERR = \"%2.2f\" % \"(pr.errppm)\";\\n\\tQS = pr.intensity;;', file=f)\n",
" \n",
"#report adjusted to PI and PG in neg mode \n",
"if lipid_class == 'PG' or lipid_class == 'PI' and ms == '-':\n",
" with open(filename, 'w') as f: #change name accordingly\n",
" print(f'#Identify {cn}#', file=f)\n",
" print(f'\\nQUERYNAME = {qn};', file=f)\n",
" print(f\"\\nDEFINE pr = 'C[{res['C']}] H[{res['H']}] D[{res['2H']}] O[{res['O']}] P[{res['P']}]' WITH DBR = ({dbe},{dbe}), CHG = {ms}1;\", file=f)\n",
" print(f'\\nIDENTIFY\\n\\tpr in MS1{ms}', file=f)\n",
" print(f'\\nSUCHTHAT\\n\\t{such}(pr.chemsc[H]) AND \\n\\tisOdd(pr.chemsc[db]*2)', file=f)\n",
" print(f'\\nREPORT\\n\\tPRM = pr.mass;\\n\\tEC = pr.chemsc;\\n\\tCLASS = \"{qn}\" % \"()\";\\n\\tQSERR = \"%2.2f\" % \"(pr.errppm)\";\\n\\tQS = pr.intensity;;', file=f) "
"ec=''\n",
"for k,v in res.items():\n",
" if k == '2H':\n",
" k = 'D' \n",
" ec += f'{k}[{v}] '\n",
"ec"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dbe = calc_dbe(res)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"line1 = f'#Identify {cn}#'\n",
"line2 = f'QUERYNAME = {qn};'\n",
"line3 = f\"DEFINE pr = '{ec}' WITH DBR = ({dbe},{dbe}), CHG = {ms}1;\"\n",
"line4 = f'IDENTIFY\\n\\tpr in MS1{ms}'\n",
"line5 = f'SUCHTHAT\\n\\t{such}(pr.chemsc[H]) AND \\n\\tisOdd(pr.chemsc[db]*2)'\n",
"line6 = f'REPORT\\n\\tPRM = pr.mass;\\n\\tEC = pr.chemsc;\\n\\tCLASS = \"{qn}\" % \"()\";\\n\\tQSERR = \"%2.2f\" % \"(pr.errppm)\";\\n\\tQS = pr.intensity;;'\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open(filename, 'w') as f:\n",
" f.write(line1 + '\\n')\n",
" f.write(line2 + '\\n')\n",
" f.write(line3 + '\\n')\n",
" f.write(line4 + '\\n')\n",
" f.write(line5 + '\\n')\n",
" f.write(line6 + '\\n')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.7.5 64-bit ('mfql_des': conda)",
"language": "python",
"name": "python3"
"name": "python37564bitmfqldesconda008f121642b041f890de0d051e241abf"
},
"language_info": {
"codemirror_mode": {
......@@ -258,7 +239,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6-final"
"version": "3.7.5-final"
}
},
"nbformat": 4,
......
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