Example #1
0
    def add_case(self, case_obj, vtype='snv', mode='vcf', ped_svg=None):
        """Load a case with individuals.

        Args:
            case_obj (puzzle.models.Case): initialized case model
        """
        new_case = Case(case_id=case_obj['case_id'],
                        name=case_obj['name'],
                        variant_source=case_obj['variant_source'],
                        variant_type=vtype,
                        variant_mode=mode,
                        pedigree=ped_svg)

        # build individuals
        inds = [Individual(
            ind_id=ind['ind_id'],
            mother=ind['mother'],
            father=ind['father'],
            sex=ind['sex'],
            phenotype=ind['phenotype'],
            ind_index=ind['index'],
            variant_source=ind['variant_source'],
            bam_path=ind['bam_path'],
        ) for ind in case_obj['individuals']]

        new_case.individuals = inds
        self.session.add(new_case)
        self.save()
        return new_case
Example #2
0
    def add_case(self, case_obj, vtype='snv', mode='vcf', ped_svg=None):
        """Load a case with individuals.

        Args:
            case_obj (puzzle.models.Case): initialized case model
        """
        new_case = Case(case_id=case_obj.case_id,
                        name=case_obj.name,
                        variant_source=case_obj.variant_source,
                        variant_type=vtype,
                        variant_mode=mode,
                        pedigree=ped_svg)

        # build individuals
        inds = [Individual(
            ind_id=ind.ind_id,
            name=ind.name,
            mother=ind.mother,
            father=ind.father,
            sex=ind.sex,
            phenotype=ind.phenotype,
            ind_index=ind.ind_index,
            variant_source=ind.variant_source,
            bam_path=ind.bam_path,
        ) for ind in case_obj.individuals]

        new_case.individuals = inds
        self.session.add(new_case)
        self.save()
        return new_case
Example #3
0
    def add_case(self, case_obj, vtype="snv", mode="vcf", ped_svg=None):
        """Load a case with individuals.

        Args:
            case_obj (puzzle.models.Case): initialized case model
        """
        new_case = Case(
            case_id=case_obj["case_id"],
            name=case_obj["name"],
            variant_source=case_obj["variant_source"],
            variant_type=vtype,
            variant_mode=mode,
            pedigree=ped_svg,
        )

        # build individuals
        inds = [
            Individual(
                ind_id=ind["ind_id"],
                mother=ind["mother"],
                father=ind["father"],
                sex=ind["sex"],
                phenotype=ind["phenotype"],
                ind_index=ind["index"],
                variant_source=ind["variant_source"],
                bam_path=ind["bam_path"],
            )
            for ind in case_obj["individuals"]
        ]

        new_case.individuals = inds
        self.session.add(new_case)
        self.save()
        return new_case
Example #4
0
    def add_case(self, case_obj, vtype='snv', mode='vcf', ped_svg=None):
        """Load a case with individuals.

        Args:
            case_obj (puzzle.models.Case): initialized case model
        """
        new_case = Case(case_id=case_obj.case_id,
                        name=case_obj.name,
                        variant_source=case_obj.variant_source,
                        variant_type=vtype,
                        variant_mode=mode,
                        pedigree=ped_svg,
                        compressed=case_obj.compressed,
                        tabix_index=case_obj.tabix_index)

        # build individuals
        inds = [Individual(
            ind_id=ind.ind_id,
            name=ind.name,
            mother=ind.mother,
            father=ind.father,
            sex=ind.sex,
            phenotype=ind.phenotype,
            ind_index=ind.ind_index,
            variant_source=ind.variant_source,
            bam_path=ind.bam_path,
        ) for ind in case_obj.individuals]
        new_case.individuals = inds
        
        if self.case(new_case.case_id):
            logger.warning("Case already exists in database!")
        else:
            self.session.add(new_case)
            self.save()
        return new_case
Example #5
0
def add_case():
    """Make a new case out of a list of individuals."""
    ind_ids = request.form.getlist('ind_id')
    case_id = request.form['case_id']
    source = request.form['source']
    variant_type = request.form['type']

    if len(ind_ids) == 0:
        return abort(400, "must add at least one member of case")

    # only GEMINI supported
    new_case = Case(case_id=case_id,
                    name=case_id,
                    variant_source=source,
                    variant_type=variant_type,
                    variant_mode='gemini')

    # Add individuals to the correct case
    for ind_id in ind_ids:
        ind_obj = app.db.individual(ind_id)
        new_case.individuals.append(ind_obj)

    app.db.session.add(new_case)
    app.db.save()

    return redirect(url_for('.case', case_id=new_case.name))
Example #6
0
def test_case(session):
    """Test to add a case to the session"""
    # proband = Individual(ind_id="Proband")
    family = Case(case_id="afamily")
    # proband.case = family
    session.add(family)
    session.commit()

    fam = session.query(Case).filter(Case.case_id == "afamily").one()
    assert fam.id == 1
Example #7
0
def test_individual(session):
    """Test to add a case to the session"""
    # proband = Individual(ind_id="Proband")
    family = Case(case_id="2")
    proband = Individual(ind_id="Proband")
    proband.cases.append(family)
    session.add(proband)
    session.add(family)
    session.commit()

    fam = session.query(Case).filter(Case.case_id == "2").one()
    assert fam.individuals[0].ind_id == "Proband"
Example #8
0
    def add_case(self, case_obj, vtype='snv', mode='vcf', ped_svg=None):
        """Load a case with individuals.

        Args:
            case_obj (puzzle.models.Case): initialized case model
        """
        new_case = Case(case_id=case_obj.case_id,
                        name=case_obj.name,
                        variant_source=case_obj.variant_source,
                        variant_type=vtype,
                        variant_mode=mode,
                        pedigree=ped_svg,
                        compressed=case_obj.compressed,
                        tabix_index=case_obj.tabix_index)

        # build individuals
        inds = [
            Individual(
                ind_id=ind.ind_id,
                name=ind.name,
                mother=ind.mother,
                father=ind.father,
                sex=ind.sex,
                phenotype=ind.phenotype,
                ind_index=ind.ind_index,
                variant_source=ind.variant_source,
                bam_path=ind.bam_path,
            ) for ind in case_obj.individuals
        ]
        new_case.individuals = inds

        if self.case(new_case.case_id):
            logger.warning("Case already exists in database!")
        else:
            self.session.add(new_case)
            self.save()
        return new_case