parameters: (map_data)
return_statement: return bad_segments, missing_multimarkers, missing_stoich, missing_gene_names
docstring: Check reactions and metabolites.
  
      1. Make sure that nodes exist on either end of each segment
  
      2. check that every metabolite is represented with stoichiometry information
  
      3. that every gene in the gene_reaction_rule has a name
docstring_summary: Check reactions and metabolites.
docstring_tokens: Check reactions and metabolites .
function: def check_map(map_data):
      """Check reactions and metabolites.
  
      1. Make sure that nodes exist on either end of each segment
  
      2. check that every metabolite is represented with stoichiometry information
  
      3. that every gene in the gene_reaction_rule has a name
  
      """
      reactions = map_data[1]['reactions'];
      nodes = map_data[1]['nodes'];
      bad_segments = []
      missing_multimarkers = []
      missing_stoich = []
      missing_gene_names = []
      for _, reaction in reactions.items():
          metabolites = reaction['metabolites']
          for segment_id, segment in reaction['segments'].items():
              for n in ['to_node_id', 'from_node_id']:
                  # check that the node exists
                  if segment[n] not in nodes:
                      bad_segments.append((n, segment_id))
                  else:
                      # check that the coefficients exist and are non-zero
                      node = nodes[segment[n]]
                      if node['node_type'] == 'metabolite':
                          if not any((node['bigg_id'] == m['bigg_id'] and abs(m['coefficient']) > 0) for m in metabolites):
                              missing_stoich.append((n, segment_id))
  
          # check gene reaction rule
          found_genes = genes_for_gene_reaction_rule(reaction['gene_reaction_rule'])
          for found_gene in found_genes:
              if not any((found_gene == g['bigg_id'] and 'name' in g) for g in reaction['genes']):
                  missing_gene_names.append(found_gene)
      return bad_segments, missing_multimarkers, missing_stoich, missing_gene_names
function_tokens: def check_map ( map_data ) : reactions = map_data [ 1 ] [ 'reactions' ] nodes = map_data [ 1 ] [ 'nodes' ] bad_segments = [ ] missing_multimarkers = [ ] missing_stoich = [ ] missing_gene_names = [ ] for _ , reaction in reactions . items ( ) : metabolites = reaction [ 'metabolites' ] for segment_id , segment in reaction [ 'segments' ] . items ( ) : for n in [ 'to_node_id' , 'from_node_id' ] : # check that the node exists if segment [ n ] not in nodes : bad_segments . append ( ( n , segment_id ) ) else : # check that the coefficients exist and are non-zero node = nodes [ segment [ n ] ] if node [ 'node_type' ] == 'metabolite' : if not any ( ( node [ 'bigg_id' ] == m [ 'bigg_id' ] and abs ( m [ 'coefficient' ] ) > 0 ) for m in metabolites ) : missing_stoich . append ( ( n , segment_id ) ) # check gene reaction rule found_genes = genes_for_gene_reaction_rule ( reaction [ 'gene_reaction_rule' ] ) for found_gene in found_genes : if not any ( ( found_gene == g [ 'bigg_id' ] and 'name' in g ) for g in reaction [ 'genes' ] ) : missing_gene_names . append ( found_gene ) return bad_segments , missing_multimarkers , missing_stoich , missing_gene_names