示例#1
0
    def test_create_dataset__aa_with_bad_codon(self):
        """Test when trying to translate 'N--' codon. Should translate to X"""
        dataset_obj = Dataset.objects.create()
        v = Vouchers.objects.get(code="CP100-10")
        seq = Sequences.objects.get(code=v, gene_code="COI-begin")
        seq.sequences = "TCAN--CGTCCC"
        seq.save()

        create_dataset(
            taxonset_id=1,
            geneset_id=1,
            gene_codes_ids=[],
            voucher_codes='CP100-10',
            file_format='FASTA',
            outgroup='',
            positions='ALL',
            partition_by_positions='by gene',
            translations=False,
            aminoacids=True,
            degen_translations='normal',
            special=False,
            taxon_names=['CODE', 'GENUS', 'SPECIES'],
            number_genes='',
            introns='YES',
            dataset_obj_id=dataset_obj.id,
        )
        dataset_obj.refresh_from_db()
        self.assertEqual([], dataset_obj.warnings)
        self.assertEqual([], dataset_obj.errors)
    def test_create_dataset(self):
        """Test that gaps have not been converted to underscores."""
        seq = Sequences.objects.get(code="CP100-10", gene_code="COI-begin")
        this_seq = list(seq.sequences)
        this_seq[-3:] = '---'
        seq.sequences = "".join(this_seq)
        seq.save()

        dataset_obj = Dataset.objects.create()

        create_dataset(
            taxonset_id=TaxonSets.objects.last().id,
            geneset_id=GeneSets.objects.last().id,
            gene_codes_ids=[2],  # COI-begin
            voucher_codes='CP100-10',
            file_format='FASTA',
            outgroup='',
            positions='ALL',
            partition_by_positions='by gene',
            translations=False,
            aminoacids=False,
            degen_translations='NORMAL',
            special=False,
            taxon_names=['CODE', 'GENUS', 'SPECIES'],
            number_genes='',
            introns='YES',
            dataset_obj_id=dataset_obj.id,
        )
        dataset_obj.refresh_from_db()
        self.assertFalse("___" in str(dataset_obj.content))
    def test_fasta_with_seqs_of_different_sizes(self):
        """Test that an error message is shown to the users GUI."""
        seq = Sequences.objects.get(code="CP100-10", gene_code="COI-begin")
        seq.sequences += 'AAAAAAAAAA'
        seq.save()

        dataset_obj = Dataset.objects.create()
        create_dataset(
            taxonset_id=TaxonSets.objects.last().id,
            geneset_id=GeneSets.objects.last().id,
            gene_codes_ids=[2],
            voucher_codes='',
            file_format='FASTA',
            outgroup='',
            positions='ALL',
            partition_by_positions='by gene',
            translations=False,
            aminoacids=False,
            degen_translations='normal',
            special=False,
            taxon_names=['CODE', 'GENUS', 'SPECIES'],
            number_genes='',
            introns='YES',
            dataset_obj_id=dataset_obj.id,
        )
        expected = "Matrix Nchar 4749 does not match data length (4739) for taxon"
        dataset_obj.refresh_from_db()
        self.assertTrue(expected in str(dataset_obj.errors))
示例#4
0
 def test_create_dataset2(self):
     dataset_obj = Dataset.objects.create()
     create_dataset(
         taxonset_id=1,
         geneset_id=1,
         gene_codes_ids=[],
         voucher_codes='CP100-10',
         file_format='FASTA',
         outgroup='',
         positions='ALL',
         partition_by_positions='by gene',
         translations=False,
         aminoacids=False,
         degen_translations='normal',
         special=False,
         taxon_names=['CODE', 'GENUS', 'SPECIES'],
         number_genes='',
         introns='YES',
         dataset_obj_id=dataset_obj.id,
     )
     expected = ">CP100_10_Aus_aus\nACGACGACGACGACGACGACGACGACGACGACGACGACGACGACGACGACGACGACGACG"
     dataset_obj.refresh_from_db()
     self.assertIn(expected, dataset_obj.content)
 def test_create_dataset_degenerated(self):
     dataset_obj = Dataset.objects.create()
     gene = Genes.objects.get(gene_code="RpS2")
     create_dataset(
         taxonset_id=TaxonSets.objects.last().id,
         geneset_id=GeneSets.objects.last().id,
         gene_codes_ids=[gene.id],
         voucher_codes='CP100-10',
         file_format='FASTA',
         outgroup='',
         positions='ALL',
         partition_by_positions='by gene',
         translations=True,
         aminoacids=False,
         degen_translations='normal',
         special=False,
         taxon_names=['CODE', 'GENUS', 'SPECIES'],
         number_genes='',
         introns='YES',
         dataset_obj_id=dataset_obj.id,
     )
     expected = 'MGNMGNMGNMGNMGNMGNMGNMGNMG'
     dataset_obj.refresh_from_db()
     self.assertTrue(expected in str(dataset_obj.content))
 def test_create_dataset_degenerated_warning_data_cannot_be_of_partial_codons(
         self):
     dataset_obj = Dataset.objects.create()
     create_dataset(
         taxonset_id=TaxonSets.objects.last().id,
         geneset_id=GeneSets.objects.last().id,
         gene_codes_ids=[4],
         voucher_codes='CP100-10',
         file_format='FASTA',
         outgroup='',
         positions='1st',
         partition_by_positions='by gene',
         translations=True,
         aminoacids=False,
         degen_translations='normal',
         special=False,
         taxon_names=['CODE', 'GENUS', 'SPECIES'],
         number_genes='',
         introns='YES',
         dataset_obj_id=dataset_obj.id,
     )
     dataset_obj.refresh_from_db()
     expected = 'Cannot degenerate codons if you have not selected all codon positions'
     self.assertTrue(expected in dataset_obj.errors)