本文整理汇总了Python中ngs.NGS类的典型用法代码示例。如果您正苦于以下问题:Python NGS类的具体用法?Python NGS怎么用?Python NGS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NGS类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run
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))
开发者ID:dasmoocher,项目名称:ngs,代码行数:26,代码来源:AlignTest.py
示例2: test_ReadGroupIterator_ThrowBeforeNext
def test_ReadGroupIterator_ThrowBeforeNext(self):
it = NGS.openReadCollection(PrimaryOnly).getReadGroups()
try:
it.getName()
self.fail()
except ErrorMsg:
pass
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:7,代码来源:tests.py
示例3: run
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))
开发者ID:dasmoocher,项目名称:ngs,代码行数:26,代码来源:FragTest.py
示例4: run
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))
开发者ID:karapetk,项目名称:ngs,代码行数:32,代码来源:AlignTest26.py
示例5: run
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))
开发者ID:Shane-Qiu,项目名称:ngs,代码行数:26,代码来源:FragTest26.py
示例6: run
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))
开发者ID:ncbi,项目名称:ngs,代码行数:59,代码来源:PileupTest.py
示例7: test_ReferenceWindow_Slice_Filtered_Category
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())
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:9,代码来源:tests.py
示例8: test_ReadGroup_getStatistics
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"))
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:10,代码来源:tests.py
示例9: test_Alignment_isPaired_MultiFragmentsPerSpot
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())
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:11,代码来源:tests.py
示例10: test_ReferenceWindow_Slice_Filtered_Start_Within_Slice
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
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:11,代码来源:tests.py
示例11: run
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("")
开发者ID:dasmoocher,项目名称:ngs,代码行数:11,代码来源:DumpReferenceFASTA.py
示例12: run
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))
开发者ID:DCGenomics,项目名称:ngs,代码行数:16,代码来源:RefTest.py
示例13: run
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))
开发者ID:dasmoocher,项目名称:ngs,代码行数:17,代码来源:RefTest26.py
示例14: test_ReferenceWindow
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)
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:18,代码来源:tests.py
示例15: run
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))
开发者ID:dasmoocher,项目名称:ngs,代码行数:20,代码来源:AlignSliceTest.py
示例16: run
def run(acc, refName, start, stop): # 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
ref = run.getReference(refName)
# start iterator on requested range
it = ref.getAlignmentSlice(start, stop-start+1, Alignment.primaryAlignment)
i = 0
while it.nextAlignment():
print ("%s\t%s\t%d\t%s\t%s" % (
it.getReadId(),
it.getReferenceSpec(),
it.getAlignmentPosition(),
it.getLongCigar(False),
it.getAlignedFragmentBases(),
))
i += 1
print ("Read %d alignments for %s" % (i, run_name))
开发者ID:dasmoocher,项目名称:ngs,代码行数:21,代码来源:AlignSliceTest26.py
示例17: test_ReadCollection_getAlignmentCount_WithSecondary_Secondary
def test_ReadCollection_getAlignmentCount_WithSecondary_Secondary(self):
self.assertEqual(10, NGS.openReadCollection(WithSecondary).getAlignmentCount(Alignment.secondaryAlignment))
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:2,代码来源:tests.py
示例18: test_ReadCollection_getAlignmentCount_PrimaryOnly_All
def test_ReadCollection_getAlignmentCount_PrimaryOnly_All(self):
self.assertEqual(3987701, NGS.openReadCollection(PrimaryOnly).getAlignmentCount(Alignment.all))
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:2,代码来源:tests.py
示例19: test_ReadCollection_getAlignmentCount_PrimaryOnly_Secondary
def test_ReadCollection_getAlignmentCount_PrimaryOnly_Secondary(self):
self.assertEqual(0, NGS.openReadCollection(PrimaryOnly).getAlignmentCount(Alignment.secondaryAlignment))
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:2,代码来源:tests.py
示例20: test_ReadCollection_getAlignments_all
def test_ReadCollection_getAlignments_all(self):
alIt = NGS.openReadCollection(PrimaryOnly).getAlignments(Alignment.all)
开发者ID:binlu1981,项目名称:ncbi-vdb,代码行数:2,代码来源:tests.py
注:本文中的ngs.NGS类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论