def test_add_new_vcf_variant_set(self):
     vcf = VCF(f="tests/vcf_tests/test.vcf",
               reference_set_id=self.reference_set.id,
               method="CORTEX")
     vcf.add_to_database()
     # We create a global variant set as well as one for the individual VCF
     assert VariantSet.objects().count() == 2
     vs = VariantSet.objects()[0]
     assert len(Variant.objects()[0].variant_sets) == 2
     assert vs.name == "test.vcf"
Пример #2
0
 def _create_new_variant_set(self):
     variant_set_name = os.path.basename(self.f)
     if VariantSet.objects(name=variant_set_name,
                           reference_set=self.reference_set):
         if not self.force:
             raise NotUniqueError(
                 "VariantSet %s already exists. Rerun with -f to recreate."
                 % variant_set_name)
         else:
             self._remove_variant_set(variant_set_name)
     self.vcf_variant_set = VariantSet.create_and_save(
         name=variant_set_name, reference_set=self.reference_set)
Пример #3
0
    def setup(self):
        DB.drop_database('mykrobe-test')

        self.reference_set = ReferenceSet().create_and_save(name="ref_set")
        self.variant_set = VariantSet.create_and_save(
            name="this_vcf_file2", reference_set=self.reference_set)
        self.variant_sets = [self.variant_set]
        self.reference = Reference().create_and_save(
            name="ref", md5checksum="sre", reference_sets=[self.reference_set])
        self.call_set = VariantCallSet.create(sample_id="C00123",
                                              name="C00123",
                                              variant_sets=self.variant_sets)
        self.variant_snp = Variant.create(variant_sets=self.variant_sets,
                                          start=0,
                                          end=1,
                                          reference_bases="A",
                                          alternate_bases=["T"],
                                          reference=self.reference)

        self.variant_snp_mult_alts = Variant.create(
            variant_sets=self.variant_sets,
            start=0,
            end=1,
            reference_bases="T",
            alternate_bases=["A", "C"],
            reference=self.reference)
Пример #4
0
    def setup(self):
        DB.drop_database('mykrobe-test')

        self.reference_set = ReferenceSet().create_and_save(name="ref_set")
        self.variant_set = VariantSet.create_and_save(
            name="this_vcf_file", reference_set=self.reference_set)
        self.variant_sets = [self.variant_set]
Пример #5
0
 def global_variant_set(self):
     try:
         vs = VariantSet.objects.get(name=GLOBAL_VARIANT_SET_NAME)
     except:
         vs = VariantSet.create_and_save(name=GLOBAL_VARIANT_SET_NAME,
                                         reference_set=self.reference_set)
     return vs
Пример #6
0
 def setup(self):
     DB.drop_database('mykrobe-test')
     self.pg = AlleleGenerator(
         reference_filepath="src/mykrobe/data/BX571856.1.fasta")
     self.reference_set = ReferenceSet().create_and_save(name="ref_set")
     self.variant_set = VariantSet.create_and_save(
         name="this_vcf_file", reference_set=self.reference_set)
     self.variant_sets = [self.variant_set]
     self.reference = Reference().create_and_save(
         name="ref", md5checksum="sre", reference_sets=[self.reference_set])
Пример #7
0
 def setup(self):
     DB.drop_database("mykrobe-test")
     self.pg = AlleleGenerator(
         reference_filepath=f"{DATA_DIR}/NC_000962.3.fasta", kmer=31)
     self.reference_set = ReferenceSet().create_and_save(name="ref_set")
     self.variant_set = VariantSet.create_and_save(
         name="this_vcf_file", reference_set=self.reference_set)
     self.variant_sets = [self.variant_set]
     self.reference = Reference().create_and_save(
         name="ref", md5checksum="sre", reference_sets=[self.reference_set])
Пример #8
0
    def setup(self):
        DB.drop_database('mykrobe-test')
        with open("src/mykrobe/data/NC_000962.3.fasta", 'r') as infile:
            self.reference_seq = list(SeqIO.parse(infile, "fasta"))[0].seq

        self.gm = GeneAminoAcidChangeToDNAVariants(
            reference="src/mykrobe/data/NC_000962.3.fasta",
            genbank="src/mykrobe/data/NC_000962.3.gb")
        self.reference_set = ReferenceSet().create_and_save(name="ref_set")
        self.variant_set = VariantSet.create_and_save(
            name="this_vcf_file", reference_set=self.reference_set)
        self.variant_sets = [self.variant_set]
        self.reference_id = Reference().create_and_save(
            name="ref", md5checksum="sre", reference_sets=[self.reference_set])
 def test_add_second_vcf_variant_set(self):
     # This VCF only has one Variant which is not in the first VCF
     vcf = VCF(f="tests/vcf_tests/test2.vcf",
               reference_set_id=self.reference_set.id,
               method="CORTEX")
     vcf.add_to_database()
     assert VariantSet.objects().count() == 3
     assert VariantCallSet.objects().count() == 2
     assert VariantCall.objects().count() == 42
     assert Variant.objects().count() == 22
     assert len(Variant.objects()[0].variant_sets) == 3
     assert len(
         Variant.objects.get(
             names="UNION_BC_k31_var_147").variant_sets) == 3
 def test_add_second_vcf_variant_set(self):
     # This VCF only has one Variant which is not in the first VCF
     vcf = VCF(f="tests/vcf_tests/test3.vcf",
               reference_set_id=self.reference_set.id,
               method="CORTEX")
     vcf.add_to_database()
     assert VariantSet.objects().count() == 2
     assert VariantCallSet.objects().count() == 1
     assert VariantCall.objects().count() == 106
     assert Variant.objects().count() == 106
     assert Variant.snps().count() == 89
     assert Variant.indels().count() == 17
     assert Variant.insertions().count() == 8
     assert Variant.deletions().count() == 8
     assert Variant.ph_snps.count() == 1
Пример #11
0
 def test_create_new_variant(self):
     variant_set = VariantSet.create_and_save(
         name="this_vcf_file", reference_set=self.reference_set)
     vs = VariantSet.objects.get(name="this_vcf_file")
     assert variant_set == vs
     assert vs.reference_set.name == "ref_set"