Exemplo n.º 1
0
    def search(self):
        if self.app.pargs.product is None:
            print("Argument --product must be provided")
            exit(1)

        result = products.search(self.app.pargs.product)
        if len(result) > 0:
            print(result[['name', 'formula', 'mass', 'search_rank']])
        else:
            print("No results found")
Exemplo n.º 2
0
 def __translate_product_to_universal_reactions_model_metabolite(self, product, database):
     if isinstance(product, Metabolite):
         return product
     elif isinstance(product, str):
         search_result = products.search(product)
         notice("Found %d compounds that match query '%s'" % (len(search_result), product))
         self.__display_product_search_result(search_result)
         notice("Choosing best match (%s) ... please interrupt if this is not the desired compound."
                % search_result.name[0])
         self.__display_compound(search_result.InChI[0])
         return database.metabolites.get_by_id(search_result.index[0])
Exemplo n.º 3
0
 def translate_product_to_universal_reactions_model_metabolite(self, product, database):
     if isinstance(product, Metabolite):
         return product
     elif isinstance(product, six.text_type) or isinstance(product, six.string_types):
         search_result = products.search(product)
         search_result = search_result.loc[[i for i in search_result.index if i in database.metabolites]]
         if len(search_result) == 0:
             raise KeyError("No compound matches found for query %s" % product)
         notice("Found %d compounds that match query '%s'" % (len(search_result), product))
         self.__display_product_search_result(search_result)
         notice("Choosing best match (%s) ... please interrupt if this is not the desired compound."
                % search_result.name.values[0])
         self.__display_compound(search_result.InChI.values[0])
         return database.metabolites.get_by_id(search_result.index[0])
Exemplo n.º 4
0
 def __translate_product_to_universal_reactions_model_metabolite(
         self, product, database):
     if isinstance(product, Metabolite):
         return product
     elif isinstance(product, str):
         search_result = products.search(product)
         notice("Found %d compounds that match query '%s'" %
                (len(search_result), product))
         self.__display_product_search_result(search_result)
         notice(
             "Choosing best match (%s) ... please interrupt if this is not the desired compound."
             % search_result.name[0])
         self.__display_compound(search_result.InChI[0])
         return database.metabolites.get_by_id(search_result.index[0])
Exemplo n.º 5
0
 def translate_product_to_universal_reactions_model_metabolite(self, product, database):
     if isinstance(product, Metabolite):
         return product
     elif isinstance(product, six.text_type) or isinstance(product, six.string_types):
         search_result = products.search(product)
         search_result = search_result.loc[[i for i in search_result.index if i in database.metabolites]]
         if len(search_result) == 0:
             raise KeyError("No compound matches found for query %s" % product)
         notice("Found %d compounds that match query '%s'" % (len(search_result), product))
         self.__display_product_search_result(search_result)
         notice("Choosing best match (%s) ... please interrupt if this is not the desired compound."
                % search_result.name.values[0])
         self.__display_compound(search_result.InChI.values[0])
         return database.metabolites.get_by_id(search_result.index[0])
Exemplo n.º 6
0
Arquivo: cli.py Projeto: weif000/cameo
def search(product):
    """Search for available products.

    PRODUCT: The target product. You can search by name, InChI, and metanetx ID.

    \b
    Examples
    --------
    $ cameo search chebi:30838  # search for itaconate
    """
    click.echo('Loading product database ...')
    from cameo.api.products import products
    click.echo('Searching product database ...')
    result = products.search(product)
    if len(result) > 0:
        click.echo('The following products were found:')
        click.echo(result[['name', 'formula', 'mass', 'InChI', 'search_rank']])
    else:
        click.echo("No products could be found that match the search query.")
Exemplo n.º 7
0
def search(product):
    """Search for available products.

    PRODUCT: The target product. You can search by name, InChI, and metanetx ID.

    \b
    Examples
    --------
    $ cameo search chebi:30838  # search for itaconate
    """
    click.echo('Loading product database ...')
    from cameo.api.products import products
    click.echo('Searching product database ...')
    result = products.search(product)
    if len(result) > 0:
        click.echo('The following products were found:')
        click.echo(result[['name', 'formula', 'mass', 'InChI', 'search_rank']])
    else:
        click.echo("No products could be found that match the search query.")