Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def analyzeSpaceDistribution(analyzedModels):
bio = bioservices.BioModels()
number,spaceCovered = zip(*analyzedModels)
hist,bin_edges = np.histogram(spaceCovered,bins=5)
binIndexArray = np.digitize(spaceCovered,bin_edges)
modelAnnotationBin = defaultdict(list)
for element,binIndex in zip(number,binIndexArray):
try:
info = bio.getSimpleModelsByIds('BIOMD%010i' % element)
parsedInfo = bioservices.Service('name').easyXML(info)
modelName = stats.removeTags(str(parsedInfo['modelname'][0]))
modelName = modelName.split(' - ')
if len(modelName) > 1:
modelName = modelName[1]
else:
modelName = modelName[0].split('_')
if len(modelName) > 1:
modelName = ' '.join(modelName[1:])
else:
modelName = modelName[0]
print element,binIndex
modelAnnotationBin[binIndex].append(modelName)
except:
print parsedInfo
break
print modelAnnotationBin
def analyzeGroupingCDF():
bio = bioservices.BioModels()
with open('groupedProcessList.dump','rb') as f:
groupedDict = pickle.load(f)
elementList,groupedProcessList,redundantProcessList = zip(*groupedDict)
hist,bin_edges = np.histogram(redundantProcessList,bins=5)
binIndexArray = np.digitize(redundantProcessList,bin_edges)
modelAnnotationBin = defaultdict(list)
for element,binIndex in zip(elementList,binIndexArray):
try:
info = bio.getSimpleModelsByIds('BIOMD%010i' % element)
parsedInfo = bioservices.Service('name').easyXML(info)
modelName = stats.removeTags(str(parsedInfo['modelname'][0]))
modelName = modelName.split(' - ')
if len(modelName) > 1:
modelName = modelName[1]
else:
modelName = modelName[0].split('_')
if len(modelName) > 1:
modelName = ' '.join(modelName[1:])
else:
modelName = modelName[0]
print element,binIndex
modelAnnotationBin[binIndex].append((element,modelName))
except:
print parsedInfo
break
print modelAnnotationBin
resolveAnnotation.db['http://identifiers.org/uniprot/P07006'] = 'http://identifiers.org/uniprot/P06842'
if annotation in resolveAnnotation.db:
return annotation,resolveAnnotation.db[annotation]
tAnnotation = annotation.replace('%3A',':')
tAnnotation = annotation.split('/')[-1]
#tAnnotation = re.search(':([^:]+:[^:]+$)',tAnnotation).group(1)
try:
if 'obo.go' in annotation or '/go/GO' in annotation:
res = resolveAnnotation.qg.Term(tAnnotation)
finalArray = []
if type(res) not in [int]:
res = bioservices.Service('name').easyXML(res)
tmp = res.findAll('name')
for x in tmp:
try:
tagString = str(goGrammar.parseString(str(x))[0])
if tagString not in ['Systematic synonym']:
finalArray.append(str(goGrammar.parseString(str(x))[0]))
except pyp.ParseBaseException:
continue
if len(finalArray) > 0:
resolveAnnotation.db[annotation] = finalArray[0]
else:
resolveAnnotation.db[annotation] = ''
finalAnnotation = resolveAnnotation.db[annotation]
elif 'kegg' in annotation:
#with open('ratomization.dump','rb') as f:
# ratomizationDict = pickle.load(f)
for x,z,w in zip(rulesLength,number,evaluation2):
if x>=0:
trueRatio.append([z,1-w])
bio = bioservices.BioModels()
modelAnnotationArray = []
for element,compression in trueRatio:
try:
info = bio.getSimpleModelsByIds('BIOMD%010i' % element)
parsedInfo = bioservices.Service('name').easyXML(info)
modelName = removeTags(str(parsedInfo['modelname'][0]))
modelName = modelName.split(' - ')
if len(modelName) > 1:
modelName = modelName[1]
else:
modelName = modelName[0].split('_')
if len(modelName) > 1:
modelName = ' '.join(modelName[1:])
else:
modelName = modelName[0]
modelAnnotationArray.append([element,compression,modelName])
print modelAnnotationArray[-1]
except:
print parsedInfo
break
with open('compressionAnnotation.dump','wb') as f:
def analyzeGroupingCDF():
bio = bioservices.BioModels()
with open('groupedProcessList.dump', 'rb') as f:
groupedDict = pickle.load(f)
elementList, groupedProcessList, redundantProcessList = zip(*groupedDict)
hist, bin_edges = np.histogram(redundantProcessList, bins=5)
binIndexArray = np.digitize(redundantProcessList, bin_edges)
modelAnnotationBin = defaultdict(list)
for element, binIndex in zip(elementList, binIndexArray):
try:
info = bio.getSimpleModelsByIds('BIOMD%010i' % element)
parsedInfo = bioservices.Service('name').easyXML(info)
modelName = stats.removeTags(str(parsedInfo['modelname'][0]))
modelName = modelName.split(' - ')
if len(modelName) > 1:
modelName = modelName[1]
else:
modelName = modelName[0].split('_')
if len(modelName) > 1:
modelName = ' '.join(modelName[1:])
else:
modelName = modelName[0]
print element, binIndex
modelAnnotationBin[binIndex].append((element, modelName))
except:
print parsedInfo
break
print modelAnnotationBin
def resolveAnnotation(annotation):
if not hasattr(resolveAnnotation, 'db'):
resolveAnnotation.db = {}
resolveAnnotation.ch = bioservices.ChEBI(verbose=False)
resolveAnnotation.bio = bioservices.BioModels(verbose=False)
resolveAnnotation.uni = bioservices.UniProt(verbose=False)
resolveAnnotation.k = bioservices.kegg.KeggParser(verbose=False)
resolveAnnotation.s = bioservices.Service('name')
resolveAnnotation.qg = bioservices.QuickGO(verbose=False)
resolveAnnotation.db['http://identifiers.org/uniprot/P62988'] = 'http://identifiers.org/uniprot/P62988'
resolveAnnotation.db['http://identifiers.org/uniprot/P06842'] = 'http://identifiers.org/uniprot/P06842'
resolveAnnotation.db['http://identifiers.org/uniprot/P07006'] = 'http://identifiers.org/uniprot/P06842'
if annotation in resolveAnnotation.db:
return resolveAnnotation.db[annotation]
tAnnotation = annotation.replace('%3A',':')
tAnnotation = annotation.split('/')[-1]
#tAnnotation = re.search(':([^:]+:[^:]+$)',tAnnotation).group(1)
tmpArray = {}
try:
if 'obo.go' in annotation:
res = resolveAnnotation.qg.Term(tAnnotation)
def resolveAnnotation(annotation):
if not hasattr(resolveAnnotation, 'db'):
resolveAnnotation.db = {}
resolveAnnotation.ch = bioservices.ChEBI(verbose=False)
resolveAnnotation.bio = bioservices.BioModels(verbose=False)
resolveAnnotation.uni = bioservices.UniProt(verbose=False)
resolveAnnotation.k = bioservices.kegg.KeggParser(verbose=False)
resolveAnnotation.s = bioservices.Service('name')
resolveAnnotation.qg = bioservices.QuickGO(verbose=False)
resolveAnnotation.db['http://identifiers.org/uniprot/P62988'] = 'http://identifiers.org/uniprot/P62988'
resolveAnnotation.db['http://identifiers.org/uniprot/P06842'] = 'http://identifiers.org/uniprot/P06842'
resolveAnnotation.db['http://identifiers.org/uniprot/P07006'] = 'http://identifiers.org/uniprot/P06842'
if annotation in resolveAnnotation.db:
return resolveAnnotation.db[annotation]
tAnnotation = annotation.replace('%3A',':')
tAnnotation = annotation.split('/')[-1]
#tAnnotation = re.search(':([^:]+:[^:]+$)',tAnnotation).group(1)
tmpArray = {}
if 'obo.go' in annotation:
res = resolveAnnotation.qg.Term(tAnnotation)
tmp = res.findAll('name')
def analyzeSpaceDistribution(analyzedModels):
bio = bioservices.BioModels()
number,spaceCovered = zip(*analyzedModels)
hist,bin_edges = np.histogram(spaceCovered,bins=5)
binIndexArray = np.digitize(spaceCovered,bin_edges)
modelAnnotationBin = defaultdict(list)
for element,binIndex in zip(number,binIndexArray):
try:
info = bio.getSimpleModelsByIds('BIOMD%010i' % element)
parsedInfo = bioservices.Service('name').easyXML(info)
modelName = stats.removeTags(str(parsedInfo['modelname'][0]))
modelName = modelName.split(' - ')
if len(modelName) > 1:
modelName = modelName[1]
else:
modelName = modelName[0].split('_')
if len(modelName) > 1:
modelName = ' '.join(modelName[1:])
else:
modelName = modelName[0]
print element,binIndex
modelAnnotationBin[binIndex].append(modelName)
except:
print parsedInfo
break
print modelAnnotationBin
resolveAnnotation.db['http://identifiers.org/uniprot/P62988'] = 'http://identifiers.org/uniprot/P62988'
resolveAnnotation.db['http://identifiers.org/uniprot/P06842'] = 'http://identifiers.org/uniprot/P06842'
resolveAnnotation.db['http://identifiers.org/uniprot/P07006'] = 'http://identifiers.org/uniprot/P06842'
if annotation in resolveAnnotation.db:
return annotation,resolveAnnotation.db[annotation]
tAnnotation = annotation.replace('%3A',':')
tAnnotation = annotation.split('/')[-1]
#tAnnotation = re.search(':([^:]+:[^:]+$)',tAnnotation).group(1)
try:
if 'obo.go' in annotation or '/go/GO' in annotation:
res = resolveAnnotation.qg.Term(tAnnotation)
res = bioservices.Service('name').easyXML(res)
tmp = res.findAll('name')
finalArray = []
for x in tmp:
try:
tagString = str(goGrammar.parseString(str(x))[0])
if tagString not in ['Systematic synonym']:
finalArray.append(str(goGrammar.parseString(str(x))[0]))
except pyp.ParseBaseException:
continue
resolveAnnotation.db[annotation] = finalArray
finalAnnotation = resolveAnnotation.db[annotation]
elif 'kegg' in annotation:
data = resolveAnnotation.k.get(tAnnotation)