示例#1
0
    def test_import_adaptive_data_to_database(self):
        # Make a test sample
        p = Patient()
        p.save()
        s = Sample(patient=p)
        s.save()

       # Model can read in a file
        Clonotype.import_adaptive(s, 'clonotypes/tests/data/test_adaptive.tsv')
        all_clonotypes = Clonotype.objects.all()
        self.assertEquals(len(all_clonotypes), 100)
示例#2
0
    def test_import_miTCR_to_database(self):
        # Make a test sample
        p = Patient()
        p.save()
        s = Sample(patient=p)
        s.save()

       # Model can read in a file
        Clonotype.import_mitcr(s, 'clonotypes/tests/data/test_mitcr.txt')
        all_clonotypes = Clonotype.objects.all()
        self.assertEquals(len(all_clonotypes), 100)
        self.fail('todo')
示例#3
0
    def handle(self, *args, **options):
        try:
            sample_id, tsv_filename = args
#    self.stdout.write(" ".join(args))
            self.stdout.write(sample_id + " " + tsv_filename)
        except:
            raise BaseException("Incorrect number of arguments for import")

        try:
            sample = Sample.objects.get(id=sample_id)
        except:
            raise BaseException(
                "Sample with sample id " + sample_id + " not found.")

        Clonotype.import_mitcr(sample, tsv_filename)
示例#4
0
    def test_clonotypes_have_these_required_fields(self):
        s = SampleFactory()
        r = RecombinationFactory()
        data = {'sample': s,
                'frequency': 0.1,
                'count': 1,
                'recombination': r,
                }
        c = Clonotype()
        for key, value in data.items():
            setattr(c, key, value)
        c.save()

        c_in_db = Clonotype.objects.get()

        for key, value in data.items():
            self.assertEqual(
                value, getattr(c_in_db, key), 'key value %s not equal' % key)
示例#5
0
    def test_create_clonotypes_for_a_sample(self):
        p = Patient()
        p.save()
        s = Sample(patient=p)
        s.save()
        r = RecombinationFactory()

        c = Clonotype(
            sample=s,
            recombination=r,
            frequency=9.336458E-6,
            count=2,
        )
        c.save()

        # Get all clonotypes from database
        all_clonotypes = Clonotype.objects.all()

        self.assertEqual(all_clonotypes[0], c)