コード例 #1
0
    def get(self, ref_taxonid, comp_taxonid, chromosome):

        # check that the reference species are available in the application
        ref_species_exists = check_species_exists(ref_taxonid)
        if ref_species_exists is False:
            message = f'The species with ID: <{ref_taxonid}> is not represented in the database ' \
                      f'and thus there is no associated genes data.'
            raise InvalidRequestArgumentValueException(400, message)

        # check that the comparison species are available in the application
        comp_species_exists = check_species_exists(comp_taxonid)
        if comp_species_exists is False:
            message = f'The species with ID: <{comp_taxonid}> is not represented in the database ' \
                      f'and thus there is no associated genes data.'
            raise InvalidRequestArgumentValueException(400, message)

        # check that the reference chromosome is valid (for that species)
        chromosome_exists = check_chromosome_exists(ref_taxonid, chromosome)
        if chromosome_exists is False:
            message = f'The species with ID: <{ref_taxonid}> does not have chromosome: <{chromosome}>'
            raise InvalidRequestArgumentValueException(400, message)

        res = get_homologs_by_species_ids_and_reference_chromosome(
            ref_taxonid, comp_taxonid, chromosome)
        return res, 200
    def get(self, species_id, trait_id, chromosome):
        """
        Returns SNP variants data for the specified species, trait and chromosome.
        """

        # check whether the specified species is available in the application
        species_exists = check_species_exists(species_id)
        if species_exists is False:
            message = f'The species with ID: <{species_id}> is not represented in the database and thus there is ' \
                      f'no associated SNP variants data.'
            raise InvalidRequestArgumentValueException(400, message)

        # check whether there is data available for that trait
        trait_exists = check_trait_exists(species_id, trait_id)
        if trait_exists is False:
            message = f'The species with ID: <{species_id}> is represented in the database, ' \
                      f'but there is no SNP variants data available for trait with ID: <{trait_id}>. ' \
                      f'Please check the documentation to make sure the correct trait ID is provided.'
            raise InvalidRequestArgumentValueException(400, message)

        # check that the specified chromosome is valid (for that species)
        chromosome_exists = check_chromosome_exists(species_id, chromosome)
        if chromosome_exists is False:
            message = f'The species with ID: <{species_id}> is represented in the database, ' \
                      f'but has no associated data for chromosome: <{chromosome}>.'
            raise InvalidRequestArgumentValueException(400, message)

        res = get_snps_by_species_trait_and_chromosome(species_id, trait_id,
                                                       chromosome)
        return res, 200
コード例 #3
0
    def get(self, species_id):
        """
        Returns cytogenetic bands data for the specified species.
        """
        species_exists = check_species_exists(species_id)

        if species_exists is False:
            message = f'The species with ID: <{species_id}> is not represented in the database and thus there is ' \
                      f'no associated bands data.'
            raise InvalidRequestArgumentValueException(400, message)

        res = get_bands_by_species(species_id)
        return res, 200
コード例 #4
0
def _get_genes_data_by_species_and_chromosome(species_id, chromosome):
    """
    Calls a service to get features based on specific species and chromosome, checks the result and handles a response.

    :param species_id: NCBI species ID, such as 9606 (H. sapiens), 10090 (M. musculus), etc.
    :param chromosome: species chromosome ID
    :return: a list of Gene objects (or an empty) and a status code
    """
    res = get_genes_by_species_chromosome(species_id, chromosome)

    if not res:
        species_exists = check_species_exists(species_id)
        if species_exists:
            message = f'The species with ID: <{species_id}> is represented in the database, ' \
                      f'but has no associated data for chromosome: <{chromosome}>.'
        else:
            message = f'The species with ID: <{species_id}> is not represented in the database and thus there is ' \
                      f'no associated genes data.'
        abort(400, message=message)
    return res, 200
コード例 #5
0
    def get(self, species_id, chromosome):
        """
        Returns cytogenetic bands data for the specified species and chromosome.
        """

        # check that the species are available in the application
        species_exists = check_species_exists(species_id)
        if species_exists is False:
            message = f'The species with ID: <{species_id}> is not represented in the database and thus there is ' \
                      f'no associated cytogenetic bands data.'
            raise InvalidRequestArgumentValueException(400, message)

        # check that the specified chromosome is valid (for that species)
        chromosome_exists = check_chromosome_exists(species_id, chromosome)
        if chromosome_exists is False:
            message = f'The species with ID: <{species_id}> is represented in the database, ' \
                      f'but has no associated data for chromosome: <{chromosome}>.'
            raise InvalidRequestArgumentValueException(400, message)

        res = get_bands_by_species_and_chromosome(species_id, chromosome)
        return res, 200