In [5]:
import sys
#sys.path.insert(0,'/global/project/projectdirs/metatlas/anaconda/lib/python2.7/site-packages' )
from metatlas import metatlas_objects as metob
import qgrid
%matplotlib notebook
import pandas as pd
print metob.database
In [14]:
#c = metob.retrieve('Groups', description='15_42h')
atlas = metob.retrieve('Atlas',name = '%_KZ_%',username='*')
len(atlas)
atlase_names = list()
for cc in atlas:
atlase_names.append(cc.name)
#print cc.compound_identifications
print atlase_names
In [3]:
#make file info template sheet by selecting a folder:
# bpb@edison06:/project/projectdirs/metatlas/raw_data/lpsilva> ls -lta
# total 3584
# drwxrws--- 17 silvest metatlas 131072 Oct 11 10:18 ..
# drwxrws--- 2 silvest metatlas 131072 Sep 29 15:30 Actinobacillus test
# drwxrws--- 2 silvest metatlas 262144 Sep 29 14:13 20150521_LPSilva_Actino_C18_NEG_51isolates
# drwxrws--- 2 silvest metatlas 262144 Sep 29 13:43 20150514_LPSilva_Actino_C18_POS_51isolates
# drwxrws--- 2 silvest metatlas 262144 Sep 29 13:09 20150512_LPSilva_Actino_HILIC_NEG_51isolates
# drwxrws--- 2 silvest metatlas 262144 Sep 29 11:46 20150504_LPSilva_Actino_HILIC_POS_51isolates
# files = metob.retrieve('LcmsRun',mzml_file='%katezh/20151016_%')
files = metob.retrieve('LcmsRun',experiment='20160203_KBL-BC_Root-Exudate_Hilic_QExactive_Trial-Run', username='*')
# files = metob.retrieve('LcmsRun',mzml_file='%_LPSilva_Actino_%_51isolates%', username='*')
flist = []
for f in files:
flist.append(f.mzml_file)
import numpy as np
flist = np.unique(flist)
print len(flist)
In [14]:
files[0]
Out[14]:
In [4]:
#dump all the files to a spreadheet, download it, and make a "filled in" one.
with open('FileInfo_Sheet_Unique_20160203_KBL-BC_Root-Exudate_Hilic_QExactive_Trial-Run.tab','w') as fid:
fid.write('mzml_file\tgroup\tdescription\n')
for f in flist:
fid.write('%s\t\t\n'%f)
In [5]:
#Download the fileinfo sheet and fill it in!
df = pd.read_csv('FileInfo_Sheet_Unique_20160203_KBL-BC_Root-Exudate_Hilic_QExactive_Trial-Run.tab',sep='\t')
df
Out[5]:
In [6]:
grouped = df.groupby(by='group')
# list(grouped)
In [16]:
grouped.groups.keys()
Out[16]:
In [17]:
# metob.retrieve('LcmsRun',mzml_file='%0150115_pHILIC_NEG_MSMS_R2A-1An%',username='*')
In [7]:
for g in grouped.groups.keys():
indices = grouped.groups[g]
myGroup = metob.Group()
myGroup.name = '%s'%g
myGroup.description = df.loc[indices[0],'description']
file_set = []
for i in indices:
file_set.append(metob.retrieve('LcmsRun',mzml_file='%%%s'%df.loc[i,'mzml_file'],username='*')[0])
myGroup.items = file_set
metob.store(myGroup)
In [19]:
g = metob.retrieve('Groups',name = '%_KBL_PS_%')
print len(g)
for gg in g:
print gg.name
for i in gg.items:
print i.name
print " "
In [ ]:
In [ ]: