Changeset 281
- Timestamp:
- 01/26/08 23:02:35 (10 months ago)
- Files:
-
- trunk/cartwheel-server/lib/cartwheel/website/LeafFolder.py (modified) (1 diff)
- trunk/cartwheel-server/tests/functional-tests/test-with-user/test-web/__init__.py (modified) (1 diff)
- trunk/cartwheel-server/website/canal/__init__.py (modified) (2 diffs)
- trunk/cartwheel-server/website/canal/motif/__init__.py (modified) (3 diffs)
- trunk/cartwheel-server/website/canal/motif/analyze.ptl (modified) (20 diffs)
- trunk/cartwheel-server/website/canal/motif/pages.ptl (modified) (11 diffs)
- trunk/cartwheel-server/website/canal/pages.ptl (modified) (3 diffs)
- trunk/cartwheel-server/website/canal/templates.ptl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cartwheel-server/lib/cartwheel/website/LeafFolder.py
r273 r281 64 64 c = DeepCatalog(m, NamedMotif, 65 65 limits, 66 "ORDER BY UPPER(named_motifs.name)")66 "ORDER BY named_motifs.id") 67 67 68 68 return c trunk/cartwheel-server/tests/functional-tests/test-with-user/test-web/__init__.py
r239 r281 140 140 follow('admin') 141 141 code('200') 142 143 def test_style(): 144 "Load the style file" 145 146 go('http://localhost/style') 147 code('200') trunk/cartwheel-server/website/canal/__init__.py
r4 r281 15 15 'my', # personal page 16 16 'stats', # server statistics 17 'locked'] # locked-out account. 17 'locked', # locked-out account. 18 'style' ] # CSS 18 19 19 20 import quixote … … 58 59 59 60 return request.redirect(request.get_url(1)) 61 62 # 63 # style 64 # 65 66 def style(request): 67 from templates import get_style_contents 68 response = request.response 69 response.set_content_type('text/css') 70 return get_style_contents() trunk/cartwheel-server/website/canal/motif/__init__.py
r280 r281 8 8 import cartwheel.website 9 9 10 from canal.templates import header, footer 10 from canal.templates import header, footer, wrap 11 11 from canal.motif import utils 12 12 from canal.motif.analyze import AnalyzeSequenceHandler … … 121 121 """ % (motif.name,) 122 122 123 return htmlfill.render(formhtml, values)123 return wrap(htmlfill.render(formhtml, values), show_anything=False) 124 124 125 125 def edit_pwm_motif(request, motif): … … 197 197 formhtml = htmlfill.render(formhtml, values) 198 198 199 return str(header("Edit PWM Motif '%s'" % (name,))) + \200 formhtml + \201 str(display_pwm_information(pwm, sequences, threshold)) + \202 str(footer())199 return wrap(htmlfill.render(formhtml, values), 200 display_pwm_information(pwm, sequences, threshold), 201 title="Edit PWM Motif '%s'" % (name,), 202 show_anything = False) 203 203 204 204 def batch_export(request): trunk/cartwheel-server/website/canal/motif/analyze.ptl
r279 r281 9 9 10 10 import cartwheel.website 11 from canal.templates import header, footer 11 from canal.templates import header, footer, wrap 12 12 13 13 import pygr_draw … … 29 29 Do the motif search & use pygr_draw to actually draw a picture. 30 30 """ 31 seq_start -= 1 # adjust for users thinking ! 0 31 32 32 33 sequencedb = dict(sequence=pygr.sequence.Sequence(dna_seq.seq,'sequence')) … … 81 82 template _q_index(self, request): 82 83 form = request.form 83 start = int(form.get('start', 0))84 start = max(start, 0)84 start = int(form.get('start', 1)) 85 start = max(start, 1) 85 86 86 87 stop = int(form.get('stop', len(self.seq.seq))) 87 88 stop = min(len(self.seq.seq), stop) 89 90 start, stop = min(start, stop), max(start, stop) 91 92 if form.get('reset_coords'): 93 start = 1 94 stop = len(self.seq.seq) 95 96 ### 88 97 89 98 (folder, motifs) = get_folder_motifs(self.manager, request) … … 98 107 """ 99 108 <p> 109 <a href='../'>return to motif library page</a> 110 <hr> 100 111 <h4>Motif matches graphed against sequence:</h4> 101 112 <a href='draw_pdf?start=%d&stop=%d'>(download as PDF)</a><br> … … 116 127 key = motif.simple_key() 117 128 118 search_results = motif.search(self.seq, start , stop)129 search_results = motif.search(self.seq, start - 1, stop) 119 130 120 131 param_dict = dict(motif_id=motif.id, start=start, stop=stop) … … 137 148 <p> 138 149 <input type='submit' value='redraw'> 150 <input type='submit' value='show entire sequence' name='reset_coords'> 139 151 </form> 152 <p> 153 <a href='../'>return to motif library page</a> 140 154 """ % (start, stop) 141 155 … … 144 158 def draw_png(self, request): 145 159 form = request.form 146 seq_start = int(form.get('start', 0))147 seq_start = max(seq_start, 0)160 seq_start = int(form.get('start', 1)) 161 seq_start = max(seq_start, 1) 148 162 149 163 seq_stop = int(form.get('stop', len(self.seq.seq))) 150 164 seq_stop = min(len(self.seq.seq), seq_stop) 165 166 seq_start, seq_stop = min(seq_start, seq_stop),max(seq_start, seq_stop) 151 167 152 168 (folder, motifs) = get_folder_motifs(self.manager, request) … … 161 177 def draw_pdf(self, request): 162 178 form = request.form 163 seq_start = int(form.get('start', 0))164 seq_start = max(seq_start, 0)179 seq_start = int(form.get('start', 1)) 180 seq_start = max(seq_start, 1) 165 181 166 182 seq_stop = int(form.get('stop', len(self.seq.seq))) 167 183 seq_stop = min(len(self.seq.seq), seq_stop) 184 185 seq_start, seq_stop = min(seq_start, seq_stop),max(seq_start, seq_stop) 168 186 169 187 (folder, motifs) = get_folder_motifs(self.manager, request) … … 192 210 template matches_detail_IUPAC(self, request, motif): 193 211 form = request.form 194 seq_start = int(form.get('start', 0))195 seq_start = max(seq_start, 0)212 seq_start = int(form.get('start', 1)) 213 seq_start = max(seq_start, 1) 196 214 197 215 seq_stop = int(form.get('stop', len(self.seq.seq))) 198 216 seq_stop = min(len(self.seq.seq), seq_stop) 199 217 200 matches = motif.search(self.seq, seq_start, seq_stop) 218 seq_start, seq_stop = min(seq_start, seq_stop),max(seq_start, seq_stop) 219 220 matches = motif.search(self.seq, seq_start - 1, seq_stop) 201 221 202 222 ### sort … … 236 256 Mismatches allowed: %d<p> 237 257 <p> 258 <a href='./'>return to analysis page</a> 238 259 <hr> 239 260 """ % (name, len(self.seq.seq), … … 269 290 """ 270 291 <tr><td>%d</td><td>%d</td><td>%s</td><td>%s</td></tr> 271 """ % (start , stop, o, match_seq,)292 """ % (start + 1, stop, o, match_seq,) 272 293 273 294 """ 274 295 </table> 296 <p> 297 <a href='./'>return to analysis page</a> 275 298 """ 276 299 … … 279 302 template matches_detail_PWM(self, request, motif): 280 303 form = request.form 281 seq_start = int(form.get('start', 0))282 seq_start = max(seq_start, 0)304 seq_start = int(form.get('start', 1)) 305 seq_start = max(seq_start, 1) 283 306 284 307 seq_stop = int(form.get('stop', len(self.seq.seq))) 285 308 seq_stop = min(len(self.seq.seq), seq_stop) 286 309 310 seq_start, seq_stop = min(seq_start, seq_stop),max(seq_start, seq_stop) 311 287 312 ## 288 313 289 314 pwm = motif.make_pwm() 290 matches = motif.search(self.seq, seq_start , seq_stop)315 matches = motif.search(self.seq, seq_start - 1, seq_stop) 291 316 292 317 # add in score. … … 332 357 Default threshold: %f 333 358 <p> 359 <a href='./'>return to analysis page</a> 334 360 <hr> 335 361 """ % (name, len(self.seq.seq), … … 367 393 """ 368 394 <tr><td>%d</td><td>%d</td><td>%s</td><td>%s</td><td>%.2f</td></tr> 369 """ % (start , stop, o, match_seq, score)395 """ % (start + 1, stop, o, match_seq, score) 370 396 371 397 """ 372 398 </table> 399 <p> 400 <a href='./'>return to analysis page</a> 373 401 """ 374 402 … … 383 411 seq_stop = min(len(self.seq.seq), seq_stop) 384 412 413 seq_start, seq_stop = min(seq_start, seq_stop),max(seq_start, seq_stop) 414 385 415 ### 386 416 … … 388 418 motif = self.manager.load(motif_id) 389 419 390 matches = motif.search(self.seq, seq_start , seq_stop)420 matches = motif.search(self.seq, seq_start - 1, seq_stop) 391 421 392 422 s = """# motif: %s/%s/%d mismatches\n# sequence: %s\n""" % \ … … 395 425 l = ["start,stop,orientation,match"] 396 426 for (start, stop, orientation, match_seq) in matches: 397 l.append("%d,%d,%d,%s" % (start, stop, orientation, match_seq,)) 427 l.append("%d,%d,%d,%s" % (start + 1, stop, 428 orientation, match_seq,)) 398 429 399 430 request.response.set_content_type('text/plain') … … 409 440 seq_stop = min(len(self.seq.seq), seq_stop) 410 441 442 seq_start, seq_stop = min(seq_start, seq_stop),max(seq_start, seq_stop) 443 411 444 ### 412 445 … … 416 449 consensus = motif.simple_key() 417 450 pwm = motif.make_pwm() 418 matches = motif.search(self.seq, seq_start , seq_stop)451 matches = motif.search(self.seq, seq_start - 1, seq_stop) 419 452 420 453 s = """# PWM motif %s: consensus %s/threshold %f\n# sequence: %s\n"""%\ … … 426 459 l = ["start,stop,orientation,match,score"] 427 460 for (start, stop, orientation, match_seq, score) in matches: 428 l.append("%d,%d,%d,%s,%s" % (start , stop, orientation, match_seq,429 score,))461 l.append("%d,%d,%d,%s,%s" % (start + 1, stop, 462 orientation, match_seq, score,)) 430 463 431 464 request.response.set_content_type('text/plain') trunk/cartwheel-server/website/canal/motif/pages.ptl
r280 r281 1 1 import cartwheel.website 2 from canal.templates import header, footer 2 from canal.templates import header, footer, wrap, error 3 3 from cartwheel.website.IUPACMotif import IUPACMotif 4 4 from cartwheel.website.PWMMotif import PWMMotif … … 62 62 <hr> 63 63 64 <b>Add motifs:</b> <a href="add_iupac">add a simple motif</a> | 65 <a href="build_pwm_from_list">build a matrix (PWM) 64 <b>Add motifs:</b> <ul> 65 <li> <a href="add_iupac">add a simple motif</a> 66 <li> <a href="build_pwm_from_list">build a matrix (PWM) 66 67 from a list of sites</a> 67 68 <!-- | 69 <font color='red'>import a matrix from JASPAR (not yet!)</font> --> 68 <li> <a href="">import matrix from JASPAR</a> 69 </ul> 70 71 70 72 <p> 71 73 """ … … 86 88 87 89 """ 88 <b>Other actions:</b> 89 <a href="batch_export">export motifs to a text file</a> | 90 <a href="batch_import">import motifs from a text file</a> 90 <b>Other actions:</b> <ul> 91 <li> <a href="batch_export">export motifs to a text file</a> 92 <li> <a href="batch_import">import motifs from a text file</a> 93 </ul> 91 94 <p> 92 95 <a href="../">Return to folder menu</a> … … 101 104 102 105 if not request.form: 103 return """\106 return wrap("""\ 104 107 <h2>Add an IUPAC motif</h2> 105 108 <form method='POST' action='add_iupac'> … … 130 133 N G or A or T or C 131 134 </pre></blockquote> 132 """ 135 """, show_anything=False) 133 136 134 137 d = make_add_iupac_motif_form(request) … … 139 142 140 143 if not (request.form and name and iupac_str and mismatches): 141 return "ERROR: you have to enter name and motif!"144 return error("ERROR: you have to enter name and motif!") 142 145 143 146 errors = [] … … 153 156 154 157 if errors: 155 return "ERROR:<p><ul><li> %s</ul>" % ("<li>".join(errors))158 return error("ERROR:<p><ul><li> %s</ul>" % ("<li>".join(errors))) 156 159 157 160 ### create the motif & put it into the database … … 185 188 def build_pwm_from_list(request): 186 189 if not request.form: 187 return """\190 return wrap("""\ 188 191 <form method="POST"> 189 192 <h3>Build a matrix motif (PWM) from a list of known sites</h3> 190 Name: <input type='text' name='name'> 191 <p> 192 Aligned sequences:<br> 193 <textarea name='sequences' rows='5' cols='30'></textarea> 194 <p> 195 <input type='submit' value='build PWM'> 196 </form> 197 <hr> 193 198 194 <b>Instructions:</b> 199 195 <p> 200 196 To build a matrix motif (a.k.a. Position-Weight Matrix, or PWM), 201 enter a list of ungapped, aligned sequences. For example, here is a list 197 enter a list of ungapped, aligned sequences. 198 <p> 199 For example, here is a list 202 200 of GATA-type motifs: 203 201 <pre> … … 209 207 After submitting this list, a matrix motif will be built and you can 210 208 then define a threshold for searches. 211 """ 209 <p> 210 <hr> 211 Name: <input type='text' name='name'> 212 <p> 213 Aligned sequences:<br> 214 <textarea name='sequences' rows='5' cols='30'></textarea> 215 <p> 216 <input type='submit' value='build PWM'> 217 </form> 218 <p> 219 Note: PWMs are built as in Wasserman and Sandelin, Nat Rev 220 Genet. 2004 Apr;5(4):276-87 (PubMed ID 15131651; <a 221 href='http://www.ncbi.nlm.nih.gov/pubmed/15131651'>PubMed Record</a>). 222 See Box 1 of that paper for details. 223 <hr> 224 """, show_anything=False) 212 225 213 226 errors = [] … … 229 242 230 243 if errors: 231 return "ERROR:<p><ul><li> %s</ul>" % ("<li>".join(errors,))244 return error("ERROR:<p><ul><li> %s</ul>" % ("<li>".join(errors,))) 232 245 233 246 ### ok, validation good so far. build the PWM & display... … … 340 353 """ 341 354 <p> 342 Maximum threshold: %.2 g343 """ % ( pwm.max_score(),)355 Maximum threshold: %.2f 356 """ % (round(pwm.max_score(), 2)) 344 357 345 358 if len(pwm) < 10: trunk/cartwheel-server/website/canal/pages.ptl
r4 r281 21 21 conf = cartwheel.website.get_config() 22 22 """ 23 Welcome to %s! 23 <h2>Welcome to %s!</h2> 24 <p> 24 25 """ % (cartwheel.config.get_server_name(conf),) 26 27 news() 25 28 26 29 user = request.session.get_user() … … 29 32 <p> 30 33 This computer is currently logged in as <b>%s</b>. You can either 31 <a href="logout">log out</a>, <a href="lab/">continue this session</a>,34 <a href="logout">log out</a>, <a href="lab/">continue</a>, 32 35 or use this form to log in as a different user. 33 36 <p> … … 382 385 """ 383 386 387 ### 388 389 template news(): 390 """ 391 <p> 392 393 Cartwheel is a system for cis-regulatory analysis; it lets you create 394 custom analyses and display the results. 395 396 <p> 397 Accounts are free and simply to create -- just click "add account"! 398 399 <p> 400 401 For a tutorial on using Cartwheel and FamilyRelations, please 402 visit <a href="http://family.caltech.edu/tutorial/">family.caltech.edu/tutorial/</a>. 403 404 <P> 405 """ trunk/cartwheel-server/website/canal/templates.ptl
r4 r281 14 14 if title: 15 15 title = title + " -- " 16 else: 17 title = "" 18 19 request = quixote.get_request() 20 base_path = request.get_environ('SCRIPT_NAME') 16 21 17 22 """ 18 23 <html> 19 24 <head> 20 <title>%sCartwheel Analysis Server</title> 25 <link REL="stylesheet" TYPE="text/css" href="%(base_path)s/style"> 26 <title>%(title)sCartwheel Analysis Server</title> 21 27 </head> 22 28 <body bgcolor=white> 23 """ % (title,)29 """ % dict(title=title, base_path=base_path,) 24 30 25 31 # … … 27 33 # 28 34 29 def footer[html](show_functions= 1):35 def footer[html](show_functions=True, show_anything=True): 30 36 request = quixote.get_request() 31 37 base_path = request.get_environ('SCRIPT_NAME') … … 40 46 41 47 functions_html = '' 42 if show_functions :48 if show_functions and show_anything: 43 49 admin_html = '' 44 50 session = quixote.publish.get_request().session … … 67 73 <p> 68 74 """ % pageDict 69 # <a href="%(base_path)s/start/FR/jnlp"><b>start FamilyRelations</b></a> /70 75 71 76 # … … 73 78 # 74 79 80 if show_anything: 81 """ 82 <hr> 83 <font size=-1> 84 %s 85 Questions? Comments? Contact the server administrator at <a href="mailto:%s"><i>%s</i></a>. 86 </font> 87 """ % (functions_html, admin_email, admin_email) 88 75 89 """ 76 <hr>77 <font size=-1>78 %s79 Problems? Questions? Contact the server administrator at <a href="mailto:%s"><i>%s</i></a>.80 </font>81 90 </body> 82 """ % (functions_html, admin_email, admin_email) 91 """ 92 93 def wrap[html](*content, **kw): 94 title = kw.get('title') 95 show_functions = kw.get('show_functions', True) 96 show_anything = kw.get('show_anything', True) 97 98 text = "".join([ htmltext(i) for i in content ]) 99 100 return header(title) + text + footer(show_functions, show_anything) 101 102 def error[html](error_text): 103 return wrap(error_text, title="ERROR!", show_anything=False) 104 105 def get_style_contents(): 106 return """\ 107 h1,h2,h3 { 108 padding: 30px 0; 109 # background: #655A46; 110 color: #333; 111 # color: #E4DBCF; 112 font-size: 1.4em; 113 # letter-spacing: 3px; 114 margin: 0; 115 # text-align: right; 116 # font: normal 3.4em "Lucida Sans Unicode","Trebuchet MS",sans-serif; 117 } 118 119 body,p,table,li,hr 120 { 121 font-family: verdana, arial, 'sans serif'; 122 font-size: 95% 123 } 124 125 body 126 { 127 #ffffff; 128 } 129 130 a:link {COLOR: navy;} 131 a:visited {COLOR: navy;} 132 /* a:active {COLOR: seashell;} */ 133 a:hover {COLOR: navy;} 134 135 div { 136 margin:0; 137 padding:0 .25em 0 0; 138 /* text-align: right 139 border:1px solid #aaa; 140 background-color:#ececec; */ 141 } 142 """
