def createProject(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` # Handlers pHandler = ProjectDatabaseHandler(db, cursor) uHandler = UserHandler(db, cursor) # Get form values projectID = form.getvalue("packetID") ownerID = form.getvalue("packetOwner") # get owner's name packetOwner = uHandler.getUserByID(ownerID) packetName = form.getvalue("packetName") packetDescription = form.getvalue("packetDescription") # private or public if form.getvalue("private_or_public") == "public": isPrivate = False else: isPrivate = True # Lists of project readers & editors # These are lists of INTEGER USER IDs!!!!! # A User instance needs to be created for each!!!!!!! projectReaderIDs = form.getlist("readersTargetList") projectWriterIDs = form.getlist("writersTargetList") projectReaders = [] projectWriters = [] for rID in projectReaderIDs: tmpReader = uHandler.getUserByID(rID) projectReaders.append(tmpReader) for wID in projectWriterIDs: tmpWriter = uHandler.getUserByID(wID) # Now check if the user is an OpenFreezer writer - otherwise cannot be made Writer on a project if tmpWriter.getCategory() != 'Reader': projectWriters.append(tmpWriter) newProject = Packet(projectID, packetName, packetDescription, packetOwner, isPrivate, projectReaders, projectWriters) packetID = pHandler.insertPacket( newProject) # new project is empty by default self.showProjectDetails('view', newProject)
def createProject(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` # Handlers pHandler = ProjectDatabaseHandler(db, cursor) uHandler = UserHandler(db, cursor) # Get form values projectID = form.getvalue("packetID") ownerID = form.getvalue("packetOwner") # get owner's name packetOwner = uHandler.getUserByID(ownerID) packetName = form.getvalue("packetName") packetDescription = form.getvalue("packetDescription") # private or public if form.getvalue("private_or_public") == "public": isPrivate = False else: isPrivate = True # Lists of project readers & editors # These are lists of INTEGER USER IDs!!!!! # A User instance needs to be created for each!!!!!!! projectReaderIDs = form.getlist("readersTargetList") projectWriterIDs = form.getlist("writersTargetList") projectReaders = [] projectWriters = [] for rID in projectReaderIDs: tmpReader = uHandler.getUserByID(rID) projectReaders.append(tmpReader) for wID in projectWriterIDs: tmpWriter = uHandler.getUserByID(wID) # Now check if the user is an OpenFreezer writer - otherwise cannot be made Writer on a project if tmpWriter.getCategory() != 'Reader': projectWriters.append(tmpWriter) newProject = Packet(projectID, packetName, packetDescription, packetOwner, isPrivate, projectReaders, projectWriters) packetID = pHandler.insertPacket(newProject) # new project is empty by default self.showProjectDetails('view', newProject)
def deleteProject(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` pHandler = ProjectDatabaseHandler(db, cursor) # Get form values pID = int(form.getvalue("packetID")) success = int(pHandler.deleteProject(pID)) utils.redirect(hostname + "Project.php?View=3&Success=" + `success` + "&pID=" + `pID`)
def printProjectInfo(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` projectID = int(form.getvalue('packets')) pHandler = ProjectDatabaseHandler(db, cursor) newProject = pHandler.findPacket(projectID) self.showProjectDetails('view', newProject)
def deleteProject(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` pHandler = ProjectDatabaseHandler(db, cursor) # Get form values pID = int(form.getvalue("packetID")) success = int(pHandler.deleteProject(pID)) utils.redirect(hostname + "Project.php?View=3&Success=" + ` success ` + "&pID=" + ` pID `)
def modifyProject(self, form): #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` db = self.__db cursor = self.__cursor hostname = self.__hostname # Handlers pHandler = ProjectDatabaseHandler(db, cursor) uHandler = UserHandler(db, cursor) # Get project ID from form projectID = form.getvalue("packetID") ownerID = form.getvalue("packetOwner") # get owner's name packetOwner = uHandler.getUserByID(ownerID) packetName = form.getvalue("packetName") packetDescription = form.getvalue("packetDescription") # access type: accessType = form.getvalue("private_or_public") if accessType == 'Private': isPrivate = True else: isPrivate = False # Lists of project readers & editors # In this view, these are list of INTEGER USER IDs # A User instance needs to be created for each!!!!!!! projectReaderIDs = form.getlist("projectReaders") projectWriterIDs = form.getlist("projectWriters") projectReaders = [] projectWriters = [] for rID in projectReaderIDs: tmpReader = uHandler.getUserByID(rID) projectReaders.append(tmpReader) for wID in projectWriterIDs: tmpWriter = uHandler.getUserByID(wID) projectWriters.append(tmpWriter) newProject = Packet(projectID, packetName, packetDescription, packetOwner, isPrivate, projectReaders, projectWriters) self.showProjectDetails('edit', newProject)
def modifyUser(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname uHandler = UserHandler(db, cursor) lHandler = LabHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) ucMapper = UserCategoryMapper(db, cursor) category_Name_ID_Map = ucMapper.mapCategoryNameToID() # print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! # print # DITTO # print `form` # Get form values userID = int(form.getvalue("userID")) newUser = uHandler.getUserByID(userID) """ labID = int(form.getvalue("labID")) username = form.getvalue("username") firstName = form.getvalue("firstName") lastName = form.getvalue("lastName") description = firstName + " " + lastName email = form.getvalue("email") passwd = form.getvalue("password") """ readProjects = pHandler.findMemberProjects(userID, "Reader") newUser.setReadProjects(readProjects) writeProjects = pHandler.findMemberProjects(userID, "Writer") newUser.setWriteProjects(writeProjects) self.printUserInfo("edit", newUser)
def modifyUser(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname uHandler = UserHandler(db, cursor) lHandler = LabHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) ucMapper = UserCategoryMapper(db, cursor) category_Name_ID_Map = ucMapper.mapCategoryNameToID() #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` # Get form values userID = int(form.getvalue("userID")) newUser = uHandler.getUserByID(userID) ''' labID = int(form.getvalue("labID")) username = form.getvalue("username") firstName = form.getvalue("firstName") lastName = form.getvalue("lastName") description = firstName + " " + lastName email = form.getvalue("email") passwd = form.getvalue("password") ''' readProjects = pHandler.findMemberProjects(userID, 'Reader') newUser.setReadProjects(readProjects) writeProjects = pHandler.findMemberProjects(userID, 'Writer') newUser.setWriteProjects(writeProjects) self.printUserInfo('edit', newUser)
def findPacket(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname pHandler = ProjectDatabaseHandler(db, cursor) packets = [] pString = "" keyword = form.getvalue("keyword") packetsList = pHandler.matchProjectKeyword(keyword) for pID in packetsList: pText = packetsList[pID] packets.append(pText) pString = string.join(packets, ", ") print "Content-type:text/html" print print pString
def deleteUser(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname uHandler = UserHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) # print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! # print # DITTO # print `form` uid = form.getvalue("userID") # list of user IDs # deletionCandidates = form.getlist("deletionCandidates") # Delete users and revoke their access to projects # for uid in deletionCandidates: uHandler.deleteUser(uid) pHandler.deleteMemberFromllProjects(uid) utils.redirect(hostname + "User.php?View=2&Del=1")
def deleteUser(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname uHandler = UserHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` uid = form.getvalue("userID") # list of user IDs #deletionCandidates = form.getlist("deletionCandidates") # Delete users and revoke their access to projects #for uid in deletionCandidates: uHandler.deleteUser(uid) pHandler.deleteMemberFromllProjects(uid) utils.redirect(hostname + "User.php?View=2&Del=1")
def cancelUserModification(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` uHandler = UserHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) userID = int(form.getvalue('userID')) newUser = uHandler.getUserByID(userID) self.printUserInfo('view', newUser)
def saveUser(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname # print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! # print # DITTO # print `form` uHandler = UserHandler(db, cursor) lHandler = LabHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) ucMapper = UserCategoryMapper(db, cursor) category_ID_Name_Map = ucMapper.mapCategoryIDToName() newProps = {} # Get form values userID = int(form.getvalue("userID")) newUser = uHandler.getUserByID(userID) labID = int(form.getvalue("labs")) tmpLab = lHandler.findLabByID(labID) # rest of user properties username = form.getvalue("username") firstName = form.getvalue("firstName") lastName = form.getvalue("lastName") description = firstName + " " + lastName email = form.getvalue("email") category = category_ID_Name_Map[int(form.getvalue("system_access_level"))] newProps["labID"] = labID newProps["username"] = username newProps["firstname"] = firstName newProps["lastname"] = lastName newProps["description"] = description newProps["email"] = email newProps["category"] = category try: # Now do an update on database level AND on class level: uHandler.updateUserProperties(userID, newProps) # database update # Interface level newUser.setUsername(username) newUser.setFirstName(firstName) newUser.setLastName(lastName) newUser.setDescription(description) newUser.setEmail(email) newUser.setLab(tmpLab) newUser.setCategory(category) # update list of user's projects if form.has_key("userProjectsReadonly"): # list of IDs readonlyProjects = utils.unique(form.getlist("userProjectsReadonly")) pHandler.updateUserProjects(userID, readonlyProjects, "Reader") else: # safe to assume should delete projects? pHandler.deleteMemberProjects(userID, "Reader") if form.has_key("userProjectsWrite"): writeProjects = utils.unique(form.getlist("userProjectsWrite")) pHandler.updateUserProjects(userID, writeProjects, "Writer") else: # safe to assume should delete projects? pHandler.deleteMemberProjects(userID, "Writer") # think about this # newUser.setReadProjects(readProjects) # newUser.setWriteProjects(writeProjects) # return to detailed view self.printUserInfo("view", newUser) # utils.redirect(hostname + "User.php?View=3&fd=" + filename) except DuplicateUsernameException: # return to the view with input values and error message # Need to construct a dummy User instance to save form values for error output on the next page (otherwise they're lost as soon as Submit is pressed and creation view is exited) newLab = lHandler.findLabByID(labID) newUser = User(userID, username, firstName, lastName, description, newLab, category, email, "") self.printUserInfo("edit", newUser, "Dup_un")
def saveProject(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` # Handlers pHandler = ProjectDatabaseHandler(db, cursor) uHandler = UserHandler(db, cursor) # Get project ID from form projectID = form.getvalue("packetID") ownerID = form.getvalue("packetOwner") # get owner's name packetOwner = uHandler.getUserByID(ownerID) packetName = form.getvalue("packetName") packetDescription = form.getvalue("packetDescription") # private or public if form.getvalue("private_or_public") == "public": isPrivate = False else: isPrivate = True # Lists of project readers & editors # Updated Sept. 3/08: Do NOT save readers for a public project if isPrivate: projectReaderIDs = form.getlist("readersList") else: projectReaderIDs = [] # writers are always needed projectWriterIDs = form.getlist("writersList") projectReaders = [] projectWriters = [] for rID in projectReaderIDs: tmpReader = uHandler.getUserByID(rID) projectReaders.append(tmpReader) for wID in projectWriterIDs: tmpWriter = uHandler.getUserByID(wID) # check categories - a Reader cannot be given Write access to a project if tmpWriter.getCategory() != 'Reader': projectWriters.append(tmpWriter) #projectWriters.append(tmpWriter) # Update database values pHandler.updatePacket(projectID, ownerID, packetName, packetDescription, isPrivate, projectReaderIDs, projectWriterIDs) # Output new values newProject = Packet(projectID, packetName, packetDescription, packetOwner, isPrivate, projectReaders, projectWriters) self.showProjectDetails('view', newProject)
def addUser(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname mail_server = self.__mail_server # August 19, 2011 mail_programmer = self.__mail_programmer # July 30, 2010 mail_biologist = self.__mail_biologist mail_admin = self.__mail_admin # print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! # print # DITTO # print `form` uHandler = UserHandler(db, cursor) lHandler = LabHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) ucMapper = UserCategoryMapper(db, cursor) category_Name_ID_Map = ucMapper.mapCategoryNameToID() # Get form values labID = int(form.getvalue("labs")) username = form.getvalue("username") firstName = form.getvalue("firstName") lastName = form.getvalue("lastName") description = firstName + " " + lastName to_email = form.getvalue("email") from_email = mail_admin # Change July 30, 2010 - random password generator # passwd = form.getvalue("password") chars = string.letters + string.digits passwd = "" for i in range(10): passwd += choice(chars) # System access level: Lab default or override? # if form.getvalue("privChoiceRadio") == 'override': accessLevel = category_Name_ID_Map[form.getvalue("system_access_level")] # else: # accessLevel = lHandler.findDefaultAccessLevel(labID) newProps = {} try: # Insert User information userID = uHandler.insertUser( username, firstName, lastName, description, accessLevel, to_email, passwd, labID ) # newUser = uHandler.getUserByID(userID) tmpLab = lHandler.findLabByID(labID) # print tmpLab.getName() # Insert Project info # Sept. 11/07: Differentiate between user categories Reader and Writer - different field names if form.has_key("userProjectsReadonly"): # list of IDs readonlyProjects = utils.unique(form.getlist("userProjectsReadonly")) # print `readonlyProjects` pHandler.insertMemberProjects(userID, readonlyProjects, "Reader") elif form.has_key("userProjectsReadonlyWrite"): # list of IDs readonlyProjects = utils.unique(form.getlist("userProjectsReadonlyWrite")) # print `readonlyProjects` pHandler.insertMemberProjects(userID, readonlyProjects, "Reader") # Write projects exist only for Writers if form.has_key("userProjectsWrite"): writeProjects = utils.unique(form.getlist("userProjectsWrite")) pHandler.insertMemberProjects(userID, writeProjects, "Writer") # don't assign projects to a User instance - will retrieve them from db in output function newUser = User( userID, username, firstName, lastName, description, tmpLab, form.getvalue("system_access_level"), to_email, passwd, [], [], ) email_subject = "OpenFreezer User Account" msg = email.MIMEMultipart.MIMEMultipart("alternative") msg["Subject"] = email_subject msg["To"] = to_email msgText = ( "Hi " + firstName + ",<BR><BR>An OpenFreezer account has been created for you. Your access level is " + form.getvalue("system_access_level") + ", so you can " ) if form.getvalue("system_access_level") == "Reader": msgText += "search for clones. If you wish to add/modify reagents or create projects, please contact the administrator to upgrade your access level.<BR>" elif form.getvalue("system_access_level") == "Writer": msgText += "search, add, and modify reagents. If you wish to create projects, please contact the administrator to upgrade your access level.<BR>" elif form.getvalue("system_access_level") == "Creator": msgText += "search for clones, add and modify reagents, as well as create your own projects.<BR>" ##################################################### # CHANGE TEXT AS NEEDED ##################################################### msgText += ( "<BR>The URL to access the system is <a href='" + hostname + "'>" + hostname + "</a>. Your username is <b>" + username + "</b>, and your temporary password is <b>" + passwd + "</b>. Please <u>change the temporary password as soon as you log into the website</u> - you can do it through the 'Change your password' link under the 'User Management' menu section.<BR><BR>Please refer to http://openfreezer.org for additional support.<BR><BR>Sincerely,<BR>OpenFreezer support team.<BR><BR><span style='font-family:Courier; font-size:10pt;'><HR>This is an automatically generated e-mail message. Please do not reply to this e-mail. All questions should be directed to your local administrator.</span>" ) msgText = email.MIMEText.MIMEText(msgText, "html") msg.attach(msgText) server = smtplib.SMTP(mail_server) server.set_debuglevel(1) server.sendmail(from_email, [to_email], msg.as_string()) server.quit() self.printUserInfo("view", newUser) except DeletedUserException: # Without asking too many questions, reactivate the deleted user and overwrite his/her attributes with the form input values userID = uHandler.findUserIDByUsername(username) newProps["firstname"] = firstName newProps["lastname"] = lastName newProps["description"] = description newProps["email"] = email newProps["status"] = "ACTIVE" newProps["password"] = passwd # Insert new database values and create new object uHandler.updateUserProperties(userID, newProps) # database update newUser = uHandler.getUserByID(userID) # Insert Project info readProjects = [] writeProjects = [] if form.has_key("userProjectsReadonly"): # list of IDs readonlyProjects = form.getlist("userProjectsReadonly") for r in readonlyProjects: pHandler.addProjectMember(r, userID, "Reader") # tmpReadProject = pHandler.findPacket(r) # readProjects.append(tmpReadProject) # newUser.addProject(tmpReadProject, 'read') if form.has_key("userProjectsWrite"): writeProjects = form.getlist("userProjectsWrite") for w in writeProjects: pHandler.addProjectMember(w, userID, "Writer") # tmpWriteProject = pHandler.findPacket(w) # writeProjects.append(tmpWriteProject) # newUser.addProject(tmpWriteProject, 'write') # newUser.setReadProjects(readProjects) # newUser.setWriteProjects(writeProjects) self.printUserInfo("view", newUser) # utils.redirect(hostname + "User.php?View=3&fd=" + filename) except DuplicateUsernameException: # return to the view with input values and error message # Need to construct a dummy User instance to save form values for error output on the next page (otherwise they're lost as soon as Submit is pressed and creation view is exited) newLab = lHandler.findLabByID(labID) newUser = User(0, username, firstName, lastName, description, newLab, "", email, passwd) self.printUserInfo("create", newUser)
def printReagentInfo(self, cmd, reagent, errMsg=""): dbConn = DatabaseConn() hostname = dbConn.getHostname() # to define form action URL db = dbConn.databaseConnect() cursor = db.cursor() gOut = GeneralOutputClass() currUser = Session.getUser() currUserID = currUser.getUserID() sHandler = SystemSetHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) # print menu content = gOut.printHeader() + gOut.printMainMenu() # common to all reagent types projectList = utils.unique(pHandler.findMemberProjects(currUserID, 'Writer') + pHandler.findMemberProjects(currUserID, 'Owner')) # Differentiate other properties by reagent type if reagent.getType() == 'Insert': # Fetch dropdown list values to output on the form iTypeList = sHandler.findAllSetValues("type of insert") statusList = sHandler.findAllSetValues("status") cloningMethodList = sHandler.findAllSetValues("insert cloning method") fpcsList = sHandler.findAllSetValues("5' cloning site") tpcsList = sHandler.findAllSetValues("3' cloning site") tagTypeList = sHandler.findAllSetValues("tag") tagPositionList = sHandler.findAllSetValues("tag position") openClosedList = sHandler.findAllSetValues("open/closed") speciesList = sHandler.findAllSetValues("species") verificationList = sHandler.findAllSetValues("verification") # Initialize property values iType = "" iName = "" iStatus = "" cloningMethod = "" projectID = "" fpcs = "" tpcs = "" tagType = "" tagPosition = "" openClosed = "" species = "" accession = "" altID = "" geneID = "" ensemblID = "" geneSymbol = "" fp_start = "" tp_stop = "" fwd_linker = "" rev_linker = "" funcDescr = "" verification = "" expComm = "" verComm = "" sequence = "" # Fetch POST values if available: allProps = reagent.getProperties() if allProps.has_key("type of insert"): iType = allProps["type of insert"] if allProps.has_key("name"): iName = allProps["name"] if allProps.has_key("status"): iStatus = allProps["status"] if allProps.has_key("insert cloning method"): cloningMethod = allProps["insert cloning method"] if allProps.has_key("packet id"): projectID = int(allProps["packet id"]) if allProps.has_key("5' cloning site"): fpcs = allProps["5' cloning site"] if allProps.has_key("3' cloning site"): tpcs = allProps["3' cloning site"] if allProps.has_key("tag"): tagType = allProps["tag"] if allProps.has_key("tag position"): tagPosition = allProps["tag position"] if allProps.has_key("open/closed"): openClosed = allProps["open/closed"] if allProps.has_key("species"): species = allProps["species"] if allProps.has_key("accession number"): accession = allProps["accession number"] if allProps.has_key("alternate id"): altID = allProps["alternate id"] if allProps.has_key("entrez gene id"): geneID = allProps["entrez gene id"] if allProps.has_key("ensembl gene id"): ensemblID = allProps["ensembl gene id"] if allProps.has_key("official gene symbol"): geneSymbol = allProps["official gene symbol"] if allProps.has_key("5' start"): fp_start = allProps["5' start"] if allProps.has_key("3' stop"): tp_stop = allProps["3' stop"] if allProps.has_key("5' linker"): fwd_linker = allProps["5' linker"] if allProps.has_key("3' linker"): rev_linker = allProps["3' linker"] if allProps.has_key("description"): funcDescr = allProps["description"] if allProps.has_key("verification"): verification = allProps["verification"] if allProps.has_key("comments"): expComm = allProps["comments"] if allProps.has_key("verification comments"): verComm = allProps["verification comments"] if allProps.has_key("sequence"): sequence = allProps["sequence"] # associations ipvID = "" senseOligoID = "" antisenseOligoID = "" allAssoc = reagent.getAssociations() ''' if allAssoc.has_key("insert_parent_vector"): ipvID = allAssoc["insert_parent_vector"] if allAssoc.has_key("sense_oligo"): senseOligoID = allAssoc["sense_oligo"] if allAssoc.has_key("antisense_oligo"): antisenseOligoID = allAssoc["antisense_oligo"] ''' # Action: Output form with POST values if set if cmd == 'create': content += ''' <div class="main"> <form NAME="create_insert_form" ACTION="%s" METHOD="POST" onSubmit="return validateInsert() && verifyParents();"> ''' content += "<INPUT type=\"hidden\" ID=\"curr_username_hidden\" NAME=\"curr_username\" value=\"" + currUser.getFullName() + "\">" content += ''' <input type="hidden" name="reagent_type_hidden" value="Insert"> <table id="vector_insertproperty_table_id" border="1" width="780px" cellpadding="4" frame="box" rules="all"> ''' if errMsg != "": content += "<th colspan=\"3\" style=\"color:#0000FF; text-align:left; font-weight:normal\">There was a problem:<br><P>" + errMsg + "<BR><BR></th>" content += ''' <tr> <td colspan="3" style="text-align:center"> <span style="color:#0000CD; font-size:13pt; font-weight:bold"> Insert Information </span> <br> <span style="font-size:8pt; color:#FF0000"> Fields marked with a red asterisk (*) are mandatory </span> </td> </tr> <tr> <td width="180px"> Type of Insert <span style="font-size:8pt; color:#FF0000; font-weight:bold">*</span> </td> <td width="275px"> <SELECT id="itype_list" size="1" NAME="INPUT_INSERT_info_insert_type_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(iType) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for it in iTypeList: content += "<OPTION VALUE=\"" + it + "\"" if it == iType: content += " SELECTED>" + it + "</OPTION>" else: content += ">" + it + "</OPTION>" content += ''' </SELECT> </td> <td> Describes the type of insert. Users select from a pre-defined list. Designed to make insert use more apparent and searches easier. </td> </tr> <tr> <td> Name </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_name_prop\" value=\"" + iName + "\">" content += ''' </td> <td> Name that describes the reagent - free text field </td> </tr> <tr> <td> Status </td> <td> <SELECT id="status_list" name="INPUT_INSERT_info_status_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(iStatus) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for s in statusList: content += "<OPTION VALUE=\"" + s + "\"" if s == iStatus: content += " SELECTED>" + s + "</OPTION>" else: content += ">" + s + "</OPTION>" content += ''' </td> <td> Indicates the status and availability of the reagent. Users select from a pre-defined list. </td> </tr> <tr> <td> Insert Cloning Method </td> <td> <SELECT size="1" id="cm_list" name="INPUT_INSERT_info_cloning_method_prop" onChange="showCMText()"> ''' # default option content += "<OPTION VALUE=\"\" " if len(cloningMethod) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for cm in cloningMethodList: content += "<OPTION VALUE=\"" + cm + "\"" if cm == cloningMethod: content += " SELECTED>" + cm + "</OPTION>" else: content += ">" + cm + "</OPTION>" content += ''' </td> <td> Describes the method used to create the insert (e.g. PCR or RE (restriction enzyme)) and provides additional information for its cloning into a vector (eg. by RE, In Fusion or BP reaction) </td> </tr> <tr> <td> Project ID <span style="font-size:8pt; color:#FF0000; font-weight:bold">*</span> </td> <td> <select id="packetList_insert" size="1" name="INPUT_INSERT_info_packet_id_prop"> ''' # need to sort projects pNums = [] projects = {} # (pID, Packet) for p in projectList: pID = p.getNumber() pNums.append(pID) projects[pID] = p pNums.sort() for pID in pNums: p = projects[pID] content += "<OPTION VALUE=\"" + `p.getNumber()` + "\"" if p.getNumber() == projectID: content += " SELECTED>" + `p.getNumber()` + ": " + p.getOwner().getLastName() + ": " + p.getName() + "</OPTION>" else: content += ">" + `p.getNumber()` + ": " + p.getOwner().getLastName() + ": " + p.getName() + "</OPTION>" content += ''' </select> <BR> <div id="packet_warning_insert" style="display:none; color:#FF0000">Please select a Project ID from the dropdown list</div> </td> <td> Indicates what person and project originally created the reagent. </td> </tr> <tr> <td> 5' Cloning Site on Insert </td> <td> <SELECT size="1" id="fpcs_list" name="INPUT_INSERT_info_5_prime_cloning_site_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(fpcs) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for fps in fpcsList: content += "<OPTION VALUE=\"" + fps + "\"" if fps == fpcs: content += " SELECTED>" + fps + "</OPTION>" else: content += ">" + fps + "</OPTION>" content += ''' </td> <td> Indicates what 5' site on the insert was used to clone it into a vector. May not necessarily be the same as for the vector. Users select from a pre-defined list. </td> </tr> <tr> <td> 3' Cloning Site on Insert </td> <td> <SELECT size="1" id="tpcs_list" name="INPUT_INSERT_info_3_prime_cloning_site_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(tpcs) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for tps in tpcsList: content += "<OPTION VALUE=\"" + tps + "\"" if tps == tpcs: content += " SELECTED>" + tps + "</OPTION>" else: content += ">" + tps + "</OPTION>" content += ''' </td> <td> Indicates what 3' site on the insert was used to clone it into a vector. May not necessarily be the same as for the vector. Users select from a pre-defined list. </td> </tr> <tr> <td> Tag </td> <td> <SELECT size="1" id="tag_list" name="INPUT_INSERT_info_tag_prop" onChange="showTagTypeBox()"> ''' # default option content += "<OPTION VALUE=\"\" " if len(tagType) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for tt in tagTypeList: content += "<OPTION VALUE=\"" + tt + "\"" if tt == tagType: content += " SELECTED>" + tt + "</OPTION>" else: content += ">" + tt + "</OPTION>" content += ''' </td> <td> Indicates if the insert itself has a tag associated with it (outside of the backbone vector). Users select from a pre-defined list. </td> </tr> <tr> <td> Tag Position </td> <td> <SELECT size="1" name="INPUT_INSERT_info_tag_position_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(tagPosition) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for tp in tagPositionList: content += "<OPTION VALUE=\"" + tp + "\"" if tp == tagPosition: content += " SELECTED>" + tp + "</OPTION>" else: content += ">" + tp + "</OPTION>" content += ''' </td> <td> Describes the position of the tag on the insert. Users select from a pre-defined list. </td> </tr> <tr> <td> Open/Closed </td> <td> <SELECT id="oc_list" size="1" name="INPUT_INSERT_info_open_closed_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(openClosed) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for oc in openClosedList: content += "<OPTION VALUE=\"" + oc + "\"" if oc == openClosed: content += " SELECTED>" + oc + "</OPTION>" else: content += ">" + oc + "</OPTION>" content += ''' </td> <td> Indicates for an Open Reading Frame if there is a start codon (ATG) or stop codon (open - no stop codon, closed - stop codon). </td> </tr> <tr> <td> Species </td> <td> <SELECT size="1" style="color:000000" id = "species_list" name="INPUT_INSERT_info_species_prop" onChange="showSpeciesBox()"> ''' # default option content += "<OPTION VALUE=\"\" " if len(species) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for sp in speciesList: content += "<OPTION VALUE=\"" + sp + "\"" if sp == species: content += " SELECTED>" + sp + "</OPTION>" else: content += ">" + sp + "</OPTION>" content += ''' </td> <td> Indicates the species from which the Insert was derived. User selects species from a pre-defined list. </td> </tr> <tr> <td> Accession Number </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_accession_number_prop\" value=\"" + accession + "\">" content += ''' </td> <td> The Accession Number from which the insert was cloned or to which the sequence maps. </td> </tr> <tr> <td> Alternate ID </td> <td> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="IMAGE" id="_alternate_id_IMAGE_checkbox" onClick="showAltIDTextBox('_alternate_id_IMAGE_checkbox', '_alternate_id_IMAGE_textbox')">IMAGE <INPUT style="display:none" id="_alternate_id_IMAGE_textbox" name="alternate_id_IMAGE_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="RIKEN" id="_alternate_id_RIKEN_checkbox" onClick="showAltIDTextBox('_alternate_id_RIKEN_checkbox', '_alternate_id_RIKEN_textbox')">RIKEN <INPUT style="display:none" id="_alternate_id_RIKEN_textbox" name="alternate_id_RIKEN_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="Kazusa" id="_alternate_id_Kazusa_checkbox" onClick="showAltIDTextBox('_alternate_id_Kazusa_checkbox', '_alternate_id_Kazusa_textbox')">Kazusa <INPUT style="display:none" id="_alternate_id_Kazusa_textbox" name="alternate_id_Kazusa_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="LIFESEQ" id="_alternate_id_LIFESEQ_checkbox" onClick="showAltIDTextBox('_alternate_id_LIFESEQ_checkbox', '_alternate_id_LIFESEQ_textbox')">LIFESEQ <INPUT style="display:none" id="_alternate_id_LIFESEQ_textbox" name="alternate_id_LIFESEQ_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="RZPD" id="_alternate_id_RZPD_checkbox" onClick="showAltIDTextBox('_alternate_id_RZPD_checkbox', '_alternate_id_RZPD_textbox')">RZPD <INPUT style="display:none" id="_alternate_id_RZPD_textbox" name="alternate_id_RZPD_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="HIP" id="_alternate_id_HIP_checkbox" onClick="showAltIDTextBox('_alternate_id_HIP_checkbox', '_alternate_id_HIP_textbox')">HIP <INPUT style="display:none" id="_alternate_id_HIP_textbox" name="alternate_id_HIP_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="ADDGENE" id="_alternate_id_ADDGENE_checkbox" onClick="showAltIDTextBox('_alternate_id_ADDGENE_checkbox', '_alternate_id_ADDGENE_textbox')">ADDGENE <INPUT style="display:none" id="_alternate_id_ADDGENE_textbox" name="alternate_id_ADDGENE_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="PMID" id="_alternate_id_PMID_checkbox" onClick="showAltIDTextBox('_alternate_id_PMID_checkbox', '_alternate_id_PMID_textbox')">PMID <INPUT style="display:none" id="_alternate_id_PMID_textbox" name="alternate_id_PMID_textbox_name" size="15"></INPUT><br> <input type="checkbox" id="_other_Alt_ID_chkbx" name="INPUT_INSERT_info_alternate_id_prop[]" value="Other" onClick="showSpecificOtherCheckbox('_alternate_id_txt')">Other: <INPUT style="display:none" id="_alternate_id_txt" name="alternate_id_name_txt" size="15"></INPUT> </td> <td> Indicates any other ID's that identify the insert, including but not limited to IMAGE, Kazusa, RIKEN, and other. <BR><BR><BR><BR>For 'Other', please enter the source name and ID separated by a semicolon (e.g. IMAGE:123456) </td> </tr> <tr> <td> Entrez Gene ID </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_gene_id_prop\" value=\"" + geneID + "\">" content += ''' </td> <td> The NCBI Gene ID to which the sequence maps. </td> </tr> <tr> <td> Ensembl Gene ID </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_ensembl_gene_id_prop\" value=\"" + ensemblID + "\">" content += ''' </td> <td> The Ensembl Gene ID to which the sequence maps. </td> </tr> <tr> <td> Official Gene Symbol </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_gene_symbol_prop\" value=\"" + geneSymbol + "\">" content += ''' </td> <td> The official gene symbol for this Insert. </td> </tr> <tr> <td> 5' Start </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_5_prime_start_prop\" value=\"" + fp_start + "\">" content += ''' </td> <td> Users can map the start of the sequence onto its accession number by indicating at what nucleotide position on the accession number that the sequence starts. </td> </tr> <tr> <td> 3' Stop </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_3_prime_stop_prop\" value=\"" + tp_stop + "\">" content += ''' </td> <td> Users can map the stop of the sequence onto its accession number by indicating at what nucleotide position on the accession number that the sequence stops </td> </tr> <tr> <td> 5' Linker </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_5_prime_linker_prop\" value=\"" + fwd_linker + "\">" content += ''' </td> <td> Indicates any sequence added to the 5' end of an insert that does not map to a cDNA sequence but should be included as part of the insert - eg kozak sequences, any nucleotides added to maintain frame. </td> </tr> <tr> <td> 3' Linker </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_3_prime_linker_prop\" value=\"" + rev_linker + "\">" content += ''' </td> <td> Indicates any sequence added to the 3' end of an insert that does not map to a cDNA sequence but should be included as part of the insert - eg any nucleotides added to maintain frame. </td> </tr> <tr> <td> Functional Description </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_description_prop\" value=\"" + funcDescr + "\">" content += ''' </td> <td> Describes the purpose of the reagent and any information that may be key to working with the reagent. </td> </tr> <tr> <td> Verification </td> <td> <select size="1" name="INPUT_INSERT_info_verification_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(verification) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for v in verificationList: content += "<OPTION VALUE=\"" + v + "\"" if v == verification: content += " SELECTED>" + v + "</OPTION>" else: content += ">" + v + "</OPTION>" content += ''' </select> </td> <td> Indicates if the reagent has been verified and how. Users select from a pre-defined list. </td> </tr> <tr> <td> Verification comments </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_verification_comments_prop\" value=\"" + verComm + "\">" content += ''' </td> <td> Allows user to provide a description of the verification status - eg comments on sequence changes, expression levels. </td> </tr> <tr> <td> Experimental comments </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_comments_prop\" value=\"" + expComm + "\">" content += ''' </td> <td> Used to describe any information that descrbes how the reagent works in the experimental context - eg low expression, difficult to grow, etc. </td> </tr> <tr> <td> Sequence </td> <td> </td> <td> The sequence of the insert that corresponds to a cDNA or fragment of interest. Does include artificial start and stop codons. Does not include linker sequences as described above. </td> </tr> <tr> <td colspan="3"> <textarea rows="10" cols="93" id="dna_sequence" name="INPUT_INSERT_info_sequence_prop"> ''' content += sequence content += ''' </textarea> </td> </tr> ''' content += self.printParents('Insert', allAssoc) content += ''' <tr> <td colspan="3"> <hr><br> <input type="submit" name="create_reagent" value="Create" onclick="document.pressed = this.value"> </td> </tr> </table> </form> </div> ''' # Common to all content += gOut.printFooter() page_content = content % (hostname + "cgi/create.py") print "Content-type:text/html" # THIS IS PERMANENT; DO NOT REMOVE print # DITTO print page_content
def update(): dbConn = DatabaseConn() db = dbConn.databaseConnect() cursor = db.cursor() hostname = dbConn.getHostname() form = cgi.FieldStorage(keep_blank_values="True") print "Content-type:text/html" # REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! print # DITTO #print `form` # Aug 29/07 uHandler = UserHandler(db, cursor) if form.has_key("curr_username"): # store the user ID for use throughout the session; add to other views in addition to create in PHP currUname = form.getvalue("curr_username") currUser = uHandler.getUserByDescription(currUname) Session.setUser(currUser) #else: # debug #currUname = 'Administrator' #currUser = uHandler.getUserByDescription(currUname) #Session.setUser(currUser) if form.has_key("cloning_method"): cloning_method = form.getvalue("cloning_method") #else: # debug #cloning_method = '1' # Handlers and mappers rHandler = ReagentHandler(db, cursor) #sHandler = SystemSetHandler(db, cursor) pHandler = ReagentPropertyHandler(db, cursor) raHandler = ReagentAssociationHandler(db, cursor) aHandler = AssociationHandler(db, cursor) dnaHandler = DNAHandler(db, cursor) commHandler = CommentHandler(db, cursor) protHandler = ProteinHandler(db, cursor) propMapper = ReagentPropertyMapper(db, cursor) assocMapper = ReagentAssociationMapper(db, cursor) # August 29/07: Restrict creation by user and project access packetHandler = ProjectDatabaseHandler(db, cursor) ######################################################## # Various maps ######################################################## prop_Alias_ID_Map = propMapper.mapPropAliasID( ) # (propAlias, propID) - e.g. ('insert_type', '48') --> represents 'type of insert' property prop_Name_Alias_Map = propMapper.mapPropNameAlias( ) # (propName, propAlias) prop_Name_ID_Map = propMapper.mapPropNameID() # (prop name, prop id) # Restriction sites fpcs_prop_id = pHandler.findPropID("5' cloning site") tpcs_prop_id = pHandler.findPropID("3' cloning site") newFivePrime = form.getvalue("fpcs") newThreePrime = form.getvalue("tpcs") gatewaySites = ['attb', 'attl', 'attp', 'attr'] # nov. 16/07 # resulting sequence newSeq = "" # Fetch projects the user has AT LEAST Read access to (i.e. if he is explicitly declared a Writer on a project but not declared a Reader, include that project, plus all public projects) currReadProj = packetHandler.findMemberProjects(currUser.getUserID(), 'Reader') currWriteProj = packetHandler.findMemberProjects(currUser.getUserID(), 'Writer') publicProj = packetHandler.findAllProjects(isPrivate="FALSE") # list of Packet OBJECTS currUserWriteProjects = utils.unique(currReadProj + currWriteProj + publicProj) uPackets = [] for p in currUserWriteProjects: uPackets.append(p.getNumber()) # Get project IDs of parents packetPropID = pHandler.findPropID("packet id") # August 29/07: Need to verify parent project access AND (Sept. 12/07) reconstruct the sequence IFF parent values are changed newSeq = "" # Fetch projects the user has AT LEAST Read access to (i.e. if he is explicitly declared a Writer on a project but not declared a Reader, include that project, plus all public projects) currReadProj = packetHandler.findMemberProjects(currUser.getUserID(), 'Reader') currWriteProj = packetHandler.findMemberProjects(currUser.getUserID(), 'Writer') publicProj = packetHandler.findAllProjects(isPrivate="FALSE") # list of Packet OBJECTS currUserWriteProjects = utils.unique(currReadProj + currWriteProj + publicProj) uPackets = [] for p in currUserWriteProjects: uPackets.append(p.getNumber()) # Get project IDs of parents packetPropID = pHandler.findPropID("packet id") if form.has_key("PV"): pvVal = form.getvalue("PV") if len(pvVal) > 0: pvID = rHandler.convertReagentToDatabaseID(pvVal) try: pvProjectID = int( rHandler.findSimplePropertyValue(pvID, packetPropID)) pvSeqID = rHandler.findDNASequenceKey( pvID) # get sequence for reconstitution later except TypeError: #pvProjectID = 0 e = PVProjectAccessException( "You are not authorized to use this Parent Vector, since you do not have Read access to its project." ) print ` e.err_code() ` else: e = UnknownPVIDException("Unknown Parent Vector value") print ` e.err_code() ` return # else don't do anything, maybe want to delete parents!!! #else: #e = MissingPVException("No Parent Vector provided") #print `e.err_code()` if pvProjectID > 0 and currUser.getCategory( ) != 'Admin' and pvProjectID not in uPackets: e = PVProjectAccessException("Not authorized to access parent") print ` e.err_code() ` return if cloning_method == '1': # Non-recombination vector - Get the Insert if form.has_key("I"): insertVal = form.getvalue("I") if len(insertVal) > 0: insertID = rHandler.convertReagentToDatabaseID(insertVal) insertSeqID = rHandler.findDNASequenceKey( insertID) # fetch Insert sequence for reconstitution later try: insertProjectID = int( rHandler.findSimplePropertyValue( insertID, packetPropID)) except TypeError: #insertProjectID = 0 e = InsertProjectAccessException( "You are not authorized to use this Insert, since you do not have Read access to its project." ) print ` e.err_code() ` else: #insertID = -1 #insertProjectID = 0 #print "Invalid Insert value" e = UnknownInsertIDException("Unknown Insert value") print ` e.err_code() ` return #else: # NO!!!!!!!! #e = MissingInsertException("No Insert provided") #print `e.err_code()` if insertProjectID > 0 and currUser.getCategory( ) != 'Admin' and insertProjectID not in uPackets: e = InsertProjectAccessException( "You are not authorized to use this Insert, since you do not have Read access to its project." ) print ` e.err_code() ` return if pvID > 0 and insertID > 0: # try to reconstruct sequence and issue warning if unable if pvSeqID > 0 and insertSeqID > 0: # fetch insert cloning sites insertCloningSites = [] fpcs_prop_id = pHandler.findPropID("5' cloning site") tpcs_prop_id = pHandler.findPropID("3' cloning site") fp_insert_cs = rHandler.findSimplePropertyValue( insertID, fpcs_prop_id) tp_insert_cs = rHandler.findSimplePropertyValue( insertID, tpcs_prop_id) # Determine if this is a Gateway clone from sites gwSites = False if fp_insert_cs and tp_insert_cs and fp_insert_cs.lower( ) == 'attl' and tp_insert_cs.lower() == 'attl': gwSites = True elif not fp_insert_cs or not tp_insert_cs: gwSites = True # nov. 16/07: added this for check elif fp_insert_cs.lower( ) in gatewaySites or tp_insert_cs.lower() in gatewaySites: gwSites = True else: gwSites = False if gwSites: # this is a gateway clone # if sites were changed to something other than gateway, clear sequence if newFivePrime.lower() != 'attl' or newThreePrime.lower( ) != 'attl': e = InsertSitesNotFoundOnParentSequenceException() print ` e.err_code() ` return else: pvSeqKey = rHandler.findDNASequenceKey(pvID) # For Gateway clones, linkers are found from primers - so find the sense and antisense Oligos for this Insert insertLinkers = [] # Find Sense and Antisense Oligos for this Insert # (not using antisense just yet - verify with Karen) iHandler = InsertHandler(db, cursor) senseOligoID = iHandler.findSenseOligoID(insertID) #antisenseOligoID = iHandler.findAntisenseOligoID(insert_db_id) # Find Oligo sequences seqPropID = pHandler.findPropID("sequence") senseOligoSeqID = rHandler.findIndexPropertyValue( senseOligoID, seqPropID) senseOligoSequence = dnaHandler.findSequenceByID( senseOligoSeqID) # Fetch Insert sequence and find linkers from Oligo and Insert sequences insertSequence = dnaHandler.findSequenceByID( insertSeqID) attB_const = "ggggacaactttgtacaaaaaagttggc" fwd_primer_seq = senseOligoSequence[len(attB_const):] # First, find linkers from Oligos fwd_linker = dnaHandler.linker_from_oligo( insertSequence, fwd_primer_seq) #rev_linker = sHandler.linker_from_oligo(insertSequence, rev_primer_seq) rev_linker = "" # Now see if the Insert had its own linkers stored and append them to the Oligo linker fpLinkerPropID = pHandler.findPropID("5' linker") tpLinkerPropID = pHandler.findPropID("3' linker") fp_insert_linker = rHandler.findSimplePropertyValue( insertID, fpLinkerPropID) tp_insert_linker = rHandler.findSimplePropertyValue( insertID, tpLinkerPropID) if fp_insert_linker and len( fp_insert_linker ) > 0 and fp_insert_linker != 0 and fp_insert_linker != '0': fp_insert_linker = fwd_linker + fp_insert_linker else: fp_insert_linker = fwd_linker tp_insert_linker = rev_linker insertLinkers.append(fp_insert_linker) insertLinkers.append(tp_insert_linker) try: newSeq = dnaHandler.entryVectorSequence( pvSeqKey, insertSeqID, insertLinkers) print newSeq except MultipleSiteOccurrenceException: e = MultipleSiteOccurrenceException( "Sites found more than once on parent vector sequence" ) print ` e.err_code() ` except FivePrimeAfterThreePrimeException: e = FivePrimeAfterThreePrimeException( "5' after 3'") print ` e.err_code() ` except InsertSitesNotFoundOnParentSequenceException: e = InsertSitesNotFoundOnParentSequenceException( "Gateway sites not found on parent vector sequence" ) print ` e.err_code() ` else: # Non-Gateway non-recombination Vector fp_insert_cs = newFivePrime tp_insert_cs = newThreePrime if fp_insert_cs: insertCloningSites.append(fp_insert_cs) else: insertCloningSites.append("") if tp_insert_cs: insertCloningSites.append(tp_insert_cs) else: insertCloningSites.append("") # get linkers if there are any insertLinkers = [] fpLinkerPropID = pHandler.findPropID("5' linker") tpLinkerPropID = pHandler.findPropID("3' linker") fp_insert_linker = rHandler.findSimplePropertyValue( insertID, fpLinkerPropID) tp_insert_linker = rHandler.findSimplePropertyValue( insertID, tpLinkerPropID) # sept. 3/07 fwd_linker = "" if fp_insert_linker and len( fp_insert_linker ) > 0 and fp_insert_linker != 0 and fp_insert_linker != '0': fp_insert_linker = fwd_linker + fp_insert_linker else: fp_insert_linker = fwd_linker insertLinkers.append(fp_insert_linker) insertLinkers.append(tp_insert_linker) try: newSeq = dnaHandler.constructNonRecombSequence( pvSeqID, insertSeqID, insertCloningSites, insertLinkers) print newSeq except (InsertSitesException): e = InsertSitesException( "Could not reconstitute sequence: Unknown sites on Insert." ) print e.err_code() except (InsertSitesNotFoundOnParentSequenceException): e = InsertSitesNotFoundOnParentSequenceException( "Could not reconstitute sequence: Parent vector sequence does not contain restriction sites." ) print e.err_code() except (MultipleSiteOccurrenceException): e = MultipleSiteOccurrenceException( "Could not reconstitute sequence: Restriction sites occur more than once on parent vector sequence" ) print e.err_code() except (HybridizationException): e = HybridizationException( "Could not reconstitute sequence: Restriction sites cannot be hybridized." ) print e.err_code() except (FivePrimeAfterThreePrimeException): e = FivePrimeAfterThreePrimeException( "Could not reconstitute sequence: 5' site occurs after 3' site on parent vector sequence." ) print e.err_code() else: e = InvalidSequenceException("Invalid parent sequence") print ` e.err_code() ` else: e = UnknownPVIDException("Unknown PV ID") print ` e.err_code() ` elif cloning_method == '2': # Recombination vector - check IPV ipvVal = form.getvalue("IPV") if len(ipvVal) > 0: ipvID = rHandler.convertReagentToDatabaseID(ipvVal) ipvProjectID = int( rHandler.findSimplePropertyValue(ipvID, packetPropID)) else: e = UnknownIPVIDException("Unknown IPV ID") print ` e.err_code() ` if ipvProjectID > 0 and currUser.getCategory( ) != 'Admin' and ipvProjectID not in uPackets: e = IPVProjectAccessException("Not authorized to view IPV") print ` e.err_code() ` if ipvID > 0 and pvID > 0: # If restriction sites were modified to anything other than LoxP or gateway att sites, clear the sequence if not (newFivePrime == newThreePrime and (newFivePrime.lower() == 'loxp' and newThreePrime.lower() == 'loxp') or (newFivePrime.lower() == 'attb' and newThreePrime.lower() == 'attb')): e = InsertSitesNotFoundOnParentSequenceException( "Invalid restriction sites for Non-Recombination Clone - must be LoxP only" ) print ` e.err_code() ` else: # get internal db IDs pv_db_id = rHandler.convertReagentToDatabaseID(pvVal) ipv_db_id = rHandler.convertReagentToDatabaseID(ipvVal) # Get the Insert that belongs to the donor vector ipvInsertAssocID = raHandler.findReagentAssociationID( ipv_db_id) insertAssocPropID = aHandler.findAssocPropID("insert id") insert_db_id = aHandler.findAssocPropValue( ipvInsertAssocID, insertAssocPropID) # Construct a sequence for the new vector from the sequences of its parents pvSeqKey = rHandler.findDNASequenceKey(pv_db_id) #print "pv seq " + `pvSeqKey` ipvSeqKey = rHandler.findDNASequenceKey(ipv_db_id) #print "ipv seq " + `ipvSeqKey` insertSeqKey = rHandler.findDNASequenceKey(insert_db_id) #print "i seq " + `insertSeqKey` if pvSeqKey > 0 and ipvSeqKey > 0 and insertSeqKey > 0: # See if there are linkers, although there most likely aren't any insertLinkers = [] fpLinkerPropID = pHandler.findPropID("5' linker") tpLinkerPropID = pHandler.findPropID("3' linker") fp_insert_linker = rHandler.findSimplePropertyValue( insert_db_id, fpLinkerPropID) tp_insert_linker = rHandler.findSimplePropertyValue( insert_db_id, tpLinkerPropID) # sept. 3/07 fwd_linker = "" if fp_insert_linker and len( fp_insert_linker ) > 0 and fp_insert_linker != 0 and fp_insert_linker != '0': fp_insert_linker = fwd_linker + fp_insert_linker else: fp_insert_linker = fwd_linker insertLinkers.append(fp_insert_linker) insertLinkers.append(tp_insert_linker) # Differentiate by cloning sites whether this is a recombination vector or a Gateway Expression Vector if newFivePrime == 'LoxP' and newThreePrime == 'LoxP': # recombination try: newSeq = dnaHandler.constructRecombSequence( pvSeqKey, ipvSeqKey, insertSeqKey, insertLinkers) newSeqID = dnaHandler.matchSequence(newSeq) print newSeq except InsertSitesNotFoundOnParentSequenceException: e = InsertSitesNotFoundOnParentSequenceException( "LOXP sites not found on parent vector sequence" ) print ` e.err_code() ` except MultipleSiteOccurrenceException: e = MultipleSiteOccurrenceException( "LOXP found more than once on parent vector sequence" ) print ` e.err_code() ` elif newFivePrime == 'attB' and newThreePrime == 'attB': # Gateway Expression iHandler = InsertHandler(db, cursor) senseOligoID = iHandler.findSenseOligoID(insert_db_id) #antisenseOligoID = iHandler.findAntisenseOligoID(insert_db_id) # Find Oligo sequences seqPropID = pHandler.findPropID("sequence") senseOligoSeqID = rHandler.findIndexPropertyValue( senseOligoID, seqPropID) senseOligoSequence = dnaHandler.findSequenceByID( senseOligoSeqID) # Fetch Insert sequence and find linkers from Oligo and Insert sequences insertSequence = dnaHandler.findSequenceByID( insertSeqKey) attB_const = "ggggacaactttgtacaaaaaagttggc" fwd_primer_seq = senseOligoSequence[len(attB_const):] # First, find linkers from Oligos fwd_linker = dnaHandler.linker_from_oligo( insertSequence, fwd_primer_seq) #rev_linker = sHandler.linker_from_oligo(insertSequence, rev_primer_seq) rev_linker = "" # Now see if the Insert had its own linkers stored and append them to the Oligo linker fpLinkerPropID = pHandler.findPropID("5' linker") tpLinkerPropID = pHandler.findPropID("3' linker") fp_insert_linker = rHandler.findSimplePropertyValue( insert_db_id, fpLinkerPropID) tp_insert_linker = rHandler.findSimplePropertyValue( insert_db_id, tpLinkerPropID) if fp_insert_linker and len( fp_insert_linker ) > 0 and fp_insert_linker != 0 and fp_insert_linker != '0': fp_insert_linker = fwd_linker + fp_insert_linker else: fp_insert_linker = fwd_linker tp_insert_linker = rev_linker insertLinkers.append(fp_insert_linker) insertLinkers.append(tp_insert_linker) try: newSeq = dnaHandler.expressionVectorSequence( pvSeqKey, insertSeqKey, insertLinkers) print newSeq except MultipleSiteOccurrenceException: e = MultipleSiteOccurrenceException( "Sites found more than once on parent vector sequence" ) print ` e.err_code() ` except FivePrimeAfterThreePrimeException: e = FivePrimeAfterThreePrimeException( "5' after 3'") print ` e.err_code() ` except InsertSitesNotFoundOnParentSequenceException: e = InsertSitesNotFoundOnParentSequenceException( "Gateway sites not found on parent vector sequence" ) print ` e.err_code() ` else: e = InvalidSequenceException("Invalid parent sequence") print ` e.err_code() ` else: e = ReagentDoesNotExistException("Unknown parent values") print ` e.err_code() `
def printUserInfo(self, cmd, user, errCode=""): dbConn = DatabaseConn() hostname = dbConn.getHostname() # to define form action URL db = dbConn.databaseConnect() cursor = db.cursor() uHandler = UserHandler(db, cursor) lHandler = LabHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) ucMapper = UserCategoryMapper(db, cursor) category_ID_Name_Map = ucMapper.mapCategoryIDToName() category_Name_ID_Map = ucMapper.mapCategoryNameToID() currUser = Session.getUser() gOut = GeneralOutputClass() if cmd =='create': username = user.getUsername() firstname = user.getFirstName() lastname = user.getLastName() email = user.getEmail() passwd = user.getPassword() lab = user.getLab() uLabID = lab.getID() uLabName = lab.getName() labs = lHandler.findAllLabs() # changed Aug. 18/08 - new format #content = gOut.printHeader() + gOut.printMainMenu() content = gOut.printHeader() content += ''' <FORM NAME="create_user_form" METHOD="POST" ACTION="%s" onSubmit="return verifyAddUser();"> <!-- pass current user as hidden form field --> <INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"''' content += "value=\"" + currUser.getFullName() + "\">" content += ''' <TABLE width="760px" cellpadding="5" cellspacing="5"> <TH colspan="4" style="color:#0000FF; border-top:1px groove black; border-bottom: 1px groove black; padding-top: 10px; padding-top:5px;"> ADD NEW USER <P style="color:#FF0000; font-weight:normal; font-size:8pt; margin-top:5px;">Fields in red marked with an asterisk (<span style="font-size:9pt; color:#FF0000;">*</span>) are mandatory</P> </TH> <TR> <TD style="width:150px; vertical-align:top; padding-top:10px; color:#FF0000;"> Laboratory: <sup style="font-size:10pt; color:#FF0000;">*</sup> </TD> <TD style="vertical-align:top; padding-top:10px"> <SELECT id="labList" name="labs"> <OPTION>Select Lab</OPTION> ''' # sort labs by name labSortedDict = {} # will store (labName, labID) tuples labNames = [] # just hold lab names for labID in labs.keys(): labName = labs[labID] labNames.append(labName) labSortedDict[labName] = labID labNames.sort() #for labID in labs.keys(): for labName in labNames: labID = labSortedDict[labName] labName = labs[labID] content += "<OPTION ID=\"" + `labID` + "\" NAME=\"lab_optn\" VALUE=\"" + `labID` + "\"" if labID == uLabID: content += " SELECTED>" + labName else: content += ">" + labName content += "</OPTION>" content += ''' </SELECT> <BR/> <P id="lab_warning" style="color:#FF0000; display:none">Please select a laboratory name from the dropdown list above.</P> </TD> </TR> <TR> <TD class="createViewColName" style="color:#FF0000;"> Username: <sup style="font-size:10pt; color:#FF0000;">*</sup> </TD> <TD class="createViewColValue"> <INPUT TYPE="TEXT" SIZE="35px" id="user_name" NAME="username" VALUE="%s"/> <BR/> <!-- Warning anchor --> <a name="w1" style="text-decoration:none; font-weight:normal; font-size:8pt"> <P id="dup_uname_warning" style="color:#FF0000; display:inline">This username already exists. Please specify a different username.</P> </a> </TD> <TD style="font-size:8pt"> Alphanumeric string up to 10 characters used to log into the system. </TD> </TR> <TR> <TD class="createViewColName" style="color:#FF0000;"> Password: <sup style="font-size:10pt; color:#FF0000;">*</sup> </TD> <TD class="createViewColValue"> <INPUT TYPE="PASSWORD" SIZE="35px" id="passwd" NAME="password" VALUE="%s"/> </TD> </TR> <TR> <TD class="createViewColName" style="color:#FF0000;"> First name: <sup style="font-size:10pt; color:#FF0000;">*</sup> </TD> <TD class="createViewColValue"> <INPUT TYPE="TEXT" SIZE="35px" id="first_name" NAME="firstName" VALUE="%s"/> </TD> </TR> <TR> <TD class="createViewColName" style="color:#FF0000;"> Last name: <sup style="font-size:10pt; color:#FF0000;">*</sup> </TD> <TD class="createViewColName"> <INPUT TYPE="TEXT" SIZE="35px" id="last_name" NAME="lastName" VALUE="%s"/> </TD> </TR> <TR> <TD class="createViewColName"> Email: </TD> <TD class="createViewColValue"> <INPUT TYPE="TEXT" SIZE="35px" id="e_mail" NAME="email" VALUE="%s"/> </TD> </TR> <TR> <TD> Access Level: </TD> <TD class="createViewColName" colspan="3"> <INPUT TYPE="RADIO" name="system_access_level" value="Reader" style="margin-top:8px; font-size:9pt" checked>Reader<BR/> <INPUT TYPE="RADIO" name="system_access_level" value="Writer" style="margin-top:8px; font-size:9pt">Writer<BR/> <INPUT TYPE="RADIO" name="system_access_level" value="Creator" style="margin-top:8px; font-size:9pt">Creator<BR/> <INPUT TYPE="RADIO" name="system_access_level" value="Admin" style="margin-top:8px; font-size:9pt">Admin<BR/> </TD> </TR> <TR id="project_access"> <TD colspan="4"> <TABLE width="100%%"> <TR> <TD colspan="4" style="border-top:1px groove black; border-bottom:1px groove black; padding-top:8px; font-size:8pt; font-weight:bold"> Grant project access permissions to this user: </TD> </TR> <TR> <TD style="width:210px"> <SELECT id="packetList" name="packets" multiple size="15"> ''' # PRINT PROJECT LIST projects = pHandler.findAllProjects() for project in projects: projectNumber = project.getNumber() projectName = project.getName() tmpProject = `projectNumber` + ": " + projectName content += "<OPTION value=\"" + `projectNumber` + "\">" + tmpProject + "</OPTION>" content += ''' </SELECT> <BR/> <INPUT TYPE="checkbox" style="margin-top:10px; font-size:8pt;" onClick="selectAll(this.id, 'packetList')" id="add_all_chkbx"> Select All</INPUT> </TD> <TD style="vertical-align:top" colspan="3"> <span style="font-size:8pt; font-weight:bold">User's access level to selected projects:<BR/></span> <input type="radio" id="access_level_radio_read" name="access_levels" value="read" style="margin-top:8px; font-size:9pt" checked>Read-Only <BR/> <input type="radio" id="access_level_radio_write" name="access_levels" value="write" style="margin-top:5px; font-size:9pt">Write <BR/> <input style="margin-top:8px" onclick="addProjects('packetList', getSelectedRole('1'))" value="Go" type="button"></INPUT> <P style="font-size:8pt; border-top:1px groove black; padding-top:10px; padding-bottom:5px; margin-top:10px"> Access levels: <BR/> <span style="font-size: 8pt; margin-left: 9px; font-weight:bold; ">- Read-Only:</span> May view reagents in a project but may NOT modify them or add new reagents<BR/> <span style="font-size: 8pt; margin-left: 9px; font-weight:bold;">- Write:</span> May create and modify reagents in a project but may NOT change project details or add/remove members to/from the project<BR/> </P> </TD> </TR> <TR> <TD colspan="4" style="border-top:1px groove black; border-bottom:1px groove black; font-size:8pt; font-weight:bold"> User's current project access privileges: </TD> </TR> <TR> <TD style="border-right:1px solid black; font-size:8pt"> <B>Read-Only</B><BR/> <SELECT id="user_projects_readonly" name="userProjectsReadonly" style="margin-top:5px" multiple size="12"> ''' # August 10/07: Default reader access to all on public projects publicProjects = pHandler.findAllProjects('FALSE') for proj in publicProjects: pID = proj.getNumber() pName = proj.getName(); # concatenate project ID and name in the form '1:parent' tmpDescr = `pID` + ": " + pName content += "<OPTION VALUE=\"" + `pID` + "\">" + tmpDescr + "</OPTION>" content += ''' </SELECT><BR/> <INPUT style="margin-top:10px;" TYPE="checkbox" onClick="selectAll(this.id, 'user_projects_readonly')" id="select_all_reader_chkbx"> Select All</INPUT> </TD> <TD style="text-align:center; width:100px; border-right: 1px solid black; padding-left:20px; padding-right:20px;"> <input onclick="addProjects('user_projects_readonly', 'write')" value=" Make Writeable >>" type="button"></INPUT><BR/> <input style="margin-top:30px;" onclick="addProjects('user_projects_write', 'read')" value="<< Make Read-Only" type="button"></INPUT><BR/> <input style="margin-top:30px;" onclick="addProjects('user_projects_write'); addProjects('user_projects_readonly')" value="Remove Selected" type="button"></INPUT> </TD> <TD style="padding-left:50px; font-size:8pt"> <B>Write</B><BR/> <SELECT id="user_projects_write" name="userProjectsWrite" style="margin-top:5px" multiple size="12"></SELECT><BR/> <INPUT style="margin-top:10px;" TYPE="checkbox" onClick="selectAll(this.id, 'user_projects_write')" id="select_all_writer_chkbx"> Select All</INPUT> </TD> </TR> </TABLE> </TD> </TR> <TR> <TD colspan="4" style="border-top:1px groove black; border-bottom:1px groove black"> <INPUT TYPE="SUBMIT" id="addUser" NAME="add_user" VALUE="Add User" onClick="selectAllElements('user_projects_readonly'); selectAllElements('user_projects_write');"> </TD> </TR> </TABLE> </FORM> <blockquote> </blockquote> <blockquote> </blockquote> </div> ''' content += gOut.printFooter() page_content = content % (hostname + "cgi/user_request_handler.py", username, passwd, firstname, lastname, email) print "Content-type:text/html" # THIS IS PERMANENT; DO NOT REMOVE print # DITTO print page_content elif cmd == 'view': userID = user.getUserID() username = user.getUsername() firstname = user.getFirstName() lastname = user.getLastName() email = user.getEmail() userCat = user.getCategory() lab = user.getLab() labID = lab.getID() labName = lab.getName() # Only allow modification by admin modify_disabled = True if (currUser.getCategory() == 'Admin'): modify_disabled = False content = gOut.printHeader() #content += gOut.printMainMenu() content += ''' <FORM name="user_form" method="POST" action="%s"> <!-- pass current user as hidden form field --> <INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"''' content += "value=\"" + currUser.getFullName() + "\">" content += ''' <TABLE width="767px" style="margin-left:2px" cellpadding="5px" cellspacing="5px" class="detailedView_tbl" border="1" frame="box" rules="none"> <TR> <TD colspan="6" class="detailedView_heading" style="padding-left:265px"> USER DETAILS PAGE ''' content += "<INPUT TYPE=\"submit\" style=\"margin-left:50px;\" name=\"modify_user\" value=\"Change User Details\"" if modify_disabled: content += " disabled>" else: content += ">" content += "<INPUT TYPE=\"submit\" style=\"margin-left:2px;\" name=\"delete_user\" value=\"Delete User\" onClick=\"return verifyDeleteUser();\"" if modify_disabled: content += " disabled>" else: content += ">" content += ''' </TD> </TR> <TR> <TD class="projectDetailedViewName" width="50px"> Username: </TD> <TD class="detailedView_value" colspan="2" style="width:400px"> %s <INPUT TYPE="hidden" name="username" value="%s"> <!-- user ID a hidden value --> <INPUT TYPE="hidden" name="userID" value="%d"> </TD> </TR> <TR> <TD class="projectDetailedViewName" width="50px"> First Name: </TD> <TD class="detailedView_value" colspan="2" style="width:400px"> %s <INPUT TYPE="hidden" name="firstName" value="%s"> </TD> </TR> <TR> <TD class="projectDetailedViewName" width="50px"> Last Name: </TD> <TD class="detailedView_value" colspan="2" style="width:400px"> %s <INPUT TYPE="hidden" name="lastName" value="%s"> </TD> </TR> <TR> <TD class="projectDetailedViewName" width="50px"> Laboratory: </TD> <TD class="detailedView_value" colspan="2" style="width:400px"> ''' if modify_disabled: content += labName else: content += "<span class=\"linkShow\" onClick=\"redirectToLabView(" + `labID` + ");\">" + labName + "</span>" content += ''' <INPUT TYPE="hidden" name="labID" value="%d"> <INPUT type="hidden" id="view_lab_hidden" name="view_lab"> </TD> </TR> <TR> <TD class="projectDetailedViewName" width="50px"> Email: </TD> <TD class="detailedView_value" colspan="2" style="width:400px"> %s <INPUT TYPE="hidden" name="email" value="%s"> </TD> </TR> <TR> <TD class="projectDetailedViewName" width="50px"> Access Level: </TD> <TD class="detailedView_value" colspan="2" style="width:400px"> %s <INPUT TYPE="hidden" name="system_access_level" value="%d"> </TD> </TR> <TR> <TD class="projectDetailedViewName" width="50px"> Projects: </TD> </TR> <TR> <TD style="font-weight:bold; font-size:8pt; width:250px" colspan="2"> Read-Only: </TD> <TD style="font-weight:bold; font-size:8pt"> Write: </TD> </TR> <TR> <TD style="vertical-align:top;" colspan="2"> <UL> ''' # show projects for the user publicProj = pHandler.findAllProjects("FALSE") readOnlyProj = pHandler.findMemberProjects(userID, 'Reader') readProj = utils.merge(publicProj, readOnlyProj) writeProj = pHandler.findMemberProjects(userID, 'Writer') # sort read projects readKeys = [] readSorted = {} for r in readProj: rProjectID = r.getNumber() readKeys.append(rProjectID) readSorted[rProjectID] = r readKeys = utils.unique(readKeys) readKeys.sort() #for r in readProj: for rProjectID in readKeys: #rProjectID = r.getNumber() r = readSorted[rProjectID] rProjectName = r.getName() rProjectOwner = r.getOwner() try: rOwnerName = rProjectOwner.getLastName() except AttributeError: rOwnerName = "" #content += "<LI>" + `rProjectID` + ": " + rOwnerName + ": " + rProjectName content += "<LI>" content += "<span class=\"linkShow\" onClick=\"redirectToProjectDetailedView(" + `rProjectID` + ");\">" + `rProjectID` + ": " + rOwnerName + ": " + rProjectName + "</span>" content += "</LI>" content += ''' </UL> </TD> <TD style="vertical-align:top;"> <UL> ''' # sort write projects writeKeys = [] writeSorted = {} for w in writeProj: wProjectID = w.getNumber() writeKeys.append(wProjectID) writeSorted[wProjectID] = w writeKeys = utils.unique(writeKeys) writeKeys.sort() #for w in writeProj: for wProjectID in writeKeys: #wProjectID = w.getNumber() w = writeSorted[wProjectID] wProjectName = w.getName() wProjectOwner = w.getOwner() wOwnerName = wProjectOwner.getLastName() #content += "<LI>" + `wProjectID` + ": " + wProjectName content += "<LI>" content += "<span class=\"linkShow\" onClick=\"redirectToProjectDetailedView(" + `wProjectID` + ");\">" + `wProjectID` + ": " + wOwnerName + ": " + wProjectName + "</span>" content += "</LI>" content += ''' </UL> </TD> </TR> </TABLE> </FORM> <FORM id="viewProjectForm" method="POST" action="%s"> <INPUT type="hidden" id="view_packet_hidden" name="view_packet"> <INPUT type="hidden" ID="curr_userid_hidden" NAME="curr_user_id" value="%d"> </FORM> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> </div> ''' content += gOut.printFooter() page_content = content % (hostname + "cgi/user_request_handler.py", username, username, userID, firstname, firstname, lastname, lastname, labID, email, email, userCat, category_Name_ID_Map[userCat], hostname + "cgi/project_request_handler.py", currUser.getUserID()) print "Content-type:text/html" # print # DITTO print page_content elif cmd == 'edit': userID = user.getUserID() username = user.getUsername() firstname = user.getFirstName() lastname = user.getLastName() email = user.getEmail() passwd = user.getPassword() userCat = user.getCategory() lab = user.getLab() uLabID = lab.getID() labName = lab.getName() labs = lHandler.findAllLabs() if errCode == "Dup_un": un_warn_display = "inline" else: un_warn_display = "none" content = gOut.printHeader() #content += gOut.printMainMenu() content += ''' <FORM name="user_form" method="POST" action="%s" onSubmit="return verifyWriteProjects();"> <!-- pass current user as hidden form field --> <INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username"''' content += "value=\"" + currUser.getFullName() + "\">" content += ''' <TABLE width="760px" cellpadding="5px" cellspacing="5px" style="border:1px solid black" frame="box" rules="rows"> <TR> <TD colspan="3" style="padding-left:200px; text-align:center"> <span style="color:#0000FF; font-weight:bold">CHANGE USER INFORMATION</span> <INPUT TYPE="submit" style="margin-left:50px;" name="save_user" value="Save" onClick="selectAllElements('user_projects_readonly'); selectAllElements('user_projects_write');"> <INPUT TYPE="submit" style="margin-left:20px;" name="cancel_user" value="Cancel"> </TD> </TR> <TR> <TD class="projectDetailedViewName"> Username: </TD> <TD class="detailedView_value" style="width:400px"> <INPUT TYPE="text" size="50px" name="username" value="%s"> <BR/> <!-- Warning anchor --> <a name="w1" style="text-decoration:none; font-weight:normal; font-size:8pt"> <P id="dup_uname_warning" style="color:#FF0000; display:%s">This username already exists. Please specify a different username.</P> </a> <!-- user ID hidden value --> <INPUT TYPE="hidden" name="userID" value="%d"> </TD> </TR> <TR> <TD class="projectDetailedViewName"> Laboratory: </TD> <TD style="vertical-align:top; padding-top:10px"> <SELECT id="labList" name="labs"> ''' # sort labs by name labSortedDict = {} # will store (labName, labID) tuples labNames = [] # just hold lab names for labID in labs.keys(): labName = labs[labID] labNames.append(labName) labSortedDict[labName] = labID labNames.sort() #for labID in labs.keys(): for labName in labNames: labID = labSortedDict[labName] labName = labs[labID] content += "<OPTION ID=\"" + `labID` + "\" NAME=\"lab_optn\" VALUE=\"" + `labID` + "\"" if labID == uLabID: content += " SELECTED>" + labName else: content += ">" + labName content += "</OPTION>" content += ''' </SELECT> </TD> </TR> <TR> <TD class="projectDetailedViewName"> First Name: </TD> <TD class="detailedView_value" colspan="2"> <INPUT TYPE="text" size="50px" name="firstName" value="%s"> </TD> </TR> <TR> <TD class="projectDetailedViewName"> Last Name: </TD> <TD class="detailedView_value" colspan="2"> <INPUT TYPE="text" size="50px" name="lastName" value="%s"> </TD> </TR> <TR> <TD class="projectDetailedViewName"> Email: </TD> <TD class="detailedView_value" colspan="2"> <INPUT TYPE="text" size="50px" name="email" value="%s"> </TD> </TR> <TR> <TD class="projectDetailedViewName"> Access Level: </TD> <TD class="detailedView_value" colspan="2"> <SELECT ID="user_category" NAME="system_access_level"> ''' ucHandler = UserCategoryHandler(db, cursor) categories = ucHandler.findAllCategories() for cID in categories.keys(): if categories[cID] == userCat: content += "<OPTION VALUE=\"" + `cID` + "\" SELECTED>" + categories[cID] + "</OPTION>" else: content += "<OPTION VALUE=\"" + `cID` + "\">" + categories[cID] + "</OPTION>" # Don't allow addition of Writeable projects to Readers thru Modify view if userCat == 'Reader': write_disabled = True else: write_disabled = False content += ''' </SELECT> </TD> </TR> <TR> <TD class="detailedView_value" colspan="3"> Projects user has access to: </TD> </TR> <TR> <td colspan="3"> <table width="700px"> <tr> <TD colspan="2" style="font-size:8pt; vertical-align:top""> Read-Only </TD> <TD style="font-size:8pt; vertical-align:top"> ''' if not write_disabled: content += "Write" else: content += " " content += ''' </TD> </TR> <TR> <TD style=""> <SELECT id="user_projects_readonly" name="userProjectsReadonly" style="margin-top:5px" multiple size="12"> ''' # show projects for the user readProj = pHandler.findMemberProjects(userID, 'Reader') writeProj = pHandler.findMemberProjects(userID, 'Writer') for r in readProj: rProjectID = r.getNumber() rProjectName = r.getName() content += "<OPTION name=\"project_read\" value=\"" + `rProjectID` + "\">" + `rProjectID` + ": " + rProjectName + "</OPTION>" content += ''' </SELECT> <BR/> <INPUT TYPE="checkbox" style="margin-top:10px;" onClick="selectAll(this.id, 'user_projects_readonly')" id="select_all_reader_chkbx"> Select All</INPUT> ''' if not write_disabled: content += ''' </TD> <TD style="text-align:center; padding-right:15px;"> <input onclick="addProjects('user_projects_readonly', 'write')" value=" Make Writeable >>" type="button"></INPUT><BR/> <input style="margin-top:30px;" onclick="addProjects('user_projects_write', 'read')" value="<< Make Read-Only" type="button"></INPUT><BR/> <input type="button" style="margin-top:30px;" value="Remove" onclick="removeUserProjects();"></INPUT> </TD> ''' else: content += ''' <input type="button" value="Remove Selected" onclick="removeUserProjects();"></INPUT> ''' if not write_disabled: content += ''' <TD style="font-size:8pt"> <SELECT id="user_projects_write" name="userProjectsWrite" style="margin-top:5px" multiple size="12"> ''' for w in writeProj: wProjectID = w.getNumber() wProjectName = w.getName() content += "<OPTION name=\"project_write\" value=\"" + `wProjectID` + "\">" + `wProjectID` + ": " + wProjectName + "</OPTION>" content += ''' </SELECT><BR/> <INPUT style="margin-top:10px;" TYPE="checkbox" onClick="selectAll(this.id, 'user_projects_write')" id="select_all_writer_chkbx"> Select All</INPUT> </TD> ''' content += ''' </TR> </table> </td> </tr> <TR> <TD class="detailedView_value" colspan="3"> Add new projects: </TD> </TR> <TR> <TD colspan="3"> <TABLE> <TR> <TD> <SELECT multiple ID="packetList"> ''' # Fetch the list of read and write projects for this user and extract their IDs readProjID = [] # list of numerical IDs of read projects for r in readProj: rNum = r.getNumber() readProjID.append(rNum) writeProjID = [] for w in writeProjID: wNum = w.getNumber() writeProjID.append(wNum) allPackets = pHandler.findAllProjects() for p in allPackets: pID = p.getNumber() pName = p.getName() pOwner = p.getOwner() #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `pOwner` # update March 11, 2011 try: lastName = pOwner.getLastName() except AttributeError: lastName = "" #pDesc = `pID` + " : " + pOwner + " : " + pName pDesc = `pID` + " : " + lastName + " : " + pName if not pID in readProjID and not pID in writeProjID: content += "<OPTION VALUE=\"" + `pID` + "\">" + pDesc content += ''' </SELECT> <BR> <INPUT TYPE="checkbox" style="margin-top:10px; font-size:8pt;" onClick="selectAll(this.id, 'packetList')" id="add_all_chkbx"> Select All</INPUT> ''' if not write_disabled: content += ''' </TD> <TD style="vertical-align:top"> <span style="font-size:8pt; font-weight:bold">User's access level to selected projects:<BR/></span> <input type="radio" id="access_level_radio_read" name="access_levels" value="read" style="margin-top:8px; font-size:9pt" checked>Read-Only <BR/> <input type="radio" id="access_level_radio_write" name="access_levels" value="write" style="margin-top:5px; font-size:9pt">Write <BR/> <input style="margin-top:8px" onclick="addProjects('packetList', getSelectedRole('1'))" value="Add project" type="button"></INPUT> </TD> </TABLE> </TD> </TR> ''' else: content += ''' <input style="margin-left:5px; margin-top:8px" onclick="addProjects('packetList', 'read')" value="Add project" type="button"></INPUT> ''' content += ''' </TR> </TABLE> </FORM> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> <blockquote> </blockquote> </div> ''' content += gOut.printFooter() page_content = content % (hostname + "cgi/user_request_handler.py", username, un_warn_display, userID, firstname, lastname, email) print "Content-type:text/html" # THIS IS PERMANENT; DO NOT REMOVE print # DITTO print page_content
def addUser(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname mail_server = self.__mail_server # August 19, 2011 mail_programmer = self.__mail_programmer # July 30, 2010 mail_biologist = self.__mail_biologist mail_admin = self.__mail_admin #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` uHandler = UserHandler(db, cursor) lHandler = LabHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) ucMapper = UserCategoryMapper(db, cursor) category_Name_ID_Map = ucMapper.mapCategoryNameToID() # Get form values labID = int(form.getvalue("labs")) username = form.getvalue("username") firstName = form.getvalue("firstName") lastName = form.getvalue("lastName") description = firstName + " " + lastName to_email = form.getvalue("email") from_email = mail_admin # Change July 30, 2010 - random password generator #passwd = form.getvalue("password") chars = string.letters + string.digits passwd = "" for i in range(10): passwd += choice(chars) # System access level: Lab default or override? #if form.getvalue("privChoiceRadio") == 'override': accessLevel = category_Name_ID_Map[form.getvalue( "system_access_level")] #else: #accessLevel = lHandler.findDefaultAccessLevel(labID) newProps = {} try: # Insert User information userID = uHandler.insertUser(username, firstName, lastName, description, accessLevel, to_email, passwd, labID) #newUser = uHandler.getUserByID(userID) tmpLab = lHandler.findLabByID(labID) #print tmpLab.getName() # Insert Project info # Sept. 11/07: Differentiate between user categories Reader and Writer - different field names if form.has_key("userProjectsReadonly"): # list of IDs readonlyProjects = utils.unique( form.getlist("userProjectsReadonly")) #print `readonlyProjects` pHandler.insertMemberProjects(userID, readonlyProjects, 'Reader') elif form.has_key("userProjectsReadonlyWrite"): # list of IDs readonlyProjects = utils.unique( form.getlist("userProjectsReadonlyWrite")) #print `readonlyProjects` pHandler.insertMemberProjects(userID, readonlyProjects, 'Reader') # Write projects exist only for Writers if form.has_key("userProjectsWrite"): writeProjects = utils.unique(form.getlist("userProjectsWrite")) pHandler.insertMemberProjects(userID, writeProjects, 'Writer') # don't assign projects to a User instance - will retrieve them from db in output function newUser = User(userID, username, firstName, lastName, description, tmpLab, form.getvalue("system_access_level"), to_email, passwd, [], []) email_subject = "OpenFreezer User Account" msg = email.MIMEMultipart.MIMEMultipart('alternative') msg['Subject'] = email_subject msg['To'] = to_email msgText = "Hi " + firstName + ",<BR><BR>An OpenFreezer account has been created for you. Your access level is " + form.getvalue( "system_access_level") + ", so you can " if form.getvalue("system_access_level") == 'Reader': msgText += "search for clones. If you wish to add/modify reagents or create projects, please contact the administrator to upgrade your access level.<BR>" elif form.getvalue("system_access_level") == 'Writer': msgText += "search, add, and modify reagents. If you wish to create projects, please contact the administrator to upgrade your access level.<BR>" elif form.getvalue("system_access_level") == 'Creator': msgText += "search for clones, add and modify reagents, as well as create your own projects.<BR>" ##################################################### # CHANGE TEXT AS NEEDED ##################################################### msgText += "<BR>The URL to access the system is <a href='" + hostname + "'>" + hostname + "</a>. Your username is <b>" + username + "</b>, and your temporary password is <b>" + passwd + "</b>. Please <u>change the temporary password as soon as you log into the website</u> - you can do it through the 'Change your password' link under the 'User Management' menu section.<BR><BR>Please refer to http://openfreezer.org for additional support.<BR><BR>Sincerely,<BR>OpenFreezer support team.<BR><BR><span style='font-family:Courier; font-size:10pt;'><HR>This is an automatically generated e-mail message. Please do not reply to this e-mail. All questions should be directed to your local administrator.</span>" msgText = email.MIMEText.MIMEText(msgText, 'html') msg.attach(msgText) server = smtplib.SMTP(mail_server) server.set_debuglevel(1) server.sendmail(from_email, [to_email], msg.as_string()) server.quit() self.printUserInfo('view', newUser) except DeletedUserException: # Without asking too many questions, reactivate the deleted user and overwrite his/her attributes with the form input values userID = uHandler.findUserIDByUsername(username) newProps["firstname"] = firstName newProps["lastname"] = lastName newProps["description"] = description newProps["email"] = email newProps["status"] = "ACTIVE" newProps["password"] = passwd # Insert new database values and create new object uHandler.updateUserProperties(userID, newProps) # database update newUser = uHandler.getUserByID(userID) # Insert Project info readProjects = [] writeProjects = [] if form.has_key("userProjectsReadonly"): # list of IDs readonlyProjects = form.getlist("userProjectsReadonly") for r in readonlyProjects: pHandler.addProjectMember(r, userID, 'Reader') #tmpReadProject = pHandler.findPacket(r) #readProjects.append(tmpReadProject) #newUser.addProject(tmpReadProject, 'read') if form.has_key("userProjectsWrite"): writeProjects = form.getlist("userProjectsWrite") for w in writeProjects: pHandler.addProjectMember(w, userID, 'Writer') #tmpWriteProject = pHandler.findPacket(w) #writeProjects.append(tmpWriteProject) #newUser.addProject(tmpWriteProject, 'write') #newUser.setReadProjects(readProjects) #newUser.setWriteProjects(writeProjects) self.printUserInfo('view', newUser) #utils.redirect(hostname + "User.php?View=3&fd=" + filename) except DuplicateUsernameException: # return to the view with input values and error message # Need to construct a dummy User instance to save form values for error output on the next page (otherwise they're lost as soon as Submit is pressed and creation view is exited) newLab = lHandler.findLabByID(labID) newUser = User(0, username, firstName, lastName, description, newLab, "", email, passwd) self.printUserInfo('create', newUser)
def update(): dbConn = DatabaseConn() db = dbConn.databaseConnect() cursor = db.cursor() hostname = dbConn.getHostname() form = cgi.FieldStorage(keep_blank_values="True") print "Content-type:text/html" # REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! print # DITTO #print `form` # Aug 29/07 uHandler = UserHandler(db, cursor) if form.has_key("curr_username"): # store the user ID for use throughout the session; add to other views in addition to create in PHP currUname = form.getvalue("curr_username") currUser = uHandler.getUserByDescription(currUname) Session.setUser(currUser) #else: # debug #currUname = 'Administrator' #currUser = uHandler.getUserByDescription(currUname) #Session.setUser(currUser) if form.has_key("cloning_method"): cloning_method = form.getvalue("cloning_method") #else: # debug #cloning_method = '1' # Handlers and mappers rHandler = ReagentHandler(db, cursor) #sHandler = SystemSetHandler(db, cursor) pHandler = ReagentPropertyHandler(db, cursor) raHandler = ReagentAssociationHandler(db, cursor) aHandler = AssociationHandler(db, cursor) dnaHandler = DNAHandler(db, cursor) commHandler = CommentHandler(db, cursor) protHandler = ProteinHandler(db, cursor) propMapper = ReagentPropertyMapper(db, cursor) assocMapper = ReagentAssociationMapper(db, cursor) # August 29/07: Restrict creation by user and project access packetHandler = ProjectDatabaseHandler(db, cursor) ######################################################## # Various maps ######################################################## prop_Alias_ID_Map = propMapper.mapPropAliasID() # (propAlias, propID) - e.g. ('insert_type', '48') --> represents 'type of insert' property prop_Name_Alias_Map = propMapper.mapPropNameAlias() # (propName, propAlias) prop_Name_ID_Map = propMapper.mapPropNameID() # (prop name, prop id) # Restriction sites fpcs_prop_id = pHandler.findPropID("5' cloning site") tpcs_prop_id = pHandler.findPropID("3' cloning site") newFivePrime = form.getvalue("fpcs") newThreePrime = form.getvalue("tpcs") gatewaySites = ['attb', 'attl', 'attp', 'attr'] # nov. 16/07 # resulting sequence newSeq = "" # Fetch projects the user has AT LEAST Read access to (i.e. if he is explicitly declared a Writer on a project but not declared a Reader, include that project, plus all public projects) currReadProj = packetHandler.findMemberProjects(currUser.getUserID(), 'Reader') currWriteProj = packetHandler.findMemberProjects(currUser.getUserID(), 'Writer') publicProj = packetHandler.findAllProjects(isPrivate="FALSE") # list of Packet OBJECTS currUserWriteProjects = utils.unique(currReadProj + currWriteProj + publicProj) uPackets = [] for p in currUserWriteProjects: uPackets.append(p.getNumber()) # Get project IDs of parents packetPropID = pHandler.findPropID("packet id") # August 29/07: Need to verify parent project access AND (Sept. 12/07) reconstruct the sequence IFF parent values are changed newSeq = "" # Fetch projects the user has AT LEAST Read access to (i.e. if he is explicitly declared a Writer on a project but not declared a Reader, include that project, plus all public projects) currReadProj = packetHandler.findMemberProjects(currUser.getUserID(), 'Reader') currWriteProj = packetHandler.findMemberProjects(currUser.getUserID(), 'Writer') publicProj = packetHandler.findAllProjects(isPrivate="FALSE") # list of Packet OBJECTS currUserWriteProjects = utils.unique(currReadProj + currWriteProj + publicProj) uPackets = [] for p in currUserWriteProjects: uPackets.append(p.getNumber()) # Get project IDs of parents packetPropID = pHandler.findPropID("packet id") if form.has_key("PV"): pvVal = form.getvalue("PV") if len(pvVal) > 0: pvID = rHandler.convertReagentToDatabaseID(pvVal) try: pvProjectID = int(rHandler.findSimplePropertyValue(pvID, packetPropID)) pvSeqID = rHandler.findDNASequenceKey(pvID) # get sequence for reconstitution later except TypeError: #pvProjectID = 0 e = PVProjectAccessException("You are not authorized to use this Parent Vector, since you do not have Read access to its project.") print `e.err_code()` else: e = UnknownPVIDException("Unknown Parent Vector value") print `e.err_code()` return # else don't do anything, maybe want to delete parents!!! #else: #e = MissingPVException("No Parent Vector provided") #print `e.err_code()` if pvProjectID > 0 and currUser.getCategory() != 'Admin' and pvProjectID not in uPackets: e = PVProjectAccessException("Not authorized to access parent") print `e.err_code()` return if cloning_method == '1': # Non-recombination vector - Get the Insert if form.has_key("I"): insertVal = form.getvalue("I") if len(insertVal) > 0: insertID = rHandler.convertReagentToDatabaseID(insertVal) insertSeqID = rHandler.findDNASequenceKey(insertID) # fetch Insert sequence for reconstitution later try: insertProjectID = int(rHandler.findSimplePropertyValue(insertID, packetPropID)) except TypeError: #insertProjectID = 0 e = InsertProjectAccessException("You are not authorized to use this Insert, since you do not have Read access to its project.") print `e.err_code()` else: #insertID = -1 #insertProjectID = 0 #print "Invalid Insert value" e = UnknownInsertIDException("Unknown Insert value") print `e.err_code()` return #else: # NO!!!!!!!! #e = MissingInsertException("No Insert provided") #print `e.err_code()` if insertProjectID > 0 and currUser.getCategory() != 'Admin' and insertProjectID not in uPackets: e = InsertProjectAccessException("You are not authorized to use this Insert, since you do not have Read access to its project.") print `e.err_code()` return if pvID > 0 and insertID > 0 : # try to reconstruct sequence and issue warning if unable if pvSeqID > 0 and insertSeqID > 0: # fetch insert cloning sites insertCloningSites = [] fpcs_prop_id = pHandler.findPropID("5' cloning site") tpcs_prop_id = pHandler.findPropID("3' cloning site") fp_insert_cs = rHandler.findSimplePropertyValue(insertID, fpcs_prop_id) tp_insert_cs = rHandler.findSimplePropertyValue(insertID, tpcs_prop_id) # Determine if this is a Gateway clone from sites gwSites = False; if fp_insert_cs and tp_insert_cs and fp_insert_cs.lower() == 'attl' and tp_insert_cs.lower() == 'attl': gwSites = True elif not fp_insert_cs or not tp_insert_cs: gwSites = True # nov. 16/07: added this for check elif fp_insert_cs.lower() in gatewaySites or tp_insert_cs.lower() in gatewaySites: gwSites = True else: gwSites = False; if gwSites: # this is a gateway clone # if sites were changed to something other than gateway, clear sequence if newFivePrime.lower() != 'attl' or newThreePrime.lower() != 'attl': e = InsertSitesNotFoundOnParentSequenceException() print `e.err_code()` return else: pvSeqKey = rHandler.findDNASequenceKey(pvID) # For Gateway clones, linkers are found from primers - so find the sense and antisense Oligos for this Insert insertLinkers = [] # Find Sense and Antisense Oligos for this Insert # (not using antisense just yet - verify with Karen) iHandler = InsertHandler(db, cursor) senseOligoID = iHandler.findSenseOligoID(insertID) #antisenseOligoID = iHandler.findAntisenseOligoID(insert_db_id) # Find Oligo sequences seqPropID = pHandler.findPropID("sequence") senseOligoSeqID = rHandler.findIndexPropertyValue(senseOligoID, seqPropID) senseOligoSequence = dnaHandler.findSequenceByID(senseOligoSeqID) # Fetch Insert sequence and find linkers from Oligo and Insert sequences insertSequence = dnaHandler.findSequenceByID(insertSeqID) attB_const = "ggggacaactttgtacaaaaaagttggc" fwd_primer_seq = senseOligoSequence[len(attB_const):] # First, find linkers from Oligos fwd_linker = dnaHandler.linker_from_oligo(insertSequence, fwd_primer_seq) #rev_linker = sHandler.linker_from_oligo(insertSequence, rev_primer_seq) rev_linker = "" # Now see if the Insert had its own linkers stored and append them to the Oligo linker fpLinkerPropID = pHandler.findPropID("5' linker") tpLinkerPropID = pHandler.findPropID("3' linker") fp_insert_linker = rHandler.findSimplePropertyValue(insertID, fpLinkerPropID) tp_insert_linker = rHandler.findSimplePropertyValue(insertID, tpLinkerPropID) if fp_insert_linker and len(fp_insert_linker) > 0 and fp_insert_linker != 0 and fp_insert_linker != '0': fp_insert_linker = fwd_linker + fp_insert_linker else: fp_insert_linker = fwd_linker tp_insert_linker = rev_linker insertLinkers.append(fp_insert_linker) insertLinkers.append(tp_insert_linker) try: newSeq = dnaHandler.entryVectorSequence(pvSeqKey, insertSeqID, insertLinkers) print newSeq except MultipleSiteOccurrenceException: e = MultipleSiteOccurrenceException("Sites found more than once on parent vector sequence") print `e.err_code()` except FivePrimeAfterThreePrimeException: e = FivePrimeAfterThreePrimeException("5' after 3'") print `e.err_code()` except InsertSitesNotFoundOnParentSequenceException: e = InsertSitesNotFoundOnParentSequenceException("Gateway sites not found on parent vector sequence") print `e.err_code()` else: # Non-Gateway non-recombination Vector fp_insert_cs = newFivePrime tp_insert_cs = newThreePrime if fp_insert_cs: insertCloningSites.append(fp_insert_cs) else: insertCloningSites.append("") if tp_insert_cs: insertCloningSites.append(tp_insert_cs) else: insertCloningSites.append("") # get linkers if there are any insertLinkers = [] fpLinkerPropID = pHandler.findPropID("5' linker") tpLinkerPropID = pHandler.findPropID("3' linker") fp_insert_linker = rHandler.findSimplePropertyValue(insertID, fpLinkerPropID) tp_insert_linker = rHandler.findSimplePropertyValue(insertID, tpLinkerPropID) # sept. 3/07 fwd_linker = "" if fp_insert_linker and len(fp_insert_linker) > 0 and fp_insert_linker != 0 and fp_insert_linker != '0': fp_insert_linker = fwd_linker + fp_insert_linker else: fp_insert_linker = fwd_linker insertLinkers.append(fp_insert_linker) insertLinkers.append(tp_insert_linker) try: newSeq = dnaHandler.constructNonRecombSequence(pvSeqID, insertSeqID, insertCloningSites, insertLinkers) print newSeq except (InsertSitesException): e = InsertSitesException("Could not reconstitute sequence: Unknown sites on Insert.") print e.err_code() except (InsertSitesNotFoundOnParentSequenceException): e = InsertSitesNotFoundOnParentSequenceException("Could not reconstitute sequence: Parent vector sequence does not contain restriction sites.") print e.err_code() except (MultipleSiteOccurrenceException): e = MultipleSiteOccurrenceException("Could not reconstitute sequence: Restriction sites occur more than once on parent vector sequence") print e.err_code() except (HybridizationException): e = HybridizationException("Could not reconstitute sequence: Restriction sites cannot be hybridized.") print e.err_code() except (FivePrimeAfterThreePrimeException): e = FivePrimeAfterThreePrimeException("Could not reconstitute sequence: 5' site occurs after 3' site on parent vector sequence.") print e.err_code() else: e = InvalidSequenceException("Invalid parent sequence") print `e.err_code()` else: e = UnknownPVIDException("Unknown PV ID") print `e.err_code()` elif cloning_method == '2': # Recombination vector - check IPV ipvVal = form.getvalue("IPV") if len(ipvVal) > 0: ipvID = rHandler.convertReagentToDatabaseID(ipvVal) ipvProjectID = int(rHandler.findSimplePropertyValue(ipvID, packetPropID)) else: e = UnknownIPVIDException("Unknown IPV ID") print `e.err_code()` if ipvProjectID > 0 and currUser.getCategory() != 'Admin' and ipvProjectID not in uPackets: e = IPVProjectAccessException("Not authorized to view IPV") print `e.err_code()` if ipvID > 0 and pvID > 0: # If restriction sites were modified to anything other than LoxP or gateway att sites, clear the sequence if not (newFivePrime == newThreePrime and (newFivePrime.lower() == 'loxp' and newThreePrime.lower() == 'loxp') or (newFivePrime.lower() == 'attb' and newThreePrime.lower() == 'attb')): e = InsertSitesNotFoundOnParentSequenceException("Invalid restriction sites for Non-Recombination Clone - must be LoxP only") print `e.err_code()` else: # get internal db IDs pv_db_id = rHandler.convertReagentToDatabaseID(pvVal) ipv_db_id = rHandler.convertReagentToDatabaseID(ipvVal) # Get the Insert that belongs to the donor vector ipvInsertAssocID = raHandler.findReagentAssociationID(ipv_db_id) insertAssocPropID = aHandler.findAssocPropID("insert id") insert_db_id = aHandler.findAssocPropValue(ipvInsertAssocID, insertAssocPropID) # Construct a sequence for the new vector from the sequences of its parents pvSeqKey = rHandler.findDNASequenceKey(pv_db_id) #print "pv seq " + `pvSeqKey` ipvSeqKey = rHandler.findDNASequenceKey(ipv_db_id) #print "ipv seq " + `ipvSeqKey` insertSeqKey = rHandler.findDNASequenceKey(insert_db_id) #print "i seq " + `insertSeqKey` if pvSeqKey > 0 and ipvSeqKey > 0 and insertSeqKey > 0: # See if there are linkers, although there most likely aren't any insertLinkers = [] fpLinkerPropID = pHandler.findPropID("5' linker") tpLinkerPropID = pHandler.findPropID("3' linker") fp_insert_linker = rHandler.findSimplePropertyValue(insert_db_id, fpLinkerPropID) tp_insert_linker = rHandler.findSimplePropertyValue(insert_db_id, tpLinkerPropID) # sept. 3/07 fwd_linker = "" if fp_insert_linker and len(fp_insert_linker) > 0 and fp_insert_linker != 0 and fp_insert_linker != '0': fp_insert_linker = fwd_linker + fp_insert_linker else: fp_insert_linker = fwd_linker insertLinkers.append(fp_insert_linker) insertLinkers.append(tp_insert_linker) # Differentiate by cloning sites whether this is a recombination vector or a Gateway Expression Vector if newFivePrime == 'LoxP' and newThreePrime == 'LoxP': # recombination try: newSeq = dnaHandler.constructRecombSequence(pvSeqKey, ipvSeqKey, insertSeqKey, insertLinkers) newSeqID = dnaHandler.matchSequence(newSeq) print newSeq except InsertSitesNotFoundOnParentSequenceException: e = InsertSitesNotFoundOnParentSequenceException("LOXP sites not found on parent vector sequence") print `e.err_code()` except MultipleSiteOccurrenceException: e = MultipleSiteOccurrenceException("LOXP found more than once on parent vector sequence") print `e.err_code()` elif newFivePrime == 'attB' and newThreePrime == 'attB': # Gateway Expression iHandler = InsertHandler(db, cursor) senseOligoID = iHandler.findSenseOligoID(insert_db_id) #antisenseOligoID = iHandler.findAntisenseOligoID(insert_db_id) # Find Oligo sequences seqPropID = pHandler.findPropID("sequence") senseOligoSeqID = rHandler.findIndexPropertyValue(senseOligoID, seqPropID) senseOligoSequence = dnaHandler.findSequenceByID(senseOligoSeqID) # Fetch Insert sequence and find linkers from Oligo and Insert sequences insertSequence = dnaHandler.findSequenceByID(insertSeqKey) attB_const = "ggggacaactttgtacaaaaaagttggc" fwd_primer_seq = senseOligoSequence[len(attB_const):] # First, find linkers from Oligos fwd_linker = dnaHandler.linker_from_oligo(insertSequence, fwd_primer_seq) #rev_linker = sHandler.linker_from_oligo(insertSequence, rev_primer_seq) rev_linker = "" # Now see if the Insert had its own linkers stored and append them to the Oligo linker fpLinkerPropID = pHandler.findPropID("5' linker") tpLinkerPropID = pHandler.findPropID("3' linker") fp_insert_linker = rHandler.findSimplePropertyValue(insert_db_id, fpLinkerPropID) tp_insert_linker = rHandler.findSimplePropertyValue(insert_db_id, tpLinkerPropID) if fp_insert_linker and len(fp_insert_linker) > 0 and fp_insert_linker != 0 and fp_insert_linker != '0': fp_insert_linker = fwd_linker + fp_insert_linker else: fp_insert_linker = fwd_linker tp_insert_linker = rev_linker insertLinkers.append(fp_insert_linker) insertLinkers.append(tp_insert_linker) try: newSeq = dnaHandler.expressionVectorSequence(pvSeqKey, insertSeqKey, insertLinkers) print newSeq except MultipleSiteOccurrenceException: e = MultipleSiteOccurrenceException("Sites found more than once on parent vector sequence") print `e.err_code()` except FivePrimeAfterThreePrimeException: e = FivePrimeAfterThreePrimeException("5' after 3'") print `e.err_code()` except InsertSitesNotFoundOnParentSequenceException: e = InsertSitesNotFoundOnParentSequenceException("Gateway sites not found on parent vector sequence") print `e.err_code()` else: e = InvalidSequenceException("Invalid parent sequence") print `e.err_code()` else: e = ReagentDoesNotExistException("Unknown parent values") print `e.err_code()`
def saveUser(self, form): db = self.__db cursor = self.__cursor hostname = self.__hostname #print "Content-type:text/html" # TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!! #print # DITTO #print `form` uHandler = UserHandler(db, cursor) lHandler = LabHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) ucMapper = UserCategoryMapper(db, cursor) category_ID_Name_Map = ucMapper.mapCategoryIDToName() newProps = {} # Get form values userID = int(form.getvalue("userID")) newUser = uHandler.getUserByID(userID) labID = int(form.getvalue("labs")) tmpLab = lHandler.findLabByID(labID) # rest of user properties username = form.getvalue("username") firstName = form.getvalue("firstName") lastName = form.getvalue("lastName") description = firstName + " " + lastName email = form.getvalue("email") category = category_ID_Name_Map[int( form.getvalue("system_access_level"))] newProps["labID"] = labID newProps["username"] = username newProps["firstname"] = firstName newProps["lastname"] = lastName newProps["description"] = description newProps["email"] = email newProps["category"] = category try: # Now do an update on database level AND on class level: uHandler.updateUserProperties(userID, newProps) # database update # Interface level newUser.setUsername(username) newUser.setFirstName(firstName) newUser.setLastName(lastName) newUser.setDescription(description) newUser.setEmail(email) newUser.setLab(tmpLab) newUser.setCategory(category) # update list of user's projects if form.has_key("userProjectsReadonly"): # list of IDs readonlyProjects = utils.unique( form.getlist("userProjectsReadonly")) pHandler.updateUserProjects(userID, readonlyProjects, 'Reader') else: # safe to assume should delete projects? pHandler.deleteMemberProjects(userID, 'Reader') if form.has_key("userProjectsWrite"): writeProjects = utils.unique(form.getlist("userProjectsWrite")) pHandler.updateUserProjects(userID, writeProjects, 'Writer') else: # safe to assume should delete projects? pHandler.deleteMemberProjects(userID, 'Writer') # think about this #newUser.setReadProjects(readProjects) #newUser.setWriteProjects(writeProjects) # return to detailed view self.printUserInfo('view', newUser) #utils.redirect(hostname + "User.php?View=3&fd=" + filename) except DuplicateUsernameException: # return to the view with input values and error message # Need to construct a dummy User instance to save form values for error output on the next page (otherwise they're lost as soon as Submit is pressed and creation view is exited) newLab = lHandler.findLabByID(labID) newUser = User(userID, username, firstName, lastName, description, newLab, category, email, "") self.printUserInfo('edit', newUser, "Dup_un")
from session import Session # make global?? dbConn = DatabaseConn() db = dbConn.databaseConnect() hostname = dbConn.getHostname() cursor = db.cursor() # Handlers and Mappers aHandler = AssociationHandler(db, cursor) rHandler = ReagentHandler(db, cursor) iHandler = InsertHandler(db, cursor) raHandler = ReagentAssociationHandler(db, cursor) sHandler = DNAHandler(db, cursor) pHandler = ReagentPropertyHandler(db, cursor) packetHandler = ProjectDatabaseHandler(db, cursor) uHandler = UserHandler(db, cursor) rtPropHandler = ReagentTypePropertyHandler(db, cursor) oHandler = OligoHandler(db, cursor) propMapper = ReagentPropertyMapper(db, cursor) aMapper = ReagentAssociationMapper(db, cursor) rMapper = ReagentTypeMapper(db, cursor) # Various maps reagentType_Name_ID_Map = rMapper.mapTypeNameID() reagentType_ID_Name_Map = rMapper.mapTypeIDName() assoc_Type_Name_Map = aMapper.mapAssocTypeNameID() assoc_Name_Alias_Map = aMapper.mapAssocNameAlias()
def printReagentInfo(self, cmd, reagent, errMsg=""): dbConn = DatabaseConn() hostname = dbConn.getHostname() # to define form action URL db = dbConn.databaseConnect() cursor = db.cursor() gOut = GeneralOutputClass() currUser = Session.getUser() currUserID = currUser.getUserID() sHandler = SystemSetHandler(db, cursor) pHandler = ProjectDatabaseHandler(db, cursor) # print menu content = gOut.printHeader() + gOut.printMainMenu() # common to all reagent types projectList = utils.unique( pHandler.findMemberProjects(currUserID, 'Writer') + pHandler.findMemberProjects(currUserID, 'Owner')) # Differentiate other properties by reagent type if reagent.getType() == 'Insert': # Fetch dropdown list values to output on the form iTypeList = sHandler.findAllSetValues("type of insert") statusList = sHandler.findAllSetValues("status") cloningMethodList = sHandler.findAllSetValues( "insert cloning method") fpcsList = sHandler.findAllSetValues("5' cloning site") tpcsList = sHandler.findAllSetValues("3' cloning site") tagTypeList = sHandler.findAllSetValues("tag") tagPositionList = sHandler.findAllSetValues("tag position") openClosedList = sHandler.findAllSetValues("open/closed") speciesList = sHandler.findAllSetValues("species") verificationList = sHandler.findAllSetValues("verification") # Initialize property values iType = "" iName = "" iStatus = "" cloningMethod = "" projectID = "" fpcs = "" tpcs = "" tagType = "" tagPosition = "" openClosed = "" species = "" accession = "" altID = "" geneID = "" ensemblID = "" geneSymbol = "" fp_start = "" tp_stop = "" fwd_linker = "" rev_linker = "" funcDescr = "" verification = "" expComm = "" verComm = "" sequence = "" # Fetch POST values if available: allProps = reagent.getProperties() if allProps.has_key("type of insert"): iType = allProps["type of insert"] if allProps.has_key("name"): iName = allProps["name"] if allProps.has_key("status"): iStatus = allProps["status"] if allProps.has_key("insert cloning method"): cloningMethod = allProps["insert cloning method"] if allProps.has_key("packet id"): projectID = int(allProps["packet id"]) if allProps.has_key("5' cloning site"): fpcs = allProps["5' cloning site"] if allProps.has_key("3' cloning site"): tpcs = allProps["3' cloning site"] if allProps.has_key("tag"): tagType = allProps["tag"] if allProps.has_key("tag position"): tagPosition = allProps["tag position"] if allProps.has_key("open/closed"): openClosed = allProps["open/closed"] if allProps.has_key("species"): species = allProps["species"] if allProps.has_key("accession number"): accession = allProps["accession number"] if allProps.has_key("alternate id"): altID = allProps["alternate id"] if allProps.has_key("entrez gene id"): geneID = allProps["entrez gene id"] if allProps.has_key("ensembl gene id"): ensemblID = allProps["ensembl gene id"] if allProps.has_key("official gene symbol"): geneSymbol = allProps["official gene symbol"] if allProps.has_key("5' start"): fp_start = allProps["5' start"] if allProps.has_key("3' stop"): tp_stop = allProps["3' stop"] if allProps.has_key("5' linker"): fwd_linker = allProps["5' linker"] if allProps.has_key("3' linker"): rev_linker = allProps["3' linker"] if allProps.has_key("description"): funcDescr = allProps["description"] if allProps.has_key("verification"): verification = allProps["verification"] if allProps.has_key("comments"): expComm = allProps["comments"] if allProps.has_key("verification comments"): verComm = allProps["verification comments"] if allProps.has_key("sequence"): sequence = allProps["sequence"] # associations ipvID = "" senseOligoID = "" antisenseOligoID = "" allAssoc = reagent.getAssociations() ''' if allAssoc.has_key("insert_parent_vector"): ipvID = allAssoc["insert_parent_vector"] if allAssoc.has_key("sense_oligo"): senseOligoID = allAssoc["sense_oligo"] if allAssoc.has_key("antisense_oligo"): antisenseOligoID = allAssoc["antisense_oligo"] ''' # Action: Output form with POST values if set if cmd == 'create': content += ''' <div class="main"> <form NAME="create_insert_form" ACTION="%s" METHOD="POST" onSubmit="return validateInsert() && verifyParents();"> ''' content += "<INPUT type=\"hidden\" ID=\"curr_username_hidden\" NAME=\"curr_username\" value=\"" + currUser.getFullName( ) + "\">" content += ''' <input type="hidden" name="reagent_type_hidden" value="Insert"> <table id="vector_insertproperty_table_id" border="1" width="780px" cellpadding="4" frame="box" rules="all"> ''' if errMsg != "": content += "<th colspan=\"3\" style=\"color:#0000FF; text-align:left; font-weight:normal\">There was a problem:<br><P>" + errMsg + "<BR><BR></th>" content += ''' <tr> <td colspan="3" style="text-align:center"> <span style="color:#0000CD; font-size:13pt; font-weight:bold"> Insert Information </span> <br> <span style="font-size:8pt; color:#FF0000"> Fields marked with a red asterisk (*) are mandatory </span> </td> </tr> <tr> <td width="180px"> Type of Insert <span style="font-size:8pt; color:#FF0000; font-weight:bold">*</span> </td> <td width="275px"> <SELECT id="itype_list" size="1" NAME="INPUT_INSERT_info_insert_type_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(iType) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for it in iTypeList: content += "<OPTION VALUE=\"" + it + "\"" if it == iType: content += " SELECTED>" + it + "</OPTION>" else: content += ">" + it + "</OPTION>" content += ''' </SELECT> </td> <td> Describes the type of insert. Users select from a pre-defined list. Designed to make insert use more apparent and searches easier. </td> </tr> <tr> <td> Name </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_name_prop\" value=\"" + iName + "\">" content += ''' </td> <td> Name that describes the reagent - free text field </td> </tr> <tr> <td> Status </td> <td> <SELECT id="status_list" name="INPUT_INSERT_info_status_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(iStatus) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for s in statusList: content += "<OPTION VALUE=\"" + s + "\"" if s == iStatus: content += " SELECTED>" + s + "</OPTION>" else: content += ">" + s + "</OPTION>" content += ''' </td> <td> Indicates the status and availability of the reagent. Users select from a pre-defined list. </td> </tr> <tr> <td> Insert Cloning Method </td> <td> <SELECT size="1" id="cm_list" name="INPUT_INSERT_info_cloning_method_prop" onChange="showCMText()"> ''' # default option content += "<OPTION VALUE=\"\" " if len(cloningMethod) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for cm in cloningMethodList: content += "<OPTION VALUE=\"" + cm + "\"" if cm == cloningMethod: content += " SELECTED>" + cm + "</OPTION>" else: content += ">" + cm + "</OPTION>" content += ''' </td> <td> Describes the method used to create the insert (e.g. PCR or RE (restriction enzyme)) and provides additional information for its cloning into a vector (eg. by RE, In Fusion or BP reaction) </td> </tr> <tr> <td> Project ID <span style="font-size:8pt; color:#FF0000; font-weight:bold">*</span> </td> <td> <select id="packetList_insert" size="1" name="INPUT_INSERT_info_packet_id_prop"> ''' # need to sort projects pNums = [] projects = {} # (pID, Packet) for p in projectList: pID = p.getNumber() pNums.append(pID) projects[pID] = p pNums.sort() for pID in pNums: p = projects[pID] content += "<OPTION VALUE=\"" + ` p.getNumber() ` + "\"" if p.getNumber() == projectID: content += " SELECTED>" + ` p.getNumber( ) ` + ": " + p.getOwner().getLastName( ) + ": " + p.getName() + "</OPTION>" else: content += ">" + ` p.getNumber() ` + ": " + p.getOwner( ).getLastName() + ": " + p.getName() + "</OPTION>" content += ''' </select> <BR> <div id="packet_warning_insert" style="display:none; color:#FF0000">Please select a Project ID from the dropdown list</div> </td> <td> Indicates what person and project originally created the reagent. </td> </tr> <tr> <td> 5' Cloning Site on Insert </td> <td> <SELECT size="1" id="fpcs_list" name="INPUT_INSERT_info_5_prime_cloning_site_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(fpcs) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for fps in fpcsList: content += "<OPTION VALUE=\"" + fps + "\"" if fps == fpcs: content += " SELECTED>" + fps + "</OPTION>" else: content += ">" + fps + "</OPTION>" content += ''' </td> <td> Indicates what 5' site on the insert was used to clone it into a vector. May not necessarily be the same as for the vector. Users select from a pre-defined list. </td> </tr> <tr> <td> 3' Cloning Site on Insert </td> <td> <SELECT size="1" id="tpcs_list" name="INPUT_INSERT_info_3_prime_cloning_site_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(tpcs) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for tps in tpcsList: content += "<OPTION VALUE=\"" + tps + "\"" if tps == tpcs: content += " SELECTED>" + tps + "</OPTION>" else: content += ">" + tps + "</OPTION>" content += ''' </td> <td> Indicates what 3' site on the insert was used to clone it into a vector. May not necessarily be the same as for the vector. Users select from a pre-defined list. </td> </tr> <tr> <td> Tag </td> <td> <SELECT size="1" id="tag_list" name="INPUT_INSERT_info_tag_prop" onChange="showTagTypeBox()"> ''' # default option content += "<OPTION VALUE=\"\" " if len(tagType) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for tt in tagTypeList: content += "<OPTION VALUE=\"" + tt + "\"" if tt == tagType: content += " SELECTED>" + tt + "</OPTION>" else: content += ">" + tt + "</OPTION>" content += ''' </td> <td> Indicates if the insert itself has a tag associated with it (outside of the backbone vector). Users select from a pre-defined list. </td> </tr> <tr> <td> Tag Position </td> <td> <SELECT size="1" name="INPUT_INSERT_info_tag_position_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(tagPosition) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for tp in tagPositionList: content += "<OPTION VALUE=\"" + tp + "\"" if tp == tagPosition: content += " SELECTED>" + tp + "</OPTION>" else: content += ">" + tp + "</OPTION>" content += ''' </td> <td> Describes the position of the tag on the insert. Users select from a pre-defined list. </td> </tr> <tr> <td> Open/Closed </td> <td> <SELECT id="oc_list" size="1" name="INPUT_INSERT_info_open_closed_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(openClosed) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for oc in openClosedList: content += "<OPTION VALUE=\"" + oc + "\"" if oc == openClosed: content += " SELECTED>" + oc + "</OPTION>" else: content += ">" + oc + "</OPTION>" content += ''' </td> <td> Indicates for an Open Reading Frame if there is a start codon (ATG) or stop codon (open - no stop codon, closed - stop codon). </td> </tr> <tr> <td> Species </td> <td> <SELECT size="1" style="color:000000" id = "species_list" name="INPUT_INSERT_info_species_prop" onChange="showSpeciesBox()"> ''' # default option content += "<OPTION VALUE=\"\" " if len(species) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for sp in speciesList: content += "<OPTION VALUE=\"" + sp + "\"" if sp == species: content += " SELECTED>" + sp + "</OPTION>" else: content += ">" + sp + "</OPTION>" content += ''' </td> <td> Indicates the species from which the Insert was derived. User selects species from a pre-defined list. </td> </tr> <tr> <td> Accession Number </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_accession_number_prop\" value=\"" + accession + "\">" content += ''' </td> <td> The Accession Number from which the insert was cloned or to which the sequence maps. </td> </tr> <tr> <td> Alternate ID </td> <td> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="IMAGE" id="_alternate_id_IMAGE_checkbox" onClick="showAltIDTextBox('_alternate_id_IMAGE_checkbox', '_alternate_id_IMAGE_textbox')">IMAGE <INPUT style="display:none" id="_alternate_id_IMAGE_textbox" name="alternate_id_IMAGE_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="RIKEN" id="_alternate_id_RIKEN_checkbox" onClick="showAltIDTextBox('_alternate_id_RIKEN_checkbox', '_alternate_id_RIKEN_textbox')">RIKEN <INPUT style="display:none" id="_alternate_id_RIKEN_textbox" name="alternate_id_RIKEN_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="Kazusa" id="_alternate_id_Kazusa_checkbox" onClick="showAltIDTextBox('_alternate_id_Kazusa_checkbox', '_alternate_id_Kazusa_textbox')">Kazusa <INPUT style="display:none" id="_alternate_id_Kazusa_textbox" name="alternate_id_Kazusa_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="LIFESEQ" id="_alternate_id_LIFESEQ_checkbox" onClick="showAltIDTextBox('_alternate_id_LIFESEQ_checkbox', '_alternate_id_LIFESEQ_textbox')">LIFESEQ <INPUT style="display:none" id="_alternate_id_LIFESEQ_textbox" name="alternate_id_LIFESEQ_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="RZPD" id="_alternate_id_RZPD_checkbox" onClick="showAltIDTextBox('_alternate_id_RZPD_checkbox', '_alternate_id_RZPD_textbox')">RZPD <INPUT style="display:none" id="_alternate_id_RZPD_textbox" name="alternate_id_RZPD_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="HIP" id="_alternate_id_HIP_checkbox" onClick="showAltIDTextBox('_alternate_id_HIP_checkbox', '_alternate_id_HIP_textbox')">HIP <INPUT style="display:none" id="_alternate_id_HIP_textbox" name="alternate_id_HIP_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="ADDGENE" id="_alternate_id_ADDGENE_checkbox" onClick="showAltIDTextBox('_alternate_id_ADDGENE_checkbox', '_alternate_id_ADDGENE_textbox')">ADDGENE <INPUT style="display:none" id="_alternate_id_ADDGENE_textbox" name="alternate_id_ADDGENE_textbox_name" size="15"></INPUT><br> <input type="checkbox" name="INPUT_INSERT_info_alternate_id_prop[]" value="PMID" id="_alternate_id_PMID_checkbox" onClick="showAltIDTextBox('_alternate_id_PMID_checkbox', '_alternate_id_PMID_textbox')">PMID <INPUT style="display:none" id="_alternate_id_PMID_textbox" name="alternate_id_PMID_textbox_name" size="15"></INPUT><br> <input type="checkbox" id="_other_Alt_ID_chkbx" name="INPUT_INSERT_info_alternate_id_prop[]" value="Other" onClick="showSpecificOtherCheckbox('_alternate_id_txt')">Other: <INPUT style="display:none" id="_alternate_id_txt" name="alternate_id_name_txt" size="15"></INPUT> </td> <td> Indicates any other ID's that identify the insert, including but not limited to IMAGE, Kazusa, RIKEN, and other. <BR><BR><BR><BR>For 'Other', please enter the source name and ID separated by a semicolon (e.g. IMAGE:123456) </td> </tr> <tr> <td> Entrez Gene ID </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_gene_id_prop\" value=\"" + geneID + "\">" content += ''' </td> <td> The NCBI Gene ID to which the sequence maps. </td> </tr> <tr> <td> Ensembl Gene ID </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_ensembl_gene_id_prop\" value=\"" + ensemblID + "\">" content += ''' </td> <td> The Ensembl Gene ID to which the sequence maps. </td> </tr> <tr> <td> Official Gene Symbol </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_gene_symbol_prop\" value=\"" + geneSymbol + "\">" content += ''' </td> <td> The official gene symbol for this Insert. </td> </tr> <tr> <td> 5' Start </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_5_prime_start_prop\" value=\"" + fp_start + "\">" content += ''' </td> <td> Users can map the start of the sequence onto its accession number by indicating at what nucleotide position on the accession number that the sequence starts. </td> </tr> <tr> <td> 3' Stop </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_3_prime_stop_prop\" value=\"" + tp_stop + "\">" content += ''' </td> <td> Users can map the stop of the sequence onto its accession number by indicating at what nucleotide position on the accession number that the sequence stops </td> </tr> <tr> <td> 5' Linker </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_5_prime_linker_prop\" value=\"" + fwd_linker + "\">" content += ''' </td> <td> Indicates any sequence added to the 5' end of an insert that does not map to a cDNA sequence but should be included as part of the insert - eg kozak sequences, any nucleotides added to maintain frame. </td> </tr> <tr> <td> 3' Linker </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_3_prime_linker_prop\" value=\"" + rev_linker + "\">" content += ''' </td> <td> Indicates any sequence added to the 3' end of an insert that does not map to a cDNA sequence but should be included as part of the insert - eg any nucleotides added to maintain frame. </td> </tr> <tr> <td> Functional Description </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_description_prop\" value=\"" + funcDescr + "\">" content += ''' </td> <td> Describes the purpose of the reagent and any information that may be key to working with the reagent. </td> </tr> <tr> <td> Verification </td> <td> <select size="1" name="INPUT_INSERT_info_verification_prop"> ''' # default option content += "<OPTION VALUE=\"\" " if len(verification) == 0: content += "SELECTED></OPTION>" else: content += "></OPTION>" for v in verificationList: content += "<OPTION VALUE=\"" + v + "\"" if v == verification: content += " SELECTED>" + v + "</OPTION>" else: content += ">" + v + "</OPTION>" content += ''' </select> </td> <td> Indicates if the reagent has been verified and how. Users select from a pre-defined list. </td> </tr> <tr> <td> Verification comments </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_verification_comments_prop\" value=\"" + verComm + "\">" content += ''' </td> <td> Allows user to provide a description of the verification status - eg comments on sequence changes, expression levels. </td> </tr> <tr> <td> Experimental comments </td> <td> ''' content += "<INPUT type=\"text\" name=\"INPUT_INSERT_info_comments_prop\" value=\"" + expComm + "\">" content += ''' </td> <td> Used to describe any information that descrbes how the reagent works in the experimental context - eg low expression, difficult to grow, etc. </td> </tr> <tr> <td> Sequence </td> <td> </td> <td> The sequence of the insert that corresponds to a cDNA or fragment of interest. Does include artificial start and stop codons. Does not include linker sequences as described above. </td> </tr> <tr> <td colspan="3"> <textarea rows="10" cols="93" id="dna_sequence" name="INPUT_INSERT_info_sequence_prop"> ''' content += sequence content += ''' </textarea> </td> </tr> ''' content += self.printParents('Insert', allAssoc) content += ''' <tr> <td colspan="3"> <hr><br> <input type="submit" name="create_reagent" value="Create" onclick="document.pressed = this.value"> </td> </tr> </table> </form> </div> ''' # Common to all content += gOut.printFooter() page_content = content % (hostname + "cgi/create.py") print "Content-type:text/html" # THIS IS PERMANENT; DO NOT REMOVE print # DITTO print page_content