<commit_before>import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ms2ldaviz.settings")

import django
django.setup()

import sys
import csv

from basicviz.models import Experiment,Mass2Motif
from annotation.models import SubstituentTerm,TaxaTerm,SubstituentInstance,TaxaInstance

if __name__=='__main__':
	experiment_name = sys.argv[1]
	term_type = sys.argv[2]
	file_name = sys.argv[3]


	term_input = []


	experiment = Experiment.objects.get(name = experiment_name)
	motifs = Mass2Motif.objecte.get(experiment = experiment)
	if term_type == 'sub':
		current_terms = SubstituentInstance.objects.filter(motif__in = motifs)
	else:
		current_terms = TaxaInstance.objects.filter(motif__in = motifs)

	print "Deleting {} term instances".format(len(current_terms))
	for term in current_terms:
		term.delete()

	with open(file_name,'r') as f:
		reader = csv.reader(f)
		for line in reader:
			term_input.append(line)
	
	for motif_name,term_name,probability in term_input:
		motif = Mass2Motif.objects.get(experiment = experiment,name = motif_name)
		if term_type == 'sub':
			term = SubstituentTerm.objects.get_or_create(name = term_name)[0]
			ti = SubstituentInstance.objects.create(subterm = term,motif = motif,probability = probability)
		else:
			term = TaxaTerm.objects.get_or_create(name = term_name)[0]
			ti = TaxaInstance.objects.create(taxterm = term,motif = motif,probability = probability)<commit_msg>changed settings file linked from script<commit_after>import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ms2ldaviz.settings")

import django
django.setup()

import sys
import csv

from basicviz.models import Experiment,Mass2Motif
from annotation.models import SubstituentTerm,TaxaTerm,SubstituentInstance,TaxaInstance

if __name__=='__main__':
	experiment_name = sys.argv[1]
	term_type = sys.argv[2]
	file_name = sys.argv[3]


	term_input = []


	experiment = Experiment.objects.get(name = experiment_name)
	motifs = Mass2Motif.objects.get(experiment = experiment)
	if term_type == 'sub':
		current_terms = SubstituentInstance.objects.filter(motif__in = motifs)
	else:
		current_terms = TaxaInstance.objects.filter(motif__in = motifs)

	print "Deleting {} term instances".format(len(current_terms))
	for term in current_terms:
		term.delete()

	with open(file_name,'r') as f:
		reader = csv.reader(f)
		for line in reader:
			term_input.append(line)
	
	for motif_name,term_name,probability in term_input:
		motif = Mass2Motif.objects.get(experiment = experiment,name = motif_name)
		if term_type == 'sub':
			term = SubstituentTerm.objects.get_or_create(name = term_name)[0]
			ti = SubstituentInstance.objects.create(subterm = term,motif = motif,probability = probability)
		else:
			term = TaxaTerm.objects.get_or_create(name = term_name)[0]
			ti = TaxaInstance.objects.create(taxterm = term,motif = motif,probability = probability)
{'fraction_non_alphanumeric': 0.10633088492479888, 'fraction_numerical': 0.0062959076600209865, 'mean_word_length': 5.745283018867925, 'pattern_counts': {'":': 0, '<': 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': '7038032', 'n_tokens_mistral': 1057, 'n_tokens_neox': 957, 'n_words': 188}