本文整理汇总了Python中edge.models.Fragment.create_with_sequence方法的典型用法代码示例。如果您正苦于以下问题:Python Fragment.create_with_sequence方法的具体用法?Python Fragment.create_with_sequence怎么用?Python Fragment.create_with_sequence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edge.models.Fragment
的用法示例。
在下文中一共展示了Fragment.create_with_sequence方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_finds_sequence_on_specified_genome
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例2: test_can_create_fragment_with_different_chunk_sizes
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例3: test_blast_aligns_sequence_to_antisense_strand
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例4: test_insert_existing_fragment_in_middle
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例5: test_does_not_allow_insert_same_fragment_twice_which_creates_loops
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例6: test_user_defined_fragments_does_not_include_inactive_fragments
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例7: test_inherits_new_annotations_on_inserted_fragment
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例8: test_blast_finds_sequence_on_specified_genome
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例9: test_insert_fragment_inherits_annotations_from_new_fragment
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例10: test_insert_new_fragment_at_end
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例11: test_user_defined_fragments_does_not_include_genomic_fragment
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例12: test_replace_fragment_past_end
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例13: test_insert_new_fragment_in_middle
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
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)
示例14: test_annotate_circular_fragment_ending_at_base_last
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
def test_annotate_circular_fragment_ending_at_base_last(self):
f = Fragment.create_with_sequence('Foo', self.root_sequence, circular=True)
f.annotate(9, len(self.root_sequence), 'A1', 'gene', 1)
self.assertEquals(len(f.annotations()), 1)
self.assertEquals(f.annotations()[0].base_first, 9)
self.assertEquals(f.annotations()[0].base_last, len(self.root_sequence))
self.assertEquals(f.annotations()[0].feature.name, 'A1')
self.assertEquals(f.annotations()[0].feature_base_first, 1)
self.assertEquals(f.annotations()[0].feature_base_last, len(self.root_sequence) - 9 + 1)
self.assertEquals(f.annotations()[0].feature.length, len(self.root_sequence) - 9 + 1)
示例15: build_genome
# 需要导入模块: from edge.models import Fragment [as 别名]
# 或者: from edge.models.Fragment import create_with_sequence [as 别名]
def build_genome(self, circular, *templates):
g = Genome(name='Foo')
g.save()
for seq in templates:
f = Fragment.create_with_sequence('Bar', seq, circular=circular)
Genome_Fragment(genome=g, fragment=f, inherited=False).save()
try:
os.unlink(fragment_fasta_fn(f))
except:
pass
build_all_genome_dbs(refresh=True)
return Genome.objects.get(pk=g.id)