本文整理汇总了Python中ngs.NGS.openReadCollection方法的典型用法代码示例。如果您正苦于以下问题:Python NGS.openReadCollection方法的具体用法?Python NGS.openReadCollection怎么用?Python NGS.openReadCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ngs.NGS
的用法示例。
在下文中一共展示了NGS.openReadCollection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def run(acc, splitNum, splitNo):
# open requested accession using SRA implementation of the API
with NGS.openReadCollection(acc) as run:
run_name = run.getName()
# compute window to iterate through
MAX_ROW = run.getAlignmentCount()
chunk = MAX_ROW / splitNum
first = int(round(chunk * (splitNo-1)))
next_first = int(round(chunk * (splitNo)))
if next_first > MAX_ROW:
next_first = MAX_ROW
# start iterator on reads
with run.getAlignmentRange(first+1, next_first-first, Alignment.primaryAlignment) as it:
i = 0
while it.nextAlignment():
print ("{}\t{}\t{}\t{}\t{}\t{}".format(it.getReadId(),
it.getReferenceSpec(),
it.getAlignmentPosition(),
it.getShortCigar(False),
it.getFragmentBases(),
("aligned" if it.isAligned() else "unaligned"),
))
i += 1
print ("Read {} alignments for {}".format(i, run_name))
示例2: test_ReadGroupIterator_ThrowBeforeNext
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def test_ReadGroupIterator_ThrowBeforeNext(self):
it = NGS.openReadCollection(PrimaryOnly).getReadGroups()
try:
it.getName()
self.fail()
except ErrorMsg:
pass
示例3: run
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def run(acc, splitNum, splitNo):
# open requested accession using SRA implementation of the API
with NGS.openReadCollection(acc) as run:
run_name = run.getName()
# compute window to iterate through
MAX_ROW = run.getReadCount()
chunk = MAX_ROW/splitNum
first = int(round(chunk*(splitNo-1)))
next_first = int(round(chunk*(splitNo)))
if next_first > MAX_ROW:
next_first = MAX_ROW
# start iterator on reads
with run.getReadRange(first+1, next_first-first, Read.all) as it:
i = 0
while it.nextRead():
i += 1
print (it.getReadId())
# iterate through fragments
while it.nextFragment():
bases = it.getFragmentBases()
if bases:
print ("\t{} - {}".format(bases, "aligned" if it.isAligned() else "unaligned"))
print ("\n")
print ("Read {} spots for {}".format(i, run_name))
示例4: run
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def run(acc, splitNum, splitNo): # this function doesn't release NGS objects however it might
# open requested accession using SRA implementation of the API
run = NGS.openReadCollection(acc)
run_name = run.getName()
# compute window to iterate through
MAX_ROW = run.getAlignmentCount()
chunk = MAX_ROW / splitNum
first = int(round(chunk * (splitNo - 1)))
next_first = int(round(chunk * (splitNo)))
if next_first > MAX_ROW:
next_first = MAX_ROW
# start iterator on reads
it = run.getAlignmentRange(first + 1, next_first - first, Alignment.primaryAlignment)
i = 0
while it.nextAlignment():
print(
it.getReadId()
+ "\t"
+ it.getReferenceSpec()
+ "\t"
+ str(it.getAlignmentPosition())
+ "\t"
+ it.getShortCigar(False)
+ "\t"
+ it.getFragmentBases()
+ "\t"
+ ("aligned" if it.isAligned() else "unaligned")
)
i += 1
print("Read {} alignments for {}".format(i, run_name))
示例5: run
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def run(acc, splitNum, splitNo): # this function doesn't release NGS objects however it might
# open requested accession using SRA implementation of the API
run = NGS.openReadCollection(acc)
run_name = run.getName()
# compute window to iterate through
MAX_ROW = run.getReadCount()
chunk = MAX_ROW/splitNum
first = int(round(chunk*(splitNo-1)))
next_first = int(round(chunk*(splitNo)))
if next_first > MAX_ROW:
next_first = MAX_ROW
# start iterator on reads
it = run.getReadRange(first+1, next_first-first, Read.all)
i = 0
while it.nextRead():
i += 1
print (it.getReadId())
# iterate through fragments
while it.nextFragment():
bases = it.getFragmentBases()
if bases:
print ("\t" + bases + " - " + ("aligned" if it.isAligned() else "unaligned"))
print ("\n")
print ("Read {} spots for {}".format(i, run_name))
示例6: run
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def run(acc, refName, start, stop):
# open requested accession using SRA implementation of the API
with NGS.openReadCollection(acc) as run:
run_name = run.getName()
# get requested reference
with run.getReference(refName) as ref:
# start iterator on requested range
with ref.getPileupSlice(start - 1, stop - start + 1) as it:
i = 0
while it.nextPileup():
qual = ""
base = ""
line = "{}\t{}\t{}\t{}".format(
it.getReferenceSpec(), it.getReferencePosition() + 1, it.getReferenceBase(), it.getPileupDepth()
)
while it.nextPileupEvent():
e = it.getEventType()
if (e & PileupEvent.alignment_start) != 0:
base = base + "^"
base = base + chr(it.getMappingQuality() + 33)
if (e & PileupEvent.insertion) != 0:
base = base + "+"
ibases = it.getInsertionBases()
c = len(ibases)
base = base + str(c)
if (e & PileupEvent.alignment_minus_strand) != 0:
base = base + ibases.lower()
else:
base = base + ibases
evt = e & 7
if (e & PileupEvent.alignment_minus_strand) != 0:
if evt == PileupEvent.deletion:
base = base + "<"
elif evt == PileupEvent.match:
base = base + ","
elif evt == PileupEvent.mismatch:
base = base + str(it.getAlignmentBase()).lower()
else:
if evt == PileupEvent.deletion:
base = base + ">"
elif evt == PileupEvent.match:
base = base + "."
elif evt == PileupEvent.mismatch:
base = base + str(it.getAlignmentBase()).upper()
if (e & PileupEvent.alignment_stop) != 0:
base = base + "$"
qual = qual + it.getAlignmentQuality()
i += 1
print("{}\t{}\t{}".format(line, base, qual))
print("Read {} pileups for {}".format(i, run_name))
示例7: test_ReferenceWindow_Slice_Filtered_Category
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def test_ReferenceWindow_Slice_Filtered_Category (self):
it = NGS.openReadCollection(WithSecondary).getReference("gi|169794206|ref|NC_010410.1|").getAlignmentSlice(516000, 100000, Alignment.primaryAlignment)
self.assertTrue(it.nextAlignment())
self.assertEqual(WithSecondary + ".PA.33", it. getAlignmentId())
self.assertTrue(it.nextAlignment())
self.assertEqual(WithSecondary + ".PA.34", it. getAlignmentId())
self.assertTrue(it.nextAlignment())
self.assertEqual(WithSecondary + ".PA.35", it. getAlignmentId()) # no secondary
self.assertFalse(it.nextAlignment())
示例8: test_ReadGroup_getStatistics
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def test_ReadGroup_getStatistics(self):
gr = NGS.openReadCollection(WithGroups).getReadGroup("GS57510-FS3-L03")
stats = gr.getStatistics()
self.assertEqual(34164461870, stats.getAsU64("BASE_COUNT"))
self.assertEqual(34164461870, stats.getAsU64("BIO_BASE_COUNT"))
self.assertEqual(488063741, stats.getAsU64("SPOT_COUNT"))
self.assertEqual(5368875807, stats.getAsU64("SPOT_MAX"))
self.assertEqual(4880812067, stats.getAsU64("SPOT_MIN"))
示例9: test_Alignment_isPaired_MultiFragmentsPerSpot
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def test_Alignment_isPaired_MultiFragmentsPerSpot(self):
readCollection = NGS.openReadCollection(PrimaryOnly)
alignment = readCollection.getAlignment(PrimaryOnly + ".PA.1")
self.assertTrue(alignment.isPaired())
alignment = readCollection.getAlignment(PrimaryOnly + ".PA.2")
self.assertTrue(alignment.isPaired())
# has unaligned mate
alignment = readCollection.getAlignment (PrimaryOnly + ".PA.6")
self.assertTrue(alignment.isPaired())
示例10: test_ReferenceWindow_Slice_Filtered_Start_Within_Slice
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def test_ReferenceWindow_Slice_Filtered_Start_Within_Slice (self):
ref = NGS.openReadCollection(WithCircularRef).getReference("NC_012920.1")
it = ref.getFilteredAlignmentSlice(0, ref.getLength(), Alignment.all, Alignment.startWithinSlice, 0)
self.assertTrue(it.nextAlignment())
lastAlignmentPosition = it.getAlignmentPosition()
while it.nextAlignment():
currentPosition = it.getAlignmentPosition()
errorMsg = "Sorting violated. Last position (" + str(lastAlignmentPosition) + ") is higher than current one (" + str(currentPosition) + ")"
self.assertTrue ( lastAlignmentPosition <= currentPosition, errorMsg )
lastAlignmentPosition = currentPosition
示例11: run
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def run(acc, refName=None):
# open requested accession using SRA implementation of the API
with NGS.openReadCollection(acc) as run:
if refName:
with run.getReference(refName) as ref:
process(ref)
else:
with run.getReferences() as refs:
while refs.nextReference():
process(refs)
print("")
示例12: run
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def run(acc):
# open requested accession using SRA implementation of the API
with NGS.openReadCollection(acc) as run:
run_name = run.getName()
# get requested reference
with run.getReferences() as it:
i = 0
while it.nextReference():
print ("{}\t{}\t{}\t{}".format(it.getCommonName(),
it.getCanonicalName(),
it.getLength(),
"circular" if it.getIsCircular() else "linear",
))
print ("Read {} references for {}".format(i, run_name))
示例13: run
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def run(acc): # this function doesn't release NGS objects however it might
# open requested accession using SRA implementation of the API
run = NGS.openReadCollection(acc)
run_name = run.getName()
# get requested reference
it = run.getReferences()
i = 0
while it.nextReference():
print (
it.getCommonName() + "\t" +
it.getCanonicalName() + "\t" +
str(it.getLength()) + "\t" +
("circular" if it.getIsCircular() else "linear")
)
print ("Read {} references for {}".format(i, run_name))
示例14: test_ReferenceWindow
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def test_ReferenceWindow(self):
it = NGS.openReadCollection(WithSecondary).getReference("gi|169794206|ref|NC_010410.1|").getAlignments(Alignment.all)
self.assertTrue(it.nextAlignment())
# the first 2 secondary alignments' locations on the list: #34, #61
count = 1;
while it.nextAlignment():
if it.getAlignmentCategory() == Alignment.secondaryAlignment:
break
count += 1
self.assertEqual(34, count)
while it.nextAlignment():
if it.getAlignmentCategory() == Alignment.secondaryAlignment:
break
count += 1
self.assertEqual(61, count)
示例15: run
# 需要导入模块: from ngs import NGS [as 别名]
# 或者: from ngs.NGS import openReadCollection [as 别名]
def run(acc, refName, start, stop):
# open requested accession using SRA implementation of the API
with NGS.openReadCollection(acc) as run:
run_name = run.getName()
# get requested reference
with run.getReference(refName) as ref:
# start iterator on requested range
with ref.getAlignmentSlice(start, stop-start+1, Alignment.primaryAlignment) as it:
i = 0
while it.nextAlignment():
print ("{}\t{}\t{}\t{}\t{}".format(
it.getReadId(),
it.getReferenceSpec(),
it.getAlignmentPosition(),
it.getLongCigar(False),
it.getAlignedFragmentBases(),
))
i += 1
print ("Read {} alignments for {}".format(i, run_name))