示例#1
0
def rMap_full(f_in, f_out):

    # Database connection parameters
    dbConn = DatabaseConn()
    db = dbConn.databaseConnect()
    cursor = db.cursor()

    gHandler = GeneralHandler(db, cursor)
    rHandler = ReagentHandler(db, cursor)
    seqHandler = SequenceHandler(db, cursor)

    infile = open(f_in, 'r')
    outfile = open(f_out, 'w')

    for line in infile.readlines():
        reagentID = line.strip()  # e.g. V123

        rID = rHandler.convertReagentToDatabaseID(reagentID)
        seqID = rHandler.findDNASequenceKey(rID)

        if seqID:
            mySeq = seqHandler.findSequenceByID(seqID)

            # Construct a Seq object readable by BioPython:
            bioSeq = Seq(mySeq)
            fSeq = FormattedSeq(bioSeq)  # default linear = TRUE

            analysis = Analysis(AllEnzymes, fSeq)  # linear = true
            result = analysis.full()
            header = "==============================================\nRestriction analysis for " + reagentID + "\n==============================================\n"
            analysis.print_that(title=header + '\n\n')
示例#2
0
def rMap_full(f_in, f_out):
	
	# Database connection parameters
	dbConn = DatabaseConn()
	db = dbConn.databaseConnect()
	cursor = db.cursor()

	gHandler = GeneralHandler(db, cursor)
	rHandler = ReagentHandler(db, cursor)
	seqHandler = SequenceHandler(db, cursor)

	infile = open(f_in, 'r')
	outfile = open(f_out, 'w')
	
	for line in infile.readlines():
		reagentID = line.strip()	# e.g. V123
		
		rID = rHandler.convertReagentToDatabaseID(reagentID)
		seqID = rHandler.findDNASequenceKey(rID)
		
		if seqID:
			mySeq = seqHandler.findSequenceByID(seqID)

                	# Construct a Seq object readable by BioPython:
			bioSeq = Seq(mySeq)
			fSeq = FormattedSeq(bioSeq)             # default linear = TRUE

			analysis = Analysis(AllEnzymes, fSeq)   # linear = true
			result = analysis.full()
			header = "==============================================\nRestriction analysis for " + reagentID + "\n==============================================\n"
			analysis.print_that(title=header+'\n\n')
示例#3
0
    def __init__(self):

        dbConn = DatabaseConn()
        db = dbConn.databaseConnect()
        cursor = db.cursor()
        hostname = dbConn.getHostname()

        self.__db = db
        self.__cursor = cursor
        self.__hostname = hostname
	def __init__(self):
	
		dbConn = DatabaseConn()
		db = dbConn.databaseConnect()
		cursor = db.cursor()
		hostname = dbConn.getHostname()

		self.__db = db
		self.__cursor = cursor
		self.__hostname = hostname
示例#5
0
def add_members():

    dbConn = DatabaseConn()

    db = dbConn.databaseConnect()
    cursor = db.cursor()
    hostname = dbConn.getHostname()

    form = cgi.FieldStorage(keep_blank_values="True")

    pHandler = PacketHandler(db, cursor)

    #print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
    #print					# DITTO
    #print `form`

    # Get form values
    projectID = form.getvalue("packets")
    projectMembers = form.getlist("projectMembers")

    pHandler.insertProjectMembers(projectID, projectMembers)

    redirect(hostname)
def add_members():

	dbConn = DatabaseConn()
	
	db = dbConn.databaseConnect()
	cursor = db.cursor()
	hostname = dbConn.getHostname()
		
	form = cgi.FieldStorage(keep_blank_values="True")
	
	pHandler = PacketHandler(db, cursor)
	
	#print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
	#print					# DITTO
	#print `form`

	# Get form values
	projectID = form.getvalue("packets")
	projectMembers = form.getlist("projectMembers")
	
	pHandler.insertProjectMembers(projectID, projectMembers)
		
	redirect(hostname)
示例#7
0
def preview():
	dbConn = DatabaseConn()
	db = dbConn.databaseConnect()
	
	cursor = db.cursor()
	hostname = dbConn.getHostname()

	rHandler = ReagentHandler(db, cursor)
	propMapper = ReagentPropertyMapper(db, cursor)
	
	prop_Alias_ID_Map = propMapper.mapPropAliasID()
	
	form = cgi.FieldStorage(keep_blank_values="True")

	#print "Content-type:text/html"		# REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
	#print					# DITTO
	#print `form`
	
	propVal = ""
	
	if form.has_key("PV"):
		pvVal = form.getvalue("PV")
		pvID = rHandler.convertReagentToDatabaseID(pvVal)
		
	if form.has_key("propAlias"):
		propAlias = form.getvalue("propAlias")
	
	
	if prop_Alias_ID_Map.has_key(propAlias):
		propID = prop_Alias_ID_Map[propAlias]	
		propVal = rHandler.findSimplePropertyValue(pvID, propID)
		
	
	print "Content-type:text/html"		# REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
	print					# DITTO
	print propVal
    def __init__(self):

        dbConn = DatabaseConn()
        db = dbConn.databaseConnect()
        cursor = db.cursor()
        hostname = dbConn.getHostname()
        clone_request = dbConn.getMailCloneRequest()

        mail_programmer = dbConn.getProgrammerEmail()
        mail_biologist = dbConn.getBiologistEmail()
        mail_admin = dbConn.getAdminEmail()  # August 19, 2011

        mail_server = dbConn.getMailServer()  # August 19, 2011

        self.__db = db
        self.__cursor = cursor
        self.__hostname = hostname
        self.__clone_request = clone_request
        self.__mail_programmer = mail_programmer  # July 30, 2010
        self.__mail_biologist = mail_biologist  # July 30, 2010
        self.__mail_admin = mail_admin  # August 19, 2011
        self.__mail_server = mail_server  # August 19, 2011
    def __init__(self):

        dbConn = DatabaseConn()
        db = dbConn.databaseConnect()
        cursor = db.cursor()
        hostname = dbConn.getHostname()
        clone_request = dbConn.getMailCloneRequest()

        mail_programmer = dbConn.getProgrammerEmail()
        mail_biologist = dbConn.getBiologistEmail()
        mail_admin = dbConn.getAdminEmail()  # August 19, 2011

        mail_server = dbConn.getMailServer()  # August 19, 2011

        self.__db = db
        self.__cursor = cursor
        self.__hostname = hostname
        self.__clone_request = clone_request
        self.__mail_programmer = mail_programmer  # July 30, 2010
        self.__mail_biologist = mail_biologist  # July 30, 2010
        self.__mail_admin = mail_admin  # August 19, 2011
        self.__mail_server = mail_server  # August 19, 2011
示例#10
0
	def printProjectInfo(self, cmd, project):
		
		dbConn = DatabaseConn()
		hostname = dbConn.getHostname()		# to define form action URL
		
		db = dbConn.databaseConnect()
		cursor = db.cursor()
		
		uHandler = UserHandler(db, cursor)
		lHandler = LabHandler(db, cursor)

		gOut = GeneralOutputClass()

		currUser = Session.getUser()

		if cmd == 'view':

			projectID = project.getNumber()
			projectOwner = project.getOwner()
			ownerName = projectOwner.getFullName()
			ownerID = projectOwner.getUserID()
			projectName = project.getName()
			projectDescr = project.getDescription()
			
			# private or public
			isPrivate = project.isPrivate()
			
			if isPrivate:
				accessType = 'Private'
			else:
				accessType = 'Public'
			
			# Only allow modification by owner or admin AND disallow project deletion if there are reagents in it!!!
			modify_disabled = True
			delete_disabled = True
			
			if (currUser.getUserID() == ownerID) or (currUser.getCategory() == 'Admin'):
				modify_disabled = False

			if project.isEmpty():
				delete_disabled = False

			# Aug. 18/08: Changed b/c of new format
			#content = gOut.printHeader() + gOut.printMainMenu()
			content = gOut.printHeader()
			
			content += '''
				<FORM name="project_form" method="POST" action="%s">
			
					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="username_hidden" NAME="username"'''
					
			content += "value=\"" + currUser.getFullName() + "\">"
			
			content += '''
					<TABLE height="100%%">
						<TABLE width="770px" cellpadding="5px" cellspacing="5px" class="detailedView_tbl">
							<TR>
								<TD class="detailedView_heading" style="white-space:nowrap;">
									PROJECT DETAILS PAGE
								</TD>
								
								<TD class="detailedView_heading" style="text-align:right">
									'''
			content += "<INPUT TYPE=\"submit\" name=\"modify_project\" value=\"Modify Project\""
			
			if modify_disabled:
				content += " disabled>"
			else:
				content += ">"
							
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:2px;\" name=\"delete_project\" value=\"Delete Project\" onClick=\"return confirmDeleteProject();\""
			
			if modify_disabled or delete_disabled:
				content += " disabled>"
			else:
				content += ">"
				
			content += '''
								</TD>
	
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project #
								</TD>
	
								<TD class="detailedView_value" width="87%%">
									%d
									<INPUT TYPE="hidden" name="packetID" value="%d">
								</TD>
	
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Owner:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="packetOwner" value="%d">
								</TD>
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Name:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="packetName" value="%s">
								</TD>
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Description:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="packetDescription" value="%s">
								</TD>
							</TR>
							
							<TR>
								<TD class="projectDetailedViewName">
									Access type:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="private_or_public" value="%s">
								</TD>
							</TR>
							
							<TR>
								<TD colspan="2">
									<HR/>
								</TD>
							</TR>
							
							'''
						
			# Now here, show or hide members section depending on the user's access level
			# Condition is the same as for determining whether modification is allowed - so use 'modify_disabled' variable
			if not modify_disabled:
				content += '''
							<TR>
								<TD class="projectDetailedViewName">
									Project Members:
								</TD>
								
								<TD>&nbsp;</TD>
							</TR>
							
							<TR>
								<TD class="detailedView_value" colspan="2">
									<TABLE width="100%%">
										<TR>
											<TD style="font-weight:bold; padding-left:10px" width="30%%">
												Readers:
											</TD>
	
											<TD style="font-weight:bold; padding-left:10px">
												Writers:
											</TD>
										</TR>
	
										<TR>
											<TD class="detailedView_value" style="vertical-align:top">
												<UL>
												'''
			
				if not isPrivate:
					content += "All OpenFreezer Users"
				else:
					# maintain the indent
					readers = project.getReaders()
					
					# sort by labs
					labs = []
					rdrLabs = {}
	
					# First, iterate over readers list to extract all the labs
					for rdr in readers:
						lab = rdr.getLab().getID()
	
						if lab not in labs:
							labs.append(lab)
	
					# Now iterate over the list of labs and link its readers to it
					for lab in labs:
						tmpRdrs = []		# list of members in one lab
	
						for rdr in readers:
							tmpLab = rdr.getLab().getID()
	
							if tmpLab == lab:
								# append reader to list of members of this lab
								if rdrLabs.has_key(lab):
									tmpRdrs = rdrLabs[lab]
	
								tmpRdrs.append(rdr)
								rdrLabs[lab] = tmpRdrs
	
					#for rdr in readers:
					for lab_id in rdrLabs.keys():
						rdrs = rdrLabs[lab_id]		# list of objects!!
						tmp_lab_name = lHandler.findLabName(lab_id)
	
						# print out the lab name
						
						if currUser.getCategory() == 'Admin':
							content += "<span class=\"linkShow\" style=\"color:#2E8B57\" onClick=\"goToLabViewFromProject(" + `lab_id` + ");\">" + tmp_lab_name + "</span><BR/>"
						else:
							content += "<span style=\"color:#2E8B57\">" + tmp_lab_name + "</span><BR/>"
	
						# print reader names
						for rdr in rdrs:
							content += "<INPUT TYPE=\"hidden\" name=\"projectReaders\" value=\"" + `rdr.getUserID()` + "\"></INPUT>"
							
							# Only show hyperlinks if the viewer is an Admin; otherwise just output plain names
							if currUser.getCategory() == 'Admin':
								content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;<span class=\"linkShow\" onClick=\"redirectToUserFromProject(" + `rdr.getUserID()` + ");\">" + rdr.getFullName() + "</span></LI>"
							else:
								content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;" + rdr.getFullName() + "</LI>"
											
				content += '''			
											</UL>
										</TD>


										<TD class="detailedView_value" style="width:250px; vertical-align:top">
											<UL>
											'''
				writers = project.getWriters()
				
				# sort them by lab too, same as for readers
				labs = []
				wrtrLabs = {}

				# First, iterate over readers list to extract all the labs
				for wrtr in writers:
					lab = wrtr.getLab().getID()

					if lab not in labs:
						labs.append(lab)

				# Now iterate over the list of labs and link its readers to it
				for lab in labs:
					tmpWrtrs = []		# list of members in one lab

					for wrtr in writers:
						tmpLab = wrtr.getLab().getID()

						if tmpLab == lab:
							# append reader to list of members of this lab
							if wrtrLabs.has_key(lab):
								tmpWrtrs = wrtrLabs[lab]

							tmpWrtrs.append(wrtr)
							wrtrLabs[lab] = tmpWrtrs


				for lab_id in wrtrLabs.keys():
					wrtrs = wrtrLabs[lab_id]		# list of objects!!
					tmp_lab_name = lHandler.findLabName(lab_id)

					# print out the lab name
					if currUser.getCategory() == 'Admin':
						content += "<span class=\"linkShow\" style=\"color:#2E8B57\" onClick=\"goToLabViewFromProject(" + `lab_id` + ");\">" + tmp_lab_name + "</span><BR/>"
					else:
						content += "<span style=\"color:#2E8B57\" " + `lab_id` + ");\">" + tmp_lab_name + "</span><BR/>"

					for wrtr in wrtrs:
	
						content += "<INPUT TYPE=\"hidden\" name=\"projectWriters\" value=\"" + `wrtr.getUserID()` + "\">"
						
						if currUser.getCategory() == 'Admin':
							content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;<span class=\"linkShow\" onClick=\"redirectToUserFromProject(" + `wrtr.getUserID()` + ");\">" + wrtr.getFullName() + "</span></LI>"
						else:
							content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;" + wrtr.getFullName() + "</LI>"
							
				content += '''
											</UL>
										</TD>
									</TR>
								</TABLE>
							</TD>	
						</TR>
					</TABLE>
				</FORM>
				
				<FORM id="viewUserForm" method="POST" action="%s">
					<INPUT type="hidden" id="view_user_hidden" name="view_user">
					<INPUT type="hidden" ID="curr_userid_hidden" NAME="curr_user_id" value="%d">
				</FORM>
				
				<FORM id="viewLabForm" method="POST" action="%s">
					<INPUT type="hidden" ID="curr_userid_hidden" NAME="curr_user_id" value="%d">
					<INPUT type="hidden" id="view_lab_hidden" name="view_lab">
				</FORM>
				</TABLE>
				'''
				
				content += gOut.printFooter()
				
			else:
				content += '''
					</TABLE>
				</FORM>
				</TABLE>
				'''
				
				content += gOut.printFooter()

			# and here, depending on what sections of the project view were printed, the number of arguments would vary
			if not modify_disabled:
				page_content = content % (hostname + "cgi/project_request_handler.py", projectID, projectID, ownerName, ownerID, projectName, projectName, projectDescr, projectDescr, accessType, accessType, hostname + "cgi/user_request_handler.py", currUser.getUserID(), hostname + "cgi/user_request_handler.py", currUser.getUserID())
			else:
				page_content = content % (hostname + "cgi/project_request_handler.py", projectID, projectID, ownerName, ownerID, projectName, projectName, projectDescr, projectDescr, accessType, accessType)

			print "Content-type:text/html"		# THIS IS PERMANENT; DO NOT REMOVE
			print					# DITTO
			print page_content

		elif cmd == 'edit':
				
			projectID = project.getNumber()
			projectOwner = project.getOwner()
			ownerName = projectOwner.getFullName()
			ownerID = projectOwner.getUserID()
			projectName = project.getName()
			projectDescr = project.getDescription()
			isPrivate = project.isPrivate()
			
			content = gOut.printHeader()
			#content += gOut.printMainMenu()
			
			content += '''
				<FORM name="project_form" method="POST" action="%s">

					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="username_hidden" NAME="username"'''
			content += "value=\"" + currUser.getFullName() + "\">"

			content += '''
					<TABLE width="770px" 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">MODIFY PROJECT </span>
							<span style="color:#FF0000; font-weight:bold">%d</span>
							
							<INPUT TYPE="hidden" name="packetID" value="%d">
							
							<INPUT TYPE="submit" style="margin-left:200px;" name="save_project" value="Save" onClick=\"alert('Please note: If your project writers list contains names of users who have read-only access to OpenFreezer, their names will be removed from the list during saving.'); addProjectOwnerToWritersList(); selectAllElements('readers_target_list'); selectAllElements('writers_target_list'); return verifyProjectOwner('projectOwnersList') && verifyProjectName('packet_name') && verifyProjectDescr('packet_descr') && verifyMembers('readers_target_list') && verifyMembers('writers_target_list');\">
							
							<INPUT TYPE="submit" style="margin-left:20px;" name="cancel_project" value="Cancel">
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Owner:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<SELECT ID="projectOwnersList" name="packetOwner">
							'''

			# Get list of all potential project owners - users with 'CREATOR' or higher privileges
			# Returns list of User **objects**
			creators = uHandler.findAllMembersInCategory('Creator', False, '<=')
			creatorsDict = {}	# name, uid
			
			for creator in creators:
				uid = creator.getUserID()
				name = creator.getFullName()
				creatorsDict[name] = uid
				
			names = creatorsDict.keys()
			names.sort()
			
			#print "Content-type:text/html"
			#print
			
			for name in names:
				#print name
				uid = creatorsDict[name]
				#print uid
				#print ownerID

				if uid == ownerID:
					content += "<OPTION SELECTED value=" + `uid` + ">" + name + "</OPTION>"
				else:
					content += "<OPTION value=" + `uid` + ">" + name + "</OPTION>"
							
			content += '''
							</SELECT>
							
							<DIV ID="projectOwnerWarning" STYLE="display:none; color:#FF0000; font-weight:normal;">
								<BR>Please select a name from the list above.
							</DIV>
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Name:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" id="packet_name" name="packetName" value="%s">
							
							<DIV ID="projectNameWarning" STYLE="display:none; color:#FF0000; font-weight:normal;">
								<BR>Please provide a project name.
							</DIV>
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Description:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" id="packet_descr" name="packetDescription" value="%s">
							
							<DIV ID="projectDescrWarning" STYLE="display:none; color:#FF0000; font-weight:normal;">
								<BR>Please provide a project description.
							</DIV>
						</TD>
					</TR>
					
					
					<TR>
						<TD class="projectDetailedViewName">
							Access type:
						</TD>

						<TD class="detailedView_value" style="width:400px">
						'''
			if not isPrivate:
				content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"public\" checked>Public&nbsp;&nbsp;&nbsp;&nbsp;"
				content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"private\">Private"
			else:
				content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"public\">Public&nbsp;&nbsp;&nbsp;&nbsp;"
				content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"private\" checked>Private"
				
			content += '''
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Members:
						</TD>

						<TD class="detailedView_value" colspan="2">
							&nbsp;
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Edit existing project members lists:
						</TD>
					</TR>

					<TR>
						<TD style="width:100px">
							<SELECT multiple size="10" id="readers_target_list" name="readersList">
						'''
			# Readers and writers associated with this project
			currReaders = project.getReaders()
			currWriters = project.getWriters()
	
			# Since object comparison is done by reference, cannot check if a User object returned by findAllMembers is a member of this project by using 'in array'.  Need to compare user IDs explicitly
			currReaderIDs = []
			currWriterIDs = []

			currReaderNames = []
			currWriterNames = []

			currReadersDict = {}	# name, id
			currWritersDict = {}

			# need lab IDs too - to match members to their labs when moved between lists, but having a 'memberID, labID' dictionary is too clumsy.  Easiest approach: have 'memberID, Member Object' dictionary
			currReaderObjDict = {}	# id, User object
			currWriterObjDict = {}

			for r in currReaders:
				rID = r.getUserID()
				rName = r.getFullName()
				
				# associate rID with its containing object 
				currReaderObjDict[rID] = r
				
				currReaderIDs.append(rID)
				currReaderNames.append(rName)
				currReadersDict[rName] = rID


			for w in currWriters:
				wID = w.getUserID()
				wName = w.getFullName()
				
				currWriterObjDict[wID] = w

				currWriterIDs.append(wID)
				currWriterNames.append(wName)
				currWritersDict[wName] = wID

			currReaderNames.sort()
			currWriterNames.sort()
			
			for rName in currReaderNames:
				rID = currReadersDict[rName]
				rdr = currReaderObjDict[rID]
				rdrLabID = rdr.getLab().getID()
				
				#content += "<OPTION id=" + `rID` + " value=" + `rID` + ">" + rName + "</OPTION>"
				
				# June 28/07: Include labID in the option id 
				content += "<OPTION id=\"user_" + `rID` + "_lab_" + `rdrLabID` + "\" value=" + `rID` + ">" + rName + "</OPTION>"

			content += '''
							</SELECT>
							<BR/>
							<INPUT TYPE="checkbox" style="margin-top:10px" onClick="selectAll(this.id, 'readers_target_list')" id="select_all_reader_chkbx"> Select All</INPUT>
						</TD>

						<TD width="30px">
							<input onclick="addMembers('readers_target_list', 'write')" value="   Make Writer >>" type="button"></INPUT><BR/>
							<input style="margin-top:10px;" onclick="addMembers('writers_target_list', 'read')" value="<< Make Reader" type="button"></INPUT><BR/>
							<input style="margin-top:10px;" onclick="removeProjectMembers()" value="Remove Selected" type="button"></INPUT>
						</TD>

						<TD>
							<SELECT multiple size="10" id="writers_target_list" name="writersList">
						'''
			for wName in currWriterNames:
				wID = currWritersDict[wName]
				wrtr = currWriterObjDict[wID]
				wrtrLabID = wrtr.getLab().getID()
				
				#content += "<OPTION id=" + `wID` + " value=" + `wID` + ">" + wName + "</OPTION>"
				
				# June 28/07: Include labID in the option id 
				content += "<OPTION id=\"user_" + `wID` + "_lab_" + `wrtrLabID` + "\" value=" + `wID` + ">" + wName + "</OPTION>"

			content += '''
							</SELECT>
							
							<BR/>
							<INPUT style="margin-top:10px;" TYPE="checkbox" onClick="selectAll(this.id, 'writers_target_list')" id="select_all_writer_chkbx"> Select All</INPUT>
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Add new members to this project:
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Laboratory:&nbsp;&nbsp;&nbsp;&nbsp;
			
							<SELECT id="labList" name="labs" onChange="showLabMembersList()">
							'''
			# fetch lab list - Updated August 90/7: Fetch ALL labs, with any access - then if a read-only lab has members with higher access, would show these members in list
			#labs = lHandler.findAllLabs('Writer', '<=')
			labs = lHandler.findAllLabs()
			
			# sort lab names alphabetically
			labNames = []
			labsDict = {}	# name, id
			
			for labID in labs.keys():
				labName = labs[labID]
				labNames.append(labName)
				labsDict[labName] = labID
			
			labNames.sort()
			
			currLab = projectOwner.getLab()
			currLabID = currLab.getID()
			
			#for labID in labs.keys():
			for labName in labNames:
				#labName = labs[labID]
				labID = labsDict[labName]
				
				if labID == currLabID:
					content += "<OPTION SELECTED id='" + `labID` + "' NAME='lab_optn' value=" + `labName` + ">" + labName + "</OPTION>"
				else:
					content += "<OPTION id='" + `labID` + "' NAME='lab_optn' value=" + `labName` + ">" + labName + "</OPTION>"

			content += '''
							</SELECT>
						</TD>
					</TR>
					
					<TR>
						<TD width="100px">
							'''
							
			# For each lab, print a list of its members
			for labID in labs.keys():
	
				# First, fetch a list of users 
				# These are **User instances** - need to get their names and IDs for comparison
				
				# August 9/07: Don't fetch only writers, fetch readers too - it's up to the project owner to grant them access to the project
				#writers = uHandler.findAllMembersInCategory('Writer', True, '<=', labID)
				writers = uHandler.findAllMembersInCategory('Reader', True, '<=', labID)
				writersDict = {}	# name, uid
				writersObjDict = {}	# id, User object
				
				# Fetch user IDs and sort their names alphabetically
				for writer in writers:
					name = writer.getFullName()
					uid = writer.getUserID()
					labID = (writer.getLab()).getID()
					writersDict[name] = uid
					writersObjDict[uid] = writer
					
				names = writersDict.keys()
				names.sort()

				# Show members for one lab at a time
				if labID == currLabID:
					display = "inline"
				else:
					display = "none"
				
				content += "<SELECT MULTIPLE id=\"lab_source_list_" + `labID` + "\" name=\"labSourceMembers_" + `labID` + "\" SIZE=\"10\" style=\"display:" + display + "\">"

				for name in names:
					uid = writersDict[name]
					labID = writersObjDict[uid].getLab().getID()
					
					if uid not in currReaderIDs and uid not in currWriterIDs:
						#content += "<OPTION value=" + `uid` + ">" + name + "</OPTION>"
						content += "<OPTION id=\"user_" + `uid` + "_lab_" + `labID` + "\" value=" + `uid` + ">" + name + "</OPTION>"
				
				content += "</SELECT>"
				
			content += '''
							<BR/>
							<INPUT TYPE="checkbox" style="margin-top:8px" onClick="selectAll(this.id, 'lab_source_list_' + getSelectedLab())" id="add_all_chkbx"> Select All Members</INPUT>
						</TD>

						<TD colspan="2" style="vertical-align:top">
							Add selected members to:
							
							<P style="font-size:9pt; margin-top:5px;">
								<input type="radio" id="access_level_radio_read" name="access_levels" value="read" checked>Readers list</INPUT><BR/> 
								<input type="radio" id="access_level_radio_write" name="access_levels" value="write">Writers list</INPUT><BR/>
								<input style="margin-top:8px" onclick="addMembers('lab_source_list_' + getSelectedLab(), getSelectedRole('1'))" value="Go" type="button"></INPUT>
								<BR/>
							</P>

						</TD>
					</TR>
				</TABLE>
			</FORM>
			'''
				
			content += gOut.printFooter()
		
			page_content = content % (hostname + "cgi/project_request_handler.py", project.getNumber(),  project.getNumber(), project.getName(), project.getDescription())		

			print "Content-type:text/html"		# THIS IS PERMANENT; DO NOT REMOVE
			print					# DITTO
			print page_content
示例#11
0
    def printSubmenuHeader(self, submenu_type):

        dbConn = DatabaseConn()
        hostname = dbConn.getHostname()  # to define form action URL

        db = dbConn.databaseConnect()
        cursor = db.cursor()

        uHandler = UserHandler(db, cursor)

        current_selection_names = []  # plain list of section names
        current_selection_links = {}  # dictionary, where section names are keys and their URLs are values

        if submenu_type == "Location":

            location_submenu_names = []
            location_submenu_links = {}

            location_submenu_names.append("Add container types")
            location_submenu_links["Add container types"] = "../Location.php?View=6&Sub=3"

            location_submenu_names.append("Add container sizes")
            location_submenu_links["Add container sizes"] = "../Location.php?View=6&Sub=1"

            location_submenu_names.append("Add containers")
            location_submenu_links["Add containers"] = "../Location.php?View=6&Sub=3"

            location_submenu_names.append("Search containers")
            location_submenu_links["Search containers"] = "../Location.php?View=2"

            current_selection_names = location_submenu_names
            current_selection_links = location_submenu_links

        elif submenu_type == "Reagent":

            reagent_submenu_names = []
            reagent_submenu_links = {}

            reagent_submenu_names.append("Add reagents")
            reagent_submenu_links["Add reagents"] = "../Reagent.php?View=2"

            reagent_submenu_names.append("Search reagents")
            reagent_submenu_links["Search reagents"] = "../search.php?View=1"

            # June 3/09
            reagent_submenu_names.append("Add reagent types")
            reagent_submenu_links["Add reagent types"] = "../Reagent.php?View=3"

            reagent_submenu_names.append("Search reagent types")
            reagent_submenu_links["Search reagent types"] = "../Reagent.php?View=5"

            current_selection_names = reagent_submenu_names
            current_selection_links = reagent_submenu_links

        elif submenu_type == "Chemical":

            chemical_submenu_names = []
            chemical_submenu_links = {}

            chemical_submenu_names.append("Add Chemicals")
            chemical_submenu_links["Add Chemicals"] = "../Chemical.php?View=2"

            chemical_submenu_names.append("Search Chemicals")
            chemical_submenu_links["Search Chemicals"] = "../Chemical.php?View=1"

            current_selection_names = chemical_submenu_names
            current_selection_links = chemical_submenu_links

        elif submenu_type == "Prediction":

            prediction_submenu_names = []
            prediction_submenu_links = {}

            prediction_submenu_names.append("Search predictions")
            prediction_submenu_links["Search predictions"] = "../Prediction.php?View=1"

            current_selection_names = prediction_submenu_names
            current_selection_links = prediction_submenu_links

        elif submenu_type == "Project":

            project_submenu_names = []
            project_submenu_links = {}

            project_submenu_names.append("Add projects")
            project_submenu_links["Add projects"] = "../Project.php?View=1"

            project_submenu_names.append("Search projects")
            project_submenu_links["Search projects"] = "../Project.php?View=2"

            current_selection_names = project_submenu_names
            current_selection_links = project_submenu_links

        elif submenu_type == "User":

            user_submenu_names = []
            user_submenu_links = {}

            user_submenu_names.append("Add users")
            user_submenu_links["Add users"] = "../User.php?View=1"

            user_submenu_names.append("Search users")
            user_submenu_links["Search users"] = "../User.php?View=2"

            user_submenu_names.append("Change your password")
            user_submenu_links["Change your password"] = "******"

            user_submenu_names.append("Personal page")
            user_submenu_links["Personal page"] = "User.php?View=7"

            user_submenu_names.append("View your orders")
            user_submenu_links["View your orders"] = "../User.php?View=8"

            current_selection_names = user_submenu_names
            current_selection_links = user_submenu_links

        elif submenu_type == "Lab":

            lab_submenu_names = []
            lab_submenu_links = {}

            lab_submenu_names.append("Add laboratories")
            lab_submenu_links["Add laboratories"] = "../User.php?View=3"

            lab_submenu_names.append("Search laboratories")
            lab_submenu_links["Search laboratories"] = "../User.php?View=4"

            current_selection_names = lab_submenu_names
            current_selection_links = lab_submenu_links

            # There can be permission differentiations within a menu section as well (e.g. Projects - only Creators can create, buit Writers can view)
        currUser = Session.getUser()

        ucMapper = UserCategoryMapper(db, cursor)
        category_Name_ID_Map = ucMapper.mapCategoryNameToID()

        currUserCategory = category_Name_ID_Map[currUser.getCategory()]
        allowedSections = uHandler.getAllowedSections(currUserCategory)

        # print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
        # print					# DITTO
        # print `allowedSections`

        content = ""

        for name in current_selection_names:

            if name in allowedSections:

                if name == "Personal page":
                    content += '<LI class="submenu">'

                    content += '<IMG SRC="../pictures/star_bullet.gif" WIDTH="10" HEIGHT="10" BORDER="0" ALT="plus" class="menu-leaf">'

                    content += (
                        '<span class="linkShow" style="font-size:9pt" onClick="redirectToCurrentUserDetailedView('
                        + ` currUser.getUserID() `
                        + ');">'
                        + name
                        + "</span>"
                    )

                    content += "</LI>"

                    content += '<form name="curr_user_form" style="display:none" method="post" action="user_request_handler.py">'

                    content += (
                        '<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username" VALUE="'
                        + currUser.getFullName()
                        + '">'
                    )

                    content += '<INPUT type="hidden" id="curr_user_hidden" name="view_user">'
                    content += "</FORM>"
                else:
                    content += '<LI class="submenu">'

                    content += '<IMG SRC="../pictures/star_bullet.gif" WIDTH="10" HEIGHT="10" BORDER="0" ALT="plus" class="menu-leaf">'

                    content += '<a class="submenu" href="' + current_selection_links[name] + '">' + name + "</a>"
                    content += "</LI>"

        return content
示例#12
0
def drawMap():

    dbConn = DatabaseConn()
    db = dbConn.databaseConnect()

    cursor = db.cursor()
    hostname = dbConn.getHostname()
    root_path = dbConn.getRootDir()

    form = cgi.FieldStorage(keep_blank_values="True")

    #print "Content-type:text/html"
    #print
    #print `form`

    if form.has_key("rID"):
        rID = form.getvalue("rID")
    else:
        #rID = 148913	# V4550
        rID = 29125
        #rID = 72
        #rID = 309
        #rID = 1901	# small feature labels @ start of seq. overlap
        #rID = 36415
        #print rID

    reagentID = rHandler.convertDatabaseToReagentID(rID)

    #print "Content-type:text/html"
    #print
    #print reagentID

    namePropID = pHandler.findReagentPropertyInCategoryID(
        prop_Name_ID_Map["name"],
        prop_Category_Name_ID_Map["General Properties"])

    rName = rHandler.findSimplePropertyValue(rID, namePropID)
    #rName = rHandler.findSimplePropertyValue(rID, prop_Name_ID_Map["name"])
    rTypeID = rHandler.findReagentTypeID(rID)

    try:
        os.remove(root_path + "Reagent/vector_maps/" + reagentID + "_map.pdf")
    except OSError:
        pass

    #print root_path

    c = Canvas(root_path + "Reagent/vector_maps/" + reagentID + "_map.pdf")

    c.setPageSize((1000, 1000))
    c.setStrokeColorRGB(0, 0, 0)
    c.saveState()

    # Draw circle
    origin = 0
    origin_x = 500
    origin_y = 470
    radius = 200

    c.circle(origin_x, origin_y, radius)
    c.restoreState()

    # Divide circle into 100-unit sectors
    rSeqID = rHandler.findDNASequenceKey(rID)
    rSeq = sHandler.findSequenceByID(rSeqID)
    seqLen = len(rSeq)

    #print "Content-type:text/html"
    #print
    #print `rID`

    unit_angle_measure = float(360) / float(seqLen)
    #print unit_angle_measure

    # Mark 1 on the circle - KEEP, Karen said!
    c.setLineWidth(1)
    c.setStrokeColor(black)
    c.setFillColor(black)
    c.saveState()

    path = c.beginPath()
    path.moveTo(origin_x, origin_y + radius + 7)
    path.lineTo(origin_x - 5, origin_y + radius + 14)
    path.lineTo(origin_x + 5, origin_y + radius + 14)
    path.lineTo(origin_x, origin_y + radius + 7)
    c.drawPath(path, True, True)

    # label 1
    t = c.beginText()
    t.setStrokeColor(black)
    t.setFillColor(black)
    t.setFont("Helvetica-Bold", 16)
    t.setTextOrigin(origin_x - 5, origin_y + radius + 19)
    t.textOut("1")
    c.drawText(t)

    c.restoreState()

    # Calculate feature segment sizes
    sequenceFeatures = rHandler.findReagentSequenceFeatures(rID)
    #print `sequenceFeatures`

    # Draw legend
    ox_legend = 800
    oy_legend = 985

    prev_legend = oy_legend

    # draw frame
    c.setStrokeColor(darkgray)
    #c.setStrokeColor(white)
    #c.setFillColor(lightgrey)
    c.setFillColor(white)
    c.saveState()

    # Output the rest of the features in alphabetical order - Moved here Jan. 26/10
    #featureNames = featureNameColorMap.keys()

    #print `featureNameColorMap.keys()`
    #print len(featureNameColorMap.keys())

    #fnames = rtPropHandler.findReagentTypeAttributeNamesByCategory(rTypeID, prop_Category_Name_ID_Map["DNA Sequence Features"])
    #fnames.remove('expression system')
    #fnames.remove('tag position')

    #print `fnames`
    #print len(fnames)

    featureNames = rtPropHandler.findReagentTypeAttributeNamesByCategory(
        rTypeID, prop_Category_Name_ID_Map["DNA Sequence Features"])
    featureNames.sort()

    #print `featureNames`
    #print prev_legend-240
    #print prev_legend-15-len(featureNames)*15

    #c.rect(ox_legend-25, prev_legend-240, 215, 235, 1, 1)
    #c.rect(ox_legend-25, prev_legend-15-len(featureNames)*15, 215, 10+len(featureNames)*15, 1, 1)	# good for list of all db features

    if len(featureNames) > 15:
        origin_spacer = -19
        coeff = 12
    else:
        origin_spacer = 65
        coeff = 15

    #origin_legend = prev_legend+65-len(featureNames)*15
    origin_legend = prev_legend + origin_spacer - len(featureNames) * coeff

    x = (990 - origin_legend) / len(featureNames)
    #print x

    if x < 12:
        x = 12

    legend_height = len(featureNames) * x + 15
    #print legend_height

    c.rect(ox_legend - 25, origin_legend - 17, 215, legend_height, 1,
           1)  # good for specific rtype attributes

    c.restoreState()

    # Order: 5' site, 3' site, 5' linker, 3' linker, then the rest
    sites_color = featureNameColorMap["5' cloning site"]  # same for 3' site

    # 5' site
    c.setStrokeColor(sites_color)
    c.setFillColor(sites_color)
    c.saveState()
    c.rect(ox_legend - 15, prev_legend - 20, 25, 8, 1, 1)
    c.restoreState

    t = c.beginText()
    #t.setStrokeColor(black)
    t.setStrokeColor(sites_color)
    #t.setFillColor(black)
    t.setFillColor(sites_color)
    t.setFont("Helvetica-Bold", 10)
    t.setTextOrigin(ox_legend + 12, prev_legend - 20)
    t.textOut(" - " + "5' CLONING SITE")
    c.drawText(t)
    c.restoreState

    prev_legend = prev_legend - 15

    # 3' site
    c.setStrokeColor(sites_color)
    c.setFillColor(sites_color)
    c.saveState()
    c.rect(ox_legend - 15, prev_legend - 20, 25, 8, 1, 1)
    c.restoreState

    t = c.beginText()
    #t.setStrokeColor(black)
    #t.setFillColor(black)

    t.setStrokeColor(sites_color)
    t.setFillColor(sites_color)

    t.setFont("Helvetica-Bold", 10)
    t.setTextOrigin(ox_legend + 12, prev_legend - 20)
    t.textOut(" - " + "3' CLONING SITE")
    c.drawText(t)
    c.restoreState

    prev_legend = prev_legend - 15

    # Show legend for linkers
    linkers_color = featureNameColorMap["5' linker"]

    # 5' linker
    c.setStrokeColor(linkers_color)
    c.setFillColor(linkers_color)
    c.saveState()
    c.rect(ox_legend - 15, prev_legend - 20, 25, 8, 1, 1)
    c.restoreState

    t = c.beginText()
    #t.setStrokeColor(black)
    #t.setFillColor(black)

    t.setStrokeColor(linkers_color)
    t.setFillColor(linkers_color)

    t.setFont("Helvetica-Bold", 10)
    t.setTextOrigin(ox_legend + 12, prev_legend - 20)
    t.textOut(" - " + "5' LINKER")
    c.drawText(t)
    c.restoreState

    prev_legend = prev_legend - 15

    # 3' linker
    c.setStrokeColor(linkers_color)
    c.setFillColor(linkers_color)
    c.saveState()
    c.rect(ox_legend - 15, prev_legend - 20, 25, 8, 1, 1)
    c.restoreState

    t = c.beginText()
    #t.setStrokeColor(black)
    #t.setFillColor(black)

    t.setStrokeColor(linkers_color)
    t.setFillColor(linkers_color)

    t.setFont("Helvetica-Bold", 10)
    t.setTextOrigin(ox_legend + 12, prev_legend - 20)
    t.textOut(" - " + "3' LINKER")
    c.drawText(t)
    c.restoreState

    prev_legend = prev_legend - 15

    ## Output the rest of the features in alphabetical order
    #featureNames = featureNameColorMap.keys()
    #featureNames.sort()

    #print `featureNames`

    for featureName in featureNames:
        if featureNameColorMap.has_key(featureName):
            color = featureNameColorMap[featureName]
            #else:
            #continue

            if featureName != "5' cloning site" and featureName != "3' cloning site" and featureName != "5' linker" and featureName != "3' linker" and color != None:
                #print featureName
                c.setStrokeColor(color)
                c.setFillColor(color)
                c.saveState()
                c.rect(ox_legend - 15, prev_legend - 20, 25, 8, 1, 1)
                c.restoreState

                t = c.beginText()

                #t.setStrokeColor(black)
                #t.setFillColor(black)

                t.setStrokeColor(color)
                t.setFillColor(color)

                t.setFont("Helvetica-Bold", 10)
                t.setTextOrigin(ox_legend + 12, prev_legend - 20)
                t.textOut(" - " + featureName.upper())
                c.drawText(t)

                c.restoreState

                prev_legend = prev_legend - 15
    #print prev_legend

    # Print reagent ID and size at the centre of the circle and print name at the top of the page
    c.setFont("Helvetica-Bold", 32)
    c.setFillColor(black)
    c.saveState()

    c.drawCentredString(origin_x, origin_y + 35, reagentID)
    c.drawCentredString(origin_x, origin_y + 10, "nt 1 - " + ` seqLen `)

    if rName:
        c.setFillColor(blue)
        c.drawCentredString(origin_x, 935, rName)

    c.restoreState()

    # SORT features by size, so that short features are not hidden behind the long ones
    fSizes = []
    sortedFeatures = []

    for feature in sequenceFeatures:
        fSize = int(feature.getFeatureSize())

        if fSize > 0:
            fSizes.append(fSize)

    fSizes.sort(reverse=True)
    #print `fSizes`

    for fs in fSizes:
        for feature in sequenceFeatures:
            fSize = feature.getFeatureSize()

            # added existence check July 17/08 - different features may have same sizes so end up with duplicate features in list (e.g. cloning sizes appeared twice on the map)
            if fs == fSize and feature not in sortedFeatures:
                sortedFeatures.append(feature)

    #print `sortedFeatures`

    ox_labels = 40
    oy_labels = 910
    prev_legend = oy_labels

    t = c.beginText()
    t.setStrokeColor(black)
    t.setFillColor(black)
    t.setFont("Helvetica-Bold", 10)
    t.setTextOrigin(ox_labels, prev_legend - 15)
    t.textOut("Features shorter than 150 nt:")
    c.drawText(t)
    c.restoreState

    prev_legend = prev_legend - 18

    #for feature in sequenceFeatures:
    for feature in sortedFeatures:
        fType = feature.getFeatureType()
        fValue = feature.getFeatureName()
        fSize = feature.getFeatureSize()

        #print fType
        #print fValue
        #print fSize

        fColor = featureNameColorMap[fType]

        if fType == 'cdna insert':
            fValue = "cDNA Insert"

        elif fType == 'promoter':
            fValue = fValue + " " + fType

        fStart = feature.getFeatureStartPos()
        fEnd = feature.getFeatureEndPos()
        fDir = feature.getFeatureDirection()

        if fSize > 0:
            f_start = fStart * unit_angle_measure

            #print "Start " + `fStart`
            #print "End " + `fEnd`

            startAngle = 90 - f_start
            #print "Start angle " + `startAngle`

            f_end = fEnd * unit_angle_measure
            endAngle = 90 - f_end
            #print "End angle " + `endAngle`

            extAngle = -1 * (f_end - f_start)
            #print "Ext angle " + `extAngle`

            x1 = origin_x - radius
            y1 = origin_y - radius

            x2 = origin_x + radius
            y2 = origin_y + radius

            p = c.beginPath()
            #t = c.beginText()

            c.setLineWidth(10)
            c.setLineJoin(1)

            fColor = featureNameColorMap[fType]
            c.setStrokeColor(fColor)
            c.saveState()

            p.arc(x1, y1, x2, y2, startAngle, extAngle)
            c.drawPath(p)
            c.restoreState()

            ## jan. 27/10: this makes a contour for each arc
            #p = c.beginPath()
            #c.setLineWidth(1)

            ##fColor = featureNameColorMap[fType]
            #c.setStrokeColor(black)
            #c.setFillColor(fColor)
            #c.saveState()

            #p.arc(x1+5, y1+5, x2-5, y2-5, startAngle, extAngle)
            #c.drawPath(p)
            ##c.restoreState()

            ##c.setLineWidth(1)

            ##fColor = featureNameColorMap[fType]
            ##c.setStrokeColor(black)
            ##c.setFillColor(fColor)
            ##c.saveState()

            #p.arc(x1-5, y1-5, x2+5, y2+5, startAngle, extAngle)
            #c.drawPath(p)
            #c.restoreState()	# jan. 27/10 modification ends here

            # common to all
            startAngle_rad = (startAngle * math.pi) / 180.0
            endAngle_rad = (endAngle * math.pi) / 180.0

            #c.setStrokeColor(black)
            #c.setFillColor(black)

            c.setStrokeColor(fColor)
            c.setFillColor(fColor)

            c.setFont("Helvetica-Bold", 9)
            c.saveState()

            arc_x_start = origin_x + (radius + 5) * math.cos(startAngle_rad)
            arc_y_start = origin_y + (radius + 5) * math.sin(startAngle_rad)

            arc_x_end = origin_x + (radius + 5) * math.cos(endAngle_rad)
            arc_y_end = origin_y + (radius + 5) * math.sin(endAngle_rad)

            # draw label
            c.setStrokeColorRGB(0, 0, 1)
            c.setFillColorRGB(0, 0, 1)
            c.setFont("Helvetica-Bold", 12)
            c.saveState()

            # draw line
            delta = 45

            # Rotate labels only for SMALL features (they can be crammed together)
            #if fSize > 100:
            #delta = 45
            #else:
            #delta = 32

            if fStart < seqLen / 2:
                if arc_y_start > origin_y:

                    #c.setStrokeColor(black)
                    #c.setFillColor(black)

                    c.setStrokeColor(fColor)
                    c.setFillColor(fColor)

                    c.setLineWidth(1)
                    c.saveState()

                    #if fSize <= 100:
                    #c.line(arc_x_start, arc_y_start, arc_x_start+50*math.fabs(math.sin(delta)), arc_y_start+55*math.fabs(math.cos(delta)))
                    #else:

                    # July 17/08: Show labels for long features only
                    if fSize > 150:
                        c.line(arc_x_start, arc_y_start,
                               arc_x_start + 50 * math.fabs(math.sin(delta)),
                               arc_y_start + 55 * math.fabs(math.cos(delta)))

                    c.restoreState()

                    # July 17/08: Show labels for long features only
                    if fSize > 150:

                        # draw label

                        #c.setStrokeColorRGB(0,0,1)
                        #c.setFillColorRGB(0,0,1)

                        c.setStrokeColor(fColor)
                        c.setFillColor(fColor)

                        c.setFont("Helvetica-Bold", 11)
                        c.saveState()

                        c.drawString(
                            arc_x_start + 50 * math.fabs(math.sin(delta)),
                            arc_y_start + 55 * math.fabs(math.cos(delta)),
                            fValue + " (" + ` fStart ` + "-" + ` fEnd ` + ")")

                    else:
                        c.setStrokeColor(fColor)
                        c.setFillColor(fColor)
                        c.saveState()
                        c.rect(ox_labels + 5, prev_legend - 15, 15, 6, 1, 1)
                        c.restoreState

                        t = c.beginText()
                        #t.setStrokeColor(black)
                        #t.setFillColor(black)

                        t.setStrokeColor(fColor)
                        t.setFillColor(fColor)

                        t.setFont("Helvetica-Bold", 10)
                        t.setTextOrigin(ox_labels + 25, prev_legend - 15)
                        t.textOut(fValue + " (" + ` fStart ` + "-" + ` fEnd ` +
                                  ")")
                        c.drawText(t)
                        c.restoreState
                        prev_legend = prev_legend - 15

                    c.restoreState()

                else:
                    #c.setStrokeColor(black)
                    #c.setFillColor(black)

                    c.setStrokeColor(fColor)
                    c.setFillColor(fColor)

                    c.setLineWidth(1)
                    c.saveState()

                    if fSize > 150:
                        c.line(arc_x_start, arc_y_start,
                               arc_x_start + 50 * math.fabs(math.sin(delta)),
                               arc_y_start - 55 * math.fabs(math.cos(delta)))

                    c.restoreState()

                    # draw label
                    if fSize > 150:

                        #c.setStrokeColorRGB(0,0,1)
                        #c.setFillColorRGB(0,0,1)

                        c.setStrokeColor(fColor)
                        c.setFillColor(fColor)

                        c.setFont("Helvetica-Bold", 11)
                        c.saveState()

                        c.drawString(
                            arc_x_start + 50 * math.fabs(math.sin(delta)),
                            arc_y_start - 55 * math.fabs(math.cos(delta)),
                            fValue + " (" + ` fStart ` + "-" + ` fEnd ` + ")")
                    else:
                        c.setStrokeColor(fColor)
                        c.setFillColor(fColor)
                        c.saveState()
                        c.rect(ox_labels + 5, prev_legend - 15, 15, 6, 1, 1)
                        c.restoreState

                        t = c.beginText()
                        #t.setStrokeColor(black)
                        #t.setFillColor(black)

                        t.setStrokeColor(fColor)
                        t.setFillColor(fColor)

                        t.setFont("Helvetica-Bold", 10)
                        t.setTextOrigin(ox_labels + 25, prev_legend - 15)
                        t.textOut(fValue + " (" + ` fStart ` + "-" + ` fEnd ` +
                                  ")")
                        c.drawText(t)
                        c.restoreState
                        prev_legend = prev_legend - 15

                    c.restoreState()
            else:
                if arc_y_start > origin_y:

                    #c.setStrokeColor(black)
                    #c.setFillColor(black)

                    c.setStrokeColor(fColor)
                    c.setFillColor(fColor)

                    c.setLineWidth(1)
                    c.saveState()

                    if fSize > 150:
                        c.line(arc_x_start, arc_y_start,
                               arc_x_start - 50 * math.fabs(math.sin(delta)),
                               arc_y_start + 55 * math.fabs(math.cos(delta)))

                        #c.line(arc_x_start, arc_y_start, arc_x_start+10*math.fabs(math.sin(delta)), arc_y_start-10*math.fabs(math.cos(delta)))

                    c.restoreState()

                    # draw label
                    if fSize > 150:
                        #c.setStrokeColorRGB(0,0,1)
                        #c.setFillColorRGB(0,0,1)

                        c.setStrokeColor(fColor)
                        c.setFillColor(fColor)

                        c.setFont("Helvetica-Bold", 11)
                        c.saveState()

                        c.drawRightString(
                            arc_x_start - 50 * math.fabs(math.sin(delta)),
                            arc_y_start + 55 * math.fabs(math.cos(delta)),
                            fValue + " (" + ` fStart ` + "-" + ` fEnd ` + ")")
                    else:
                        c.setStrokeColor(fColor)
                        c.setFillColor(fColor)
                        c.saveState()
                        c.rect(ox_labels + 5, prev_legend - 15, 15, 6, 1, 1)
                        c.restoreState

                        t = c.beginText()
                        #t.setStrokeColor(black)
                        #t.setFillColor(black)

                        t.setStrokeColor(fColor)
                        t.setFillColor(fColor)

                        t.setFont("Helvetica-Bold", 10)
                        t.setTextOrigin(ox_labels + 25, prev_legend - 15)
                        t.textOut(fValue + " (" + ` fStart ` + "-" + ` fEnd ` +
                                  ")")
                        c.drawText(t)
                        c.restoreState
                        prev_legend = prev_legend - 15

                    c.restoreState()

                else:
                    #c.setStrokeColor(black)
                    #c.setFillColor(black)

                    c.setStrokeColor(fColor)
                    c.setFillColor(fColor)

                    c.setLineWidth(1)
                    c.saveState()

                    if fSize > 150:
                        c.line(arc_x_start, arc_y_start,
                               arc_x_start - 50 * math.fabs(math.sin(delta)),
                               arc_y_start - 55 * math.fabs(math.cos(delta)))

                    c.restoreState()

                    # draw label
                    if fSize > 150:

                        #c.setStrokeColorRGB(0,0,1)
                        #c.setFillColorRGB(0,0,1)

                        c.setStrokeColor(fColor)
                        c.setFillColor(fColor)

                        c.setFont("Helvetica-Bold", 11)
                        c.saveState()

                        c.drawRightString(
                            arc_x_start - 50 * math.fabs(math.sin(delta)),
                            arc_y_start - 55 * math.fabs(math.cos(delta)),
                            fValue + " (" + ` fStart ` + "-" + ` fEnd ` + ")")

                        c.restoreState()
                    else:
                        c.setStrokeColor(fColor)
                        c.setFillColor(fColor)
                        c.saveState()
                        c.rect(ox_labels + 5, prev_legend - 15, 15, 6, 1, 1)
                        c.restoreState

                        t = c.beginText()
                        #t.setStrokeColor(black)
                        #t.setFillColor(black)

                        t.setStrokeColor(fColor)
                        t.setFillColor(fColor)

                        t.setFont("Helvetica-Bold", 10)
                        t.setTextOrigin(ox_labels + 25, prev_legend - 15)
                        t.textOut(fValue + " (" + ` fStart ` + "-" + ` fEnd ` +
                                  ")")
                        c.drawText(t)
                        c.restoreState
                        prev_legend = prev_legend - 15

    c.showPage()
    c.save()
示例#13
0
def drawMap2():
    dbConn = DatabaseConn()
    db = dbConn.databaseConnect()

    cursor = db.cursor()
    hostname = dbConn.getHostname()

    form = cgi.FieldStorage(keep_blank_values="True")

    #print "Content-type:text/html"
    #print
    #print `form`

    if form.has_key("rID"):
        rID = form.getvalue("rID")
    else:
        #rID = 791
        #print rID
        rID = 154659

    reagentID = rHandler.convertDatabaseToReagentID(rID)

    d = Drawing(1000, 1000)

    origin = 0
    origin_x = 500
    origin_y = 500
    radius = 350

    c = Circle(origin_x, origin_y, radius)

    c.strokeColor = blue
    c.fillColor = white

    d.add(c)

    c.line(origin_x, origin_y + radius - 7, origin_x - 7, origin_y + radius)
    c.line(origin_x - 7, origin_y + radius, origin_x, origin_y + radius + 7)
    c.line(origin_x, origin_y + radius + 7, origin_x + 7, origin_y + radius)
    c.line(origin_x + 7, origin_y + radius, origin_x, origin_y + radius - 7)

    p = c.beginPath()
    c.setFillColor(black)
    c.saveState()
    p.moveTo(origin_x, origin_y + radius - 7)
    p.lineTo(origin_x - 7, origin_y + radius)
    p.lineTo(origin_x, origin_y + radius + 7)
    p.lineTo(origin_x + 7, origin_y + radius)
    p.close()
    c.drawPath(p)
    c.restoreState()

    # Divide circle into 100-unit sectors
    rSeqID = rHandler.findDNASequenceKey(rID)
    rSeq = sHandler.findSequenceByID(rSeqID)
    seqLen = len(rSeq)
    #print seqLen

    unit_angle_measure = float(360) / float(seqLen)

    # Calculate feature segment sizes
    sequenceFeatures = rHandler.findReagentSequenceFeatures(rID)

    for feature in sequenceFeatures:
        fType = feature.getFeatureType()
        fValue = feature.getFeatureName()

        fStart = feature.getFeatureStartPos()
        fEnd = feature.getFeatureEndPos()
        fDir = feature.getFeatureDirection()

        f_start = fStart * unit_angle_measure
        f_end = fEnd * unit_angle_measure

        if fStart > 0 and fEnd > 0:
            print "Start " + ` fStart `
            print "End " + ` fEnd `

            startAngle = 90 - f_start
            extAngle = -1 * (f_end - f_start)

            print "Angle " + ` extAngle `

            x1 = origin_x - radius
            y1 = origin_y - radius

            x2 = origin_x + radius
            y2 = origin_y + radius

            p = ArcPath()
            #p.dumpProperties()

            p.strokeWidth = 15
            p.strokeColor = black
            p.fillColor = red

            #p.addArc(x1, y1, x2, y2, startAngle, extAngle)		# NO

            d.add(p)

            d.add(String(origin_x + fStart, origin_y + fStart, fValue))

    renderPDF.drawToFile(d, "V7066_map.png")
示例#14
0
#!/usr/local/bin/python

import cgi

import utils
from sequence_handler import DNAHandler
from database_conn import DatabaseConn

import Bio
from Bio.Seq import Seq
from Bio.Restriction import *

dbConn = DatabaseConn()
db = dbConn.databaseConnect()
cursor = db.cursor()

dnaHandler = DNAHandler(db, cursor)

form = cgi.FieldStorage()

lims_id = form.getvalue("limsID")  # always exists

print "Content-type: application/octet-stream"
print "Content-Disposition: attachment; filename=" + lims_id + ".txt"
print "Pragma: no-cache"
print "Expires: 0"
#print "Content-type:text/html"
print

# sequence may be empty
if form.has_key("vector_sequence"):
示例#15
0
	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:&nbsp;<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:&nbsp;<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:&nbsp;<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:&nbsp;<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:&nbsp;<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 &nbsp;&nbsp;&nbsp;<BR/>
											<input type="radio" id="access_level_radio_write" name="access_levels" value="write" style="margin-top:5px; font-size:9pt">Write &nbsp;&nbsp;&nbsp;<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; ">&#45; 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;">&#45; 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>&nbsp;</blockquote>
				<blockquote>&nbsp;</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>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</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 += "&nbsp;"
			
			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/>
			
										&nbsp;<input type="button" style="margin-top:30px;" value="Remove" onclick="removeUserProjects();"></INPUT>
									</TD>
									'''
			
			else:
				content += '''
						&nbsp;<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 &nbsp;&nbsp;&nbsp;<BR/>
										<input type="radio" id="access_level_radio_write" name="access_levels" value="write" style="margin-top:5px; font-size:9pt">Write &nbsp;&nbsp;&nbsp;<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>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</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
示例#16
0
    def printProjectInfo(self, cmd, project):

        dbConn = DatabaseConn()
        hostname = dbConn.getHostname()  # to define form action URL

        db = dbConn.databaseConnect()
        cursor = db.cursor()

        uHandler = UserHandler(db, cursor)
        lHandler = LabHandler(db, cursor)

        gOut = GeneralOutputClass()

        currUser = Session.getUser()

        if cmd == 'view':

            projectID = project.getNumber()
            projectOwner = project.getOwner()
            ownerName = projectOwner.getFullName()
            ownerID = projectOwner.getUserID()
            projectName = project.getName()
            projectDescr = project.getDescription()

            # private or public
            isPrivate = project.isPrivate()

            if isPrivate:
                accessType = 'Private'
            else:
                accessType = 'Public'

            # Only allow modification by owner or admin AND disallow project deletion if there are reagents in it!!!
            modify_disabled = True
            delete_disabled = True

            if (currUser.getUserID() == ownerID) or (currUser.getCategory()
                                                     == 'Admin'):
                modify_disabled = False

            if project.isEmpty():
                delete_disabled = False

            # Aug. 18/08: Changed b/c of new format
            #content = gOut.printHeader() + gOut.printMainMenu()
            content = gOut.printHeader()

            content += '''
				<FORM name="project_form" method="POST" action="%s">
			
					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="username_hidden" NAME="username"'''

            content += "value=\"" + currUser.getFullName() + "\">"

            content += '''
					<TABLE height="100%%">
						<TABLE width="770px" cellpadding="5px" cellspacing="5px" class="detailedView_tbl">
							<TR>
								<TD class="detailedView_heading" style="white-space:nowrap;">
									PROJECT DETAILS PAGE
								</TD>
								
								<TD class="detailedView_heading" style="text-align:right">
									'''
            content += "<INPUT TYPE=\"submit\" name=\"modify_project\" value=\"Modify Project\""

            if modify_disabled:
                content += " disabled>"
            else:
                content += ">"

            content += "<INPUT TYPE=\"submit\" style=\"margin-left:2px;\" name=\"delete_project\" value=\"Delete Project\" onClick=\"return confirmDeleteProject();\""

            if modify_disabled or delete_disabled:
                content += " disabled>"
            else:
                content += ">"

            content += '''
								</TD>
	
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project #
								</TD>
	
								<TD class="detailedView_value" width="87%%">
									%d
									<INPUT TYPE="hidden" name="packetID" value="%d">
								</TD>
	
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Owner:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="packetOwner" value="%d">
								</TD>
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Name:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="packetName" value="%s">
								</TD>
							</TR>
	
							<TR>
								<TD class="projectDetailedViewName">
									Project Description:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="packetDescription" value="%s">
								</TD>
							</TR>
							
							<TR>
								<TD class="projectDetailedViewName">
									Access type:
								</TD>
	
								<TD class="detailedView_value">
									%s
									<INPUT TYPE="hidden" name="private_or_public" value="%s">
								</TD>
							</TR>
							
							<TR>
								<TD colspan="2">
									<HR/>
								</TD>
							</TR>
							
							'''

            # Now here, show or hide members section depending on the user's access level
            # Condition is the same as for determining whether modification is allowed - so use 'modify_disabled' variable
            if not modify_disabled:
                content += '''
							<TR>
								<TD class="projectDetailedViewName">
									Project Members:
								</TD>
								
								<TD>&nbsp;</TD>
							</TR>
							
							<TR>
								<TD class="detailedView_value" colspan="2">
									<TABLE width="100%%">
										<TR>
											<TD style="font-weight:bold; padding-left:10px" width="30%%">
												Readers:
											</TD>
	
											<TD style="font-weight:bold; padding-left:10px">
												Writers:
											</TD>
										</TR>
	
										<TR>
											<TD class="detailedView_value" style="vertical-align:top">
												<UL>
												'''

                if not isPrivate:
                    content += "All OpenFreezer Users"
                else:
                    # maintain the indent
                    readers = project.getReaders()

                    # sort by labs
                    labs = []
                    rdrLabs = {}

                    # First, iterate over readers list to extract all the labs
                    for rdr in readers:
                        lab = rdr.getLab().getID()

                        if lab not in labs:
                            labs.append(lab)

                    # Now iterate over the list of labs and link its readers to it
                    for lab in labs:
                        tmpRdrs = []  # list of members in one lab

                        for rdr in readers:
                            tmpLab = rdr.getLab().getID()

                            if tmpLab == lab:
                                # append reader to list of members of this lab
                                if rdrLabs.has_key(lab):
                                    tmpRdrs = rdrLabs[lab]

                                tmpRdrs.append(rdr)
                                rdrLabs[lab] = tmpRdrs

                    #for rdr in readers:
                    for lab_id in rdrLabs.keys():
                        rdrs = rdrLabs[lab_id]  # list of objects!!
                        tmp_lab_name = lHandler.findLabName(lab_id)

                        # print out the lab name

                        if currUser.getCategory() == 'Admin':
                            content += "<span class=\"linkShow\" style=\"color:#2E8B57\" onClick=\"goToLabViewFromProject(" + ` lab_id ` + ");\">" + tmp_lab_name + "</span><BR/>"
                        else:
                            content += "<span style=\"color:#2E8B57\">" + tmp_lab_name + "</span><BR/>"

                        # print reader names
                        for rdr in rdrs:
                            content += "<INPUT TYPE=\"hidden\" name=\"projectReaders\" value=\"" + ` rdr.getUserID(
                            ) ` + "\"></INPUT>"

                            # Only show hyperlinks if the viewer is an Admin; otherwise just output plain names
                            if currUser.getCategory() == 'Admin':
                                content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;<span class=\"linkShow\" onClick=\"redirectToUserFromProject(" + ` rdr.getUserID(
                                ) ` + ");\">" + rdr.getFullName(
                                ) + "</span></LI>"
                            else:
                                content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;" + rdr.getFullName(
                                ) + "</LI>"

                content += '''			
											</UL>
										</TD>


										<TD class="detailedView_value" style="width:250px; vertical-align:top">
											<UL>
											'''
                writers = project.getWriters()

                # sort them by lab too, same as for readers
                labs = []
                wrtrLabs = {}

                # First, iterate over readers list to extract all the labs
                for wrtr in writers:
                    lab = wrtr.getLab().getID()

                    if lab not in labs:
                        labs.append(lab)

                # Now iterate over the list of labs and link its readers to it
                for lab in labs:
                    tmpWrtrs = []  # list of members in one lab

                    for wrtr in writers:
                        tmpLab = wrtr.getLab().getID()

                        if tmpLab == lab:
                            # append reader to list of members of this lab
                            if wrtrLabs.has_key(lab):
                                tmpWrtrs = wrtrLabs[lab]

                            tmpWrtrs.append(wrtr)
                            wrtrLabs[lab] = tmpWrtrs

                for lab_id in wrtrLabs.keys():
                    wrtrs = wrtrLabs[lab_id]  # list of objects!!
                    tmp_lab_name = lHandler.findLabName(lab_id)

                    # print out the lab name
                    if currUser.getCategory() == 'Admin':
                        content += "<span class=\"linkShow\" style=\"color:#2E8B57\" onClick=\"goToLabViewFromProject(" + ` lab_id ` + ");\">" + tmp_lab_name + "</span><BR/>"
                    else:
                        content += "<span style=\"color:#2E8B57\" " + ` lab_id ` + ");\">" + tmp_lab_name + "</span><BR/>"

                    for wrtr in wrtrs:

                        content += "<INPUT TYPE=\"hidden\" name=\"projectWriters\" value=\"" + ` wrtr.getUserID(
                        ) ` + "\">"

                        if currUser.getCategory() == 'Admin':
                            content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;<span class=\"linkShow\" onClick=\"redirectToUserFromProject(" + ` wrtr.getUserID(
                            ) ` + ");\">" + wrtr.getFullName() + "</span></LI>"
                        else:
                            content += "<LI style=\"list-style:none; padding-left:6px;\">&#45;&#45;&nbsp;&nbsp;" + wrtr.getFullName(
                            ) + "</LI>"

                content += '''
											</UL>
										</TD>
									</TR>
								</TABLE>
							</TD>	
						</TR>
					</TABLE>
				</FORM>
				
				<FORM id="viewUserForm" method="POST" action="%s">
					<INPUT type="hidden" id="view_user_hidden" name="view_user">
					<INPUT type="hidden" ID="curr_userid_hidden" NAME="curr_user_id" value="%d">
				</FORM>
				
				<FORM id="viewLabForm" method="POST" action="%s">
					<INPUT type="hidden" ID="curr_userid_hidden" NAME="curr_user_id" value="%d">
					<INPUT type="hidden" id="view_lab_hidden" name="view_lab">
				</FORM>
				</TABLE>
				'''

                content += gOut.printFooter()

            else:
                content += '''
					</TABLE>
				</FORM>
				</TABLE>
				'''

                content += gOut.printFooter()

            # and here, depending on what sections of the project view were printed, the number of arguments would vary
            if not modify_disabled:
                page_content = content % (
                    hostname + "cgi/project_request_handler.py", projectID,
                    projectID, ownerName, ownerID, projectName, projectName,
                    projectDescr, projectDescr, accessType, accessType,
                    hostname + "cgi/user_request_handler.py",
                    currUser.getUserID(), hostname +
                    "cgi/user_request_handler.py", currUser.getUserID())
            else:
                page_content = content % (
                    hostname + "cgi/project_request_handler.py", projectID,
                    projectID, ownerName, ownerID, projectName, projectName,
                    projectDescr, projectDescr, accessType, accessType)

            print "Content-type:text/html"  # THIS IS PERMANENT; DO NOT REMOVE
            print  # DITTO
            print page_content

        elif cmd == 'edit':

            projectID = project.getNumber()
            projectOwner = project.getOwner()
            ownerName = projectOwner.getFullName()
            ownerID = projectOwner.getUserID()
            projectName = project.getName()
            projectDescr = project.getDescription()
            isPrivate = project.isPrivate()

            content = gOut.printHeader()
            #content += gOut.printMainMenu()

            content += '''
				<FORM name="project_form" method="POST" action="%s">

					<!-- pass current user as hidden form field -->
					<INPUT type="hidden" ID="username_hidden" NAME="username"'''
            content += "value=\"" + currUser.getFullName() + "\">"

            content += '''
					<TABLE width="770px" 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">MODIFY PROJECT </span>
							<span style="color:#FF0000; font-weight:bold">%d</span>
							
							<INPUT TYPE="hidden" name="packetID" value="%d">
							
							<INPUT TYPE="submit" style="margin-left:200px;" name="save_project" value="Save" onClick=\"alert('Please note: If your project writers list contains names of users who have read-only access to OpenFreezer, their names will be removed from the list during saving.'); addProjectOwnerToWritersList(); selectAllElements('readers_target_list'); selectAllElements('writers_target_list'); return verifyProjectOwner('projectOwnersList') && verifyProjectName('packet_name') && verifyProjectDescr('packet_descr') && verifyMembers('readers_target_list') && verifyMembers('writers_target_list');\">
							
							<INPUT TYPE="submit" style="margin-left:20px;" name="cancel_project" value="Cancel">
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Owner:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<SELECT ID="projectOwnersList" name="packetOwner">
							'''

            # Get list of all potential project owners - users with 'CREATOR' or higher privileges
            # Returns list of User **objects**
            creators = uHandler.findAllMembersInCategory(
                'Creator', False, '<=')
            creatorsDict = {}  # name, uid

            for creator in creators:
                uid = creator.getUserID()
                name = creator.getFullName()
                creatorsDict[name] = uid

            names = creatorsDict.keys()
            names.sort()

            #print "Content-type:text/html"
            #print

            for name in names:
                #print name
                uid = creatorsDict[name]
                #print uid
                #print ownerID

                if uid == ownerID:
                    content += "<OPTION SELECTED value=" + ` uid ` + ">" + name + "</OPTION>"
                else:
                    content += "<OPTION value=" + ` uid ` + ">" + name + "</OPTION>"

            content += '''
							</SELECT>
							
							<DIV ID="projectOwnerWarning" STYLE="display:none; color:#FF0000; font-weight:normal;">
								<BR>Please select a name from the list above.
							</DIV>
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Name:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" id="packet_name" name="packetName" value="%s">
							
							<DIV ID="projectNameWarning" STYLE="display:none; color:#FF0000; font-weight:normal;">
								<BR>Please provide a project name.
							</DIV>
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Description:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" id="packet_descr" name="packetDescription" value="%s">
							
							<DIV ID="projectDescrWarning" STYLE="display:none; color:#FF0000; font-weight:normal;">
								<BR>Please provide a project description.
							</DIV>
						</TD>
					</TR>
					
					
					<TR>
						<TD class="projectDetailedViewName">
							Access type:
						</TD>

						<TD class="detailedView_value" style="width:400px">
						'''
            if not isPrivate:
                content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"public\" checked>Public&nbsp;&nbsp;&nbsp;&nbsp;"
                content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"private\">Private"
            else:
                content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"public\">Public&nbsp;&nbsp;&nbsp;&nbsp;"
                content += "<INPUT TYPE=\"RADIO\" NAME=\"private_or_public\" VALUE=\"private\" checked>Private"

            content += '''
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Project Members:
						</TD>

						<TD class="detailedView_value" colspan="2">
							&nbsp;
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Edit existing project members lists:
						</TD>
					</TR>

					<TR>
						<TD style="width:100px">
							<SELECT multiple size="10" id="readers_target_list" name="readersList">
						'''
            # Readers and writers associated with this project
            currReaders = project.getReaders()
            currWriters = project.getWriters()

            # Since object comparison is done by reference, cannot check if a User object returned by findAllMembers is a member of this project by using 'in array'.  Need to compare user IDs explicitly
            currReaderIDs = []
            currWriterIDs = []

            currReaderNames = []
            currWriterNames = []

            currReadersDict = {}  # name, id
            currWritersDict = {}

            # need lab IDs too - to match members to their labs when moved between lists, but having a 'memberID, labID' dictionary is too clumsy.  Easiest approach: have 'memberID, Member Object' dictionary
            currReaderObjDict = {}  # id, User object
            currWriterObjDict = {}

            for r in currReaders:
                rID = r.getUserID()
                rName = r.getFullName()

                # associate rID with its containing object
                currReaderObjDict[rID] = r

                currReaderIDs.append(rID)
                currReaderNames.append(rName)
                currReadersDict[rName] = rID

            for w in currWriters:
                wID = w.getUserID()
                wName = w.getFullName()

                currWriterObjDict[wID] = w

                currWriterIDs.append(wID)
                currWriterNames.append(wName)
                currWritersDict[wName] = wID

            currReaderNames.sort()
            currWriterNames.sort()

            for rName in currReaderNames:
                rID = currReadersDict[rName]
                rdr = currReaderObjDict[rID]
                rdrLabID = rdr.getLab().getID()

                #content += "<OPTION id=" + `rID` + " value=" + `rID` + ">" + rName + "</OPTION>"

                # June 28/07: Include labID in the option id
                content += "<OPTION id=\"user_" + ` rID ` + "_lab_" + ` rdrLabID ` + "\" value=" + ` rID ` + ">" + rName + "</OPTION>"

            content += '''
							</SELECT>
							<BR/>
							<INPUT TYPE="checkbox" style="margin-top:10px" onClick="selectAll(this.id, 'readers_target_list')" id="select_all_reader_chkbx"> Select All</INPUT>
						</TD>

						<TD width="30px">
							<input onclick="addMembers('readers_target_list', 'write')" value="   Make Writer >>" type="button"></INPUT><BR/>
							<input style="margin-top:10px;" onclick="addMembers('writers_target_list', 'read')" value="<< Make Reader" type="button"></INPUT><BR/>
							<input style="margin-top:10px;" onclick="removeProjectMembers()" value="Remove Selected" type="button"></INPUT>
						</TD>

						<TD>
							<SELECT multiple size="10" id="writers_target_list" name="writersList">
						'''
            for wName in currWriterNames:
                wID = currWritersDict[wName]
                wrtr = currWriterObjDict[wID]
                wrtrLabID = wrtr.getLab().getID()

                #content += "<OPTION id=" + `wID` + " value=" + `wID` + ">" + wName + "</OPTION>"

                # June 28/07: Include labID in the option id
                content += "<OPTION id=\"user_" + ` wID ` + "_lab_" + ` wrtrLabID ` + "\" value=" + ` wID ` + ">" + wName + "</OPTION>"

            content += '''
							</SELECT>
							
							<BR/>
							<INPUT style="margin-top:10px;" TYPE="checkbox" onClick="selectAll(this.id, 'writers_target_list')" id="select_all_writer_chkbx"> Select All</INPUT>
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Add new members to this project:
						</TD>
					</TR>
					
					<TR>
						<TD class="detailedView_value" colspan="3">
							Laboratory:&nbsp;&nbsp;&nbsp;&nbsp;
			
							<SELECT id="labList" name="labs" onChange="showLabMembersList()">
							'''
            # fetch lab list - Updated August 90/7: Fetch ALL labs, with any access - then if a read-only lab has members with higher access, would show these members in list
            #labs = lHandler.findAllLabs('Writer', '<=')
            labs = lHandler.findAllLabs()

            # sort lab names alphabetically
            labNames = []
            labsDict = {}  # name, id

            for labID in labs.keys():
                labName = labs[labID]
                labNames.append(labName)
                labsDict[labName] = labID

            labNames.sort()

            currLab = projectOwner.getLab()
            currLabID = currLab.getID()

            #for labID in labs.keys():
            for labName in labNames:
                #labName = labs[labID]
                labID = labsDict[labName]

                if labID == currLabID:
                    content += "<OPTION SELECTED id='" + ` labID ` + "' NAME='lab_optn' value=" + ` labName ` + ">" + labName + "</OPTION>"
                else:
                    content += "<OPTION id='" + ` labID ` + "' NAME='lab_optn' value=" + ` labName ` + ">" + labName + "</OPTION>"

            content += '''
							</SELECT>
						</TD>
					</TR>
					
					<TR>
						<TD width="100px">
							'''

            # For each lab, print a list of its members
            for labID in labs.keys():

                # First, fetch a list of users
                # These are **User instances** - need to get their names and IDs for comparison

                # August 9/07: Don't fetch only writers, fetch readers too - it's up to the project owner to grant them access to the project
                #writers = uHandler.findAllMembersInCategory('Writer', True, '<=', labID)
                writers = uHandler.findAllMembersInCategory(
                    'Reader', True, '<=', labID)
                writersDict = {}  # name, uid
                writersObjDict = {}  # id, User object

                # Fetch user IDs and sort their names alphabetically
                for writer in writers:
                    name = writer.getFullName()
                    uid = writer.getUserID()
                    labID = (writer.getLab()).getID()
                    writersDict[name] = uid
                    writersObjDict[uid] = writer

                names = writersDict.keys()
                names.sort()

                # Show members for one lab at a time
                if labID == currLabID:
                    display = "inline"
                else:
                    display = "none"

                content += "<SELECT MULTIPLE id=\"lab_source_list_" + ` labID ` + "\" name=\"labSourceMembers_" + ` labID ` + "\" SIZE=\"10\" style=\"display:" + display + "\">"

                for name in names:
                    uid = writersDict[name]
                    labID = writersObjDict[uid].getLab().getID()

                    if uid not in currReaderIDs and uid not in currWriterIDs:
                        #content += "<OPTION value=" + `uid` + ">" + name + "</OPTION>"
                        content += "<OPTION id=\"user_" + ` uid ` + "_lab_" + ` labID ` + "\" value=" + ` uid ` + ">" + name + "</OPTION>"

                content += "</SELECT>"

            content += '''
							<BR/>
							<INPUT TYPE="checkbox" style="margin-top:8px" onClick="selectAll(this.id, 'lab_source_list_' + getSelectedLab())" id="add_all_chkbx"> Select All Members</INPUT>
						</TD>

						<TD colspan="2" style="vertical-align:top">
							Add selected members to:
							
							<P style="font-size:9pt; margin-top:5px;">
								<input type="radio" id="access_level_radio_read" name="access_levels" value="read" checked>Readers list</INPUT><BR/> 
								<input type="radio" id="access_level_radio_write" name="access_levels" value="write">Writers list</INPUT><BR/>
								<input style="margin-top:8px" onclick="addMembers('lab_source_list_' + getSelectedLab(), getSelectedRole('1'))" value="Go" type="button"></INPUT>
								<BR/>
							</P>

						</TD>
					</TR>
				</TABLE>
			</FORM>
			'''

            content += gOut.printFooter()

            page_content = content % (
                hostname + "cgi/project_request_handler.py",
                project.getNumber(), project.getNumber(), project.getName(),
                project.getDescription())

            print "Content-type:text/html"  # THIS IS PERMANENT; DO NOT REMOVE
            print  # DITTO
            print page_content
示例#17
0
def rMap_specific(f_in, f_out, enz_list):

    # Database connection parameters
    dbConn = DatabaseConn()
    db = dbConn.databaseConnect()
    cursor = db.cursor()

    gHandler = GeneralHandler(db, cursor)
    rHandler = ReagentHandler(db, cursor)
    seqHandler = SequenceHandler(db, cursor)

    infile = open(f_in, 'r')
    outfile = open(f_out, 'w')

    for line in infile.readlines():
        reagentID = line.strip()  # e.g. V123
        rID = rHandler.convertReagentToDatabaseID(reagentID)
        seqID = rHandler.findDNASequenceKey(rID)

        if seqID:
            mySeq = seqHandler.findSequenceByID(seqID)

            # Construct a Seq object readable by BioPython:
            bioSeq = Seq(mySeq)
            fSeq = FormattedSeq(
                bioSeq,
                linear=False)  # linear = FALSE, we're dealing w/ VECTORS

            analysis = Analysis(
                enz_list, fSeq,
                linear=False)  # linear = FALSE again for VECTORS
            result = analysis.full()

            outfile.write(reagentID + ": " + '\n')

            # calculate bandwidths
            allSites = []

            for enz in result.keys():
                sites = result[enz]

                if len(allSites) == 0:
                    allSites = sites
                else:
                    # concatenate
                    for s in sites:
                        allSites.append(s)

            allSites.sort()

            if len(allSites) > 0:

                # calculate distances between sites
                bandSizes = []

                i = 1

                while i < len(allSites):
                    tmpLen = allSites[i] - allSites[i - 1]
                    bandSizes.append(tmpLen)
                    i += 1

                # last band
                tmpLen = len(mySeq) - allSites[i - 1] + allSites[0]
                bandSizes.append(tmpLen)

                bandSizes.sort()

                outfile.write( ` bandSizes ` + '\n')

            outfile.write('\n')

    infile.close()
    outfile.close()
    cursor.close()
    db.close()
示例#18
0
	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">
										&nbsp;&nbsp;&nbsp;&nbsp;Type of Insert&nbsp;&nbsp;
										<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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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:&nbsp;<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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;Sequence
									</td>
					
									<td>
										&nbsp;
									</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>
										&nbsp;&nbsp;&nbsp;&nbsp;<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
示例#19
0
    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">
										&nbsp;&nbsp;&nbsp;&nbsp;Type of Insert&nbsp;&nbsp;
										<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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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 &nbsp;<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:&nbsp;<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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;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>
										&nbsp;&nbsp;&nbsp;&nbsp;Sequence
									</td>
					
									<td>
										&nbsp;
									</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>
										&nbsp;&nbsp;&nbsp;&nbsp;<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
示例#20
0
	def printMainMenu(self):

		dbConn = DatabaseConn()
		hostname = dbConn.getHostname()		# to define form action URL
		
		db = dbConn.databaseConnect()
		cursor = db.cursor()

		uHandler = UserHandler(db, cursor)
		
		# Aug. 20, 2010
		pageMapper = SystemModuleMapper(db, cursor)
		
		pageLinkMap = pageMapper.mapPageNameLink()
		
		# Array of section names
		currentSectionNames = []

		# Dictionary of links to names, with names as dictionary keys and links as values
		currentSectionLinks = {}

		# Added Nov. 10/06 by Marina - Classify each header as to what OF section it belongs
    		menuTypes = {}

		# June 04/07 - Differentiate between 'public' and 'private' pages
		publicSectionNames = []
    		publicSectionLinks = []

		publicSections = {}
		
		# Feb. 2, 2010: change menu layout (reflect HeaderFunctions.php code changes Jan. 12/10)
		submenu_links = {}
		submenu_types = {}
		menuitems = {}
		
		# Home
		currentSectionNames.append("Home")
		currentSectionLinks["Home"] = "../index.php"
		publicSections["Home"] = "index.php"

		# Reagent
		currentSectionNames.append("Reagent Tracker")
		currentSectionLinks["Reagent Tracker"] = "../Reagent.php?View=1"
		
		menuTypes["Reagent Tracker"] = "Reagent"
		publicSections["Reagent Tracker"] = "../Reagent.php?View=1"
		
		# Feb. 2, 2010
		tmp_list = []
		tmp_list.append("Reagents")
		tmp_list.append("Reagent Types")
		
		submenu_types["Reagent Tracker"] = tmp_list
		
		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		tmp_order_list[1] = "Search"
		tmp_order_list[2] = "Statistics"

		submenu_order = {}
		submenu_order["Reagents"] = tmp_order_list

		tmp_list = {}
		tmp_list["Add"] = "../Reagent.php?View=2"
		tmp_list["Search"] = "../search.php?View=1"
		tmp_list["Statistics"] = "../Reagent.php?View=4"
		
		submenu_links["Reagents"] = tmp_list
		
		tmp_list = {}
		tmp_list["Add"] = "Add reagents"
		tmp_list["Search"] = "Search reagents"
		tmp_list["Statistics"] = "Statistics"
	
		menuitems["Reagents"] = tmp_list
	
		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		tmp_order_list[1] = "Search"
	
		submenu_order["Reagent Types"] = tmp_order_list

		tmp_list = {}
		tmp_list["Add"] = "../Reagent.php?View=3"
		tmp_list["Search"] = "../Reagent.php?View=5"
		submenu_links["Reagent Types"] = tmp_list
		
		tmp_list = {}
		tmp_list["Add"] = "Add reagent types"
		tmp_list["Search"] = "Search reagent types"
		menuitems["Reagent Types"] = tmp_list
		
		# Locations
		currentSectionNames.append("Location Tracker")
		currentSectionLinks["Location Tracker"] = "../Location.php?View=1"
		
		menuTypes["Location Tracker"] = "Location"
		publicSections["Location Tracker"] = "../Location.php?View=1"

		# Feb. 2/10
		tmp_list = []
		tmp_list.append("Containers")
		tmp_list.append("Container Sizes")
		tmp_list.append("Container Types")
		submenu_types["Location Tracker"] = tmp_list
		
		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		tmp_order_list[1] = "Search"
	
		submenu_order["Container Types"] = tmp_order_list
	
		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		#tmp_order_list[1] = "Search"
	
		submenu_order["Container Sizes"] = tmp_order_list
	
		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		tmp_order_list[1] = "Search"
	
		submenu_order["Containers"] = tmp_order_list
	
		tmp_list = {}
		tmp_list["Add"] = "../Location.php?View=6&Sub=2"
		tmp_list["Search"] = "../Location.php?View=6&Sub=4"
		submenu_links["Container Types"] = tmp_list
	
		tmp_list = {}
		tmp_list["Add"] = "Add container types"
		tmp_list["Search"] = "Search container types"
		menuitems["Container Types"] = tmp_list
		
		tmp_list = {}
		tmp_list["Add"] = "../Location.php?View=6&Sub=1"
		tmp_list["Search"] = "../Location.php?View=6&Sub=5"
		submenu_links["Container Sizes"] = tmp_list
	
		tmp_list = {}
		tmp_list["Add"] = "Add container sizes"
		#tmp_list["Search"] = "Search container sizes"
		menuitems["Container Sizes"] = tmp_list
		
		tmp_list = {}
		tmp_list["Add"] = "../Location.php?View=6&Sub=3"
		tmp_list["Search"] = "../Location.php?View=2"
		submenu_links["Containers"] = tmp_list
		
		tmp_list = {}
		tmp_list["Add"] = "Add containers"
		tmp_list["Search"] = "Search containers"
		menuitems["Containers"] = tmp_list
		
		# Projects
		currentSectionNames.append("Project Management")
		currentSectionLinks["Project Management"] = "../Project.php?View=1"
		menuTypes["Project Management"] = "Project"
		
		# Feb. 2/10
		tmp_list = []
		tmp_list.append("Projects")
		submenu_types["Project Management"] = tmp_list

		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		tmp_order_list[1] = "Search"
	
		submenu_order["Projects"] = tmp_order_list
	
		tmp_list = {}
		tmp_list["Add"] = "../Project.php?View=1"
		tmp_list["Search"] = "../Project.php?View=2"
		submenu_links["Projects"] = tmp_list
	
		tmp_list = {}
		tmp_list["Add"] = "Add projects"
		tmp_list["Search"] = "Search projects"
		menuitems["Projects"] = tmp_list

		# Users and Labs
		currentSectionNames.append("User Management")
		currentSectionLinks["User Management"] = "../User.php"
		menuTypes["User Management"] = "User"

		currentSectionNames.append("Lab Management")
		currentSectionLinks["Lab Management"] = "../User.php"
		menuTypes["Lab Management"] = "Laboratories"

		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		tmp_order_list[1] = "Search"
	
		submenu_order["Laboratories"] = tmp_order_list
	
		# Jan. 7/09: Chemicals
		currentSectionNames.append("Chemical Tracker")
		currentSectionLinks["Chemical Tracker"] = "../Chemical.php?View=1"
		menuTypes["Chemical Tracker"] = "Chemical"
		
		# Feb. 2, 2010
		tmp_list = []
		tmp_list.append("Chemicals")
		submenu_types["Chemical Tracker"] = tmp_list
		
		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		tmp_order_list[1] = "Search"
	
		submenu_order["Chemicals"] = tmp_order_list
	
		tmp_list = {}
		tmp_list["Add"] = "../Chemical.php?View=2"
		tmp_list["Search"] = "../Chemical.php?View=1"
		submenu_links["Chemicals"] = tmp_list
		
		tmp_list = {}
		tmp_list["Add"] = "Add Chemicals"
		tmp_list["Search"] = "Search Chemicals"
		menuitems["Chemicals"] = tmp_list

		# Feb. 2/10
		tmp_list = []
		tmp_list.append("Users")
		submenu_types["User Management"] = tmp_list

		tmp_list = {}
		tmp_list["Add"] = "../User.php?View=1"
		tmp_list["Search"] = "../User.php?View=2"
		tmp_list["Change your password"] = "******"
		tmp_list["Personal page"] = "../User.php?View=7"
		tmp_list["View your orders"] = "../User.php?View=8"
		submenu_links["Users"] = tmp_list
	
		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		tmp_order_list[1] = "Search"
		tmp_order_list[2] = "Change your password"
		tmp_order_list[3] = "Personal page"
		tmp_order_list[4] = "View your orders"
		
		submenu_order["Users"] = tmp_order_list
	
		tmp_list = {}
		tmp_list["Add"] = "Add users"
		tmp_list["Search"] = "Search users"
		tmp_list["Change your password"] = "******"
		tmp_list["Personal page"] = "Personal page"
		tmp_list["View your orders"] = "View your orders"
		menuitems["Users"] = tmp_list
		
		tmp_list = []
		tmp_list.append("Laboratories")
		submenu_types["Lab Management"] = tmp_list
		
		tmp_list = {}
		tmp_list["Add"] = "../User.php?View=3"
		tmp_list["Search"] = "../User.php?View=4"
		submenu_links["Laboratories"] = tmp_list
		
		tmp_order_list = {}
		tmp_order_list[0] = "Add"
		tmp_order_list[1] = "Search"
		submenu_order["Laboratories"] = tmp_order_list
		
		tmp_list = {}
		
		tmp_list["Add"] = "Add laboratories"
		tmp_list["Search"] = "Search laboratories"
		menuitems["Laboratories"] = tmp_list

		currentSectionNames.append("Documentation")
		currentSectionLinks["Documentation"] = "../docs.php"
		publicSections["Documentation"] = "docs.php"

 		currentSectionNames.append("Terms and Conditions")
 		currentSectionLinks["Terms and Conditions"] = "../copyright.php"
		publicSections["Terms and Conditions"] = "copyright.php"

		currentSectionNames.append("Help and Support")
 		currentSectionLinks["Help and Support"] = "../bugreport.php"
		publicSections["Help and Support"] = "bugreport.php"

 		currentSectionNames.append("Contact Us")
 		currentSectionLinks["Contact Us"] = "../contacts.php"
		publicSections["Contact Us"] = "contacts.php"
		
		# Aug. 20/10: Quick links
		
		tmp_ql = []
		quickLinks = {}

		tmp_ql.append("Add reagents")
		tmp_ql.append("Search reagents")

		quickLinks["Reagent Tracker"] = tmp_ql
		
		tmp_ql = []
		
		tmp_ql.append("Add containers")
		tmp_ql.append("Search containers")
	
		quickLinks["Location Tracker"] = tmp_ql
		
		tmp_ql = []
		
		tmp_ql.append("Add projects")
		tmp_ql.append("Search projects")
		
		quickLinks["Project Management"] = tmp_ql
		
		tmp_ql = []
		
		tmp_ql.append("Change your password")
		tmp_ql.append("View your orders")
		
		quickLinks["User Management"] = tmp_ql
		
		content = '''
			<div class="sidemenu" ID="mainMenu">
				<div class="menu-content">
					<ul class="menulist">
						<!-- menu goes here -->
						'''
		
		# Output the menu link IFF the user is authorized to access that page
		currUser = Session.getUser()

		if currUser:
			ucMapper = UserCategoryMapper(db, cursor)
			category_Name_ID_Map = ucMapper.mapCategoryNameToID()
			currUserCategory = category_Name_ID_Map[currUser.getCategory()]
			
			#print "Content-type:text/html"
			#print
			allowedSections = uHandler.getAllowedSections(currUserCategory)
			#print `allowedSections`
			
			for name in currentSectionNames:
				
				if name in allowedSections:
					
					# added Jan. 7/09
					if name in menuTypes:
						#print "Content-type:text/html"
						#print
						#print name
						
						content += "<DIV style=\"border-top:3px double #FFF8DC; border-right:6px double #FFF8DC; border-bottom:3px double #FFF8DC; border-left:6px double #FFF8DC; margin-top:2px; width:162px; padding-top:5px; padding-bottom:0;\">"
						
						content += "<DIV style=\"background-image:url('../pictures/small_bg.png'); width:166px; height:30px;\">"
						
						content += "<select style=\"cursor:pointer; width:150px; background:#FFF8DC; font-weight:bold; color:#555; font-size:9pt; margin-top:3px; margin-left:2px;  font-family:Helvetica; border:0;\" onChange=\"openPage(this.options[this.options.selectedIndex]);\">"
						
						content += "<option selected style=\"cursor:pointer; font-weight:bold; color:#555; font-size:9pt; border:0; font-family:Helvetica;\" value=\"\">&nbsp;" + name + "</option>"
						
						for st_val in submenu_types[name]:
							numDisallowed = 0
							
							# Jan. 13, 2010: Don't print category heading if user has no access to any of its subitems
							for s_ord in submenu_order[st_val]:
								linkName = submenu_order[st_val][s_ord]
								linkURL = submenu_links[st_val][linkName]
								
								if not menuitems[st_val][linkName] in allowedSections:
									numDisallowed += 1
							
							if numDisallowed == len(submenu_links[st_val]):
								continue
							
							#print st_val.upper()
							content += "<option style=\"cursor:pointer; font-weight:bold; color:#555; background:#EFEFEF; font-size:9pt; border:0; font-family:Helvetica;\" onclick\"\">&nbsp;" + st_val.upper() + "</option>"
						
							# Now: since Python dictionaries are not ordered, arrays with > 2 items (e.g. Users - has more than 'add' and 'search') would appear scrambled.  Use an 'order' array instead
							for s_ord in submenu_order[st_val]:
								
								linkName = submenu_order[st_val][s_ord]
								linkURL = submenu_links[st_val][linkName]
								
								#print st_val
								#print linkName
								
								if menuitems[st_val][linkName] in allowedSections:

									content += "<option style=\"padding-left:15px; font-weight:bold; color:#555; font-size:8pt; border:0; font-family:Helvetica; cursor:pointer;\" value=\"" + linkURL + "\">&nbsp;&nbsp;&nbsp;" + linkName + "</option>"
							
						content += "</SELECT>"
						
						content += "</DIV>"
						
						# Quick links
						if quickLinks.has_key(name):
							content += "<div id=\"quick_links_" + name + "\" style=\"font-family:Helvetica; width:166px; padding-bottom:0; margin-top:0; padding-top:0; padding-left:2px;\">"
							
							content += "<UL style=\"padding-bottom:2px; padding-top:2px; padding-left:10px; position:relative;\">"
							
							for qlName in quickLinks[name]:
							
								if qlName in allowedSections:
								
									content += "<LI style=\"list-style:none;\"><img  src=\"../pictures/silvermenubullet.png\" width=\"7\" height=\"6\" style=\"padding-bottom:2px;\">&nbsp;<a style=\"font-weight:bold; font-size:8pt; font-family:Helvetica; text-decoration:none; color:#555; margin-left:2px;\" href=\"../" + pageLinkMap[qlName] + "\">" + qlName + "</a></LI>"
							
							content += "</UL>"
							
							content += "</DIV>"

						content += "</DIV>"
					else:
						if name == "Home":
							content += "<DIV style=\"background:url('../pictures/small_bg.png') repeat-y; padding-top:7px; margin-top:0; width:162px; border-top:6px double #FFF8DC; border-left:6px double #FFF8DC; border-right:6px double #FFF8DC; padding-bottom:8px;\">"

						else:
							content += "<DIV style=\"background:url('../pictures/small_bg.png') repeat-y; padding-top:7px; margin-top:2px; width:162px; border-left:6px double #FFF8DC; border-right:6px double #FFF8DC; padding-bottom:8px;\">"

						content += "<img src=\"../pictures/silvermenubullet.png\" style=\"width:11px; height:9px; margin-left:5px;\">"

						content += "<a style=\"font-weight:bold; color:#555; font-size:9pt; padding-left:3px; text-decoration:none;\" href=\"" + currentSectionLinks[name] + "\">" + name + "</a>"
						
						content += "</DIV>"
		else:
			# WRITE THIS FUNCTION!!!!!!!!!!
			#content += self.printGeneralMenu(publicSections)
			print "Content-type:text/html"
			print
			print "Unknown user"
		
		content += '''
					</UL>
				
					<!-- moved form down here on Aug. 20, 2010 -->
					<form name="curr_user_form" style="display:none" method="post" action="user_request_handler.py">"
					'''

		content += "<INPUT type=\"hidden\" ID=\"curr_username_hidden\" NAME=\"curr_username\" VALUE=\"" + currUser.getFullName() + "\">"
		
		content += "<INPUT TYPE=\"hidden\" id=\"curr_user_hidden\" name=\"view_user\" VALUE=\"" + `currUser.getUserID()` + "\">"
		
		content += '''
					</FORM>
				
					<div class="login">
					'''

		content += self.printLoginBlock()
		content += '''
					</div>
				</div>
			</div>
			'''
			
		return content
示例#21
0
	def printSubmenuHeader(self, submenu_type):
		
		dbConn = DatabaseConn()
		hostname = dbConn.getHostname()		# to define form action URL
		
		db = dbConn.databaseConnect()
		cursor = db.cursor()

		uHandler = UserHandler(db, cursor)
		
		current_selection_names = []		# plain list of section names
		current_selection_links = {}		# dictionary, where section names are keys and their URLs are values
		
		if submenu_type == "Location":

			location_submenu_names = []
			location_submenu_links = {}
			
			location_submenu_names.append("Add container types")
			location_submenu_links["Add container types"] = "../Location.php?View=6&Sub=3"

			location_submenu_names.append("Add container sizes")
			location_submenu_links["Add container sizes"] = "../Location.php?View=6&Sub=1"

			location_submenu_names.append("Add containers")
			location_submenu_links["Add containers"] = "../Location.php?View=6&Sub=3"

			location_submenu_names.append("Search containers")
			location_submenu_links["Search containers"] = "../Location.php?View=2"

			current_selection_names = location_submenu_names
			current_selection_links = location_submenu_links

		elif submenu_type == "Reagent":

			reagent_submenu_names = []
			reagent_submenu_links = {}

			reagent_submenu_names.append("Add reagents")
			reagent_submenu_links["Add reagents"] = "../Reagent.php?View=2"

			reagent_submenu_names.append("Search reagents")
			reagent_submenu_links["Search reagents"] = "../search.php?View=1"

			# June 3/09
			reagent_submenu_names.append("Add reagent types")
			reagent_submenu_links["Add reagent types"] = "../Reagent.php?View=3"
			
			reagent_submenu_names.append("Search reagent types")
			reagent_submenu_links["Search reagent types"] = "../Reagent.php?View=5"
			
			current_selection_names = reagent_submenu_names
			current_selection_links = reagent_submenu_links

		elif submenu_type == "Chemical":
			
			chemical_submenu_names = []
			chemical_submenu_links = {}
			
			chemical_submenu_names.append("Add Chemicals")
			chemical_submenu_links["Add Chemicals"] = "../Chemical.php?View=2"
			
			chemical_submenu_names.append("Search Chemicals")
			chemical_submenu_links["Search Chemicals"] = "../Chemical.php?View=1"
			
			current_selection_names = chemical_submenu_names
			current_selection_links = chemical_submenu_links
			
		elif submenu_type == "Prediction":
			
			prediction_submenu_names = []
			prediction_submenu_links = {}
			
			prediction_submenu_names.append("Search predictions")
			prediction_submenu_links["Search predictions"] = "../Prediction.php?View=1"

			current_selection_names = prediction_submenu_names
			current_selection_links = prediction_submenu_links
	
		elif submenu_type == "Project":	

			project_submenu_names = []
			project_submenu_links = {}
			
			project_submenu_names.append("Add projects")
			project_submenu_links["Add projects"] = "../Project.php?View=1"

			project_submenu_names.append("Search projects")
			project_submenu_links["Search projects"] = "../Project.php?View=2"

			current_selection_names = project_submenu_names
			current_selection_links = project_submenu_links

		elif submenu_type == "User":

			user_submenu_names = []
			user_submenu_links = {}
			
			user_submenu_names.append("Add users")
			user_submenu_links["Add users"] = "../User.php?View=1"

			user_submenu_names.append("Search users")
			user_submenu_links["Search users"] = "../User.php?View=2"

			user_submenu_names.append("Change your password")
			user_submenu_links["Change your password"] = "******"

			user_submenu_names.append("Personal page")
			user_submenu_links["Personal page"] = "User.php?View=7"
			
			user_submenu_names.append("View your orders")
			user_submenu_links["View your orders"] = "../User.php?View=8"
			
			current_selection_names = user_submenu_names
			current_selection_links = user_submenu_links

		elif submenu_type == "Lab":

			lab_submenu_names = []
			lab_submenu_links = {}
			
			lab_submenu_names.append("Add laboratories")
			lab_submenu_links["Add laboratories"] = "../User.php?View=3"

			lab_submenu_names.append("Search laboratories")
			lab_submenu_links["Search laboratories"] = "../User.php?View=4"

			current_selection_names = lab_submenu_names
			current_selection_links = lab_submenu_links


		# There can be permission differentiations within a menu section as well (e.g. Projects - only Creators can create, buit Writers can view)
		currUser = Session.getUser()

		ucMapper = UserCategoryMapper(db, cursor)
		category_Name_ID_Map = ucMapper.mapCategoryNameToID()

		currUserCategory = category_Name_ID_Map[currUser.getCategory()]
		allowedSections = uHandler.getAllowedSections(currUserCategory)

		#print "Content-type:text/html"		# TEMPORARY, REMOVE AFTER DEBUGGING TO HAVE SCRIPT REDIRECT PROPERLY!!!!!!
		#print					# DITTO
		#print `allowedSections`

		content = ""

		for name in current_selection_names:
		
			if name in allowedSections:
				
				if name == 'Personal page':
					content += "<LI class=\"submenu\">"
					
					content += "<IMG SRC=\"../pictures/star_bullet.gif\" WIDTH=\"10\" HEIGHT=\"10\" BORDER=\"0\" ALT=\"plus\" class=\"menu-leaf\">"

					content += "<span class=\"linkShow\" style=\"font-size:9pt\" onClick=\"redirectToCurrentUserDetailedView(" + `currUser.getUserID()` +  ");\">" + name + "</span>"

					content += "</LI>"

					content += "<form name=\"curr_user_form\" style=\"display:none\" method=\"post\" action=\"user_request_handler.py\">"
					
					content += "<INPUT type=\"hidden\" ID=\"curr_username_hidden\" NAME=\"curr_username\" VALUE=\"" + currUser.getFullName() + "\">"
					
					content += "<INPUT type=\"hidden\" id=\"curr_user_hidden\" name=\"view_user\">"
					content += "</FORM>"
				else:
					content += "<LI class=\"submenu\">"
	
					content += "<IMG SRC=\"../pictures/star_bullet.gif\" WIDTH=\"10\" HEIGHT=\"10\" BORDER=\"0\" ALT=\"plus\" class=\"menu-leaf\">"
	
					content += "<a class=\"submenu\" href=\"" + current_selection_links[name] + "\">" + name + "</a>"
					content += "</LI>"
				
		return content		
示例#22
0
#!/usr/local/bin/python

import cgi

import utils
from sequence_handler import DNAHandler
from database_conn import DatabaseConn

import Bio
from Bio.Seq import Seq
from Bio.Restriction import *

dbConn = DatabaseConn()
db = dbConn.databaseConnect()
cursor = db.cursor()

dnaHandler = DNAHandler(db, cursor)

form = cgi.FieldStorage()

lims_id = form.getvalue("limsID")		# always exists

print "Content-type: application/octet-stream"
print "Content-Disposition: attachment; filename=" + lims_id + ".txt"
print "Pragma: no-cache"
print "Expires: 0"
#print "Content-type:text/html"
print

# sequence may be empty
if form.has_key("vector_sequence"):
示例#23
0
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() `
示例#24
0
    def printMainMenu(self):

        dbConn = DatabaseConn()
        hostname = dbConn.getHostname()  # to define form action URL

        db = dbConn.databaseConnect()
        cursor = db.cursor()

        uHandler = UserHandler(db, cursor)

        # Aug. 20, 2010
        pageMapper = SystemModuleMapper(db, cursor)

        pageLinkMap = pageMapper.mapPageNameLink()

        # Array of section names
        currentSectionNames = []

        # Dictionary of links to names, with names as dictionary keys and links as values
        currentSectionLinks = {}

        # Added Nov. 10/06 by Marina - Classify each header as to what OF section it belongs
        menuTypes = {}

        # June 04/07 - Differentiate between 'public' and 'private' pages
        publicSectionNames = []
        publicSectionLinks = []

        publicSections = {}

        # Feb. 2, 2010: change menu layout (reflect HeaderFunctions.php code changes Jan. 12/10)
        submenu_links = {}
        submenu_types = {}
        menuitems = {}

        # Home
        currentSectionNames.append("Home")
        currentSectionLinks["Home"] = "../index.php"
        publicSections["Home"] = "index.php"

        # Reagent
        currentSectionNames.append("Reagent Tracker")
        currentSectionLinks["Reagent Tracker"] = "../Reagent.php?View=1"

        menuTypes["Reagent Tracker"] = "Reagent"
        publicSections["Reagent Tracker"] = "../Reagent.php?View=1"

        # Feb. 2, 2010
        tmp_list = []
        tmp_list.append("Reagents")
        tmp_list.append("Reagent Types")

        submenu_types["Reagent Tracker"] = tmp_list

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        tmp_order_list[1] = "Search"
        tmp_order_list[2] = "Statistics"

        submenu_order = {}
        submenu_order["Reagents"] = tmp_order_list

        tmp_list = {}
        tmp_list["Add"] = "../Reagent.php?View=2"
        tmp_list["Search"] = "../search.php?View=1"
        tmp_list["Statistics"] = "../Reagent.php?View=4"

        submenu_links["Reagents"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "Add reagents"
        tmp_list["Search"] = "Search reagents"
        tmp_list["Statistics"] = "Statistics"

        menuitems["Reagents"] = tmp_list

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        tmp_order_list[1] = "Search"

        submenu_order["Reagent Types"] = tmp_order_list

        tmp_list = {}
        tmp_list["Add"] = "../Reagent.php?View=3"
        tmp_list["Search"] = "../Reagent.php?View=5"
        submenu_links["Reagent Types"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "Add reagent types"
        tmp_list["Search"] = "Search reagent types"
        menuitems["Reagent Types"] = tmp_list

        # Locations
        currentSectionNames.append("Location Tracker")
        currentSectionLinks["Location Tracker"] = "../Location.php?View=1"

        menuTypes["Location Tracker"] = "Location"
        publicSections["Location Tracker"] = "../Location.php?View=1"

        # Feb. 2/10
        tmp_list = []
        tmp_list.append("Containers")
        tmp_list.append("Container Sizes")
        tmp_list.append("Container Types")
        submenu_types["Location Tracker"] = tmp_list

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        tmp_order_list[1] = "Search"

        submenu_order["Container Types"] = tmp_order_list

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        # tmp_order_list[1] = "Search"

        submenu_order["Container Sizes"] = tmp_order_list

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        tmp_order_list[1] = "Search"

        submenu_order["Containers"] = tmp_order_list

        tmp_list = {}
        tmp_list["Add"] = "../Location.php?View=6&Sub=2"
        tmp_list["Search"] = "../Location.php?View=6&Sub=4"
        submenu_links["Container Types"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "Add container types"
        tmp_list["Search"] = "Search container types"
        menuitems["Container Types"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "../Location.php?View=6&Sub=1"
        tmp_list["Search"] = "../Location.php?View=6&Sub=5"
        submenu_links["Container Sizes"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "Add container sizes"
        # tmp_list["Search"] = "Search container sizes"
        menuitems["Container Sizes"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "../Location.php?View=6&Sub=3"
        tmp_list["Search"] = "../Location.php?View=2"
        submenu_links["Containers"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "Add containers"
        tmp_list["Search"] = "Search containers"
        menuitems["Containers"] = tmp_list

        # Projects
        currentSectionNames.append("Project Management")
        currentSectionLinks["Project Management"] = "../Project.php?View=1"
        menuTypes["Project Management"] = "Project"

        # Feb. 2/10
        tmp_list = []
        tmp_list.append("Projects")
        submenu_types["Project Management"] = tmp_list

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        tmp_order_list[1] = "Search"

        submenu_order["Projects"] = tmp_order_list

        tmp_list = {}
        tmp_list["Add"] = "../Project.php?View=1"
        tmp_list["Search"] = "../Project.php?View=2"
        submenu_links["Projects"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "Add projects"
        tmp_list["Search"] = "Search projects"
        menuitems["Projects"] = tmp_list

        # Users and Labs
        currentSectionNames.append("User Management")
        currentSectionLinks["User Management"] = "../User.php"
        menuTypes["User Management"] = "User"

        currentSectionNames.append("Lab Management")
        currentSectionLinks["Lab Management"] = "../User.php"
        menuTypes["Lab Management"] = "Laboratories"

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        tmp_order_list[1] = "Search"

        submenu_order["Laboratories"] = tmp_order_list

        # Jan. 7/09: Chemicals
        currentSectionNames.append("Chemical Tracker")
        currentSectionLinks["Chemical Tracker"] = "../Chemical.php?View=1"
        menuTypes["Chemical Tracker"] = "Chemical"

        # Feb. 2, 2010
        tmp_list = []
        tmp_list.append("Chemicals")
        submenu_types["Chemical Tracker"] = tmp_list

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        tmp_order_list[1] = "Search"

        submenu_order["Chemicals"] = tmp_order_list

        tmp_list = {}
        tmp_list["Add"] = "../Chemical.php?View=2"
        tmp_list["Search"] = "../Chemical.php?View=1"
        submenu_links["Chemicals"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "Add Chemicals"
        tmp_list["Search"] = "Search Chemicals"
        menuitems["Chemicals"] = tmp_list

        # Feb. 2/10
        tmp_list = []
        tmp_list.append("Users")
        submenu_types["User Management"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "../User.php?View=1"
        tmp_list["Search"] = "../User.php?View=2"
        tmp_list["Change your password"] = "******"
        tmp_list["Personal page"] = "../User.php?View=7"
        tmp_list["View your orders"] = "../User.php?View=8"
        submenu_links["Users"] = tmp_list

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        tmp_order_list[1] = "Search"
        tmp_order_list[2] = "Change your password"
        tmp_order_list[3] = "Personal page"
        tmp_order_list[4] = "View your orders"

        submenu_order["Users"] = tmp_order_list

        tmp_list = {}
        tmp_list["Add"] = "Add users"
        tmp_list["Search"] = "Search users"
        tmp_list["Change your password"] = "******"
        tmp_list["Personal page"] = "Personal page"
        tmp_list["View your orders"] = "View your orders"
        menuitems["Users"] = tmp_list

        tmp_list = []
        tmp_list.append("Laboratories")
        submenu_types["Lab Management"] = tmp_list

        tmp_list = {}
        tmp_list["Add"] = "../User.php?View=3"
        tmp_list["Search"] = "../User.php?View=4"
        submenu_links["Laboratories"] = tmp_list

        tmp_order_list = {}
        tmp_order_list[0] = "Add"
        tmp_order_list[1] = "Search"
        submenu_order["Laboratories"] = tmp_order_list

        tmp_list = {}

        tmp_list["Add"] = "Add laboratories"
        tmp_list["Search"] = "Search laboratories"
        menuitems["Laboratories"] = tmp_list

        currentSectionNames.append("Documentation")
        currentSectionLinks["Documentation"] = "../docs.php"
        publicSections["Documentation"] = "docs.php"

        currentSectionNames.append("Terms and Conditions")
        currentSectionLinks["Terms and Conditions"] = "../copyright.php"
        publicSections["Terms and Conditions"] = "copyright.php"

        currentSectionNames.append("Help and Support")
        currentSectionLinks["Help and Support"] = "../bugreport.php"
        publicSections["Help and Support"] = "bugreport.php"

        currentSectionNames.append("Contact Us")
        currentSectionLinks["Contact Us"] = "../contacts.php"
        publicSections["Contact Us"] = "contacts.php"

        # Aug. 20/10: Quick links

        tmp_ql = []
        quickLinks = {}

        tmp_ql.append("Add reagents")
        tmp_ql.append("Search reagents")

        quickLinks["Reagent Tracker"] = tmp_ql

        tmp_ql = []

        tmp_ql.append("Add containers")
        tmp_ql.append("Search containers")

        quickLinks["Location Tracker"] = tmp_ql

        tmp_ql = []

        tmp_ql.append("Add projects")
        tmp_ql.append("Search projects")

        quickLinks["Project Management"] = tmp_ql

        tmp_ql = []

        tmp_ql.append("Change your password")
        tmp_ql.append("View your orders")

        quickLinks["User Management"] = tmp_ql

        content = """
			<div class="sidemenu" ID="mainMenu">
				<div class="menu-content">
					<ul class="menulist">
						<!-- menu goes here -->
						"""

        # Output the menu link IFF the user is authorized to access that page
        currUser = Session.getUser()

        if currUser:
            ucMapper = UserCategoryMapper(db, cursor)
            category_Name_ID_Map = ucMapper.mapCategoryNameToID()
            currUserCategory = category_Name_ID_Map[currUser.getCategory()]

            # print "Content-type:text/html"
            # print
            allowedSections = uHandler.getAllowedSections(currUserCategory)
            # print `allowedSections`

            for name in currentSectionNames:

                if name in allowedSections:

                    # added Jan. 7/09
                    if name in menuTypes:
                        # print "Content-type:text/html"
                        # print
                        # print name

                        content += '<DIV style="border-top:3px double #FFF8DC; border-right:6px double #FFF8DC; border-bottom:3px double #FFF8DC; border-left:6px double #FFF8DC; margin-top:2px; width:162px; padding-top:5px; padding-bottom:0;">'

                        content += "<DIV style=\"background-image:url('../pictures/small_bg.png'); width:166px; height:30px;\">"

                        content += '<select style="cursor:pointer; width:150px; background:#FFF8DC; font-weight:bold; color:#555; font-size:9pt; margin-top:3px; margin-left:2px;  font-family:Helvetica; border:0;" onChange="openPage(this.options[this.options.selectedIndex]);">'

                        content += (
                            '<option selected style="cursor:pointer; font-weight:bold; color:#555; font-size:9pt; border:0; font-family:Helvetica;" value="">&nbsp;'
                            + name
                            + "</option>"
                        )

                        for st_val in submenu_types[name]:
                            numDisallowed = 0

                            # Jan. 13, 2010: Don't print category heading if user has no access to any of its subitems
                            for s_ord in submenu_order[st_val]:
                                linkName = submenu_order[st_val][s_ord]
                                linkURL = submenu_links[st_val][linkName]

                                if not menuitems[st_val][linkName] in allowedSections:
                                    numDisallowed += 1

                            if numDisallowed == len(submenu_links[st_val]):
                                continue

                                # print st_val.upper()
                            content += (
                                '<option style="cursor:pointer; font-weight:bold; color:#555; background:#EFEFEF; font-size:9pt; border:0; font-family:Helvetica;" onclick"">&nbsp;'
                                + st_val.upper()
                                + "</option>"
                            )

                            # Now: since Python dictionaries are not ordered, arrays with > 2 items (e.g. Users - has more than 'add' and 'search') would appear scrambled.  Use an 'order' array instead
                            for s_ord in submenu_order[st_val]:

                                linkName = submenu_order[st_val][s_ord]
                                linkURL = submenu_links[st_val][linkName]

                                # print st_val
                                # print linkName

                                if menuitems[st_val][linkName] in allowedSections:

                                    content += (
                                        '<option style="padding-left:15px; font-weight:bold; color:#555; font-size:8pt; border:0; font-family:Helvetica; cursor:pointer;" value="'
                                        + linkURL
                                        + '">&nbsp;&nbsp;&nbsp;'
                                        + linkName
                                        + "</option>"
                                    )

                        content += "</SELECT>"

                        content += "</DIV>"

                        # Quick links
                        if quickLinks.has_key(name):
                            content += (
                                '<div id="quick_links_'
                                + name
                                + '" style="font-family:Helvetica; width:166px; padding-bottom:0; margin-top:0; padding-top:0; padding-left:2px;">'
                            )

                            content += '<UL style="padding-bottom:2px; padding-top:2px; padding-left:10px; position:relative;">'

                            for qlName in quickLinks[name]:

                                if qlName in allowedSections:

                                    content += (
                                        '<LI style="list-style:none;"><img  src="../pictures/silvermenubullet.png" width="7" height="6" style="padding-bottom:2px;">&nbsp;<a style="font-weight:bold; font-size:8pt; font-family:Helvetica; text-decoration:none; color:#555; margin-left:2px;" href="../'
                                        + pageLinkMap[qlName]
                                        + '">'
                                        + qlName
                                        + "</a></LI>"
                                    )

                            content += "</UL>"

                            content += "</DIV>"

                        content += "</DIV>"
                    else:
                        if name == "Home":
                            content += "<DIV style=\"background:url('../pictures/small_bg.png') repeat-y; padding-top:7px; margin-top:0; width:162px; border-top:6px double #FFF8DC; border-left:6px double #FFF8DC; border-right:6px double #FFF8DC; padding-bottom:8px;\">"

                        else:
                            content += "<DIV style=\"background:url('../pictures/small_bg.png') repeat-y; padding-top:7px; margin-top:2px; width:162px; border-left:6px double #FFF8DC; border-right:6px double #FFF8DC; padding-bottom:8px;\">"

                        content += '<img src="../pictures/silvermenubullet.png" style="width:11px; height:9px; margin-left:5px;">'

                        content += (
                            '<a style="font-weight:bold; color:#555; font-size:9pt; padding-left:3px; text-decoration:none;" href="'
                            + currentSectionLinks[name]
                            + '">'
                            + name
                            + "</a>"
                        )

                        content += "</DIV>"
        else:
            # WRITE THIS FUNCTION!!!!!!!!!!
            # content += self.printGeneralMenu(publicSections)
            print "Content-type:text/html"
            print
            print "Unknown user"

        content += """
					</UL>
				
					<!-- moved form down here on Aug. 20, 2010 -->
					<form name="curr_user_form" style="display:none" method="post" action="user_request_handler.py">"
					"""

        content += (
            '<INPUT type="hidden" ID="curr_username_hidden" NAME="curr_username" VALUE="'
            + currUser.getFullName()
            + '">'
        )

        content += (
            '<INPUT TYPE="hidden" id="curr_user_hidden" name="view_user" VALUE="' + ` currUser.getUserID() ` + '">'
        )

        content += """
					</FORM>
				
					<div class="login">
					"""

        content += self.printLoginBlock()
        content += """
					</div>
				</div>
			</div>
			"""

        return content
示例#25
0
from general_handler import *
from reagent_handler import *
from comment_handler import CommentHandler
#from system_set_handler import SystemSetHandler
from sequence_handler import DNAHandler, ProteinHandler

from reagent import Reagent, Vector
from sequence_feature import SequenceFeature

# User and Project info
from user_handler import UserHandler
from project_database_handler import ProjectDatabaseHandler
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)
示例#26
0
from general_handler import *
from reagent_handler import *
from sequence_handler import DNAHandler, ProteinHandler
from comment_handler import CommentHandler
#from system_set_handler import SystemSetHandler
from sequence_handler import SequenceHandler
from reagent import *

import utils

from user_handler import UserHandler
from project_database_handler import ProjectDatabaseHandler
from session import Session
from exception import *

dbConn = DatabaseConn()
db = dbConn.databaseConnect()

cursor = db.cursor()
hostname = dbConn.getHostname()
root_path = dbConn.getRootDir()

dnaHandler = DNAHandler(db, cursor)
protHandler = ProteinHandler(db, cursor)
rHandler = ReagentHandler(db, cursor)
oHandler = OligoHandler(db, cursor)
propHandler = ReagentPropertyHandler(db, cursor)
packetHandler = ProjectDatabaseHandler(db, cursor)

propMapper = ReagentPropertyMapper(db, cursor)
prop_Name_ID_Map = propMapper.mapPropNameID()		# (prop name, prop id)
示例#27
0
def rMap_specific(f_in, f_out, enz_list):
	
	# Database connection parameters
	dbConn = DatabaseConn()
	db = dbConn.databaseConnect()
	cursor = db.cursor()
	
	gHandler = GeneralHandler(db, cursor)
	rHandler = ReagentHandler(db, cursor)
	seqHandler = SequenceHandler(db, cursor)

	infile = open(f_in, 'r')
	outfile = open(f_out, 'w')	

	for line in infile.readlines():
		reagentID = line.strip()	# e.g. V123
		rID = rHandler.convertReagentToDatabaseID(reagentID)
		seqID = rHandler.findDNASequenceKey(rID)

		if seqID:
			mySeq = seqHandler.findSequenceByID(seqID)
			
			# Construct a Seq object readable by BioPython:
			bioSeq = Seq(mySeq)
			fSeq = FormattedSeq(bioSeq, linear=False)		# linear = FALSE, we're dealing w/ VECTORS

			analysis = Analysis(enz_list, fSeq, linear=False)  	# linear = FALSE again for VECTORS
			result = analysis.full()

			outfile.write(reagentID + ": " + '\n')

			# calculate bandwidths
			allSites = []
			
			for enz in result.keys():
				sites = result[enz]
				
				if len(allSites) == 0:
					allSites = sites
				else:
					# concatenate
					for s in sites:
						allSites.append(s)

			allSites.sort()

			if len(allSites) > 0:
				
				# calculate distances between sites
				bandSizes = []
				
				i = 1
				
				while i < len(allSites):
					tmpLen = allSites[i] - allSites[i-1]
					bandSizes.append(tmpLen)
					i += 1
				
				# last band
				tmpLen = len(mySeq) - allSites[i-1] + allSites[0]
				bandSizes.append(tmpLen)
				
				bandSizes.sort()
				
				outfile.write(`bandSizes` + '\n')

			outfile.write('\n')
			
	infile.close()
	outfile.close()
	cursor.close()
	db.close()
示例#28
0
def drawMap2():
	dbConn = DatabaseConn()
	db = dbConn.databaseConnect()
	
	cursor = db.cursor()
	hostname = dbConn.getHostname()

	form = cgi.FieldStorage(keep_blank_values="True")
	
	#print "Content-type:text/html"
	#print
	#print `form`
	
	if form.has_key("rID"):
		rID = form.getvalue("rID")
	else:
		#rID = 791
		#print rID
		rID = 154659 

	reagentID = rHandler.convertDatabaseToReagentID(rID)
	
	d = Drawing(1000,1000)
	
	origin = 0
	origin_x = 500
	origin_y = 500
	radius = 350
	
	c = Circle(origin_x, origin_y, radius)
	
	c.strokeColor = blue
	c.fillColor = white
	
	d.add(c)
	
	c.line(origin_x, origin_y+radius-7, origin_x-7, origin_y+radius)
	c.line(origin_x-7, origin_y+radius, origin_x, origin_y+radius+7)
	c.line(origin_x, origin_y+radius+7, origin_x+7, origin_y+radius)
	c.line(origin_x+7, origin_y+radius, origin_x, origin_y+radius-7)
	
	
	p = c.beginPath()
	c.setFillColor(black)
	c.saveState()
	p.moveTo(origin_x, origin_y+radius-7)
	p.lineTo(origin_x-7, origin_y+radius)
	p.lineTo(origin_x, origin_y+radius+7)
	p.lineTo(origin_x+7, origin_y+radius)
	p.close()
	c.drawPath(p)
	c.restoreState()
	
	# Divide circle into 100-unit sectors
	rSeqID = rHandler.findDNASequenceKey(rID)
	rSeq = sHandler.findSequenceByID(rSeqID)
	seqLen = len(rSeq)
	#print seqLen
	
	unit_angle_measure = float(360) / float(seqLen)
	
	# Calculate feature segment sizes
	sequenceFeatures = rHandler.findReagentSequenceFeatures(rID)
	
	for feature in sequenceFeatures:
		fType = feature.getFeatureType()
		fValue = feature.getFeatureName()
		
		fStart = feature.getFeatureStartPos()
		fEnd = feature.getFeatureEndPos()
		fDir = feature.getFeatureDirection()
		
		f_start = fStart * unit_angle_measure
		f_end = fEnd * unit_angle_measure
		
		if fStart > 0 and fEnd > 0:
			print "Start " + `fStart`
			print "End " + `fEnd`
		
			startAngle = 90 - f_start
			extAngle = -1*(f_end - f_start)
			
			print "Angle " + `extAngle`
			
			x1 = origin_x - radius
			y1 = origin_y - radius
			
			x2 = origin_x + radius
			y2 = origin_y + radius
			
			p = ArcPath()
			#p.dumpProperties()
			
			p.strokeWidth=15
			p.strokeColor = black
			p.fillColor = red
			
			#p.addArc(x1, y1, x2, y2, startAngle, extAngle)		# NO
			
			d.add(p)
			
			d.add(String(origin_x+fStart, origin_y+fStart, fValue))
	
	renderPDF.drawToFile(d, "V7066_map.png")
示例#29
0
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()`
示例#30
0
	def printLabInfo(self, cmd, newLab, 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)
		
		currUser = Session.getUser()
		
		gOut = GeneralOutputClass()

		if cmd == 'view':

			labID = newLab.getID()
			labHead = newLab.getLabHead()
			labName = newLab.getName()
			labCode = newLab.getLabCode()
			labDescr = newLab.getDescription()
			address = newLab.getAddress()
			accessLevel = newLab.getDefaultAccessLevel()
			
			# Determine if 'Delete' button should be disabled - if there are members in the lab, disallow deletion
			labMembers = lHandler.findMembers(labID)

			delete_disabled = True

			if len(labMembers) == 0:
				delete_disabled = False
			
			# Only allow modification by admin
			modify_disabled = True
			
			# July 3/07: Can further disallow modification of labs other than the one currUser belongs to; however, this might be too restrictive.  Keep it in the back of our minds but out of the website for now.
			#if (currUser.getCategory() == 'Admin') and (currUser.getLab().getID() == labID):
			if (currUser.getCategory() == 'Admin'):
				modify_disabled = False
			
			#content = gOut.printHeader() + gOut.printMainMenu()
			content = gOut.printHeader()
			
			content += '''
				<FORM name="lab_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="775px" cellpadding="5px" cellspacing="5px" class="detailedView_tbl">
						<TR>
							<TD colspan="6" class="detailedView_heading" style="padding-left:250px">
								LABORATORY DETAILS PAGE
								'''
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:50px;\" name=\"modify_lab\" value=\"Change Lab Info\""
			
			if modify_disabled:
				content += " disabled>"
			else:
				content += ">"
							
			content += "<INPUT TYPE=\"submit\" style=\"margin-left:2px;\" name=\"delete_lab\" value=\"Delete Lab\" onClick=\"return verifyDeleteLab()\""
			
			if modify_disabled or delete_disabled:
				content += " disabled>"
			else:
				content += ">"
				
			content += '''
							</TD>

						</TR>
					
						<TR>
							<TD class="projectDetailedViewName">
								Name:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labName" value="%s">

								<!-- lab ID a hidden value -->
								<INPUT TYPE="hidden" name="labID" value="%d">
							</TD>
						</TR>

						<TR>
							<TD class="projectDetailedViewName">
								Lab head:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labHead" value="%s">
							</TD>
						</TR>

						<TR>
							<TD class="projectDetailedViewName">
								Lab ID:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labCode" value="%s">
							</TD>
						</TR>
						
						<TR>
							<TD class="projectDetailedViewName">
								Description:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="labDescription" value="%s">
							</TD>
						</TR>

						<TR>
							<TD class="projectDetailedViewName">
								Location:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="address" value="%s">
							</TD>
						</TR>
						
						<TR>
							<TD class="projectDetailedViewName" style="white-space:nowrap">
								Default access level:
							</TD>

							<TD class="detailedView_value" style="width:400px">
								%s
								<INPUT TYPE="hidden" name="access" value="%s">
							</TD>
						</TR>
						
						<!-- Members -->
						<TR>
							<TD class="projectDetailedViewName">
								Members:
							</TD>
							
							<TD class="detailedView_value" style="width:400px">
								<UL>
							'''
			
			content += "<INPUT type=\"hidden\" id=\"view_user_hidden\" name=\"view_user\">"
				
			for member in labMembers:
				mName = member.getFullName()
				memberID = member.getUserID()
				#content += "<LI>" + mName
				content += "<LI>"
				content += "<span class=\"linkShow\" onClick=\"redirectToUserDetailedView(" + `memberID` + ");\">" + mName + "</span>"
				content += "</LI>"

			content += '''
								</UL>
							</TD>
						</TR>
					</TABLE>
				</FORM>
				
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
				<blockquote>&nbsp;</blockquote>
			</div>
			'''
				
			content += gOut.printFooter()
			
			page_content = content % (hostname + "cgi/user_request_handler.py", labName, labName, labID,  labHead, labHead, labCode, labCode, labDescr, labDescr, address, address, accessLevel, accessLevel)

			print "Content-type:text/html"		# THIS IS PERMANENT; DO NOT REMOVE
			print					# DITTO
			print page_content

		elif cmd == 'edit':
			
			labID = newLab.getID()
			labName = newLab.getName()
			labHead = newLab.getLabHead()
			labCode = newLab.getLabCode()
			labDescr = newLab.getDescription()
			address = newLab.getAddress()
			accLev = newLab.getDefaultAccessLevel()
			
			# Disable name modification if there are members in lab
			labMembers = lHandler.findMembers(labID)

			name_readonly = True

			if len(labMembers) == 0:
				name_readonly = False

			# hide/show duplicate lab code warning
			if errCode == 14:
				dup_lab_code_warn_display = "inline"
			else:
				dup_lab_code_warn_display = "none"
			
			#content = gOut.printHeader() + gOut.printMainMenu()
			content = gOut.printHeader()
			
			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="760px" cellpadding="5px" cellspacing="5px" style="border:1px solid black" frame="box" rules="rows">
					<TR>
						<TD colspan="3" style="padding-left:100px; text-align:center">
							<span style="color:#0000FF; font-weight:bold">CHANGE LABORATORY INFORMATION</span>
							<INPUT TYPE="submit" style="margin-left:180px;" name="save_lab" value="Save" onClick="selectAllElements('labMembersList'); return checkLab();">
							<INPUT TYPE="submit" style="margin-left:20px;" name="cancel_lab" value="Cancel">
						</TD>
					</TR>
					
					<TR>
						<TD class="projectDetailedViewName">
							Name:
						</TD>

						<TD class="detailedView_value" style="width:400px" colspan="2">
							'''
							
			if name_readonly:
				content += "<INPUT TYPE=\"text\" size=\"50px\" id=\"lab_name\" name=\"labName\" value=\"%s\" readonly>"
			else:
				content += "<INPUT TYPE=\"text\" size=\"50px\" id=\"lab_name\" name=\"labName\" value=\"%s\">"
				
			content += '''
							<!-- lab ID hidden value -->
							<INPUT TYPE="hidden" name="labID" value="%d">
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Lab head:
						</TD>

						<TD class="detailedView_value" style="width:400px" colspan="2">
							<INPUT TYPE="text" size="50px" id="lab_head" name="labHead" value="%s">
						</TD>
					</TR>
					
					<TR>
						<TD class="projectDetailedViewName">
							Lab ID:
						</TD>

						<TD class="detailedView_value" style="width:400px" colspan="2">
							<INPUT TYPE="text" size="50px" id="lab_id" name="labCode" value="%s">
							<BR>
							<SPAN id="dup_labcode_warning" style="vertical-align:bottom; color:#FF0000; display:%s">This identifier already exists.  Please specify a different lab ID.</SPAN>
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Description:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" size="50px" id="lab_descr" name="description" value="%s">
						</TD>
					</TR>

					<TR>
						<TD class="projectDetailedViewName">
							Location:
						</TD>

						<TD class="detailedView_value" colspan="2">
							<INPUT TYPE="text" size="50px" id="lab_location" name="address" value="%s">
						</TD>
					</TR>
										
					<TR>
						<TD style="width:50px; vertical-align:top; padding-top:10px; white-space:nowrap; font-size:8pt">
							Default access level:
						</TD>

						<TD style="font-size:8pt; vertical-align:top; width:50px;">
						'''
			# Determine which category radio button should be checked
			ucHandler = UserCategoryHandler(db, cursor)
			categories = ucHandler.findAllCategories()
			
			for cID in categories.keys():
				cat = categories[cID]
				content += "<INPUT TYPE=\"RADIO\" name=\"system_access_level\" value=\"" + cat + "\" style=\"margin-top:8px; font-size:8pt\" onClick=\"showHideProjectAccess()\""
				
				if cat == accLev:
					content += " checked"
				
				content += ">" + cat + "<BR/>"
				
			content += '''
						</TD>
					</TR>
					
					<!-- Members - allow deletion -->
					<TR>
						<TD style="width:50px; vertical-align:top; padding-top:10px; font-size:8pt">
							<b>Members:</b>
							<BR/><BR/>
							Select one or more members to remove them from the system.<BR/><BR/>
							
							(hold down CTRL key to select multiple names)
						</TD>

						<TD style="font-size:8pt; vertical-align:top; width:50px;">
							<SELECT MULTIPLE SIZE="10" ID="labMembersList" NAME="labMembers">
						'''
			members = lHandler.findMembers(labID)
			
			for  member in members:
				mName = member.getFullName()
				memberID = member.getUserID()
				
				content += "<OPTION value=\"" + `memberID` + "\">" + mName + "</OPTION>"
			
			content += '''
							</SELECT>
						</TD>
						
						<TD>
							<INPUT TYPE=\"button\" onClick=\"removeLabMembers('labMembersList')\" value=\"Remove Selected Members\">
						</TD>
					</TR>
				</TABLE>
			</FORM>
			
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
			<blockquote>&nbsp;</blockquote>
		
			</div>
			'''
			
			content += gOut.printFooter()
			
			page_content = content % (hostname + "cgi/user_request_handler.py", labName, labID, labHead, labCode, dup_lab_code_warn_display, labDescr, address)

			print "Content-type:text/html"		# THIS IS PERMANENT; DO NOT REMOVE
			print					# DITTO
			print page_content
示例#31
0
def drawMap():
	
	dbConn = DatabaseConn()
	db = dbConn.databaseConnect()
	
	cursor = db.cursor()
	hostname = dbConn.getHostname()
	root_path = dbConn.getRootDir()
	
	form = cgi.FieldStorage(keep_blank_values="True")
	
	#print "Content-type:text/html"
	#print
	#print `form`
	
	if form.has_key("rID"):
		rID = form.getvalue("rID")
	else:	# script executed from command line
		# Worst-case scenarios
		#rID = 260	# V260
		#rID = 230	# V260
		#rID = 80	# V80 - ok
		#rID = 69661	# V2412 - not bad at all, just one of the oligos overlaps exactly with promoter (1 nt difference)
		#rID = 23999 	# V59541
		rID = 97918
		#print rID

	if form.has_key("user_id_hidden"):
		userID = form.getvalue("user_id_hidden")
	else:	# command-line execution
		userID = 1	# debug

	reagentID = rHandler.convertDatabaseToReagentID(rID)
	
	uPackets = getCurrentUserProjects(userID)
	
	#print "Content-type:text/html"
	#print
	#print reagentID
	uPackets.sort()
	#print `uPackets`

	namePropID = pHandler.findReagentPropertyInCategoryID(prop_Name_ID_Map["name"], prop_Category_Name_ID_Map["General Properties"])
	statusPropID = pHandler.findReagentPropertyInCategoryID(prop_Name_ID_Map["status"], prop_Category_Name_ID_Map["General Properties"])
	projectPropID = pHandler.findReagentPropertyInCategoryID(prop_Name_ID_Map["packet id"], prop_Category_Name_ID_Map["General Properties"])
	
	rName = rHandler.findSimplePropertyValue(rID, namePropID)
	rTypeID = rHandler.findReagentTypeID(rID)
	
	try:
		os.remove(root_path + "Reagent/vector_maps/" + reagentID + "_Oligo_map.pdf")
	except OSError:
		pass
	
	#print root_path
	
	c = Canvas(root_path + "Reagent/vector_maps/" + reagentID + "_Oligo_map.pdf")
	
	c.setPageSize((1500,1500))
	c.setStrokeColorRGB(0,0,0)
	c.saveState()
	
	# Draw circle
	origin = 0
	origin_x = 750
	origin_y = 750
	radius = 200
	
	c.circle(origin_x, origin_y, radius)
	c.restoreState()
	
	# Divide circle into 100-unit sectors
	rSeqID = rHandler.findDNASequenceKey(rID)
	rSeq = sHandler.findSequenceByID(rSeqID)
	seqLen = len(rSeq)
	
	#print "Content-type:text/html"
	#print
	#print `rID`
	
	unit_angle_measure = float(360) / float(seqLen)
	#print unit_angle_measure
	
	# Mark 1 on the circle - KEEP, Karen said!
	c.setLineWidth(1)
	c.setStrokeColor(black)
	c.setFillColor(black)
	c.saveState()

	path = c.beginPath()
	
	# Draw a triangle pointing down above the circle
	#path.moveTo(origin_x, origin_y+radius+7)
	#path.lineTo(origin_x-5, origin_y+radius+14)
	#path.lineTo(origin_x+5, origin_y+radius+14)
	#path.lineTo(origin_x, origin_y+radius+7)
	
	# Draw a triangle pointing up inside the circle
	#path.moveTo(origin_x, origin_y+radius-10)
	#path.lineTo(origin_x-5, origin_y+radius-14)
	#path.lineTo(origin_x+5, origin_y+radius-14)
	#path.lineTo(origin_x, origin_y+radius-10)
	
	# Draw a triangle pointing right inside the circle
	path.moveTo(origin_x, origin_y+radius-14)
	path.lineTo(origin_x, origin_y+radius-28)
	path.lineTo(origin_x+8, origin_y+radius-21)
	path.lineTo(origin_x, origin_y+radius-14)
	c.drawPath(path, True, True)
	
	# label 1
	t = c.beginText()
	t.setStrokeColor(black)
	t.setFillColor(black)
	t.setFont("Helvetica-Bold", 16)
	#t.setTextOrigin(origin_x-5, origin_y+radius+19)	# above circle
	t.setTextOrigin(origin_x-3, origin_y+radius-50)	# above circle
	t.textOut("1")
	c.drawText(t)
	
	c.restoreState()

	# Calculate feature segment sizes
	sequenceFeatures = rHandler.findReagentSequenceFeatures(rID)
	#print `sequenceFeatures`

	# Draw legend
	ox_legend = 1280
	oy_legend = 1465
	
	prev_legend = oy_legend
	
	# draw frame
	c.setStrokeColor(darkgray)
	c.setFillColor(white)
	c.saveState()
	
	featureNames = rtPropHandler.findReagentTypeAttributeNamesByCategory(rTypeID, prop_Category_Name_ID_Map["DNA Sequence Features"])
	featureNames.sort()

	if len(featureNames) > 15:
		origin_spacer = -19
		coeff = 12
	else:
		origin_spacer = 65
		coeff = 15
	
	origin_legend = prev_legend+origin_spacer-len(featureNames)*coeff
	
	x = (990 - origin_legend) / len(featureNames)
	#print x
	
	if x < 12:
		x = 12
	
	# WHEN WANT TO ADJUST LEGEND GREY BOX HEIGHT: UPDATE THE VALUE ADDED TO legend_height AND THE VALUE SUBTRACTED FROM origin_legend
	legend_height = len(featureNames)*x + 55
	
	c.rect(ox_legend-25, origin_legend-35, 215, legend_height, 1, 1)	# good for specific rtype attributes
	
	c.restoreState()
	
	protocolPropID = pHandler.findReagentPropertyInCategoryID(prop_Name_ID_Map["protocol"], prop_Category_Name_ID_Map["Classifiers"])
	seqPropID = pHandler.findReagentPropertyInCategoryID(prop_Name_ID_Map["sequence"], prop_Category_Name_ID_Map["DNA Sequence"])
	
	sequenceFeatures = rHandler.findAllReagentFeatures(Vector(rID), rID)
	
	# Print reagent ID and size at the centre of the circle and print name at the top of the page
	c.setFont("Helvetica-Bold", 32)
	c.setFillColor(black)
	c.saveState()
	
	c.drawCentredString(origin_x, origin_y+35, reagentID)
	c.drawCentredString(origin_x, origin_y+10, "nt 1 - " + `seqLen`)
	
	if rName:
		c.setFillColor(blue)	
		c.drawCentredString(origin_x, 1415, rName)
	
	c.restoreState()
	
	# find all Oligos whose protocol is 'sequencing'
	# April 26, 2010: Do not include status in this query, as it might just not be recorded for the oligo at all (early entries)
	cursor.execute("SELECT r.reagentID, r.groupID, s.sequence FROM Sequences_tbl s, ReagentPropList_tbl p1, ReagentPropList_tbl p2, Reagents_tbl r WHERE p1.propertyID=" + `protocolPropID` + " AND p1.propertyValue='sequencing' AND p1.reagentID=r.reagentID AND r.reagentTypeID='3' AND p1.reagentID=p2.reagentID AND p2.propertyID=" + `seqPropID` + " AND p2.propertyValue=s.seqID AND p1.status='ACTIVE' AND p2.status='ACTIVE' AND r.status='ACTIVE' AND s.status='ACTIVE'")
	
	#print "SELECT r.reagentID, r.groupID, s.sequence FROM Sequences_tbl s, ReagentPropList_tbl p1, ReagentPropList_tbl p2, Reagents_tbl r WHERE p1.propertyID=" + `protocolPropID` + " AND p1.propertyValue='sequencing' AND p1.reagentID=r.reagentID AND r.reagentTypeID='3' AND p1.reagentID=p2.reagentID AND p2.propertyID=" + `seqPropID` + " AND p2.propertyValue=s.seqID AND p1.status='ACTIVE' AND p2.status='ACTIVE' AND r.status='ACTIVE' AND s.status='ACTIVE'"
	
	results = cursor.fetchall()
	
	rSeq = utils.squeeze(rSeq).lower()
	#print rSeq
	
	oligoFeatures = []
	
	oligoIDsDict = {}	# O123 => 123
	oligoNamesDict = {}	# 123 => "O123 Name"
	oligoProjectDict = {}	# 123 => 7
	
	for result in results:
		
		if result:
			oligoID = int(result[0])
			groupID = int(result[1])
			
			oligo_lims_id = "O" + `groupID`
			oligoIDsDict[oligo_lims_id] = oligoID
			#print oligo_lims_id
			
			oligoName = rHandler.findSimplePropertyValue(oligoID, namePropID)
			
			# April 26, 2010, Karen's request: Ignore Oligos whose status is 'Failed' or 'Do Not Use'
			oligoStatus = rHandler.findSimplePropertyValue(oligoID, statusPropID)

			if oligoStatus:
				#print oligoStatus
				if oligoStatus.lower() == 'failed' or oligoStatus.lower() == 'do not use':
					continue
			
			if oligoName:
				oligoNamesDict[oligoID] = oligoName
			else:
				oligoNamesDict[oligoID] = ""
			
			#cursor.execute("SELECT propertyValue FROM ReagentPropList_tbl WHERE reagentID=" + `oligoID` + " AND propertyID=" + `namePropID` + " AND status='ACTIVE'")
			#result2 = cursor.fetchone()
			
			#if result2:
				#oligoName = result2[0]
				#oligoNamesDict[oligoID] = oligoName
			#else:
				#oligoNamesDict[oligoID] = ""
			
			# PROJECT - MUST CAST TO INT
			oligoPacket = int(rHandler.findSimplePropertyValue(oligoID, projectPropID))
			#print oligoPacket
			
			if oligoPacket:
				if oligoPacket not in uPackets:
					#print oligoPacket
					continue
			
			#cursor.execute("SELECT propertyValue FROM ReagentPropList_tbl WHERE reagentID=" + `oligoID` + " AND propertyID=" + `projectPropID` + " AND status='ACTIVE'")
			#result3 = cursor.fetchone()
			
			#if result3:
				#oligoPacket = int(result3[0])
				##print oligoPacket
				
				#if oligoPacket not in uPackets:
					##print oligoPacket
					#continue
				
				#oligoProjectDict[oligoID] = oligoPacket
			#else:
				#oligoProjectDict[oligoID] = 0
			
			if len(result) == 3:
				oligoSeq = result[2].strip().lower()
				#print oligoSeq
				
				tm = sHandler.calculateTm(oligoSeq)
				
				# Changes made April 26, 2010: Karen caught that the sense/antisense check does not work for T3 and T7 vectors and said to check oligo sequence both ways
				#if rSeq.find(oligoSeq) < 0:
					#continue
					
				if rSeq.find(oligoSeq) >= 0:
					fStart = rSeq.find(oligoSeq) + 1
					fEnd = fStart + len(oligoSeq) - 1
					
					#if oHandler.isSenseOligo(oligoID):
					oFeature = SequenceFeature("sequencing primer", oligo_lims_id, fStart, fEnd, 'forward', oligoSeq, tm)
					#else:
						#oFeature = SequenceFeature("sequencing primer", oligo_lims_id, fStart, fEnd, 'reverse', oligoSeq, tm)
					
				else:
					revSeq = sHandler.reverse_complement(oligoSeq)
					
					if rSeq.find(revSeq) < 0:
						continue
					
					fStart = rSeq.find(revSeq) + 1
					fEnd = fStart + len(revSeq)
					
					# Note: start pos > end pos, as we're talking about reverse Oligo sequence
					revStart = fEnd - 1
					revEnd = fStart
				
					# Still, record sense/antisense for displaying on the map ('forward' and 'reverse' here are just static values in Feature class, it doesn't reflect sequence orientation in our case - just use as a temporary placeholder)
					#if oHandler.isSenseOligo(oligoID):
						#oligoFeatures.append(oFeature)
						#oFeature = SequenceFeature("sequencing primer", oligo_lims_id, revStart, revEnd, 'forward', oligoSeq, tm)
					#else:
					oFeature = SequenceFeature("sequencing primer", oligo_lims_id, revStart, revEnd, 'reverse', oligoSeq, tm)
				
				oligoFeatures.append(oFeature)
	
				sequenceFeatures.append(oFeature)

	# SORT features by size, so that short features are not hidden behind the long ones
	fSizes = []
	sortedFeatures = []
	
	fSortedPos = {}
	
	fStartPos = []
	fEndPos = []
	
	for feature in sequenceFeatures:
		fSize = int(feature.getFeatureSize())
		
		if fSize > 0:
			fSizes.append(fSize)
		
		#if fSize > 150:
		f_start_tmp = int(feature.getFeatureStartPos())
		fStartPos.append(f_start_tmp)
		
		fSortedPos[f_start_tmp] = feature
	
		f_end_tmp = int(feature.getFeatureEndPos())
		fEndPos.append(f_end_tmp)
		
	
	fEndPos.sort()
	fStartPos.sort()
	
	#print `fStartPos`
	#print `fEndPos`
	
	fSizes.sort(reverse=True)
	#print `fSizes`
	
	for fs in fSizes:
		for feature in sequenceFeatures:
			fSize = feature.getFeatureSize()

			# added existence check July 17/08 - different features may have same sizes so end up with duplicate features in list (e.g. cloning sizes appeared twice on the map)
			if fs == fSize and feature not in sortedFeatures:
				sortedFeatures.append(feature)
	
	# Order: 5' site, 3' site, 5' linker, 3' linker, then the rest
	sites_color = featureNameColorMap["5' cloning site"]		# same for 3' site
	
	# 5' site
	c.setStrokeColor(sites_color)
	c.setFillColor(sites_color)
	c.saveState()
	c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
	c.restoreState
	
	t = c.beginText()
	t.setStrokeColor(sites_color)
	t.setFillColor(sites_color)
	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_legend+12, prev_legend-20)
	t.textOut(" - " + "5' CLONING SITE")
	c.drawText(t)
	c.restoreState
	
	prev_legend = prev_legend-15
	
	# 3' site
	c.setStrokeColor(sites_color)
	c.setFillColor(sites_color)
	c.saveState()
	c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
	c.restoreState
	
	t = c.beginText()
	t.setStrokeColor(sites_color)
	t.setFillColor(sites_color)
	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_legend+12, prev_legend-20)
	t.textOut(" - " + "3' CLONING SITE")
	c.drawText(t)
	c.restoreState

	prev_legend = prev_legend-15
	
	# Show legend for linkers
	linkers_color = featureNameColorMap["5' linker"]
	
	# 5' linker
	c.setStrokeColor(linkers_color)
	c.setFillColor(linkers_color)
	c.saveState()
	c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
	c.restoreState
	
	t = c.beginText()
	t.setStrokeColor(linkers_color)
	t.setFillColor(linkers_color)
	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_legend+12, prev_legend-20)
	t.textOut(" - " + "5' LINKER")
	c.drawText(t)
	c.restoreState

	prev_legend = prev_legend-15
	
	# 3' linker
	c.setStrokeColor(linkers_color)
	c.setFillColor(linkers_color)
	c.saveState()
	c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
	c.restoreState
	
	t = c.beginText()
	t.setStrokeColor(linkers_color)
	t.setFillColor(linkers_color)
	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_legend+12, prev_legend-20)
	t.textOut(" - " + "3' LINKER")
	c.drawText(t)
	c.restoreState

	prev_legend = prev_legend-15
	
	# Output the rest of the features in alphabetical order
	featureNames = featureNameColorMap.keys()
	featureNames.sort()
	
	#print `featureNames`
	
	for featureName in featureNames:
		#print featureName
		if featureNameColorMap.has_key(featureName):
			color = featureNameColorMap[featureName]
			
			if featureName != "5' cloning site" and featureName != "3' cloning site" and featureName != "5' linker" and featureName != "3' linker" and color != None:
				#print featureName
				c.setStrokeColor(color)
				c.setFillColor(color)
				c.saveState()
				c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
				c.restoreState
				
				t = c.beginText()
				t.setStrokeColor(color)
				t.setFillColor(color)
				t.setFont("Helvetica-Bold", 10)
				t.setTextOrigin(ox_legend+12, prev_legend-20)
				t.textOut(" - " + featureName.upper())
				c.drawText(t)
				
				c.restoreState
				
				prev_legend = prev_legend-15

	# Sequencing Primer
	oligoColor = "#7cfc00"
	
	c.setStrokeColor(oligoColor)
	c.setFillColor(oligoColor)
	c.saveState()
	c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
	c.restoreState
	
	t = c.beginText()
	t.setStrokeColor(oligoColor)
	t.setFillColor(oligoColor)
	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_legend+12, prev_legend-20)
	t.textOut(" - " + "SEQUENCING PRIMER")
	c.drawText(t)
	c.restoreState

	prev_legend = prev_legend-15
	
	ox_labels = 40
	oy_labels = 40
	#prev_legend = oy_labels
	
	for feature in sortedFeatures:
		
		fType = feature.getFeatureType()
		fValue = feature.getFeatureName()
		fSize = feature.getFeatureSize()
		
		#print fType
		#print fValue
		#print fSize
		
		# color
		if featureNameColorMap.has_key(fType):
			fColor = featureNameColorMap[fType]
			textColor = fColor
			
		elif fType == 'sequencing primer':
			fColor = "#7cfc00"
			textColor = "black"

			o_id = oligoIDsDict[fValue]
			oligoName = oligoNamesDict[o_id]
			
			if len(oligoName) > 0:
				fValue += " " + oligoName
		
		# property name
		if fType == 'cdna insert':
			fValue = "cDNA Insert"
			
		elif fType == 'promoter':
			fValue = fValue + " " + fType
		
		fStart = feature.getFeatureStartPos()
		fEnd = feature.getFeatureEndPos()
		fDir = feature.getFeatureDirection()
		
		# value
		#if fType == 'sequencing primer':
		
			#oligoDir = feature.getFeatureDirection()
		
			#if oligoDir == 'forward':
				#oligoType = 'Sense'
			#else:
				#oligoType = 'Antisense'
			
			#fTxt = fValue + " (" + `fStart` + "-" + `fEnd` + "), " + oligoDir
		#else:
		
		fTxt = fValue + " (" + `fStart` + "-" + `fEnd` + ")"
			
		if fSize > 0:
			f_start = fStart * unit_angle_measure
		
			#print "Start " + `fStart`
			#print "End " + `fEnd`
		
			startAngle = 90 - f_start
			#print "Start angle " + `startAngle`
			
			f_end = fEnd * unit_angle_measure
			endAngle = 90 - f_end
			#print "End angle " + `endAngle`
			
			extAngle = -1*(f_end - f_start)
			#print "Ext angle " + `extAngle`

			x1 = origin_x - radius
			y1 = origin_y - radius
			
			x2 = origin_x + radius
			y2 = origin_y + radius
			
			p = c.beginPath()
			
			c.setLineWidth(10)
			c.setLineJoin(1)
			
			c.setStrokeColor(fColor)
			c.saveState()
			
			p.arc(x1, y1, x2, y2, startAngle, extAngle)
			c.drawPath(p)
			c.restoreState()
			
			# common to all
			startAngle_rad = (startAngle * math.pi) / 180.0
			endAngle_rad = (endAngle * math.pi) / 180.0
			
			c.setStrokeColor(fColor)
			c.setFillColor(fColor)
			c.setFont("Helvetica-Bold", 9)
			c.saveState()
			
			arc_x_start = origin_x + (radius+5)*math.cos(startAngle_rad)
			arc_y_start = origin_y + (radius+5)*math.sin(startAngle_rad)
			
			arc_x_end = origin_x+(radius+5)*math.cos(endAngle_rad)
			arc_y_end = origin_y+(radius+5)*math.sin(endAngle_rad)
			
			# draw label
			#c.setStrokeColorRGB(0,0,1)
			#c.setFillColorRGB(0,0,1)
			c.setStrokeColor(fColor)
			c.setFillColor(fColor)
			c.setFont("Helvetica-Bold", 12)
			c.saveState()
			
			# draw line
			delta = 45
			
			if fStart < seqLen/2:
				
				if arc_y_start > origin_y:
					
					# THIS WORKS!!!!
					c.setStrokeColor(fColor)
					c.setFillColor(fColor)
					c.setLineWidth(1)
					c.saveState()
					
					fInd = fStartPos.index(fStart)
					fY = len(fStartPos) - fInd

					c.line(arc_x_start, arc_y_start, arc_x_start+math.fabs(math.sin(delta))*(fInd*10), arc_y_start+math.fabs(math.cos(delta))*(fY*10))

					#c.setStrokeColorRGB(0,0,1)
					#c.setFillColorRGB(0,0,1)

					c.setStrokeColor(textColor)
					c.setFillColor(textColor)
		
					c.setFont("Helvetica-Bold", 8)
					c.saveState()

					#c.drawString(arc_x_start+math.fabs(math.sin(delta))*(fInd*10)+2, arc_y_start+math.fabs(math.cos(delta))*(fY*10)-math.cos(delta)*0.9, fValue + " (" + `fStart` + "-" + `fEnd` + ")")
					
					c.drawString(arc_x_start+math.fabs(math.sin(delta))*(fInd*10)+2, arc_y_start+math.fabs(math.cos(delta))*(fY*10)-math.cos(delta)*0.9, fTxt)

					c.restoreState()
					
				else:
					fInd = fStartPos.index(fStart)
					fY = len(fStartPos) - fInd

					c.setStrokeColor(fColor)
					c.setFillColor(fColor)
					c.setLineWidth(1)
					c.saveState()
					
					c.line(arc_x_start, arc_y_start, arc_x_start+math.fabs(math.sin(delta))*(fY*10), arc_y_start-math.fabs(math.cos(delta))*(fInd*10))
				
					c.restoreState()
					
					#c.setStrokeColorRGB(0,0,1)
					#c.setFillColorRGB(0,0,1)
					
					c.setStrokeColor(textColor)
					c.setFillColor(textColor)
		
					c.setFont("Helvetica-Bold", 8)
					c.saveState()
				
					#c.drawString(arc_x_start+math.fabs(math.sin(delta))*(fY*10)+2, arc_y_start-math.fabs(math.cos(delta))*(fInd*10)-math.cos(delta)*13, fValue + " (" + `fStart` + "-" + `fEnd` + ")")
					
					c.drawString(arc_x_start+math.fabs(math.sin(delta))*(fY*10)+2, arc_y_start-math.fabs(math.cos(delta))*(fInd*10)-math.cos(delta)*13, fTxt)
					
					c.restoreState()
			else:
				if arc_y_start > origin_y:
					
					fInd = fStartPos.index(fStart)
					fY = len(fStartPos) - fInd

					c.setStrokeColor(fColor)
					c.setFillColor(fColor)
					c.setLineWidth(1)
					c.saveState()
					
					c.line(arc_x_start, arc_y_start, arc_x_start-math.fabs(math.sin(delta)*(fY*10)), arc_y_start+math.fabs(math.cos(delta)*(fInd*10)))
					
					c.restoreState()
					
					# draw label
					#c.setStrokeColorRGB(0,0,1)
					#c.setFillColorRGB(0,0,1)
					
					c.setStrokeColor(textColor)
					c.setFillColor(textColor)
		
					c.setFont("Helvetica-Bold", 8)
					c.saveState()
					
					#c.drawRightString(arc_x_start-math.fabs(math.sin(delta)*(fY*10))+2, arc_y_start+math.fabs(math.cos(delta)*(fInd*10)), fValue + " (" + `fStart` + "-" + `fEnd` + ")")
					
					c.drawRightString(arc_x_start-math.fabs(math.sin(delta)*(fY*10))+2, arc_y_start+math.fabs(math.cos(delta)*(fInd*10)), fTxt)
					
					c.restoreState()
				else:
					
					fInd = fStartPos.index(fStart)
					fY = len(fStartPos) - fInd

					c.setStrokeColor(fColor)
					c.setFillColor(fColor)
					c.setLineWidth(1)
					c.saveState()
					
					c.line(arc_x_start, arc_y_start, arc_x_start-math.fabs(math.sin(delta)*(fInd*10)), arc_y_start-math.fabs(math.cos(delta)*(fY*10)))
				
					c.restoreState()
					
					# draw label
					#c.setStrokeColorRGB(0,0,1)
					#c.setFillColorRGB(0,0,1)
					
					c.setStrokeColor(textColor)
					c.setFillColor(textColor)

					c.setFont("Helvetica-Bold", 8)
					c.saveState()
					
					#c.drawRightString(arc_x_start-math.fabs(math.sin(delta)*(fInd*10))-2, arc_y_start-math.fabs(math.cos(delta)*(fY*10))-math.cos(delta)*12, fValue + " (" + `fStart` + "-" + `fEnd` + ")")
					
					c.drawRightString(arc_x_start-math.fabs(math.sin(delta)*(fInd*10))-2, arc_y_start-math.fabs(math.cos(delta)*(fY*10))-math.cos(delta)*12, fTxt)
					
					c.restoreState()

	# print Oligo info
	#prev_legend = prev_legend-10
	prev_legend = 1365
	
	t = c.beginText()
	t.setStrokeColor(black)
	t.setFillColor(black)
	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_labels, prev_legend-15)
	t.textOut("Sequencing primers for " + reagentID + ":")
	c.drawText(t)
	c.restoreState

	prev_legend = prev_legend-18
	
	fColor = "#7cfc00"

	# sort oligos
	tmp_oligos = {}
	
	#print `oligoFeatures`
	
	for oFeature in oligoFeatures:
		oligoID = oFeature.getFeatureName()
		#print oligoID
		oligoStart = oFeature.getFeatureStartPos()
		#print oligoStart
		
		if tmp_oligos.has_key(oligoStart):
			tmp_o_list = tmp_oligos[oligoStart]
		else:
			tmp_o_list = []
			tmp_oligos[oligoStart] = oFeature
		
		tmp_o_list.append(oFeature)
		tmp_oligos[oligoStart] = tmp_o_list
		
		oligoSeq = oFeature.getFeatureDescrType()
		#print oligoSeq
	
	#print `tmp_oligos`

	for oligoStart in sorted(tmp_oligos.keys()):
		oFeatures = tmp_oligos[oligoStart]
		
		for oFeature in oFeatures:
			oligoID = oFeature.getFeatureName()
			#oligoSeq = oFeature.getFeatureDescrType()
			oligoTm = oFeature.getFeatureDescrName()
			oligoEnd = oFeature.getFeatureEndPos()
			oligoDir = oFeature.getFeatureDirection()
			
			o_rID = oligoIDsDict[oligoID]
			oligoName = oligoNamesDict[o_rID]
			
			#if oligoDir == 'forward':
				#oligoType = 'Sense'
			#else:
				#oligoType = 'Antisense'
			
			c.setStrokeColor(fColor)
			c.setFillColor(fColor)
			c.saveState()
			c.rect(ox_labels+5, prev_legend-15, 15,6, 1, 1)
			c.restoreState
		
			t = c.beginText()
			t.setStrokeColor(black)
			t.setFillColor(black)
			t.setFont("Helvetica-Bold", 10)
			t.setTextOrigin(ox_labels+25, prev_legend-15)
			
			if len(oligoName) > 0:
				#t.textOut(oligoID + ": " + oligoName + " (" + `oligoStart` + "-" + `oligoEnd` + ")" ", " + oligoType)
				t.textOut(oligoID + ": " + oligoName + " (" + `oligoStart` + "-" + `oligoEnd` + ")" ", " + oligoDir)
			else:
				#t.textOut(oligoID + ": (" + `oligoStart` + "-" + `oligoEnd` + ")" ", " + oligoType)
				t.textOut(oligoID + ": (" + `oligoStart` + "-" + `oligoEnd` + ")" ", " + oligoDir)
			
			#print oligoID + ": (" + `oligoStart` + "-" + `oligoEnd` + ")" ", " + oligoType
			
			c.drawText(t)
			c.restoreState
			prev_legend = prev_legend-15
		
			c.restoreState()
	
	c.showPage()
	c.save()
示例#32
0
from general_handler import *
from reagent_handler import *
from sequence_handler import DNAHandler, ProteinHandler
from comment_handler import CommentHandler
#from system_set_handler import SystemSetHandler
from sequence_handler import SequenceHandler
from reagent import *

import utils

from user_handler import UserHandler
from project_database_handler import ProjectDatabaseHandler
from session import Session
from exception import *

dbConn = DatabaseConn()
db = dbConn.databaseConnect()

cursor = db.cursor()
hostname = dbConn.getHostname()
root_path = dbConn.getRootDir()

dnaHandler = DNAHandler(db, cursor)
protHandler = ProteinHandler(db, cursor)
rHandler = ReagentHandler(db, cursor)
oHandler = OligoHandler(db, cursor)
propHandler = ReagentPropertyHandler(db, cursor)
packetHandler = ProjectDatabaseHandler(db, cursor)

propMapper = ReagentPropertyMapper(db, cursor)
prop_Name_ID_Map = propMapper.mapPropNameID()  # (prop name, prop id)
示例#33
0
from database_conn import DatabaseConn
from exception import *

from reagent import Reagent
from user import User

from reagent_handler import ReagentHandler
from user_handler import UserHandler
from location_database_handler import LocationHandler

from general_handler import *
from mapper import *

from session import Session

dbConn = DatabaseConn()
db = dbConn.databaseConnect()

cursor = db.cursor()
hostname = dbConn.getHostname()

rHandler = ReagentHandler(db, cursor)
lHandler = LocationHandler(db, cursor)

###################################################################################################################################
# This is an AJAX function invoked via Javascript from reagent search page
# Written June 8, 2009, by Marina Olhovsky
# Last modified June 8, 2009
###################################################################################################################################
def deleteReagent(form):
	
示例#34
0
def drawMap():
	
	dbConn = DatabaseConn()
	db = dbConn.databaseConnect()
	
	cursor = db.cursor()
	hostname = dbConn.getHostname()
	root_path = dbConn.getRootDir()
	
	form = cgi.FieldStorage(keep_blank_values="True")
	
	#print "Content-type:text/html"
	#print
	#print `form`
	
	if form.has_key("rID"):
		rID = form.getvalue("rID")
	else:
		#rID = 148913	# V4550
		rID = 29125
		#rID = 72 
		#rID = 309
		#rID = 1901	# small feature labels @ start of seq. overlap
		#rID = 36415
		#print rID

	reagentID = rHandler.convertDatabaseToReagentID(rID)
	
	#print "Content-type:text/html"
	#print
	#print reagentID
	
	namePropID = pHandler.findReagentPropertyInCategoryID(prop_Name_ID_Map["name"], prop_Category_Name_ID_Map["General Properties"])
		
	rName = rHandler.findSimplePropertyValue(rID, namePropID)
	#rName = rHandler.findSimplePropertyValue(rID, prop_Name_ID_Map["name"])
	rTypeID = rHandler.findReagentTypeID(rID)
	
	try:
		os.remove(root_path + "Reagent/vector_maps/" + reagentID + "_map.pdf")
	except OSError:
		pass
	
	#print root_path
	
	c = Canvas(root_path + "Reagent/vector_maps/" + reagentID + "_map.pdf")
	
	c.setPageSize((1000,1000))
	c.setStrokeColorRGB(0,0,0)
	c.saveState()
	
	# Draw circle
	origin = 0
	origin_x = 500
	origin_y = 470
	radius = 200

	c.circle(origin_x, origin_y, radius)
	c.restoreState()
	
	# Divide circle into 100-unit sectors
	rSeqID = rHandler.findDNASequenceKey(rID)
	rSeq = sHandler.findSequenceByID(rSeqID)
	seqLen = len(rSeq)
	
	#print "Content-type:text/html"
	#print
	#print `rID`
	
	unit_angle_measure = float(360) / float(seqLen)
	#print unit_angle_measure
	
	# Mark 1 on the circle - KEEP, Karen said!
	c.setLineWidth(1)
	c.setStrokeColor(black)
	c.setFillColor(black)
	c.saveState()
	
	path = c.beginPath()
	path.moveTo(origin_x, origin_y+radius+7)
	path.lineTo(origin_x-5, origin_y+radius+14)
	path.lineTo(origin_x+5, origin_y+radius+14)
	path.lineTo(origin_x, origin_y+radius+7)
	c.drawPath(path, True, True)
	
	# label 1
	t = c.beginText()
	t.setStrokeColor(black)
	t.setFillColor(black)
	t.setFont("Helvetica-Bold", 16)
	t.setTextOrigin(origin_x-5, origin_y+radius+19)
	t.textOut("1")
	c.drawText(t)
	
	c.restoreState()

	# Calculate feature segment sizes
	sequenceFeatures = rHandler.findReagentSequenceFeatures(rID)
	#print `sequenceFeatures`
	
	# Draw legend
	ox_legend = 800
	oy_legend = 985
	
	prev_legend = oy_legend
	
	# draw frame
	c.setStrokeColor(darkgray)
	#c.setStrokeColor(white)
	#c.setFillColor(lightgrey)
	c.setFillColor(white)
	c.saveState()
	
	# Output the rest of the features in alphabetical order - Moved here Jan. 26/10
	#featureNames = featureNameColorMap.keys()
	
	#print `featureNameColorMap.keys()`
	#print len(featureNameColorMap.keys())
	
	#fnames = rtPropHandler.findReagentTypeAttributeNamesByCategory(rTypeID, prop_Category_Name_ID_Map["DNA Sequence Features"])
	#fnames.remove('expression system')
	#fnames.remove('tag position')
	
	#print `fnames`
	#print len(fnames)
	
	featureNames = rtPropHandler.findReagentTypeAttributeNamesByCategory(rTypeID, prop_Category_Name_ID_Map["DNA Sequence Features"])
	featureNames.sort()
	
	#print `featureNames`
	#print prev_legend-240
	#print prev_legend-15-len(featureNames)*15
	
	#c.rect(ox_legend-25, prev_legend-240, 215, 235, 1, 1)
	#c.rect(ox_legend-25, prev_legend-15-len(featureNames)*15, 215, 10+len(featureNames)*15, 1, 1)	# good for list of all db features
	
	if len(featureNames) > 15:
		origin_spacer = -19
		coeff = 12
	else:
		origin_spacer = 65
		coeff = 15
	
	#origin_legend = prev_legend+65-len(featureNames)*15
	origin_legend = prev_legend+origin_spacer-len(featureNames)*coeff
	
	x = (990 - origin_legend) / len(featureNames)
	#print x
	
	if x < 12:
		x = 12
		
	legend_height = len(featureNames)*x + 15
	#print legend_height
	
	c.rect(ox_legend-25, origin_legend-17, 215, legend_height, 1, 1)	# good for specific rtype attributes
	
	c.restoreState()
	
	# Order: 5' site, 3' site, 5' linker, 3' linker, then the rest
	sites_color = featureNameColorMap["5' cloning site"]		# same for 3' site
	
	# 5' site
	c.setStrokeColor(sites_color)
	c.setFillColor(sites_color)
	c.saveState()
	c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
	c.restoreState
	
	t = c.beginText()
	#t.setStrokeColor(black)
	t.setStrokeColor(sites_color)
	#t.setFillColor(black)
	t.setFillColor(sites_color)
	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_legend+12, prev_legend-20)
	t.textOut(" - " + "5' CLONING SITE")
	c.drawText(t)
	c.restoreState
	
	prev_legend = prev_legend-15
	
	# 3' site
	c.setStrokeColor(sites_color)
	c.setFillColor(sites_color)
	c.saveState()
	c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
	c.restoreState
	
	t = c.beginText()
	#t.setStrokeColor(black)
	#t.setFillColor(black)

	t.setStrokeColor(sites_color)
	t.setFillColor(sites_color)

	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_legend+12, prev_legend-20)
	t.textOut(" - " + "3' CLONING SITE")
	c.drawText(t)
	c.restoreState

	prev_legend = prev_legend-15
	
	# Show legend for linkers
	linkers_color = featureNameColorMap["5' linker"]
	
	# 5' linker
	c.setStrokeColor(linkers_color)
	c.setFillColor(linkers_color)
	c.saveState()
	c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
	c.restoreState
	
	t = c.beginText()
	#t.setStrokeColor(black)
	#t.setFillColor(black)
	
	t.setStrokeColor(linkers_color)
	t.setFillColor(linkers_color)
	
	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_legend+12, prev_legend-20)
	t.textOut(" - " + "5' LINKER")
	c.drawText(t)
	c.restoreState

	prev_legend = prev_legend-15
	
	# 3' linker
	c.setStrokeColor(linkers_color)
	c.setFillColor(linkers_color)
	c.saveState()
	c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
	c.restoreState
	
	t = c.beginText()
	#t.setStrokeColor(black)
	#t.setFillColor(black)

	t.setStrokeColor(linkers_color)
	t.setFillColor(linkers_color)

	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_legend+12, prev_legend-20)
	t.textOut(" - " + "3' LINKER")
	c.drawText(t)
	c.restoreState

	prev_legend = prev_legend-15
	
	## Output the rest of the features in alphabetical order
	#featureNames = featureNameColorMap.keys()
	#featureNames.sort()
	
	#print `featureNames`
	
	for featureName in featureNames:
		if featureNameColorMap.has_key(featureName):
			color = featureNameColorMap[featureName]
		#else:
			#continue
			
			if featureName != "5' cloning site" and featureName != "3' cloning site" and featureName != "5' linker" and featureName != "3' linker" and color != None:
				#print featureName
				c.setStrokeColor(color)
				c.setFillColor(color)
				c.saveState()
				c.rect(ox_legend-15, prev_legend-20, 25,8, 1, 1)
				c.restoreState
				
				t = c.beginText()
				
				#t.setStrokeColor(black)
				#t.setFillColor(black)
				
				t.setStrokeColor(color)
				t.setFillColor(color)

				t.setFont("Helvetica-Bold", 10)
				t.setTextOrigin(ox_legend+12, prev_legend-20)
				t.textOut(" - " + featureName.upper())
				c.drawText(t)
				
				c.restoreState
				
				prev_legend = prev_legend-15
	#print prev_legend
	
	# Print reagent ID and size at the centre of the circle and print name at the top of the page
	c.setFont("Helvetica-Bold", 32)
	c.setFillColor(black)
	c.saveState()
	
	c.drawCentredString(origin_x, origin_y+35, reagentID)
	c.drawCentredString(origin_x, origin_y+10, "nt 1 - " + `seqLen`)
	
	if rName:
		c.setFillColor(blue)
		c.drawCentredString(origin_x, 935, rName)
	
	c.restoreState()
	
	# SORT features by size, so that short features are not hidden behind the long ones
	fSizes = []
	sortedFeatures = []
	
	for feature in sequenceFeatures:
		fSize = int(feature.getFeatureSize())
		
		if fSize > 0:
			fSizes.append(fSize)
	
	fSizes.sort(reverse=True)
	#print `fSizes`
	
	for fs in fSizes:
		for feature in sequenceFeatures:
			fSize = feature.getFeatureSize()

			# added existence check July 17/08 - different features may have same sizes so end up with duplicate features in list (e.g. cloning sizes appeared twice on the map)
			if fs == fSize and feature not in sortedFeatures:
				sortedFeatures.append(feature)
	
	#print `sortedFeatures`
	
	ox_labels = 40
	oy_labels = 910
	prev_legend = oy_labels

	t = c.beginText()
	t.setStrokeColor(black)
	t.setFillColor(black)
	t.setFont("Helvetica-Bold", 10)
	t.setTextOrigin(ox_labels, prev_legend-15)
	t.textOut("Features shorter than 150 nt:")
	c.drawText(t)
	c.restoreState

	prev_legend = prev_legend-18

	#for feature in sequenceFeatures:
	for feature in sortedFeatures:
		fType = feature.getFeatureType()
		fValue = feature.getFeatureName()
		fSize = feature.getFeatureSize()
		
		#print fType
		#print fValue
		#print fSize
		
		fColor = featureNameColorMap[fType]
		
		if fType == 'cdna insert':
			fValue = "cDNA Insert"
			
		elif fType == 'promoter':
			fValue = fValue + " " + fType
		
		fStart = feature.getFeatureStartPos()
		fEnd = feature.getFeatureEndPos()
		fDir = feature.getFeatureDirection()
		
		if fSize > 0:
			f_start = fStart * unit_angle_measure
		
			#print "Start " + `fStart`
			#print "End " + `fEnd`
		
			startAngle = 90 - f_start
			#print "Start angle " + `startAngle`
			
			f_end = fEnd * unit_angle_measure
			endAngle = 90 - f_end
			#print "End angle " + `endAngle`
			
			extAngle = -1*(f_end - f_start)
			#print "Ext angle " + `extAngle`

			x1 = origin_x - radius
			y1 = origin_y - radius
			
			x2 = origin_x + radius
			y2 = origin_y + radius
			
			p = c.beginPath()
			#t = c.beginText()
			
			c.setLineWidth(10)
			c.setLineJoin(1)
			
			fColor = featureNameColorMap[fType]
			c.setStrokeColor(fColor)
			c.saveState()
			
			p.arc(x1, y1, x2, y2, startAngle, extAngle)
			c.drawPath(p)
			c.restoreState()
			
			## jan. 27/10: this makes a contour for each arc
			#p = c.beginPath()
			#c.setLineWidth(1)
			
			##fColor = featureNameColorMap[fType]
			#c.setStrokeColor(black)
			#c.setFillColor(fColor)
			#c.saveState()
			
			#p.arc(x1+5, y1+5, x2-5, y2-5, startAngle, extAngle)
			#c.drawPath(p)
			##c.restoreState()
			
			##c.setLineWidth(1)
			
			##fColor = featureNameColorMap[fType]
			##c.setStrokeColor(black)
			##c.setFillColor(fColor)
			##c.saveState()
			
			#p.arc(x1-5, y1-5, x2+5, y2+5, startAngle, extAngle)
			#c.drawPath(p)
			#c.restoreState()	# jan. 27/10 modification ends here
			
			
			# common to all
			startAngle_rad = (startAngle * math.pi) / 180.0
			endAngle_rad = (endAngle * math.pi) / 180.0
			
			#c.setStrokeColor(black)
			#c.setFillColor(black)
			
			c.setStrokeColor(fColor)
			c.setFillColor(fColor)
			
			c.setFont("Helvetica-Bold", 9)
			c.saveState()
			
			arc_x_start = origin_x + (radius+5)*math.cos(startAngle_rad)
			arc_y_start = origin_y + (radius+5)*math.sin(startAngle_rad)
			
			arc_x_end = origin_x+(radius+5)*math.cos(endAngle_rad)
			arc_y_end = origin_y+(radius+5)*math.sin(endAngle_rad)
			
			# draw label
			c.setStrokeColorRGB(0,0,1)
			c.setFillColorRGB(0,0,1)
			c.setFont("Helvetica-Bold", 12)
			c.saveState()
			
			# draw line
			delta = 45
			
			# Rotate labels only for SMALL features (they can be crammed together)
			#if fSize > 100:
				#delta = 45
			#else:
				#delta = 32
			
			if fStart < seqLen/2:
				if arc_y_start > origin_y:
					
					#c.setStrokeColor(black)
					#c.setFillColor(black)
					
					c.setStrokeColor(fColor)
					c.setFillColor(fColor)
					
					c.setLineWidth(1)
					c.saveState()
					
					#if fSize <= 100:
						#c.line(arc_x_start, arc_y_start, arc_x_start+50*math.fabs(math.sin(delta)), arc_y_start+55*math.fabs(math.cos(delta)))
					#else:

					# July 17/08: Show labels for long features only
					if fSize > 150:
						c.line(arc_x_start, arc_y_start, arc_x_start+50*math.fabs(math.sin(delta)), arc_y_start+55*math.fabs(math.cos(delta)))
				
					c.restoreState()
					
					# July 17/08: Show labels for long features only
					if fSize > 150:
					
						# draw label
						
						#c.setStrokeColorRGB(0,0,1)
						#c.setFillColorRGB(0,0,1)
						
						c.setStrokeColor(fColor)
						c.setFillColor(fColor)

						c.setFont("Helvetica-Bold", 11)
						c.saveState()

						c.drawString(arc_x_start+50*math.fabs(math.sin(delta)), arc_y_start+55*math.fabs(math.cos(delta)), fValue + " (" + `fStart` + "-" + `fEnd` + ")")
	
					else:
						c.setStrokeColor(fColor)
						c.setFillColor(fColor)
						c.saveState()
						c.rect(ox_labels+5, prev_legend-15, 15,6, 1, 1)
						c.restoreState

						t = c.beginText()
						#t.setStrokeColor(black)
						#t.setFillColor(black)
					
						t.setStrokeColor(fColor)
						t.setFillColor(fColor)
					
						t.setFont("Helvetica-Bold", 10)
						t.setTextOrigin(ox_labels+25, prev_legend-15)
						t.textOut(fValue + " (" + `fStart` + "-" + `fEnd` + ")")
						c.drawText(t)
						c.restoreState
						prev_legend = prev_legend-15
					
					c.restoreState()
					
				else:
					#c.setStrokeColor(black)
					#c.setFillColor(black)
					
					c.setStrokeColor(fColor)
					c.setFillColor(fColor)
					
					c.setLineWidth(1)
					c.saveState()
					
					if fSize > 150:
						c.line(arc_x_start, arc_y_start, arc_x_start+50*math.fabs(math.sin(delta)), arc_y_start-55*math.fabs(math.cos(delta)))
						
					c.restoreState()
					
					# draw label
					if fSize > 150:
						
						#c.setStrokeColorRGB(0,0,1)
						#c.setFillColorRGB(0,0,1)
						
						c.setStrokeColor(fColor)
						c.setFillColor(fColor)

						c.setFont("Helvetica-Bold", 11)
						c.saveState()
						
						c.drawString(arc_x_start+50*math.fabs(math.sin(delta)), arc_y_start-55*math.fabs(math.cos(delta)), fValue + " (" + `fStart` + "-" + `fEnd` + ")")
					else:
						c.setStrokeColor(fColor)
						c.setFillColor(fColor)
						c.saveState()
						c.rect(ox_labels+5, prev_legend-15, 15,6, 1, 1)
						c.restoreState

						t = c.beginText()
						#t.setStrokeColor(black)
						#t.setFillColor(black)
						
						t.setStrokeColor(fColor)
						t.setFillColor(fColor)
						
						t.setFont("Helvetica-Bold", 10)
						t.setTextOrigin(ox_labels+25, prev_legend-15)
						t.textOut(fValue + " (" + `fStart` + "-" + `fEnd` + ")")
						c.drawText(t)
						c.restoreState
						prev_legend = prev_legend-15
						
					c.restoreState()
			else:
				if arc_y_start > origin_y:
					
					#c.setStrokeColor(black)
					#c.setFillColor(black)

					c.setStrokeColor(fColor)
					c.setFillColor(fColor)
					
					c.setLineWidth(1)
					c.saveState()
					
					if fSize > 150:
						c.line(arc_x_start, arc_y_start, arc_x_start-50*math.fabs(math.sin(delta)), arc_y_start+55*math.fabs(math.cos(delta)))
						
						#c.line(arc_x_start, arc_y_start, arc_x_start+10*math.fabs(math.sin(delta)), arc_y_start-10*math.fabs(math.cos(delta)))
				
					c.restoreState()
					
					# draw label
					if fSize > 150:
						#c.setStrokeColorRGB(0,0,1)
						#c.setFillColorRGB(0,0,1)
						
						c.setStrokeColor(fColor)
						c.setFillColor(fColor)

						c.setFont("Helvetica-Bold", 11)
						c.saveState()
						
						c.drawRightString(arc_x_start-50*math.fabs(math.sin(delta)), arc_y_start+55*math.fabs(math.cos(delta)), fValue + " (" + `fStart` + "-" + `fEnd` + ")")
					else:
						c.setStrokeColor(fColor)
						c.setFillColor(fColor)
						c.saveState()
						c.rect(ox_labels+5, prev_legend-15, 15,6, 1, 1)
						c.restoreState

						t = c.beginText()
						#t.setStrokeColor(black)
						#t.setFillColor(black)
						
						t.setStrokeColor(fColor)
						t.setFillColor(fColor)
						
						t.setFont("Helvetica-Bold", 10)
						t.setTextOrigin(ox_labels+25, prev_legend-15)
						t.textOut(fValue + " (" + `fStart` + "-" + `fEnd` + ")")
						c.drawText(t)
						c.restoreState
						prev_legend = prev_legend-15
							
					c.restoreState()
					
				else:
					#c.setStrokeColor(black)
					#c.setFillColor(black)
					
					c.setStrokeColor(fColor)
					c.setFillColor(fColor)
					
					c.setLineWidth(1)
					c.saveState()
					
					if fSize > 150:
						c.line(arc_x_start, arc_y_start, arc_x_start-50*math.fabs(math.sin(delta)), arc_y_start-55*math.fabs(math.cos(delta)))
				
					c.restoreState()
					
					# draw label
					if fSize > 150:
						
						#c.setStrokeColorRGB(0,0,1)
						#c.setFillColorRGB(0,0,1)
						
						c.setStrokeColor(fColor)
						c.setFillColor(fColor)
						
						c.setFont("Helvetica-Bold", 11)
						c.saveState()
						
						c.drawRightString(arc_x_start-50*math.fabs(math.sin(delta)), arc_y_start-55*math.fabs(math.cos(delta)), fValue + " (" + `fStart` + "-" + `fEnd` + ")")
						
						c.restoreState()
					else:
						c.setStrokeColor(fColor)
						c.setFillColor(fColor)
						c.saveState()
						c.rect(ox_labels+5, prev_legend-15, 15,6, 1, 1)
						c.restoreState

						t = c.beginText()
						#t.setStrokeColor(black)
						#t.setFillColor(black)
						
						t.setStrokeColor(fColor)
						t.setFillColor(fColor)
						
						t.setFont("Helvetica-Bold", 10)
						t.setTextOrigin(ox_labels+25, prev_legend-15)
						t.textOut(fValue + " (" + `fStart` + "-" + `fEnd` + ")")
						c.drawText(t)
						c.restoreState
						prev_legend = prev_legend-15
			
	c.showPage()
	c.save()