当前位置: 首页>>代码示例>>Python>>正文


Python models.Fragment类代码示例

本文整理汇总了Python中edge.models.Fragment的典型用法代码示例。如果您正苦于以下问题:Python Fragment类的具体用法?Python Fragment怎么用?Python Fragment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Fragment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_finds_sequence_on_specified_genome

    def test_finds_sequence_on_specified_genome(self):
        s1 = 'atcggtatcttctatgcgtatgcgtcatgattatatatattagcggcatg'
        s2 = 'agcgtcgatgcatgagtcgatcggcagtcgtgtagtcgtcgtatgcgtta'
        g1 = Genome(name='Foo')
        g1.save()
        f1 = Fragment.create_with_sequence('Bar', s1)
        f2 = Fragment.create_with_sequence('Baz', s2)
        Genome_Fragment(genome=g1, fragment=f1, inherited=False).save()
        Genome_Fragment(genome=g1, fragment=f2, inherited=False).save()

        g2 = Genome(name='Far')
        g2.save()
        f3 = Fragment.create_with_sequence('Bar', s1)
        Genome_Fragment(genome=g2, fragment=f3, inherited=False).save()

        try:
            os.unlink(fragment_fasta_fn(f1))
            os.unlink(fragment_fasta_fn(f2))
            os.unlink(fragment_fasta_fn(f3))
        except:
            pass
        build_all_genome_dbs(refresh=True)
        g1 = Genome.objects.get(pk=g1.id)

        query = s1[6:20] + 'aaaaaaaaa'
        r = blast_genome(g1, 'blastn', query)
        # only returns hit from genome
        self.assertEquals(len(r), 1)
        self.assertEquals(r[0].fragment_id, f1.id)
        self.assertEquals(r[0].query_start, 1)
        self.assertEquals(r[0].query_end, 14)
        self.assertEquals(r[0].subject_start, 7)
        self.assertEquals(r[0].subject_end, 20)
        self.assertEquals(r[0].strand(), 1)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:34,代码来源:test_blast.py

示例2: test_user_defined_fragments_does_not_include_inactive_fragments

 def test_user_defined_fragments_does_not_include_inactive_fragments(self):
     f1 = Fragment.create_with_sequence('Bar', 'aacctaaaattataa')
     self.assertEquals(len(Fragment.user_defined_fragments()), 1)
     self.assertEquals(Fragment.user_defined_fragments()[0].id, f1.id)
     f1.active = False
     f1.save()
     self.assertEquals(len(Fragment.user_defined_fragments()), 0)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:7,代码来源:test_user_defined_fragments.py

示例3: test_user_defined_fragments_does_not_include_genomic_fragment

    def test_user_defined_fragments_does_not_include_genomic_fragment(self):
        genome = Genome.create('Foo')
        s = 'atggcatattcgcagct'
        genome.add_fragment('chrI', s)

        f = Fragment.create_with_sequence('Bar', 'aacctaaaattataa')
        self.assertEquals(len(Fragment.user_defined_fragments()), 1)
        self.assertEquals(Fragment.user_defined_fragments()[0].name, 'Bar')
        self.assertEquals(Fragment.user_defined_fragments()[0].id, f.id)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:9,代码来源:test_user_defined_fragments.py

示例4: test_can_create_fragment_with_different_chunk_sizes

 def test_can_create_fragment_with_different_chunk_sizes(self):
     s = 'gataccggtactag'
     f = Fragment.create_with_sequence('Foo', s, initial_chunk_size=len(s))
     self.assertEquals(f.sequence, s)
     f = Fragment.create_with_sequence('Foo', s, initial_chunk_size=0)
     self.assertEquals(f.sequence, s)
     f = Fragment.create_with_sequence('Foo', s, initial_chunk_size=1)
     self.assertEquals(f.sequence, s)
     f = Fragment.create_with_sequence('Foo', s, initial_chunk_size=3)
     self.assertEquals(f.sequence, s)
     f = Fragment.create_with_sequence('Foo', s, initial_chunk_size=len(s) * 1000)
     self.assertEquals(f.sequence, s)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:12,代码来源:test_fragment.py

示例5: on_get

 def on_get(self, request):
     q_parser = RequestParser()
     q_parser.add_argument('q', field_type=str, location='get')
     q_parser.add_argument('s', field_type=int, location='get', default=0)
     q_parser.add_argument('p', field_type=int, location='get', default=100)
     args = q_parser.parse_args(request)
     s = args['s']
     p = args['p']
     q = args['q']
     p = 200 if p > 200 else p
     if q is not None and q.strip() != '':
         fragments = Fragment.user_defined_fragments(Q(name__icontains=q), s, s + p)
     else:
         fragments = Fragment.user_defined_fragments(None, s, s + p)
     return [FragmentView.to_dict(fragment) for fragment in fragments]
开发者ID:ginkgobioworks,项目名称:edge,代码行数:15,代码来源:views.py

示例6: test_finds_genomes_with_specified_fragment_ids

    def test_finds_genomes_with_specified_fragment_ids(self):
        from edge.models import Genome, Fragment, Genome_Fragment

        g1 = Genome(name='Foo')
        g1.save()
        g2 = Genome(name='Bar')
        g2.save()
        f1 = Fragment(circular=True, name='FooF1')
        f1.save()
        f2 = Fragment(circular=True, name='FooF2')
        f2.save()
        f3 = Fragment(circular=True, name='FooF3', parent=f2)
        f3.save()
        Genome_Fragment(genome=g1, fragment=f1, inherited=False).save()
        Genome_Fragment(genome=g1, fragment=f2, inherited=False).save()
        Genome_Fragment(genome=g2, fragment=f1, inherited=True).save()
        Genome_Fragment(genome=g2, fragment=f3, inherited=False).save()

        # no filter, return both genomes
        res = self.client.get('/edge/genomes/')
        self.assertEquals(res.status_code, 200)
        d = json.loads(res.content)
        self.assertItemsEqual([g['id'] for g in d], [g1.id, g2.id])

        # looking for f1 and f2
        res = self.client.get('/edge/genomes/?f=%d&f=%d' % (f1.id, f2.id))
        self.assertEquals(res.status_code, 200)
        d = json.loads(res.content)
        self.assertItemsEqual([g['id'] for g in d], [g1.id])

        # looking for f1 and f3
        res = self.client.get('/edge/genomes/?f=%d&f=%d' % (f1.id, f3.id))
        self.assertEquals(res.status_code, 200)
        d = json.loads(res.content)
        self.assertItemsEqual([g['id'] for g in d], [g2.id])

        # looking for f2 and f3
        res = self.client.get('/edge/genomes/?f=%d&f=%d' % (f2.id, f3.id))
        self.assertEquals(res.status_code, 200)
        d = json.loads(res.content)
        self.assertEquals(d, [])

        # looking for f1
        res = self.client.get('/edge/genomes/?f=%d' % (f1.id,))
        self.assertEquals(res.status_code, 200)
        d = json.loads(res.content)
        self.assertEquals(d, [])

        # bad input, return []
        res = self.client.get('/edge/genomes/?f=[1,2,3]')
        self.assertEquals(res.status_code, 200)
        d = json.loads(res.content)
        self.assertEquals(d, [])
开发者ID:Chris7,项目名称:edge,代码行数:53,代码来源:test_views.py

示例7: test_insert_existing_fragment_in_middle

 def test_insert_existing_fragment_in_middle(self):
     existing_f = Fragment.create_with_sequence('Test', 'gataca')
     f = self.root.update('Bar')
     f.insert_fragment(3, existing_f)
     self.assertEquals(f.sequence, self.root_sequence[0:2] + 'gataca' + self.root_sequence[2:])
     # does not affect root
     self.assertEquals(self.root.sequence, self.root_sequence)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:7,代码来源:test_fragment.py

示例8: test_does_not_allow_insert_same_fragment_twice_which_creates_loops

 def test_does_not_allow_insert_same_fragment_twice_which_creates_loops(self):
     u = self.root.update('Bar')
     new_f = Fragment.create_with_sequence('Test', 'gataca')
     new_f = new_f.update('Test')
     new_f.insert_bases(2, 'ccc')
     u.insert_fragment(3, new_f)
     self.assertRaises(Exception, u.insert_fragment, 3, new_f)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:7,代码来源:test_fragment.py

示例9: test_blast_aligns_sequence_to_antisense_strand

    def test_blast_aligns_sequence_to_antisense_strand(self):
        s1 = 'atcggtatcttctatgcgtatgcgtcatgattatatatattagcggcatg'
        g1 = Genome(name='Foo')
        g1.save()
        f1 = Fragment.create_with_sequence('Bar', s1)
        Genome_Fragment(genome=g1, fragment=f1, inherited=False).save()

        try:
            os.unlink(fragment_fasta_fn(f1))
        except:
            pass
        build_all_genome_dbs(refresh=True)

        query = str(Seq(s1[6:20]).reverse_complement())+'tttttttttt'

        res = self.client.post('/edge/genomes/%s/blast/' % g1.id,
                               data=json.dumps(dict(program='blastn', query=query)),
                               content_type='application/json')
        self.assertEquals(res.status_code, 200)
        d = json.loads(res.content)

        # only returns hit from genome
        self.assertEquals(len(d), 1)
        self.assertEquals(d[0]['fragment_id'], f1.id)
        self.assertEquals(d[0]['query_start'], 1)
        self.assertEquals(d[0]['query_end'], 14)
        self.assertEquals(d[0]['subject_start'], 20)
        self.assertEquals(d[0]['subject_end'], 7)
开发者ID:cavedweller,项目名称:edge,代码行数:28,代码来源:test_blast.py

示例10: test_inherits_new_annotations_on_inserted_fragment

    def test_inherits_new_annotations_on_inserted_fragment(self):
        new_f = Fragment.create_with_sequence('Test', 'gataca')

        self.assertEquals(len(new_f.annotations()), 0)
        self.assertEquals(len(self.root.annotations()), 0)

        f = self.root.update('Bar')
        f.insert_fragment(3, new_f)

        self.assertEquals(len(new_f.annotations()), 0)
        self.assertEquals(len(self.root.annotations()), 0)
        self.assertEquals(len(f.annotations()), 0)

        new_f.annotate(2, 4, 'X1', 'gene', 1)

        self.root = Fragment.objects.get(pk=self.root.pk).indexed_fragment()
        f = Fragment.objects.get(pk=f.pk).indexed_fragment()
        self.assertEquals(len(new_f.annotations()), 1)
        self.assertEquals(len(self.root.annotations()), 0)
        self.assertEquals(len(f.annotations()), 1)

        self.assertEquals(f.annotations()[0].base_first, 4)
        self.assertEquals(f.annotations()[0].base_last, 6)
        self.assertEquals(f.annotations()[0].feature.name, 'X1')
        self.assertEquals(f.annotations()[0].feature_base_first, 1)
        self.assertEquals(f.annotations()[0].feature_base_last, 3)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:26,代码来源:test_annotations.py

示例11: test_blast_finds_sequence_on_specified_genome

    def test_blast_finds_sequence_on_specified_genome(self):
        s1 = 'atcggtatcttctatgcgtatgcgtcatgattatatatattagcggcatg'
        s2 = 'agcgtcgatgcatgagtcgatcggcagtcgtgtagtcgtcgtatgcgtta'
        g1 = Genome(name='Foo')
        g1.save()
        f1 = Fragment.create_with_sequence('Bar', s1)
        f2 = Fragment.create_with_sequence('Baz', s2)
        Genome_Fragment(genome=g1, fragment=f1, inherited=False).save()
        Genome_Fragment(genome=g1, fragment=f2, inherited=False).save()

        g2 = Genome(name='Far')
        g2.save()
        f3 = Fragment.create_with_sequence('Bar', s1)
        Genome_Fragment(genome=g2, fragment=f3, inherited=False).save()

        try:
            os.unlink(fragment_fasta_fn(f1))
            os.unlink(fragment_fasta_fn(f2))
            os.unlink(fragment_fasta_fn(f3))
        except:
            pass
        build_all_genome_dbs(refresh=True)

        query = s1[6:20]+'aaaaaaaaa'

        res = self.client.post('/edge/genomes/%s/blast/' % g1.id,
                               data=json.dumps(dict(program='blastn', query=query)),
                               content_type='application/json')
        self.assertEquals(res.status_code, 200)
        d = json.loads(res.content)

        # only returns hit from genome
        self.assertEquals(len(d), 1)
        self.assertEquals(d[0]['fragment_id'], f1.id)
        self.assertEquals(d[0]['query_start'], 1)
        self.assertEquals(d[0]['query_end'], 14)
        self.assertEquals(d[0]['subject_start'], 7)
        self.assertEquals(d[0]['subject_end'], 20)

        # blast in other genome works too
        res = self.client.post('/edge/genomes/%s/blast/' % g2.id,
                               data=json.dumps(dict(program='blastn', query=query)),
                               content_type='application/json')
        self.assertEquals(res.status_code, 200)
        d = json.loads(res.content)
        self.assertEquals(len(d), 1)
        self.assertEquals(d[0]['fragment_id'], f3.id)
开发者ID:cavedweller,项目名称:edge,代码行数:47,代码来源:test_blast.py

示例12: test_insert_fragment_inherits_annotations_from_new_fragment

 def test_insert_fragment_inherits_annotations_from_new_fragment(self):
     f = self.root.update('Bar')
     self.assertEquals([a for a in f.annotations() if a.name == 'Uma'], [])
     new_f = Fragment.create_with_sequence('Test', 'gataca')
     new_f.annotate(2, 4, 'Uma', 'feature', 1)
     f.insert_fragment(2, new_f)
     self.assertEquals([a for a in f.annotations() if a.feature.name == 'Uma'][0].base_first, 3)
     self.assertEquals([a for a in f.annotations() if a.feature.name == 'Uma'][0].base_last, 5)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:8,代码来源:test_fragment.py

示例13: test_insert_new_fragment_at_end

 def test_insert_new_fragment_at_end(self):
     f = self.root.update('Bar')
     new_f = Fragment.create_with_sequence('Test', 'gataca')
     new_f = new_f.update('Test')
     new_f.insert_bases(2, 'ccc')
     f.insert_fragment(None, new_f)
     self.assertEquals(f.sequence, self.root_sequence + 'gcccataca')
     # does not affect root
     self.assertEquals(self.root.sequence, self.root_sequence)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:9,代码来源:test_fragment.py

示例14: test_insert_new_fragment_in_middle

 def test_insert_new_fragment_in_middle(self):
     f = self.root.update('Bar')
     new_f = Fragment.create_with_sequence('Test', 'gataca')
     new_f = new_f.update('Test')
     new_f.insert_bases(2, 'ccc')
     f.insert_fragment(3, new_f)
     self.assertEquals(
         f.sequence, self.root_sequence[0: 2] + 'gcccataca' + self.root_sequence[2:])
     # does not affect root
     self.assertEquals(self.root.sequence, self.root_sequence)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:10,代码来源:test_fragment.py

示例15: test_replace_fragment_past_end

 def test_replace_fragment_past_end(self):
     f = self.root.update('Bar')
     new_f = Fragment.create_with_sequence('Test', 'gataca')
     new_f = new_f.update('Test')
     new_f.insert_bases(2, 'ccc')
     f.replace_with_fragment(len(self.root_sequence) - 3, 6, new_f)
     self.assertEquals(f.name, 'Bar')
     self.assertEquals(f.sequence, self.root_sequence[:-4] + 'gcccataca')
     # does not affect root
     self.assertEquals(self.root.sequence, self.root_sequence)
开发者ID:ginkgobioworks,项目名称:edge,代码行数:10,代码来源:test_fragment.py


注:本文中的edge.models.Fragment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。