Ejemplo n.º 1
0
def delete(adapter,
           variant_file,
           family_file,
           family_type='ped',
           case_id=None):
    """Delete a case and all of it's variants from the database"""

    vcf = get_vcf(variant_file)

    with open(family_file, 'r') as family_lines:
        family = get_family(family_lines=family_lines, family_type=family_type)

    family_id = family.family_id
    if case_id:
        family_id = case_id

    individuals = family.individuals
    vcf_individuals = vcf.samples
    ind_positions = {}
    for i, ind_id in enumerate(vcf_individuals):
        ind_positions[ind_id] = i

    delete_family(adapter=adapter, family_id=family_id)

    delete_variants(adapter=adapter,
                    vcf=vcf,
                    ind_positions=ind_positions,
                    family_id=family_id,
                    individuals=individuals)
Ejemplo n.º 2
0
def load_database(adapter, variant_file, family_file, nr_variants=None, 
                  family_type='ped', skip_case_id=False, gq_treshold=None, 
                  case_id=None):
    """Load the database with a case and its variants
            
            Args:
                  adapter
                  variant_file(str)
                  family_file(str)
                  family_type(str)
                  skip_case_id(bool)
 
    """

    vcf = get_vcf(variant_file)
    
    with open(family_file, 'r') as family_lines:
        family = get_family(
            family_lines=family_lines, 
            family_type=family_type
        )

    family_id = family.family_id
    
    if case_id:
        family_id = case_id

    if not family.affected_individuals:
        logger.warning("No affected individuals could be found in ped file")
    
    logger.info("Found affected individuals in ped file: {0}"
                .format(', '.join(family.affected_individuals)))

    load_family(
        adapter=adapter,
        case_id=family_id,
        vcf_path=variant_file
    )

    load_variants(  
        adapter=adapter, 
        family_id=family_id, 
        individuals=family.individuals,
        vcf=vcf,
        nr_variants=nr_variants,
        skip_case_id=skip_case_id,
        gq_treshold=gq_treshold,
    )
Ejemplo n.º 3
0
def load_database(
    adapter,
    variant_file,
    family_file,
    nr_variants=None,
    family_type="ped",
    skip_case_id=False,
    gq_treshold=None,
    case_id=None,
):
    """Load the database with a case and its variants
            
            Args:
                  adapter
                  variant_file(str)
                  family_file(str)
                  family_type(str)
                  skip_case_id(bool)
 
    """

    vcf = get_vcf(variant_file)

    with open(family_file, "r") as family_lines:
        family = get_family(family_lines=family_lines, family_type=family_type)

    family_id = family.family_id

    if case_id:
        family_id = case_id

    if not family.affected_individuals:
        logger.warning("No affected individuals could be found in ped file")

    logger.info("Found affected individuals in ped file: {0}".format(", ".join(family.affected_individuals)))

    load_family(adapter=adapter, case_id=family_id, vcf_path=variant_file)

    load_variants(
        adapter=adapter,
        family_id=family_id,
        individuals=family.individuals,
        vcf=vcf,
        nr_variants=nr_variants,
        skip_case_id=skip_case_id,
        gq_treshold=gq_treshold,
    )
Ejemplo n.º 4
0
def delete(adapter, variant_file, family_file, family_type="ped", case_id=None):
    """Delete a case and all of it's variants from the database"""

    vcf = get_vcf(variant_file)

    with open(family_file, "r") as family_lines:
        family = get_family(family_lines=family_lines, family_type=family_type)

    family_id = family.family_id
    if case_id:
        family_id = case_id

    individuals = family.individuals

    delete_family(adapter=adapter, family_id=family_id)

    delete_variants(adapter=adapter, vcf=vcf, family_id=family_id, individuals=individuals)
Ejemplo n.º 5
0
def delete(adapter,
           variant_file,
           family_file,
           family_type='ped',
           case_id=None):
    """Delete a case and all of it's variants from the database"""

    vcf = get_vcf(variant_file)

    with open(family_file, 'r') as family_lines:
        family = get_family(family_lines=family_lines, family_type=family_type)

    family_id = family.family_id
    if case_id:
        family_id = case_id

    individuals = family.individuals

    delete_family(adapter=adapter, family_id=family_id)

    delete_variants(adapter=adapter,
                    vcf=vcf,
                    family_id=family_id,
                    individuals=individuals)
Ejemplo n.º 6
0
def load_database(adapter,
                  variant_file,
                  family_file,
                  nr_variants=None,
                  family_type='ped',
                  skip_case_id=False,
                  gq_treshold=None,
                  case_id=None):
    """Load the database with a case and its variants
            
            Args:
                  adapter
                  variant_file(str)
                  family_file(str)
                  family_type(str)
                  skip_case_id(bool)
 
    """
    vcf = get_vcf(variant_file)

    if gq_treshold:
        if not vcf.contains('GQ'):
            logger.warning('Set gq-treshold to 0 or add info to vcf')
            raise SyntaxError('GQ is not defined in vcf header')

    with open(family_file, 'r') as family_lines:
        family = get_family(family_lines=family_lines, family_type=family_type)

    family_id = family.family_id

    if case_id:
        family_id = case_id

    if not family.affected_individuals:
        logger.warning("No affected individuals could be found in ped file")

    logger.debug("Found affected individuals in ped file: {0}".format(
        ', '.join(family.affected_individuals)))

    vcf_individuals = vcf.samples
    ind_positions = {}
    for i, ind_id in enumerate(vcf_individuals):
        ind_positions[ind_id] = i

    for ind_id in family.individuals:
        if ind_id not in ind_positions:
            raise CaseError(
                "Ind {0} in ped file does not exist in VCF".format(ind_id))

    load_family(adapter=adapter, case_id=family_id, vcf_path=variant_file)

    try:
        load_variants(
            adapter=adapter,
            family_id=family_id,
            individuals=family.individuals,
            vcf=vcf,
            ind_positions=ind_positions,
            nr_variants=nr_variants,
            skip_case_id=skip_case_id,
            gq_treshold=gq_treshold,
        )
    except Exception as err:
        logger.warning(err)
        ##TODO Delete inserted information here
        raise err