Skip to content
Snippets Groups Projects
Select Git revision
  • 278b28bc69178f1cdebed0e6411345f5c8599eba
  • master default protected
2 results

main.py

Blame
  • dbxref.py 926 B
    def dbxrefs_from_documents(documents):
      refs = set()
      for key in documents:
        refs.update(dbxrefs_from_document(documents[key]))
      return refs
    
    def dbxrefs_from_document(document):
      '''finds all dbxrefs in the document and returns a list of ids'''
      refs = []
      for c in document['computations']:
        for r in c['results']:
            if 'target'in r and 'dbxref' in r['target']:
                refs.append(r['target']['dbxref'])
      return set(refs)
    
    def combine_with_documents(documents, informations):
      for k in documents:
        combine_with_document(documents[k], informations)
    
    def combine_with_document(document, informations):
      '''adds an information tag for each result that references a dbxref'''
      for c in document['computations']:
        for r in c['results']:
          if 'target' in r and 'dbxref' in r['target']:
            r['informations'] = next(entry for entry in informations if entry['id'] == r['target']['dbxref'])