# Path: browser/models.py
# class SearchSet(models.Model):
# 	user_id = models.CharField(max_length=200)
# 	job_name = models.CharField(max_length=200)
# 	job_id = models.CharField(max_length=200)
# 	job_start = models.CharField(max_length=30)
# 	job_status = models.CharField(max_length=20)
# 	job_progress = models.IntegerField()
# 	ss_file = models.FileField(upload_to='/var/django/melodi/abstracts')
# 	ss_desc = models.CharField(max_length=5000)
# 	pTotal = models.IntegerField()
# 
# 	class Meta:
# 		unique_together = ('user_id', 'job_name',),
# 
# 	#def __str__(self):
# 	#	return "User: " + self.user_id
# 
# class SearchSetAnalysis(models.Model):
# 	ss_id = models.ForeignKey(SearchSet)
# 	job_type =  models.CharField(max_length=20)
# 	complete = models.BooleanField(default=False)
# 	year_range = models.CharField(max_length=12)
# 
# class Compare(models.Model):
# 	user_id = models.CharField(max_length=200)
# 	job_name = models.CharField(max_length=200)
# 	job_desc = models.CharField(max_length=400)
# 	job_start = models.CharField(max_length=30)
# 	job_status = models.CharField(max_length=20)
# 	job_progress = models.IntegerField()
# 	job_type = models.CharField(max_length=20)
# 	year_range = models.CharField(max_length=12)
# 	share = models.BooleanField(default=False)
# 	hash_id = models.UUIDField(db_index=True,default=uuid.uuid4, editable=False)
# 
# class Overlap(models.Model):
# 	mc_id = models.ForeignKey(Compare)
# 	name = models.CharField(max_length=500,blank=True,db_index=True)
# 	name1 = models.CharField(max_length=200,blank=True,db_index=True)
# 	name2 = models.CharField(max_length=50,blank=True,db_index=True)
# 	name3 = models.CharField(max_length=200,blank=True,db_index=True)
# 	name4 = models.CharField(max_length=50,blank=True,db_index=True)
# 	name5 = models.CharField(max_length=200,blank=True,db_index=True)
# 	mean_cp = models.FloatField()
# 	mean_odds = models.FloatField()
# 	uniq_a = models.IntegerField()
# 	uniq_b = models.IntegerField()
# 	shared = models.IntegerField()
# 	score = models.FloatField()
# 	treeLevel = models.FloatField()
# 
# 	class Meta:
# 		unique_together = ('name', 'mc_id',)


from celery import shared_task, task
from celery.task import periodic_task
from celery.schedules import crontab
from django.core.mail import send_mail
from datetime import timedelta
from random import randint
from scipy import stats
from browser.models import SearchSet,SearchSetAnalysis,Compare,Overlap
from celery.utils.log import get_task_logger
from collections import defaultdict
from retrying import retry
from django.conf import settings
from neo4j.v1 import GraphDatabase,basic_auth
import datetime
import sys,gzip,time,os,subprocess,re,json,random
import statsmodels.sandbox.stats.multicomp as sm
import logging
import zipfile
import requests
import random
import shutil
import config
				if pmid not in p_set:
					tx.run(statement, {"pmid": pmid,'issn':issn,'dcom':dcom,'title':title,'jt':jt})
					dcom=""
					pmid=""
					issn = ""
					title=""
					jt=""
					inCount += 1
					counter += 1
					#if counter % 1000 == 0:
						# print(statement1)
					#	tx.commit()
					#	tx = session.begin_transaction()
				else:
					passCount += 1
			pmid = line.split("-", 1)[1].strip()
		if in_ti == True:
			if line[0] == " ":
				title += " "+line.strip()
			elif line[0:3] != 'TI ':
				in_ti = False
		if in_jt == True:
			if line[0] == " ":
				jt += " "+line.strip()
			elif line[0:3] != 'JT ':
				in_jt = False

	#check for bad files
	if title == "" and pmid == "":
		print "Incorrect file format - "+str(job_name)+":"+str(job_name)

# Path: browser/models.py
# class SearchSet(models.Model):
# 	user_id = models.CharField(max_length=200)
# 	job_name = models.CharField(max_length=200)
# 	job_id = models.CharField(max_length=200)
# 	job_start = models.CharField(max_length=30)
# 	job_status = models.CharField(max_length=20)
# 	job_progress = models.IntegerField()
# 	ss_file = models.FileField(upload_to='/var/django/melodi/abstracts')
# 	ss_desc = models.CharField(max_length=5000)
# 	pTotal = models.IntegerField()
# 
# 	class Meta:
# 		unique_together = ('user_id', 'job_name',),
# 
# 	#def __str__(self):
# 	#	return "User: " + self.user_id
# 
# class SearchSetAnalysis(models.Model):
# 	ss_id = models.ForeignKey(SearchSet)
# 	job_type =  models.CharField(max_length=20)
# 	complete = models.BooleanField(default=False)
# 	year_range = models.CharField(max_length=12)
# 
# class Compare(models.Model):
# 	user_id = models.CharField(max_length=200)
# 	job_name = models.CharField(max_length=200)
# 	job_desc = models.CharField(max_length=400)
# 	job_start = models.CharField(max_length=30)
# 	job_status = models.CharField(max_length=20)
# 	job_progress = models.IntegerField()
# 	job_type = models.CharField(max_length=20)
# 	year_range = models.CharField(max_length=12)
# 	share = models.BooleanField(default=False)
# 	hash_id = models.UUIDField(db_index=True,default=uuid.uuid4, editable=False)
# 
# class Overlap(models.Model):
# 	mc_id = models.ForeignKey(Compare)
# 	name = models.CharField(max_length=500,blank=True,db_index=True)
# 	name1 = models.CharField(max_length=200,blank=True,db_index=True)
# 	name2 = models.CharField(max_length=50,blank=True,db_index=True)
# 	name3 = models.CharField(max_length=200,blank=True,db_index=True)
# 	name4 = models.CharField(max_length=50,blank=True,db_index=True)
# 	name5 = models.CharField(max_length=200,blank=True,db_index=True)
# 	mean_cp = models.FloatField()
# 	mean_odds = models.FloatField()
# 	uniq_a = models.IntegerField()
# 	uniq_b = models.IntegerField()
# 	shared = models.IntegerField()
# 	score = models.FloatField()
# 	treeLevel = models.FloatField()
# 
# 	class Meta:
# 		unique_together = ('name', 'mc_id',)


# Path: browser/tasks.py
from celery import shared_task, task
from celery.task import periodic_task
from celery.schedules import crontab
from django.core.mail import send_mail
from datetime import timedelta
from random import randint
from scipy import stats
from browser.models import SearchSet,SearchSetAnalysis,Compare,Overlap
from celery.utils.log import get_task_logger
from collections import defaultdict
from retrying import retry
from django.conf import settings
from neo4j.v1 import GraphDatabase,basic_auth
import datetime
import sys,gzip,time,os,subprocess,re,json,random
import statsmodels.sandbox.stats.multicomp as sm
import logging
import zipfile
import requests
import random
import shutil
import config

				if pmid not in p_set:
					tx.run(statement, {"pmid": pmid,'issn':issn,'dcom':dcom,'title':title,'jt':jt})
					dcom=""
					pmid=""
					issn = ""
					title=""
					jt=""
					inCount += 1
					counter += 1
					#if counter % 1000 == 0:
						# print(statement1)
					#	tx.commit()
					#	tx = session.begin_transaction()
				else:
					passCount += 1
			pmid = line.split("-", 1)[1].strip()
		if in_ti == True:
			if line[0] == " ":
				title += " "+line.strip()
			elif line[0:3] != 'TI ':
				in_ti = False
		if in_jt == True:
			if line[0] == " ":
				jt += " "+line.strip()
			elif line[0:3] != 'JT ':
				in_jt = False

	#check for bad files
	if title == "" and pmid == "":
		print "Incorrect file format - "+str(job_name)+":"+str(job_name)

		SearchSet.objects.filter(job_name=job_name,user_id=user_id).update(job_status='Failed - incorrect file format',job_progress=1)