<commit_before>#!/usr/bin/env python3

import sqlite3
from sys import argv

_, db_file_name, blank_file_name, output_file_name = argv

conn = sqlite3.connect(db_file_name)
cursor = conn.cursor()

output_file = open(output_file_name, "w")

genome_query = '''select
	reference_base,
	alternative_base,
	data
from
	genome
where
	chromosome = ? and
	position = ? and
	identifier=?
'''

for i, line in enumerate(open(blank_file_name, "r")):
	if i != 0:
		output_file.write("\r\n")
	if line == "":
		break
		
	line = line.rstrip()
	output_file.write(line)
	
	if line.startswith("#"):
		continue
	
	try:
		identifier, chromosome, position = line.split("\t")[:3]
	except:
		continue
	
	cursor.execute(genome_query, (chromosome, int(position), identifier))
	row = cursor.fetchone()
	if row is None:
		output_file.write("\t--")
		continue
	reference_base, alternative_base, data = row
	
	gt = data.split(":")[0].split("/")
	genotype = (reference_base[0], alternative_base[0])[int(gt[0])]
	if chromosome != "X":
		genotype += (reference_base[0], alternative_base[0])[int(gt[1])]
	
	output_file.write("\t" + genotype)

output_file.write("\r\n")
output_file.close()
<commit_msg>Clean up code again<commit_after>#!/usr/bin/env python3

import sqlite3
from sys import argv

_, db_file_name, blank_file_name, output_file_name = argv

conn = sqlite3.connect(db_file_name)
cursor = conn.cursor()

output_file = open(output_file_name, "w")

genome_query = '''select
	reference_base,
	alternative_base,
	data
from
	genome
where
	chromosome = ? and
	position = ? and
	identifier = ?
'''

for i, line in enumerate(open(blank_file_name, "r")):
	if i != 0:
		output_file.write("\r\n")
	if line == "":
		break
		
	line = line.rstrip()
	output_file.write(line)
	
	if line.startswith("#"):
		continue
	
	try:
		identifier, chromosome, position = line.split("\t")[:3]
	except:
		continue
	
	cursor.execute(genome_query, (chromosome, int(position), identifier))
	row = cursor.fetchone()
	if row is None:
		output_file.write("\t--")
		continue
	reference_base, alternative_base, data = row
	
	gt = data.split(":")[0].split("/")
	genotype = (reference_base[0], alternative_base[0])[int(gt[0])]
	if chromosome != "X":
		genotype += (reference_base[0], alternative_base[0])[int(gt[1])]
	
	output_file.write("\t" + genotype)

output_file.write("\r\n")
output_file.close()

{'fraction_non_alphanumeric': 0.15825491873396064, 'fraction_numerical': 0.010265183917878529, 'mean_word_length': 4.818407960199005, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4955223', 'n_tokens_mistral': 922, 'n_tokens_neox': 849, 'n_words': 181}