Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def resolveAnnotationHelper(annotation):
if not hasattr(resolveAnnotation, 'db'):
resolveAnnotation.db = {}
resolveAnnotation.ch = bioservices.ChEBI(verbose=False)
resolveAnnotation.uni = bioservices.UniProt(verbose=False)
resolveAnnotation.k = bioservices.kegg.KEGG(verbose=False)
resolveAnnotation.qg = bioservices.QuickGO(verbose=False)
resolveAnnotation.t = bioservices.Taxon()
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:
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:
def resolveAnnotation(annotation):
if not hasattr(resolveAnnotation, 'db'):
resolveAnnotation.db = {}
resolveAnnotation.ch = bioservices.ChEBI(verbose=False)
resolveAnnotation.uni = bioservices.UniProt(verbose=False)
resolveAnnotation.k = bioservices.kegg.KeggParser(verbose=False)
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)
try:
if 'obo.go' in annotation:
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:
def resolveAnnotation(annotation):
if not hasattr(resolveAnnotation, 'db'):
resolveAnnotation.db = {}
resolveAnnotation.ch = bioservices.ChEBI(verbose=False)
resolveAnnotation.uni = bioservices.UniProt(verbose=False)
resolveAnnotation.k = bioservices.kegg.KEGGParser(verbose=False)
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 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:
def __init__(self, verbose=False):
self.u = UniProt(verbose=verbose)
self.sequences = {}
def __init__(self, verbosity="INFO"):
super(Mapper, self).__init__(level=verbosity)
self.logging.info("Initialising the services")
self.logging.info("... uniprots")
self._uniprot_service = UniProt()
self.logging.info("... KEGG")
self._kegg_service = KeggParser(verbose=False)
self.logging.info("... HGNC")
self._hgnc_service = HGNC()
self.logging.info("... UniChem")
self._unichem_service = UniChem()
self.logging.info("...BioDBNet")
self._biodbnet = BioDBNet()
def __main__():
ids = sys.argv[1]
filename = sys.argv[2]
# TODO: check the validity and format ?
try:
from bioservices import UniProt
u = UniProt(verbose=False)
u.debugLevel = "ERROR"
except ImportError:
print("Could not import bioservoces ? Check that it is installed. Try 'pip install bioservices'")
try:
fasta = u.searchUniProtId(ids, "fasta")
except:
print("An error occured while fetching the FASTA file from uniprot")
try:
fh = open(filename, "w")
fh.write(fasta)
fh.close()
except:
print("could not save the FASTA file")