Ejemplo n.º 1
0
def individual(ind,individual):
   t = (ind,individual)
   cur = con.cursor()
   cur.execute("select * FROM ERV WHERE repName=? AND genoStart=?", t)
   ind = cur.fetchone() #Since we are only expected one result, fetchone make the search faster. 
   
   with open('cariofunctions.R', 'r') as f: #Allows to read the scripts from R. 
     string_again = f.read()

   imgs = STAP(string_again, "imgs") #Creates and object than later can be used to calle the functions inside of the R script.
   c = ind["genoName"][:5] #Get all the variables from the database.
   c = c.replace("_", "")  #KaryoplotteR recognizes the chromosome name like chr1, chr2, etc. Since the first letters of the name of the 
   start = int(ind["genoStart"]) #chromosomes from the database match with this nomenclature, we make sure to get the names correctly.  
   end = int(ind["genoEnd"])
   pngs = ""
   zpngs = ""
   if c!="chrUn":
      pngs = "static/img/"+c+str(start)+".png"  #Allows to name the final images and locate them in the right folder. 
      zpngs = "static/img/z"+c+str(start)+".png"
      cimg = imgs.localization(c,start,end,pngs) #Calls the R functions from the script. 
      zimg = imgs.zoom(c,start,end,zpngs)
   else:
      pngs =  "static/img/un.png" #In case that the chromosome is unknown (some cases in the database), an alternative image is displayed.
   return render_template('individual.html', ind = ind, pngs=pngs, zpngs=zpngs)