Ejemplo n.º 1
0
print "done!"

##
# Calculation begins at this point.
results = {}

database = mysql.connector.Connect(**DB_INFO)
db = database.cursor()
db.execute("SELECT rsid FROM diseases.neandertal_snps;")

for nrsid in [row[0] for row in db.fetchall()]:
  user_nsnp = user_snps.get(nrsid, None)
  
  # We could not get this SNP directly: impute.
  if user_nsnp is None:
    user_nsnp = genotype_tools.impute_rsid_simple(user_snps, nrsid, population)
    print "Imputed %s -> %s." % (user_nsnp.nearest_SNP, user_nsnp.rsid,)

  snp_info = get_snp_info(user_nsnp)
  # If we imputed, user_nsnp.rsid is the imputed rsid, and nearest_SNP is the
  # rsid of the SNP we were imputing from (imputing for).
  if user_nsnp.nearest_SNP is not None:
    snp_info["imputed_from"] = user_nsnp.nearest_SNP
  results[user_nsnp.rsid] = snp_info

nnumerator   = sum(a["score"][0] for a in results.values())
ndenominator = sum(a["score"][1] for a in results.values())

# Name the output HTML file based on the input genome file"s name.
filename = os.path.splitext(os.path.split(user_genome_path)[1])[0]
out_file_name = "%s.html" % (filename,)
Ejemplo n.º 2
0
# For each EL-SNP, we get the value of that SNP from the provided genome 
# and adjust the running EL and AL scores according to those values from the
# paper.

# Track all SNPs for output.
results = {}

for el_rsid in el_rsids:
  # If we already have a value for this SNP - use it.
  user_el_snp = user_snps.get("rs" + el_rsid, None)
  
  # Impute if we have to...
  if user_el_snp is None:
    try:
      user_el_snp = genotype_tools.impute_rsid_simple(
        user_snps, "rs" + el_rsid, population
      )

    # TODO: workaround error with rs2042831 and CEU from Mikolaj Habryn.
    except ValueError, e:
      print "Error occurred imputing for rs%s: %s." % (el_rsid, e)
      continue

    # This SNP was imputed.
    print "Imputed %s." % (user_el_snp.nearest_SNP,)
    
  # Imputation returned None (this should never happen).
  if user_el_snp is None:
    print "Unable to impute value for rs%s: imputation returned None." % el_rsid
    continue