print "Chromosome " + str(curChr) + ". Inserting SNP Data." sys.stdout.flush() # Log current run start time result.snpInsertStart = time.time() # For each snp, insert record and then grab primary key 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