<commit_before># Nucleotide analysis from VCF files
# (c) 2017	<NAME>


class annuc:
	def __init__(self, **kwargs):
		self.spec_input = kwargs["dictinput"]
		self.hassle_input = kwargs["hassle"]
		self.threads = kwargs["threads"]
		# where to start from. 
		self.pos_in_iter = 147

	def specific_input(self):
		with open(self.spec_input, "r") as spec_file:	
			for spec_line in spec_file:
				temp_info = spec_line.split("\t")
				yield str(temp_info[0]), str(temp_info[1].replace("\n",""))

	def hassle(self):
		with open(self.hassle_input, "r") as hassle_file:
			for i, line in enumerate(hassle_file):
				
				if i > self.pos_in_iter:
					line = line.split("\t")
					temp = [ line[0],line[1], line[3], line[4] ]
					if self.chr_ and self.pos in temp:
						self.pos_in_iter = i
						yield temp
					else:
						self.i = i	
				else:
					self.i = i
					

	def filter(self):
		with open("defínitive_output_v3.vcf", "a") as file:
			spec_gen = self.specific_input()
			hassle_gen = self.hassle()
			try:
				while True:
					self.chr_, self.pos = next(spec_gen)
					append_this = next(self.hassle())
					text = "{}	{}	{}	{}\n".format(append_this[0],append_this[1],append_this[2],append_this[3])
					print(text)
					file.write(text)
			
			except Exception as e:
				print(e)





if __name__ == '__main__':
	a = annuc(dictinput="malbac_4_vcfoutput", hassle="malbac_4.freebayes.bwa.vcf", threads=2)
	a.filter()<commit_msg>Add files via upload<commit_after># Nucleotide analysis from VCF files
# (c) 2017	<NAME>


import time	
class annuc:
	def __init__(self, **kwargs):
		# Imports

		# Kwarg handling
		self.spec_input = kwargs["dictinput"]
		self.hass_input = kwargs["hass"]
		self.threads = kwargs["threads"]
		self.count = kwargs["count"]
		self.output = kwargs["output"]
		# where to start from. 
		self.pos_in_iter = 147

	def specific_input(self):
		with open(self.spec_input, "r") as spec_file:	
			for spec_line in spec_file:
				temp_info = spec_line.split("\t")
				yield str(temp_info[0]), str(temp_info[1].replace("\n",""))

	def hass(self):
		with open(self.hass_input, "r") as hass_file:
			for i, line in enumerate(hass_file):

				if i > self.pos_in_iter:
					line = line.split("\t")
					temp = [ line[0],line[1], line[3], line[4] ]
					if self.chr_ and self.pos in temp:
						self.pos_in_iter = i
						yield temp
					else:
						pass	
				else:
					pass
					

	def filter(self):
		with open(self.output, "a") as file:
			spec_gen = self.specific_input()
			hass_gen = self.hass()
			try:
				text = ""
				count = 0
				start = time.time()
				for self.chr_, self.pos in spec_gen:
					append_this = next(self.hass())
					text = text + "{}\t{}\t{}\t{}\n".format(*append_this)
					if count == self.count:
						file.write(text)
						text = ""
						end = time.time()
						print(end-start)
						start = time.time()
						count = 0
					count += 1
			
			except Exception as e:
				print(e)





if __name__ == '__main__':
	a = annuc(dictinput="malbac_4_vcfoutput", hass="malbac_4.freebayes.bwa.vcf", threads=2, count=100, output="1.vcf")
	a.filter()




	# with open("malbac_4.freebayes.bwa.vcf", "r") as hass_file:
	# 	print(hass_file.tell())
		# a = hass_file.readlines(100000)
		# print(a)
{'fraction_non_alphanumeric': 0.1507273290003095, 'fraction_numerical': 0.015784586815227482, 'mean_word_length': 3.0859671302149176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4747900', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1222, 'n_words': 268}