In [1]:
%matplotlib inline
from matplotlib import pylab as plt
from metatlas import metatlas_objects
from metatlas import h5_query
from metatlas.metatlas_objects import Atlas
# import glob, os
In [3]:
# myExperiment = metatlas_objects.get_experiment(name = 'Test_20150722')
metatlas_objects.list_experiments()
Out[3]:
In [10]:
import pandas as pd
atlas_file = '/global/homes/b/bpb/20150804_POS_pHILIC_R2A_Small.txt'
df = pd.read_csv(atlas_file,sep='\t')
df.fillna('',inplace=True)
comp_list = df.to_dict('records')
print comp_list
Out[10]:
In [ ]:
a = metatlas_objects.Atlas(name = 'Positive Mode R2A Media Hilic',
compounds=[c1,c2,c3,c4,c5,
c6,c7,c8,c9,c10,
c11,c12,c13,c14,c15,
c16,c17,c18,c19,c20,
c21,c22,c23,c24,c25,
c26,c27])
myExperiment.atlases.append(a)
myExperiment.save()
In [5]:
a = Atlas(name = 'Positive Mode R2A Media Hilic',
compounds=[c1,c2,c3,c4,c5,
c6,c7,c8,c9,c10,
c11,c12,c13,c14,c15,
c16,c17,c18,c19,c20,
c21,c22,c23,c24,c25,
c26,c27])
a.edit()
In [ ]:
# for i,a in enumerate(myExperiment.atlases):
# for c in a.compounds:
# print i,c.name,c.mz,c.pubchem_id
a = myExperiment.atlases[-1]
for i,c in enumerate(a.compounds):
print i,c.name,c.mz,c.pubchem_id
In [ ]:
print len(myExperiment.atlases[-1].compounds)
In [ ]:
# http://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/857,791,94244,614,1054,247,352038,107738,588,6140,80817,9837272,444109,938,6287,33032,118276,6057,6137,673,/property/MonoisotopicMass,MolecularFormula,InChI/CSV
import requests, json
# url = 'http://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/857/JSON'
url = 'http://pubchem.ncbi.nlm.nih.gov/rest/pug_view/data/compound/857/JSON'
r = requests.get(url)
d = r.json()
print d
# print d['Record']['Section'][2]['Section'][0]['Information'][0]['StringValue']
# print d
# print d['PC_Compounds'][0].keys()
# for p in d['PC_Compounds'][0]['id']:
# print p
# if 'name' in p['urn'].keys():
# print p['urn']['name'],p['urn']['label'],p['value']
In [ ]:
In [2]:
c1 = metatlas_objects.Compound(name = 'DL-Leucine',
formula = 'C6H13NO2',
adducts = 'H+',
mz = 132.10190559999998,
mz_threshold = 10,
rt_min = 6.93,
rt_max = 7.93,
rt_peak = 7.43,
neutral_mass = 131.0946296,
pubchem_id = 857)
c2 = metatlas_objects.Compound(name = 'DL-Isoleucine',
formula = 'C6H13NO2',
adducts = 'H+',
mz = 132.10190559999998,
mz_threshold = 10,
rt_min = 7.25,
rt_max = 8.25,
rt_peak = 7.75,
neutral_mass = 131.0946296,
pubchem_id = 791)
c3 = metatlas_objects.Compound(name = 'Leucyl-leucine',
formula = 'C12H24N2O3',
adducts = 'H+',
mz = 245.185969,
mz_threshold = 50,
rt_min = 3.9,
rt_max = 4.9,
rt_peak = 4.4,
neutral_mass = 244.178693,
pubchem_id = 94244)
c4 = metatlas_objects.Compound(name = 'DL-Proline',
formula = 'C5H9NO2',
adducts = 'H+',
mz = 116.070605,
mz_threshold = 10,
rt_min = 8.16,
rt_max = 9.16,
rt_peak = 8.66,
neutral_mass = 115.063329,
pubchem_id = 614)
c5 = metatlas_objects.Compound(name = 'Pyridoxine',
formula = 'C8H11NO3',
adducts = 'H+',
mz = 170.081169,
mz_threshold = 10,
rt_min = 2.17,
rt_max = 3.17,
rt_peak = 2.67,
neutral_mass = 169.073893,
pubchem_id = 1054)
c6 = metatlas_objects.Compound(name = 'Betaine',
formula = 'C5H11NO2',
adducts = 'H+',
mz = 118.086255,
mz_threshold = 10,
rt_min = 6.02,
rt_max = 7.02,
rt_peak = 6.52,
neutral_mass = 117.078979,
pubchem_id = 247)
c7 = metatlas_objects.Compound(name = 'Leu-Val',
formula = 'C11H22N2O3',
adducts = 'H+',
mz = 231.170319,
mz_threshold = 10,
rt_min = 5.03,
rt_max = 6.03,
rt_peak = 5.53,
neutral_mass = 230.163043,
pubchem_id = 352038)
c8 = metatlas_objects.Compound(name = 'Propionyl Carnitine',
formula = 'C10H19NO4',
adducts = 'NH4+', #18.033823
mz = 235.165231,
mz_threshold = 10,
rt_min = 6,
rt_max = 7,
rt_peak = 6.5,
neutral_mass = 217.131408,
pubchem_id = 107738)
c9 = metatlas_objects.Compound(name = 'Creatinine',
formula = 'C4H7N3O',
adducts = 'H+',
mz = 113.058912 + 1.007276,
mz_threshold = 10,
rt_min = 4.17,
rt_max = 5.17,
rt_peak = 4.67,
neutral_mass = 113.058912,
pubchem_id = 588)
c10 = metatlas_objects.Compound(name = 'Phenylalanine',
formula = 'C9H11NO2',
adducts = 'H+',
mz = 165.078979 + 1.007276,
mz_threshold = 10,
rt_min = 7.04,
rt_max = 8.04,
rt_peak = 7.54,
neutral_mass = 165.078979,
pubchem_id = 6140)
c11 = metatlas_objects.Compound(name = 'Leu-Pro',
formula = 'C11H20N2O3',
adducts = 'H+',
mz = 228.147393 + 1.007276,
mz_threshold = 10,
rt_min = 6.88,
rt_max = 7.88,
rt_peak = 7.38,
neutral_mass = 228.147393,
pubchem_id = 80817)
c12 = metatlas_objects.Compound(name = 'Val-Pro',
formula = 'C10H18N2O3',
adducts = 'H+',
mz = 214.131742 + 1.007276,
mz_threshold = 10,
rt_min = 7.44,
rt_max = 8.44,
rt_peak = 7.94,
neutral_mass = 214.131742,
pubchem_id = 9837272 )
c13 = metatlas_objects.Compound(name = 'Pro-Leu',
formula = 'C11H20N2O3',
adducts = 'H+',
mz = 228.147393 + 1.007276,
mz_threshold = 10,
rt_min = 5.47,
rt_max = 6.47,
rt_peak = 5.97,
neutral_mass = 228.147393,
pubchem_id = 444109 )
c14 = metatlas_objects.Compound(name = 'Nicotinic acid',
formula = 'C6H5NO2',
adducts = 'H+',
mz = 123.032028 + 1.007276,
mz_threshold = 10,
rt_min = 5.39,
rt_max = 6.39,
rt_peak = 5.89,
neutral_mass = 123.032028,
pubchem_id = 938 )
c15 = metatlas_objects.Compound(name = 'Valine',
formula = 'C5H11NO2',
adducts = 'H+',
mz = 117.078979 + 1.007276,
mz_threshold = 10,
rt_min = 8.43,
rt_max = 9.43,
rt_peak = 8.93,
neutral_mass = 117.078979,
pubchem_id = 6287 )
c16 = metatlas_objects.Compound(name = 'L-Glutamic Acid',
formula = 'C5H9NO4',
adducts = 'H+',
mz = 147.053158 + 1.007276,
mz_threshold = 10,
rt_min = 13.42,
rt_max = 14.42,
rt_peak = 13.92,
neutral_mass = 147.0531583,
pubchem_id = 33032 )
c17 = metatlas_objects.Compound(name = 'Leu-Met',
formula = 'C11H22N2O3S',
adducts = 'H+',
mz = 262.135114 + 1.007276,
mz_threshold = 10,
rt_min = 6.39,
rt_max = 7.39,
rt_peak = 6.89,
neutral_mass = 262.135114,
pubchem_id = 118276 )
c18 = metatlas_objects.Compound(name = 'Tyrosine',
formula = 'C9H11NO3',
adducts = 'H+',
mz = 181.073893 + 1.007276,
mz_threshold = 10,
rt_min = 9.53,
rt_max = 10.53,
rt_peak = 10.03,
neutral_mass = 181.073893,
pubchem_id = 6057 )
c19 = metatlas_objects.Compound(name = 'Methionine',
formula = 'C5H11NO2S',
adducts = 'H+',
mz = 149.05105 + 1.007276,
mz_threshold = 10,
rt_min = 8.09,
rt_max = 9.09,
rt_peak = 8.59,
neutral_mass = 149.05105,
pubchem_id = 6137 )
c20 = metatlas_objects.Compound(name = 'Adenosine',
formula = 'C10H13N5O4',
adducts = 'H+',
mz = 268.1040304,
mz_threshold = 10,
rt_min = 3.91,
rt_max = 4.91,
rt_peak = 4.41,
neutral_mass = 267.0967539,
pubchem_id = 60961 )
c21 = metatlas_objects.Compound(name = 'Histidine',
formula = '',
adducts = 'H+',
mz = 156.0766,
mz_threshold = 10,
rt_min = 13.68,
rt_max = 14.68,
rt_peak = 14.18,
neutral_mass = 155.0694,
pubchem_id = 6274 )
c22 = metatlas_objects.Compound(name = 'Tryptophan',
formula = 'C11H12N2O2',
adducts = 'H+',
mz = 205.0971541,
mz_threshold = 10,
rt_min = 8.02,
rt_max = 9.02,
rt_peak = 8.52,
neutral_mass = 204.0898776,
pubchem_id = 6305 )
c23 = metatlas_objects.Compound(name = 'Adenine',
formula = 'C5H5N5',
adducts = 'H+',
mz = 136.0617716,
mz_threshold = 10,
rt_min = 3.83,
rt_max = 4.83,
rt_peak = 4.33,
neutral_mass = 135.0544952,
pubchem_id = 190 )
c24 = metatlas_objects.Compound(name = 'Dimethylglycine',
formula = 'C4H9NO2',
adducts = 'H+',
mz = 103.063329 + 1.007276,
mz_threshold = 10,
rt_min = 11.44,
rt_max = 12.44,
rt_peak = 11.94,
neutral_mass = 103.063329 ,
pubchem_id = 673 )
c25 = metatlas_objects.Compound(name = 'Threonine',
formula = 'C11H20N2O3',
adducts = 'H+',
mz = 120.0656,
mz_threshold = 10,
rt_min = 11.03,
rt_max = 12.03,
rt_peak = 11.53,
neutral_mass = 119.0584,
pubchem_id = 6288 )
c26 = metatlas_objects.Compound(name = 'Alanine',
formula = '',
adducts = 'H+',
mz = 90.0555,
mz_threshold = 10,
rt_min = 10.72,
rt_max = 11.72,
rt_peak = 11.22,
neutral_mass = 89.0483,
pubchem_id = 5950 )
c27 = metatlas_objects.Compound(name = 'Serine',
formula = '',
adducts = 'H+',
mz = 106.0501,
mz_threshold = 10,
rt_min = 12.29,
rt_max = 13.29,
rt_peak = 12.79,
neutral_mass = 105.0429,
pubchem_id = 5951 )
# Rename and check! Isoprene 85.0898 86.097 15 NH4+ 7.89 6.89 7.39
# See if propionyl carnitine is right. weird that its an ammonium adduct.
In [14]:
url = 'https://docs.google.com/spreadsheets/d/1vh97rZwT9OGydqnVEQQaye-kVF3UtLSKWePzFeOdFXc'
def load_from_google_doc(url):
import requests
url = url.rpartition('/')[0]
r = requests.get(url + '/pub?output=csv')
print url + '/pub?output=csv'
print r.text
load_from_google_doc(url)
In [ ]: