Пример #1
0
def cli(fastqs, database, **kwargs):
    """Search ST number from FASTQS(.gz) raw reads using an mlst DATABASE."""

    try:
        with pymlst.open_cla(os.path.abspath(database)) as mlst:
            mlst.multi_read(fastqs, **utils.clean_kwargs(kwargs))

    except exceptions.PyMLSTError as err:
        raise click.ClickException(str(err))
Пример #2
0
def cli(genomes, database, **kwargs):
    """Search ST number for an assembly GENOME using an mlst DATABASE."""

    try:
        with pymlst.open_cla(os.path.abspath(database)) as mlst:
            mlst.multi_search(genomes, **utils.clean_kwargs(kwargs))

    except exceptions.PyMLSTError as err:
        raise click.ClickException(str(err))
Пример #3
0
def cli(database, **kwargs):
    """Remove ALLELE sequence from the GENE on a mlst DATABASE."""
    
    try:
        with pymlst.open_cla(os.path.abspath(database)) as mlst:
            mlst.remove_allele(**utils.clean_kwargs(kwargs))
                
    except exceptions.PyMLSTError as err:
        raise click.ClickException(str(err))
Пример #4
0
def cli(force, prompt, mlst, database, species):
    """Create a claMLST DATABASE from an online resource.

    The research can be filtered by adding a SPECIES name."""

    utils.create_logger()

    try:

        if os.path.exists(database):
            if force:
                open(database, "w").close()
            else:
                raise exceptions.PyMLSTError(
                    "Database alreadly exists, use --force to override it")

        url = web.retrieve_mlst(' '.join(species), prompt, mlst)

        if url is None:
            logging.info('No choice selected')
            return

        logging.info('Downloading mlst...')

        with tempfile.TemporaryDirectory() as tmp_dir, \
                pymlst.open_cla(os.path.abspath(database)) as mlst_db:

            web.get_mlst_files(url, tmp_dir)

            mlst_db.create(open(tmp_dir + '/profiles.csv', 'rt'), [
                open(tmp_dir + '/locus/' + locus, 'r')
                for locus in os.listdir(tmp_dir + '/locus')
            ])

    except requests.exceptions.HTTPError:
        raise click.ClickException('Could not retrieve online data')
    except requests.exceptions.ConnectionError:
        raise click.ClickException(
            'Could not access to the server, please verify your internet connection'
        )
    except requests.exceptions.Timeout:
        raise click.ClickException('The server took too long to respond')
    except web.StructureError:
        raise click.ClickException(
            'It seems like the structure of the website/API changed '
            'since this application was developed.')
    except exceptions.PyMLSTError as err:
        raise click.ClickException(str(err))
Пример #5
0
def cli(force, database, scheme, alleles):
    """Create a classical MLST DATABASE from a SCHEME csv and ALLELES files."""

    try:

        if os.path.exists(database):
            if force:
                open(database, "w").close()
            else:
                raise exceptions.PyMLSTError(
                    "Database alreadly exists, use --force to override it")

        with pymlst.open_cla(os.path.abspath(database)) as mlst:
            mlst.create(scheme, alleles)

    except exceptions.PyMLSTError as err:
        raise click.ClickException(str(err))
Пример #6
0
def cla():
    with pymlst.open_cla() as cla_mlst:
        yield cla_mlst