def generate_sqlite_db(variants_to_process, temp_sqlite_db_path, sqlite_db_path):
logging.info("populating sqlite database: " + temp_sqlite_db_path)
if os.path.isfile(temp_sqlite_db_path):
run("rm -f " + temp_sqlite_db_path)
sqlite_db = peewee.SqliteDatabase(temp_sqlite_db_path, autocommit=False)
class t(_SharedVariantPositionFields):
n_expected_samples = peewee.IntegerField(index=True, null=True)
n_available_samples = peewee.IntegerField(index=True, null=True)
class Meta:
database = sqlite_db
indexes = (
(('chrom', 'pos', 'ref', 'alt', 'het_or_hom_or_hemi'), True), # True means unique index
)
t.create_table(fail_silently=True)
# copy the records from the Variant table used by generate_HC_bams.py
sqlite_db.connect()
with sqlite_db.atomic():
for v in variants_to_process: #Variant.select().where(Variant.finished==1).dicts():
#shortcuts.model_to_dict(v)
d = {
'chrom': v.chrom, 'pos': v.pos, 'ref': v.ref, 'alt': v.alt, 'het_or_hom_or_hemi': v.het_or_hom_or_hemi,
'n_expected_samples': v.n_expected_samples,
'n_available_samples': v.n_available_samples,
}
# delete readviz_bam_paths as they're no longer relevant because the data from these is being combined into one bam file
#print("INSERTING " + str(d))
t.insert(**d).execute()
sqlite_db.close()
run("mv %s %s" % (temp_sqlite_db_path, sqlite_db_path))
combine_bams.py 文件源码
python
阅读 17
收藏 0
点赞 0
评论 0
评论列表
文章目录