<commit_before>import sys
import re

for lines in open(sys.argv[1], 'rU'):
	line = lines.strip().split(" ")
	acc = re.split("\||\.3", line[0])[1]
	gene = re.split("=|\]", line[1])[1]
	locus_tag = re.split("=|\]", line[2])[1]
	if "complement" in line[-1]:
		start = re.split("\(|\.\.|\)", line[-1])[1]
		end = re.split("\(|\.\.|\)", line[-1])[2]
		print "%s\t%s\t%s\t%s\t%s\t%s" % (acc, gene, locus_tag, start, end, "-")
	else:
		start = re.split("=|\.\.|\]", line[-1])[1]
		end = re.split("=|\.\.|\]", line[-1])[2]
		print "%s\t%s\t%s\t%s\t%s\t%s" % (acc, gene, locus_tag, start, end, "+")
<commit_msg>updated the gene feature parser for missing gene types<commit_after>### usage: python ~/repos/code/parsers/gene_feature_parser.py ecoli_salm_gene_features.txt > ecoli_salm_all_gene_features_w_positions.txt
import sys
import re

def get_positions(feature):
	if "complement" in feature:
		start = re.split("\(|\.\.|\)", line[-1])[1]
		end = re.split("\(|\.\.|\)", line[-1])[2]
		return "%s\t%s\t%s" % (start, end, "-")
	else:
		start = re.split("=|\.\.|\]", line[-1])[1]
		end = re.split("=|\.\.|\]", line[-1])[2]
		return "%s\t%s\t%s" % (start, end, "+")

	
for lines in open(sys.argv[1], 'rU'):
	line = lines.strip().split(" ")
	if len(line) == 4:
		acc = re.split("\||\.3", line[0])[1]
		gene = re.split("=|\]", line[1])[1]
		locus_tag = re.split("=|\]", line[2])[1]
		print "%s\t%s\t%s\t%s" % (acc, gene, locus_tag, get_positions(line[-1]))
	else:
		acc = re.split("\||\.3", line[0])[1]
		locus_tag = re.split("=|\]", line[1])[1]
		print "%s\t%s\t%s\t%s" % (acc, "NA", locus_tag, get_positions(line[-1]))
		
{'fraction_non_alphanumeric': 0.30415890751086283, 'fraction_numerical': 0.025450031036623216, 'mean_word_length': 3.6997084548104957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3603446', 'n_tokens_mistral': 764, 'n_tokens_neox': 728, 'n_words': 134}