Build Papers Page Code

From GersteinInfo

Revision as of 11:40, 16 September 2011 by Public (Talk | contribs)
Jump to: navigation, search

update.py

Basic Setup

#!/usr/bin/python
import os, sys, re
from GoogleSpreadsheet import GoogleSpreadsheet
from datetime import datetime

pubmed_spreadsheet_id = "*******************"
master_spreadsheet_id = "********************"
subject_spreadsheet_id = "*************************"
worksheet_id = "od6"
pubmed_spreadsheet = GoogleSpreadsheet(pubmed_spreadsheet_id, worksheet_id)
master_spreadsheet = GoogleSpreadsheet(master_spreadsheet_id, worksheet_id)
subject_spreadsheet = GoogleSpreadsheet(subject_spreadsheet_id, worksheet_id)
timestamp = str(datetime.now().ctime())

summaryPath = "************"
summaryIndex = "*********************"
summaryFile = open(summaryIndex,'w')
simpleIndex = "*************"
simpleFile = open(simpleIndex,'w')
subjectPath = "********************"
subjectIndex = subjectPath + "index.html"
subjectFile = open(subjectIndex,'w')
subjectSummaryIndex = "******************"
subjectSummaryFile = open(subjectSummaryIndex,'w')

header = '''
***********
'''

Generate Main Page and page for each Paper

def printPapers(master_spreadsheet,summaryFile, header):
	out = "<HTML>\n"
	out += "<HEAD>\n"
	out += "<TITLE>Gerstein Lab Publications</TITLE>\n"
	out += header
	out += "\n"
	out += "<CENTER>\n"
	out += "<FONT FACE='sans-serif, Arial, Helvetica'><FONT SIZE=+2 COLOR=993333>Main Scientific Publications</FONT>\n"
	out += "\n"
	out += "<H3><FONT SIZE=\"4\" COLOR=\"#334499\">Total papers: " + str(len(master_spreadsheet)) + "</FONT></H3></FONT>\n"
	out += "<p>(Last updated " + timestamp + ")</CENTER>\n"
	years = {}
	currentYear = 0
	for row in master_spreadsheet:
		rowYear = row['year']
		if years.has_key(rowYear):
			years[rowYear] += 1
		else:
			years[rowYear] = 1
	for row in master_spreadsheet:
		pubmed = pubmed_spreadsheet
		if currentYear != row['year']:
			currentYear = row['year']
			out += "<H3 ALIGN=center><FONT FACE='arial,helvetica,sans-serif' COLOR=334499 SIZE=4>-- " + currentYear + " (" + str(years[currentYear]) + ") --</FONT></H3>"
		summaryFile.write(out)
		simpleFile.write(out)
		simpleFile2.write(out)	
		out = ""
		printPaperEntry(row, summaryFile, pubmed)
		printSimpleEntry(row, simpleFile, pubmed)
		printSimpleEntry(row,simpleFile2,pubmed)	
		printEntrySummary(row, header, pubmed)
		printEntryExtended(row)
	out = "</BODY></HTML>"
	summaryFile.write(out)
	simpleFile.write(out)

def printEntrySummary(row,header,pubmed):
	#if row['pmid']:
		#print 'pES first: ' + row['pmid']
	#else:
		#print 'pES first: no pmid'
	pubmed.count = 0
	for pubmed_row in pubmed:
		#print 'pES pubmed: ' + pubmed_row['pmid']
		if row['pmid'] == pubmed_row['pmid']:
			row['title'] = pubmed_row['title']
			row['citation'] = pubmed_row['citation']
			row['authors'] = pubmed_row['authors']
			row['year'] = pubmed_row['year']
			break
	# create summary directory
	entrySummary = summaryPath + row['labid'].lstrip('\'')
	if not os.path.exists(entrySummary):
		os.makedirs(entrySummary)
	entrySummaryIndex = entrySummary + "/index.html"
	entrySummaryFile = open(entrySummaryIndex,'w')
    
	out = "<HTML>\n"
	out += "<HEAD>\n"
	out += "<TITLE>" + row['title'].lstrip('\'') + "</TITLE>"
	out += header
	out += "\n"
	out += "<blockquote>\n"
	out += "<font size=+3><tt>" + row['labid'] + "</tt></font><p />"
	out += "\n"
	# print title and citation
	out += "<DIV CLASS=\"paperTitle\"><FONT SIZE=+1><B><A HREF=\"/papers/" + row['labid'].lstrip('\'') + "/index.html\">" + row['title'].lstrip('\'') + "</A></B></FONT></DIV>\n"
	if row.has_key('authors'):		
		out += "<DIV CLASS=\"paperCite\">" +row['authors'].lstrip('\'')+ " " +row['citation'].lstrip('\'') + "</DIV>\n"	
	else:		
		out += "<DIV CLASS=\"paperCite\">" + " " + row['citation'].lstrip('\'') + "</DIV>\n"	
	# print links
	out += "<DIV CLASS=\"paperCite\">"
	if not row['website']:
		out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
	else:
		out += "<A HREF=\"" + row['website'].lstrip('\'')  + "\"><IMG SRC=\"/papers/website.jpg\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\"></A>"
	if not row['preprint']:
		out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
	else:
		out += "<A HREF=\"" + row['preprint'].lstrip('\'') + "\"><IMG BORDER=\"0\" HEIGHT=\"23\" WIDTH=\"56\" SRC=\"/papers/preprint.jpg\"></A>"
	if not row['pmid']:
		out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
	else:
		out += "<A HREF=\"http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=" + row['pmid'].lstrip('\'') + "&dopt=Abstract\"><IMG BORDER=\"0\" HEIGHT=\"23\" WIDTH=\"56\" SRC=\"/papers/medline.jpg\"></A>"
	#if not labid:
	#	out += "<A HREF=\"#\">" + "<IMG BORDER=\"0\" WIDTH=\"23\" HEIGHT=\"23\" SRC=\"/papers/more.gif\"></A>"
	#else:
	out += "<A HREF=\"/papers/" + row['labid'].lstrip('\'') + "/index-all.html\">" + "<IMG BORDER=\"0\" WIDTH=\"23\" HEIGHT=\"23\" SRC=\"/papers/more.gif\"></A>"
	out += "</DIV>\n<P />\n"
    
	out += "<hr><br><a href=index-all.html>View all citation information</a><br><a href='/'>Return to papers index</a><br> </blockquote></BODY></HTML>"
	entrySummaryFile.write(out)

def printEntryExtended(row):
	title = ''
	citation = ''
	authors = ''
	journal = ''
	pages = ''
	volume = ''
	year = ''
	pmcid = ''

	for pubmed_row in pubmed_spreadsheet:
		if row['pmid'] == pubmed_row['pmid']:
			title = pubmed_row['title']
			citation = pubmed_row['citation']
			authors = pubmed_row['authors']
			year = pubmed_row['year']
			journal = pubmed_row['journal']
			pages = pubmed_row['pages']
			volume = pubmed_row['volume']
			pmcid = pubmed_row['pmcid']

	# create summary directory
	entryExtended = summaryPath + row['labid'].lstrip('\'')
	if not os.path.exists(entryExtended):
		os.makedirs(entryExtended)
	entryExtendedIndex = entryExtended + "/index-all.html"
	entryExtendedFile = open(entryExtendedIndex,'w')

	out = "<HTML>\n"
	out += "<HEAD>\n"
	if not title:
		out += "<TITLE>" + row['title'].lstrip('\'') + "</TITLE>"
	else:
		out += "<TITLE>" + title.lstrip('\'') + "</TITLE>"
	out += header
	out += "\n"
	out += "<blockquote>\n"
	if not row['labid']:
		out += "<font size=+3><tt>" + row['pmid'].lstrip('\'') + "</tt></font><p />"
	else:
		out += "<font size=+3><tt>" + row['labid'] + "</tt></font><p />"
	out += "\n"
	# print title and citation
	if not title:
		out += "<DIV CLASS=\"paperTitle\"><FONT SIZE=+1><B><A HREF=\"/papers/" + row['labid'].lstrip('\'') + "/index.html\">" + row['title'].lstrip('\'') + "</A></B></FONT></DIV>\n"
	else:
		out += "<DIV CLASS=\"paperTitle\"><FONT SIZE=+1><B><A HREF=\"/papers/" + row['labid'].lstrip('\'') + "/index.html\">" + title.lstrip('\'') + "</A></B></FONT></DIV>\n"
	if not citation:
	 	if not row.has_key('authors'):		
	 		out += "<DIV CLASS=\"paperCite\">" + " " + row['citation'].lstrip('\'') + "</DIV>\n"	
	#	out += "<DIV CLASS=\"paperCite\">" + " " + row['citation'].lstrip('\'') + "</DIV>\n"	
	 	else:		
	 		out += "<DIV CLASS=\"paperCite\">" + row['authors'].lstrip('\'') + " " +row['citation'].lstrip('\'') + "</DIV>\n"	
	else:
		out += "<DIV CLASS=\"paperCite\">" + authors.lstrip('\'') + ' ' + citation.lstrip('\'') + "</DIV>\n"
	# print links
	out += "<DIV CLASS=\"paperCite\">"
	if not row['website']:
		out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
	else:
		out += "<A HREF=\"" + row['website'].lstrip('\'')  + "\"><IMG SRC=\"/papers/website.jpg\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\"></A>"
	if not row['preprint']:
		out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
	else:
		out += "<A HREF=\"" + row['preprint'].lstrip('\'') + "\"><IMG BORDER=\"0\" HEIGHT=\"23\" WIDTH=\"56\" SRC=\"/papers/preprint.jpg\"></A>"
	if not row['pmid']:
		out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
	else:
		out += "<A HREF=\"http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=" + row['pmid'].lstrip('\'') + "&dopt=Abstract\"><IMG BORDER=\"0\" HEIGHT=\"23\" WIDTH=\"56\" SRC=\"/papers/medline.jpg\"></A>"
	#if not labid:
	#       out += "<A HREF=\"#\">" + "<IMG BORDER=\"0\" WIDTH=\"23\" HEIGHT=\"23\" SRC=\"/papers/more.gif\"></A>"
	#else:
	out += "<A HREF=\"/papers/" + row['labid'].lstrip('\'') + "/index-all.html\">" + "<IMG BORDER=\"0\" WIDTH=\"23\" HEIGHT=\"23\" SRC=\"/papers/more.gif\"></A>"
	out += "</DIV>\n<P />\n"

	out += '<A HREF="index.html">Switch to compact view</A><hr>\n<table>\n'
	if not authors:
		out += '<tr><td width=100><b><font color=gray>Authors</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n'
	else:
		out += '<tr><td width=100><b><font color=gray>Authors</font></b></td><td><b><font color=#000077>'
		link = '<A HREF="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=PureSearch&db=PubMed&details_term=%s">%s</A>'
		authorlinks = [link % (a.lstrip('\'').strip().replace(' ','%20'),a.lstrip('\'').strip()) for a in authors.split(',')]
		# print authorlinks
		out += ', '.join(authorlinks)
		out += '</font></b></td></tr>\n'
	if not journal:
		out += '<tr><td width=100><b><font color=gray>Journal</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n'
	else:
		out += '<tr><td width=100><b><font color=gray>Journal</font></b></td><td><b><font color=#000077>'
		out += '<A HREF="http://locatorplus.gov/cgi-bin/Pwebrecon.cgi?DB=local&v2=1&ti=1,1&Search_Arg=9808944&Search_Code=0359&CNT=20&SID=1">'
		out += journal + '</A></font></b></td></tr>'
	if not row['pmid']:
		out += "<tr><td width=100><b><font color=gray>PMID</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n"
	else:
		out += '<tr><td width=100><b><font color=gray>PMID</font></b></td><td><b><font color=#000077>'
		out += '<A HREF="http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=' + row['pmid'].lstrip('\'') + '&dopt=Abstract">'
		out +=  row['pmid'].lstrip('\'') + '</A></font></b></td></tr>\n'
	if not pages:
		out += "<tr><td width=100><b><font color=gray>Pages</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n"
	else:
		out += "<tr><td width=100><b><font color=gray>Pages</font></b></td><td><b><font color=#000077>" + pages.lstrip('\'') + "</font></b></td></tr>\n"
	if not volume:
		out += "<tr><td width=100><b><font color=gray>Volume</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n"
	else:
		out += "<tr><td width=100><b><font color=gray>Volume</font></b></td><td><b><font color=#000077>" + volume.lstrip('\'') + "</font></b></td></tr>\n"
	if not year:
		out += "<tr><td width=100><b><font color=gray>Year</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n"
	else:
		out += "<tr><td width=100><b><font color=gray>Year</font></b></td><td><b><font color=#000077>" + year.lstrip('\'') + "</font></b></td></tr>\n"
	out += "<tr><td width=100><b><font color=gray>labcite</font></b></td><td><b><font color=#000077>" + citation.lstrip('\'') + "</font></b></td></tr>\n"
	if not row['labid']:
		out += "<tr><td width=100><b><font color=gray>labid</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n"
	else:
		out += "<tr><td width=100><b><font color=gray>labid</font></b></td><td><b><font color=#000077>" + row['labid'].lstrip('\'') + "</font></b></td></tr>\n"
	if not title:
		out += "<tr><td width=100><b><font color=gray>labtitle</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n"
	else:
		out += "<tr><td width=100><b><font color=gray>labtitle</font></b></td><td><b><font color=#000077>" + title.lstrip('\'') + "</font></b></td></tr>\n"
	if not row['subject']:
		out += "<tr><td width=100><b><font color=gray>subject</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n"
	else:
		subjects = row['subject'].split(',')
		num_subjects = len(subjects)
		out += '<tr><td width=100><b><font color=gray>subject</font></b></td><td><b><font color=#000077>'
		subject_count = 0
		for subject in subjects:
			out += '<A HREF="/subject/' + subject.lstrip('\' ') + '">' + subject.lstrip('\' ') + '</A>'
			subject_count += 1
			if subject_count < num_subjects:
				out += ', '
		out += '</font></b></td></tr>\n'
	if not row['website']:
		out += "<tr><td width=100><b><font color=gray>website</font></b></td><td><b><font color=#000077> </font></b></td></tr>\n"
	else:
		out += '<tr><td width=100><b><font color=gray>website</font></b></td><td><b><font color=#000077><A HREF="'+row['website'].lstrip('\'')+'">'+row['website'].lstrip('\'')+'</A></font></b></td></tr>\n'
	
	out += "</table><br><font color=gray>Unused tags: <i>e-print footnote grant ignore preprint sortval target website2</i></font><hr><a href='/'>Return to papers index</a><br> </blockquote></BODY></HTML>"
	entryExtendedFile.write(out)

def printPaperEntry(row, summaryFile, pubmed):
	title = ''
	citation = ''
	authors = ''
	year = ''
	for pubmed_row in pubmed:
		if row['pmid'] == pubmed_row['pmid']:
			title = pubmed_row['title']
			citation = pubmed_row['citation']
			authors = pubmed_row['authors']
			year = pubmed_row['year']
			break
	# print title and citation
	if not title:
		out = "<DIV CLASS=\"paperTitle\"><FONT SIZE=+1><B><A HREF=\"/papers/" + row['labid'].lstrip('\'') + "/index.html\">" + row['title'] + "</A></B></FONT></DIV>\n"
	else:
		out = "<DIV CLASS=\"paperTitle\"><FONT SIZE=+1><B><A HREF=\"/papers/" + row['labid'].lstrip('\'') + "/index.html\">" + title.lstrip('\'') + "</A></B></FONT></DIV>\n"
	if not citation:
		if not row.has_key('authors'):	
			out += "<DIV CLASS=\"paperCite\">" + row['citation'].lstrip('\'') + "</DIV>\n"	
		else:	
			out += "<DIV CLASS =\"paperCite\">" + row['authors'].lstrip('\'') + " " + row['citation'].lstrip('\'') + "</DIV>\n"			
	else:
		out += "<DIV CLASS=\"paperCite\">" + authors.lstrip('\'') + " " + citation.lstrip('\'') + "</DIV>\n"
	# print links
	out += "<DIV CLASS=\"paperCite\">"
	if not row['website']:
		out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
	else:
		out += "<A HREF=\"" + row['website'].lstrip('\'')  + "\"><IMG SRC=\"/papers/website.jpg\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\"></A>"
	if not row['preprint']:
		out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
	else:
		out += "<A HREF=\"" + row['preprint'].lstrip('\'') + "\"><IMG BORDER=\"0\" HEIGHT=\"23\" WIDTH=\"56\" SRC=\"/papers/preprint.jpg\"></A>"
	if not row['pmid']:
		out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
	else:
		out += "<A HREF=\"http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=" + row['pmid'].lstrip('\'') + "&dopt=Abstract\"><IMG BORDER=\"0\" HEIGHT=\"23\" WIDTH=\"56\" SRC=\"/papers/medline.jpg\"></A>"
	#if not labid:
	#	out += "<A HREF=\"#\">" + "<IMG BORDER=\"0\" WIDTH=\"23\" HEIGHT=\"23\" SRC=\"/papers/more.gif\"></A>"
	#else:
	out += "<A HREF=\"/papers/" + row['labid'].lstrip('\'') + "/index-all.html\">" + "<IMG BORDER=\"0\" WIDTH=\"23\" HEIGHT=\"23\" SRC=\"/papers/more.gif\"></A>"
	out += "</DIV>\n<P />\n"
	summaryFile.write(out)

def printSimpleEntry(row, simpleFile, pubmed):
	pmid = ''
	title = ''
	citation = ''
	authors = ''
	year = ''
	#if row['pmid']:
		#print 'pSE first: ' + row['pmid']
	#else:
		#print 'pSE first: no pmid'
	pubmed.count = 0
	for pubmed_row in pubmed:
		#print 'pSE pubmed: ' + pubmed_row['pmid']
		if row['pmid'] == pubmed_row['pmid']:
			pmid = pubmed_row['pmid']
			title = pubmed_row['title']
			citation = pubmed_row['citation']
			authors = pubmed_row['authors']
			year = pubmed_row['year']
			pmcid = pubmed_row['pmcid']
			break
		#else:
			#print 'no match'
	if row['pmid']:
		out = '<DL COMPACT>' + authors.lstrip('\'') + ' (' + year.lstrip('\'') + '). "' + title.lstrip('\'') +'" '
		p = re.compile("\(\d+\)\.")	
		p2 = re.compile(":")
		citation = p.sub("",citation)
		citation = p2.sub(": ",citation)
		out += citation.lstrip('\'') + ' <FONT SIZE=-2>[PMID: ' + pmid + ']</FONT>.</DL>\n'
	else:
		#if not row['authors']:
		out = '<DL COMPACT>' +'"' + row['title'].lstrip('\'') + '." '
			#out = '<DL COMPACT>' + ' (' + row['year'].lstrip('\'') + '). "' + row['title'].lstrip('\'') +'" '
		#else:
			#out = '<DL COMPACT>' + row['authors'].lstrip('\'') + ' (' + row['year'].lstrip('\'') + '). "' + row['title'].lstrip('\'') +'" '
		out += row['citation'].lstrip('\'') + '</DL>\n'
	simpleFile.write(out)

def printSubject(master_spreadsheet,header): allsubjects = [] subjectpapers = [] for i,row in enumerate(master_spreadsheet): if row.has_key('subject') and row['subject']: #and row['pmid'].isdigit(): subjects = row['subject'].split(',') for subject in subjects: subject = subject.strip( ) if subject not in allsubjects: allsubjects.append(subject) subjectpapers.append([i]) else: index = allsubjects.index(subject) subjectpapers[index].append(i)

for row in subject_spreadsheet: subject = row['labid'].strip( ) if subject not in allsubjects: path = subjectPath + subject if not os.path.exists(path): os.makedirs(path) subjectFile = open(path + '/index.html', 'w') out = <HTML> <HEAD> <TITLE>%s</TITLE> %subject.capitalize()

out +=header include = if row['html']: include =row['html'].lstrip('\) if include: out += include subjectFile.write(out)

subjectFile.write('</FONT>
<A HREF = "/">Return to front page</A>\n</BODY></HTML>')

subjectFile.close()

for i,subject in enumerate(allsubjects): printSubjectFile(subject,subjectpapers[i])

def printSubjectFile(subject,papers): path = subjectPath + subject if not os.path.exists(path): os.makedirs(path) subjectFile = open(path + '/index.html','w')

  1. subjectInclude = path + '/include.html'

out = <HTML> <HEAD> <TITLE>%s</TITLE>  % subject.capitalize() out += header

#include include file if exists

  1. if os.path.exists(subjectInclude):
  2. includeFile = open(subjectInclude,'r')
  3. for line in includeFile:
  4. subjectFile.write(line + '\n')
  5. includeFile.close()
  6. subjectFile.write('\n\n')

include = for row in subject_spreadsheet: if row['labid'] == subject: if row['html']: include = row['html'].lstrip('\) if include: out += include subjectFile.write(out)

for r in papers: printSubjectEntry(subjectFile,r)

subjectFile.write(' </FONT>
<A HREF= "/">Return to front page</A>\n</BODY></HTML>')

subjectFile.close()

def printSubjectEntry(subjectFile,r): row = master_spreadsheet.rows[r] found = False for sr in pubmed_spreadsheet: if row['pmid'] == sr['pmid']: #row['labid'] = sr['labid'] row['title'] = sr['title'] row['authors'] = sr['authors'] row['year'] = sr['year'] row['citation'] = sr['citation'] #row['website'] = sr['website'] #row['preprint'] = sr['preprint'] found = True # break if found:

       	# print title and citation

if not row['labid']:

out = "
" + row['title'].lstrip('\) + "</A>
\n"

else:

out = "
<A HREF=\"/papers/" + row['labid'].lstrip('\) + "/index.html\">" + row['title'].lstrip('\) + "</A>
\n" out += "
" + row['authors'].lstrip('\) + " " + row['citation'].lstrip('\) + "
\n"
       	# print links
out += "
"
       	if not row['website']:
               	out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
       	else:
               	out += "<A HREF=\"" + row['website'].lstrip('\)  + "\"><IMG SRC=\"/papers/website.jpg\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\"></A>"
       	if not row['preprint']:
               	out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
       	else:
               	out += "<A HREF=\"" + row['preprint'].lstrip('\) + "\"><IMG BORDER=\"0\" HEIGHT=\"23\" WIDTH=\"56\" SRC=\"/papers/preprint.jpg\"></A>"
       	if not row['pmid']:
               	out += "<IMG SRC=\"/papers/null.gif\" HEIGHT=\"23\" WIDTH=\"56\" BORDER=\"0\">"
       	else:
               	out += "<A HREF=\"http://www.ncbi.nlm.nih.gov:80/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=" + row['pmid'].lstrip('\) + "&dopt=Abstract\"><IMG BORDER=\"0\" HEIGHT=\"23\" WIDTH=\"56\" SRC=\"/papers/medline.jpg\"></A>"
       	if not row['labid']:
               	out += "<A HREF=\"#\">" + "<IMG BORDER=\"0\" WIDTH=\"23\" HEIGHT=\"23\" SRC=\"/papers/more.gif\"></A>"
       	else:
               	out += "<A HREF=\"/papers/" + row['labid'].lstrip('\) + "/index-all.html\">" + "<IMG BORDER=\"0\" WIDTH=\"23\" HEIGHT=\"23\" SRC=\"/papers/more.gif\"></A>"
out += "
\n<P />\n"

subjectFile.write(out)

def printSubjectSummary(subject_spreadsheet, subjectSummaryFile, header): styleSubject =
<STYLE type="text/css"> .unsel{background-color:#ffffff; background-position:top; background-repeat:repeat-x; color:#FFFFFF; font-weight:normal;} .sel {background-color:#3b5998; color:#FFFFFF; font-weight:normal;} .content{background-color:#ffffff; height:25px; padding-left:20px; padding-right:20px; padding-top:20px;color:#ffffff;}

       a{text-decoration:none;color:#ffffff;}

.unsel a:link {color:#888888;text-decoration:none;} .sel a:visited {color:#ffffff;text-decoration:none;} .sel a:active {color:#ffffff;text-decoration:none;} .sel a:hover {color:#ffffff;text-decoration:underline;} </STYLE>

category = SubjectNumber = 0 outPart = out = "<HTML>\n" out += "<HEAD>\n" out += "<TITLE>Gerstein Lab Publications</TITLE>\n" out += header out += "\n" out += styleSubject out += '<BODY onload="javascript:showdh(3);">\n'

out += '\n\n\n'

for row in subject_spreadsheet: if not category == row['category'].lstrip('\): if not category == :

outPart += "</TD>\n" SubjectNumber +=1 tableid = str(SubjectNumber) category = row['category'].lstrip('\) out +='<TD width="86" class="unsel" id="dh'+tableid+'">
<A href="javascript:showdh('+tableid+');" _fcksavedurl="javascript:showdh('+tableid+');">'+ row['category'].lstrip('\) + '</A>
</TD>\n'

out += ' <TD width="6"></TD>\n' outPart +='<TR id="menu'+ tableid+'" style="display:none">\n' outPart +='<TD class="content" style="line-height:25px">\n' outPart += " <A HREF='/subject/" + row['labid'].lstrip('\)+"/index.html' STYLE='text-decoration:none; color:black'>" title = str(row['title']) outPart += "[ "+row['labid'].lstrip('\)+" ] "+title.lstrip('\)+"</A>
\n" outPart += "</TD></TR>\n"

out += '</TR></TABLE>\n
\n' out += outPart out += <script language="javascript"> function showdh(n){ for(var i=1;i<= + tableid+;i++){ eval("dh" + i).className="unsel" eval("menu"+i).style.display="none"; } eval("dh"+n).className="sel" eval("menu"+n).style.display=""; } </script> out += "</BODY></HTML>" subjectSummaryFile.write(out) printSubjectSummary(subject_spreadsheet, subjectSummaryFile, header) printSubject(master_spreadsheet,header) printPapers(master_spreadsheet, summaryFile, header) </pre>
Personal tools