#! /usr/bin/env python 
###################################
#    Davi Ortega 1/29/2014 
###################################
import pymongo
import sys
import numpy

if '-h' in sys.argv:
	print 'This will take forever and it will require some reasonable disc space. Carefull now'
	sys.exit()

#MONGO
try:
	client = pymongo.MongoClient('localhost',27019)
except Connection:
	print "You must open a tunnel with ares.bio.utk.edu: ssh -L 27019:localhost:27017 ares.bio.utk.edu"
	sys.exit()
mist = client.mist22

local = pymongo.MongoClient()
dbcount = local.domain_count


#END MONGO

output = []
no_sequence = ''

i = 0

for aseq in mist.aseqs.find({'t.pfam27' : { '$exists' : 'true' }},{"s":1, "_id":1, "t" : 1}, timeout=False):
	if numpy.mod(i,5000) == 0:
		
		print i
#		if i != 0:
#			break
	try:
		seq = str(aseq["s"]) + '\n'
		go = 1
	except KeyError:
		go = 0
		pass

	do_dic = {}
	for domains in aseq['t']['pfam27']:
		if domains[0] not in do_dic.keys():
			do_dic[domains[0]] = 1
		else:
			do_dic[domains[0]] += 1
#	print aseq
	#doc = { '_id' : aseq['_id'], {'dom_pfam27' : do_dic }
	test = dbcount.domain_count.find_one({'_id':aseq['_id']})
	if test is None:
#		print aseq['_id'] + '\t' + str(do_dic)
		if do_dic != {}:
			dbcount.domain_count.insert({ '_id' : aseq['_id'], 'd_pf27' : do_dic })
	i += 1




89e9b275ebdd465de0f13df1daa9914d6e82061d
#! /usr/bin/env python 
###################################
#    Davi Ortega 1/29/2014 
###################################
import pymongo
import sys
import numpy

if '-h' in sys.argv:
	print 'This will take forever and it will require some reasonable disc space. Carefull now'
	sys.exit()

#MONGO
try:
	client = pymongo.MongoClient('localhost',27019)
except Connection:
	print "You must open a tunnel with ares.bio.utk.edu: ssh -L 27019:localhost:27017 ares.bio.utk.edu"
	sys.exit()
mist = client.mist22

local = pymongo.MongoClient()
dbcount = local.domain_count


#END MONGO

output = []
no_sequence = ''

i = 0

for aseq in mist.aseqs.find({'t.pfam27' : { '$exists' : 'true' }},{"s":1, "_id":1, "t" : 1}, timeout=False):
	if numpy.mod(i,5000) == 0:
		
		print i
#		if i != 0:
#			break
	try:
		seq = str(aseq["s"]) + '\n'
		go = 1
	except KeyError:
		go = 0
		pass

	do_dic = {}
	for domains in aseq['t']['pfam27']:
		if domains[0] not in do_dic.keys():
			do_dic[domains[0]] = 1
		else:
			do_dic[domains[0]] += 1
#	print aseq
	#doc = { '_id' : aseq['_id'], {'dom_pfam27' : do_dic }
	test = dbcount.domain_count.find_one({'_id':aseq['_id']})
	if test is None:
#		print aseq['_id'] + '\t' + str(do_dic)
		if do_dic != {}:
			dbcount.domain_count.insert({ '_id' : aseq['_id'], 'd_pf27' : do_dic })
	i += 1



