for rsid,snp in snpInserts.iteritems(): cursor.execute(snp) rsidList[rsid] = cursor.fetchone()[0] # Commit all inserts to pgsql and grab end time postgresConnection.commit() # Log completed time, close pgsql cursor result.snpInsertEnd=time.time() cursor.close() # Clear list of SNPs to free up memory snpInserts.clear() print "Chromosome " + str(curChr) + ". Reading loci Data." result.lociLoadStart = time.time() # Now that we have primary keys for each SNP, read in loci data with open(curLociFilePath,'r') as csvfile: data = csv.reader(csvfile,delimiter='\t') for row in data: if(len(row) == 4): # Load loci in pgsql statements if row[0] in rsidList and rsidList[row[0]] > 0: # If RSID value is present, load with PK insStr = "INSERT INTO locus (mrna_acc, gene, class, snp_id) VALUES ('{0}', '{1}', '{2}', {3})".format(row[1], row[2], row[3], rsidList[row[0]]) lociInserts.append(insStr) # Data for reporting result.lociLoadEnd = time.time() result.totalLoci = len(lociInserts)