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) # Create new cursor, enter loci data into pgsql cursor = postgresConnection.cursor() print "Chromosome " + str(curChr) + ". Inserting loci data." # Log current run start time and number of loci result.lociInsertStart = time.time() # Insert each locus for locus in lociInserts: cursor.execute(locus) # Commit data to pgsql