Commit 28ea8217 authored by Sander Bollen's avatar Sander Bollen

add maxlen arguments to prevent huge records.

parent be166c78
......@@ -21,22 +21,41 @@ from .optimized import amount_atleast
Region = namedtuple("Region", ["chr", "start", "end"])
def coverage_for_gvcf_record(record: cyvcf2.Variant) -> List[int]:
"""Get coverage for gvcf record per base"""
def coverage_for_gvcf_record(record: cyvcf2.Variant, maxlen: int = 15000) -> List[int]:
"""
Get coverage for gvcf record per base
Some records may be huge, especially those around centromeres.
Therefore, there is a maxlen argument. Maximally `maxlen` values
are returned.
"""
start = record.start
end = record.end
size = end - start
try:
dp = record.format("DP")[0][0]
except TypeError:
dp = 0
return [dp]*(end-start)
def gq_for_gvcf_record(record: cyvcf2.Variant) -> List[int]:
if size < maxlen:
return [dp]*(end-start)
else:
return [dp]*maxlen
def gq_for_gvcf_record(record: cyvcf2.Variant, maxlen: int = 15000) -> List[int]:
"""
Some records may be huge, especially those around centromeres.
Therefore, there is a maxlen argument. Maximally `maxlen` values
are returned.
"""
start = record.start
end = record.end
size = end - end
gq = record.gt_quals[0]
return [gq]*(end-start)
if size < maxlen:
return [gq]*(end-start)
else:
return [gq]*maxlen
class CovStats(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment