def __init__(self, fd=None, searchResult=None, colorScheme=None, userPrivilege=None, userName=None): cursor = webqtlDatabaseFunction.getCursor() if not cursor: return targetDescriptionChecked = fd.formdata.getvalue("targetDescriptionCheck", "") clusterChecked = fd.formdata.getvalue("clusterCheck", "") sessionfile = fd.formdata.getvalue("session") genotype = fd.genotype strainlist = [strain for strain in fd.strainlist if strain not in fd.parlist] ppolar = fd.ppolar mpolar = fd.mpolar traitList = [] traitDataList = [] for item in searchResult: thisTrait = webqtlTrait(fullname=item, cursor=cursor) thisTrait.retrieveInfo() thisTrait.retrieveData(strainlist) traitList.append(thisTrait) traitDataList.append(thisTrait.exportData(strainlist)) self.buildCanvas( colorScheme=colorScheme, targetDescriptionChecked=targetDescriptionChecked, clusterChecked=clusterChecked, sessionfile=sessionfile, genotype=genotype, strainlist=strainlist, ppolar=ppolar, mpolar=mpolar, traitList=traitList, traitDataList=traitDataList, userPrivilege=userPrivilege, userName=userName, )
def __init__(self, s): cursor = webqtlDatabaseFunction.getCursor() if not cursor: return # self.olds = s self.news = s self.match = False self.match_from = '' self.match_to = '' # search_name = re.compile('\s*go\s*[:=]\s*\S+\s*', re.I).search(self.olds) if search_name: self.match = True self.match_from = search_name.group() self.news = self.olds.replace(self.match_from, ' ') self.match_from = re.compile('\s+').sub('', self.match_from) cursor.execute( """ select genes from GORef where goterm=%s """, (self.match_from)) gorefs = cursor.fetchall() if len(gorefs) == 0: self.match_to = "" else: self.match_to = gorefs[0][0] self.news = self.match_to.strip() + ' ' + self.news.strip()
def __init__(self, fd=None): templatePage.__init__(self, fd) if webqtlConfig.USERDICT[self.privilege] >= webqtlConfig.USERDICT['admin']: pass else: heading = "Editing Info" detail = ["You don't have the permission to modify this file"] self.error(heading=heading,detail=detail,error="Error") return cursor = webqtlDatabaseFunction.getCursor() if (not cursor): return Id=self.trimValue(fd.formdata.getvalue('Id')) GN_AccesionId=self.trimValue(fd.formdata.getvalue('GN_AccesionId')) InfoPageName=self.trimValue(fd.formdata.getvalue('InfoPageName')) DatasetId=self.trimValue(fd.formdata.getvalue('DatasetId')) if Id=='-1': sharingInfoObject = SharingInfo2.SharingInfo2(GN_AccesionId, InfoPageName) GN_AccessionId,InfoPageName,info = sharingInfoObject.getInfo() if info: heading = "Editing Info" detail = ["The new dataset info record is duplicate."] self.error(heading=heading, detail=detail, error="Error") return sql = """INSERT INTO InfoFiles SET GN_AccesionId=%s, InfoPageName=%s, DatasetId=%s""" cursor.execute(sql, tuple([GN_AccesionId, InfoPageName, DatasetId])) infoupdate="This record has been succesfully added." else: sql = """UPDATE InfoFiles SET GN_AccesionId=%s, InfoPageName=%s, DatasetId=%s WHERE Id=%s""" cursor.execute(sql, tuple([GN_AccesionId, InfoPageName, DatasetId, Id])) infoupdate="This record has been succesfully updated." sharingInfoObject = SharingInfo2.SharingInfo2(GN_AccesionId, InfoPageName) sharingInfoObject.getInfo() sharingInfoObject.getDatasetsList() self.dict['body'] = sharingInfoObject.getBody(infoupdate=infoupdate)
def controlStrains(controls, strainlst): controls = controls.split(',') cvals = {} for oneTraitName in controls: oneTrait = webqtlTrait(fullname=oneTraitName, cursor=webqtlDatabaseFunction.getCursor() ) oneTrait.retrieveData() cvals[oneTraitName] = oneTrait.data tcstrains = [] tcvals = [] tcvars = [] for oneTraitName in controls: strains = [] vals = [] vars = [] for _strain in strainlst: if cvals[oneTraitName].has_key(_strain): _val = cvals[oneTraitName][_strain].val if _val != None: strains.append(_strain) vals.append(_val) vars.append(None) tcstrains.append(strains) tcvals.append(vals) tcvars.append(vars) return tcstrains, tcvals, tcvars, [len(x) for x in tcstrains]
def controlStrains(controls, strainlst): controls = controls.split(',') cvals = {} for oneTraitName in controls: oneTrait = webqtlTrait(fullname=oneTraitName, cursor=webqtlDatabaseFunction.getCursor()) oneTrait.retrieveData() cvals[oneTraitName] = oneTrait.data tcstrains = [] tcvals = [] tcvars = [] for oneTraitName in controls: strains = [] vals = [] vars = [] for _strain in strainlst: if cvals[oneTraitName].has_key(_strain): _val = cvals[oneTraitName][_strain].val if _val != None: strains.append(_strain) vals.append(_val) vars.append(None) tcstrains.append(strains) tcvals.append(vals) tcvars.append(vars) return tcstrains, tcvals, tcvars, [len(x) for x in tcstrains]
def getInfo(self): cursor = webqtlDatabaseFunction.getCursor() if (not cursor): return sql = "select Id, GEO_Series, Status, Title, Organism, Experiment_Type, Summary, Overall_Design, Contributor, Citation, Submission_Date, Contact_Name, Emails, Phone, URL, Organization_Name, Department, Laboratory, Street, City, State, ZIP, Country, Platforms, Samples, Species, Normalization, InbredSet, InfoPageName, DB_Name, Organism_Id, InfoPageTitle, GN_AccesionId, Tissue, AuthorizedUsers, About_Cases, About_Tissue, About_Download, About_Array_Platform, About_Data_Values_Processing, Data_Source_Acknowledge, Progreso from InfoFiles where " if(self.GN_AccessionId): sql += "GN_AccesionId = %s" cursor.execute(sql, self.GN_AccessionId) elif (self.InfoPageName): sql += "InfoPageName = %s" cursor.execute(sql, self.InfoPageName) else: raise 'No correct parameter found' info = cursor.fetchone() # fetch datasets file list try: conn = httplib.HTTPConnection("atlas.uthsc.edu") conn.request("GET", "/scandatasets.php?GN_AccesionId=%s" % (info[32])) response = conn.getresponse() data = response.read() filelist = data.split() conn.close() except Exception: filelist = [] return info, filelist
def __init__(self, s, ProbeSetFreezeId): cursor = webqtlDatabaseFunction.getCursor() if not cursor: return self.olds = s self.news = s sql = "SELECT ProbeSet.Symbol FROM pubmedsearch,ProbeSet,ProbeSetXRef WHERE " # pattern_name = re.compile("\s*name\s*[:=]((\s*\(.+?\)\s*)|(\s*\S+\s*))", re.I) search_name = pattern_name.search(self.news) if search_name: self.news = self.news.replace(search_name.group(), " ") keywords = search_name.group(1) keywords = keywords.strip() keywords = keywords.strip("(") keywords = keywords.strip(")") keywords = keywords.strip() keywords = keywords.split() for keyword in keywords: sql += ( "(MATCH (pubmedsearch.authorfullname,authorshortname) AGAINST ('%s' IN BOOLEAN MODE)) AND " % keyword ) _log.info("news_1: " + self.news) # pattern_inst = re.compile("\s*inst\s*[:=]((\s*\(.+?\)\s*)|(\s*\S+\s*))", re.I) search_inst = pattern_inst.search(self.news) if search_inst: self.news = self.news.replace(search_inst.group(), " ") keywords = search_inst.group(1) keywords = keywords.strip() keywords = keywords.strip("(") keywords = keywords.strip(")") keywords = keywords.strip() keywords = keywords.split() for keyword in keywords: sql += "(MATCH (pubmedsearch.institute) AGAINST ('%s' IN BOOLEAN MODE)) AND " % keyword _log.info("news_2: " + self.news) # if search_name or search_inst: sql += "pubmedsearch.geneid=ProbeSet.GeneId AND " sql += "ProbeSet.Id=ProbeSetXRef.ProbeSetId AND " sql += "ProbeSetXRef.ProbeSetFreezeId=%d " % ProbeSetFreezeId sql += "GROUP BY ProbeSet.Symbol;" _log.info("sql: " + sql) cursor.execute(sql) symbols1 = cursor.fetchall() symbols2 = "" for symbol in symbols1: symbols2 += symbol[0] + " " self.news = symbols2 + self.news _log.info("symbols2: " + symbols2) else: self.news = self.olds
def __init__(self, s, ProbeSetFreezeId): cursor = webqtlDatabaseFunction.getCursor() if (not cursor): return self.olds = s self.news = s sql = "SELECT ProbeSet.Symbol FROM pubmedsearch,ProbeSet,ProbeSetXRef WHERE " # pattern_name = re.compile('\s*name\s*[:=]((\s*\(.+?\)\s*)|(\s*\S+\s*))', re.I) search_name = pattern_name.search(self.news) if search_name: self.news = self.news.replace(search_name.group(), ' ') keywords = search_name.group(1) keywords = keywords.strip() keywords = keywords.strip('(') keywords = keywords.strip(')') keywords = keywords.strip() keywords = re.compile("[,;]").split(keywords) for keyword in keywords: keyword = keyword.strip() sql += "pubmedsearch.authorshortname like '%s' AND " % ("%" + keyword + "%") # pattern_inst = re.compile('\s*inst\s*[:=]((\s*\(.+?\)\s*)|(\s*\S+\s*))', re.I) search_inst = pattern_inst.search(self.news) if search_inst: self.news = self.news.replace(search_inst.group(), ' ') keywords = search_inst.group(1) keywords = keywords.strip() keywords = keywords.strip('(') keywords = keywords.strip(')') keywords = keywords.strip() keywords = keywords.split() for keyword in keywords: sql += "pubmedsearch.institute like '%s' AND " % ("%" + keyword + "%") # if search_name or search_inst: sql += "pubmedsearch.geneid=ProbeSet.GeneId AND " sql += "ProbeSet.Id=ProbeSetXRef.ProbeSetId AND " sql += "ProbeSetXRef.ProbeSetFreezeId=%d " % ProbeSetFreezeId sql += "GROUP BY ProbeSet.Symbol " sql += "LIMIT 200" #_log.info("pubmed sql: %s" % sql) cursor.execute(sql) symbols1 = cursor.fetchall() symbols2 = '' for symbol in symbols1: symbols2 += (symbol[0]+' ') self.news = symbols2 + self.news else: self.news = self.olds
def __init__(self, fd=None): templatePage.__init__(self, fd) GN_AccessionId = fd.formdata.getvalue('GN_AccessionId') InfoPageName = fd.formdata.getvalue('InfoPageName') cursor = webqtlDatabaseFunction.getCursor() if InfoPageName and not GN_AccessionId: sql = "select GN_AccesionId from InfoFiles where InfoPageName = %s" cursor.execute(sql, InfoPageName) GN_AccessionId = cursor.fetchone() url = webqtlConfig.CGIDIR + "main.py?FormID=sharinginfo&GN_AccessionId=%s" % GN_AccessionId self.redirection = url else: sharingInfoObject = SharingInfo.SharingInfo(GN_AccessionId, InfoPageName) self.dict['body'] = sharingInfoObject.getBody(infoupdate="")
def __init__(self, fd=None): templatePage.__init__(self, fd) if webqtlConfig.USERDICT[self.privilege] >= webqtlConfig.USERDICT['admin']: pass else: heading = "Deleting Info" detail = ["You don't have the permission to delete this dataset"] self.error(heading=heading,detail=detail,error="Error") return cursor = webqtlDatabaseFunction.getCursor() if (not cursor): return GN_AccessionId = fd.formdata.getvalue('GN_AccessionId') sql = "delete from InfoFiles where GN_AccesionId=%s" cursor.execute(sql, GN_AccessionId) re = cursor.fetchone() self.dict['body'] = "Delete dataset info record (GN_AccesionId=%s) successfully." % GN_AccessionId
def getInfo(self): cursor = webqtlDatabaseFunction.getCursor() if (not cursor): return field_names = """Id, GEO_Series, Status, Title, Organism, Experiment_Type, Summary, Overall_Design, Contributor, Citation, Submission_Date, Contact_Name, Emails, Phone, URL, Organization_Name, Department, Laboratory, Street, City, State, ZIP, Country, Platforms, Samples, Species, Normalization, InbredSet, InfoPageName, DB_Name, Organism_Id, InfoPageTitle, GN_AccesionId, Tissue, AuthorizedUsers, About_Cases, About_Tissue, About_Download, About_Array_Platform, About_Data_Values_Processing, Data_Source_Acknowledge, Progreso """ # We can use string interpolation here cause we own the string sql = """select %s from InfoFiles where """ % (field_names) if self.GN_AccessionId: sql += "GN_AccesionId = %s" cursor.execute(sql, self.GN_AccessionId) elif self.InfoPageName: sql += "InfoPageName = %s" cursor.execute(sql, self.InfoPageName) else: raise Exception('No correct parameter found') info = cursor.fetchone() info = todict(field_names, info) # fetch datasets file list filelist = [] if info["GN_AccesionId"]: url = "http://atlas.uthsc.edu/scandatasets.php?GN_AccesionId=%s" % ( info["GN_AccesionId"]) try: response = requests.get(url) except Exception as why: log.exception("Problem conneting to:", url) if response: data = response.text filelist = data.split() return info, filelist
def __init__(self, fd): templatePage.__init__(self, fd) self.redirect_url = None # Set if you want a redirect print("fd is:", pf(fd.__dict__)) # Todo: Need a [0] in line below????d GN_AccessionId = fd.get('GN_AccessionId') # Used under search datasharing InfoPageName = fd.get('database') # Might need to add a [0] cursor = webqtlDatabaseFunction.getCursor() if InfoPageName and not GN_AccessionId: sql = "select GN_AccesionId from InfoFiles where InfoPageName = %s" cursor.execute(sql, InfoPageName) GN_AccessionId = cursor.fetchone() self.redirect_url = urlparse.urljoin(webqtlConfig.ROOT_URL, "/data_sharing?GN_AccessionId=%s" % GN_AccessionId) #self.redirect_url = flask.url_for('data_sharing', GN_AccessionId=GN_AccessionId[0]) print("set self.redirect_url") #print("before redirect") #return flask.redirect(url) #print("after redirect") else: CauseError
def getInfo(self, create=False): cursor = webqtlDatabaseFunction.getCursor() if (not cursor): return sql = "SELECT InfoPageName, GN_AccesionId, Species.MenuName, Species.TaxonomyId, Tissue.Name, InbredSet.Name, GeneChip.GeneChipName, GeneChip.GeoPlatform, AvgMethod.Name, Datasets.DatasetName, Datasets.GeoSeries, Datasets.PublicationTitle, DatasetStatus.DatasetStatusName, Datasets.Summary, Datasets.AboutCases, Datasets.AboutTissue, Datasets.AboutDataProcessing, Datasets.Acknowledgment, Datasets.ExperimentDesign, Datasets.Contributors, Datasets.Citation, Datasets.Notes, Investigators.FirstName, Investigators.LastName, Investigators.Address, Investigators.City, Investigators.State, Investigators.ZipCode, Investigators.Country, Investigators.Phone, Investigators.Email, Investigators.Url, Investigators.Url, Organizations.OrganizationName, InvestigatorId, DatasetId, DatasetStatusId, Datasets.AboutPlatform FROM InfoFiles LEFT JOIN Species USING (SpeciesId) LEFT JOIN Tissue USING (TissueId) LEFT JOIN InbredSet USING (InbredSetId) LEFT JOIN GeneChip USING (GeneChipId) LEFT JOIN AvgMethod USING (AvgMethodId) LEFT JOIN Datasets USING (DatasetId) LEFT JOIN Investigators USING (InvestigatorId) LEFT JOIN Organizations USING (OrganizationId) LEFT JOIN DatasetStatus USING (DatasetStatusId) WHERE " if(self.GN_AccessionId): sql += "GN_AccesionId=%s" cursor.execute(sql, self.GN_AccessionId) elif (self.InfoPageName): sql += "InfoPageName=%s" cursor.execute(sql, self.InfoPageName) else: raise 'No correct parameter found' self.info = cursor.fetchone() if not self.info and self.InfoPageName and create: sql = "INSERT INTO InfoFiles SET InfoFiles.InfoPageName=%s" cursor.execute(sql, self.InfoPageName) return self.getInfo() if not self.GN_AccessionId and self.info: self.GN_AccessionId = self.info[1] if not self.InfoPageName and self.info: self.InfoPageName = self.info[0] return self.GN_AccessionId, self.InfoPageName, self.info
def __init__(self, fd=None): templatePage.__init__(self, fd) if webqtlConfig.USERDICT[self.privilege] >= webqtlConfig.USERDICT['admin']: pass else: heading = "Editing Info" detail = ["You don't have the permission to modify this file"] self.error(heading=heading,detail=detail,error="Error") return cursor = webqtlDatabaseFunction.getCursor() if (not cursor): return Id=fd.formdata.getvalue('Id') GN_AccesionId=fd.formdata.getvalue('GN_AccesionId') GEO_Series=fd.formdata.getvalue('GEO_Series') Status=fd.formdata.getvalue('Status') Title=fd.formdata.getvalue('Title') Organism_Id=fd.formdata.getvalue('Organism_Id') Organism=fd.formdata.getvalue('Organism') Experiment_Type =fd.formdata.getvalue('Experiment_Type') Summary=fd.formdata.getvalue('Summary') Overall_Design=fd.formdata.getvalue('Overall_Design') Contributor=fd.formdata.getvalue('Contributor') Citation=fd.formdata.getvalue('Citation') Submission_Date=fd.formdata.getvalue('Submission_Date') Contact_Name=fd.formdata.getvalue('Contact_Name') Emails=fd.formdata.getvalue('Emails') Phone=fd.formdata.getvalue('Phone') URL=fd.formdata.getvalue('URL') Organization_Name=fd.formdata.getvalue('Organization_Name') Department=fd.formdata.getvalue('Department') Laboratory=fd.formdata.getvalue('Laboratory') Street=fd.formdata.getvalue('Street') City=fd.formdata.getvalue('City') State=fd.formdata.getvalue('State') ZIP=fd.formdata.getvalue('ZIP') Country=fd.formdata.getvalue('Country') Platforms=fd.formdata.getvalue('Platforms') Samples=fd.formdata.getvalue('Samples') Species=fd.formdata.getvalue('Species') Tissue=fd.formdata.getvalue('Tissue') Normalization=fd.formdata.getvalue('Normalization') InbredSet=fd.formdata.getvalue('InbredSet') InfoPageName=fd.formdata.getvalue('InfoPageName') InfoPageTitle=fd.formdata.getvalue('InfoPageTitle') About_Cases=fd.formdata.getvalue('About_Cases') About_Tissue=fd.formdata.getvalue('About_Tissue') About_Download=fd.formdata.getvalue('About_Download') About_Array_Platform=fd.formdata.getvalue('About_Array_Platform') About_Data_Values_Processing=fd.formdata.getvalue('About_Data_Values_Processing') Data_Source_Acknowledge=fd.formdata.getvalue('Data_Source_Acknowledge') AuthorizedUsers=fd.formdata.getvalue('AuthorizedUsers') Progress=fd.formdata.getvalue('Progress') if Id=='-1': sharingInfoObject = SharingInfo.SharingInfo(GN_AccesionId, InfoPageName) info, filelist = sharingInfoObject.getInfo() if info: heading = "Editing Info" detail = ["The new dataset info record is duplicate."] self.error(heading=heading, detail=detail, error="Error") return sql = """INSERT INTO InfoFiles SET GN_AccesionId=%s, GEO_Series=%s, Status=%s, Title=%s, Organism_Id=%s, Organism=%s, Experiment_Type=%s, Summary=%s, Overall_Design=%s, Contributor=%s, Citation=%s, Submission_Date=%s, Contact_Name=%s, Emails=%s, Phone=%s, URL=%s, Organization_Name=%s, Department=%s, Laboratory=%s, Street=%s, City=%s, State=%s, ZIP=%s, Country=%s, Platforms=%s, Samples=%s, Species=%s, Tissue=%s, Normalization=%s, InbredSet=%s, InfoPageName=%s, InfoPageTitle=%s, About_Cases=%s, About_Tissue=%s, About_Download=%s, About_Array_Platform=%s, About_Data_Values_Processing=%s, Data_Source_Acknowledge=%s, AuthorizedUsers=%s, Progreso=%s""" cursor.execute(sql, tuple([GN_AccesionId, GEO_Series, Status, Title, Organism_Id, Organism, Experiment_Type, Summary, Overall_Design, Contributor, Citation, Submission_Date, Contact_Name, Emails, Phone, URL, Organization_Name, Department, Laboratory, Street, City, State, ZIP, Country, Platforms, Samples, Species, Tissue, Normalization, InbredSet, InfoPageName, InfoPageTitle, About_Cases, About_Tissue, About_Download, About_Array_Platform, About_Data_Values_Processing, Data_Source_Acknowledge, AuthorizedUsers, Progress])) infoupdate="This record has been succesfully added." else: sql = """UPDATE InfoFiles SET GN_AccesionId=%s, GEO_Series=%s, Status=%s, Title=%s, Organism_Id=%s, Organism=%s, Experiment_Type=%s, Summary=%s, Overall_Design=%s, Contributor=%s, Citation=%s, Submission_Date=%s, Contact_Name=%s, Emails=%s, Phone=%s, URL=%s, Organization_Name=%s, Department=%s, Laboratory=%s, Street=%s, City=%s, State=%s, ZIP=%s, Country=%s, Platforms=%s, Samples=%s, Species=%s, Tissue=%s, Normalization=%s, InbredSet=%s, InfoPageName=%s, InfoPageTitle=%s, About_Cases=%s, About_Tissue=%s, About_Download=%s, About_Array_Platform=%s, About_Data_Values_Processing=%s, Data_Source_Acknowledge=%s, AuthorizedUsers=%s, Progreso=%s WHERE Id=%s""" cursor.execute(sql, tuple([GN_AccesionId, GEO_Series, Status, Title, Organism_Id, Organism, Experiment_Type, Summary, Overall_Design, Contributor, Citation, Submission_Date, Contact_Name, Emails, Phone, URL, Organization_Name, Department, Laboratory, Street, City, State, ZIP, Country, Platforms, Samples, Species, Tissue, Normalization, InbredSet, InfoPageName, InfoPageTitle, About_Cases, About_Tissue, About_Download, About_Array_Platform, About_Data_Values_Processing, Data_Source_Acknowledge, AuthorizedUsers, Progress, Id])) infoupdate="This record has been succesfully updated." sharingInfoObject = SharingInfo.SharingInfo(GN_AccesionId, InfoPageName) self.dict['body'] = sharingInfoObject.getBody(infoupdate=infoupdate)
def __init__(self,tissueProbeSetFreezeId=None): #initialize parameters self.tProbeSetFreezeId = tissueProbeSetFreezeId self.cursor = webqtlDatabaseFunction.getCursor()
import csv from dbFunction import webqtlDatabaseFunction from base import webqtlConfig cursor = webqtlDatabaseFunction.getCursor() file_reader = csv.reader(open("/gnshare/gn/web/webqtl/SG-GN463.csv", "rb"), delimiter=',') for row in file_reader: if "->" in row[2]: continue; else: tissue = row[0] condition = row[1] case_name = row[2] sex = row[3] age = row[4] #ethn = row[5] #pmi = row[6] #ph = row[7] cursor.execute("""SELECT Strain.Id FROM Strain WHERE Strain.Name = '%s'""" % (case_name)) try: case_id = cursor.fetchone()[0] except: