Commits

Hanfei Sun committed 1e9add2 Draft

add integration to cistrome

  • Participants
  • Parent commits 36ed804

Comments (0)

Files changed (10)

File cistromeprimerscanner/__init__.py

     ucsc_hg19_engine = engine_from_config(settings,"sqlalchemy.ucsc.hg19.")
     UCSC_DBSession_hg19.configure(bind=ucsc_hg19_engine)
 
-    ucsc_mm9_engine = engine_from_config(settings,"sqlalchemy.ucsc.mm9.")    
+    ucsc_mm9_engine = engine_from_config(settings,"sqlalchemy.ucsc.mm9.")
     UCSC_DBSession_mm9.configure(bind=ucsc_mm9_engine)
 
-    # ucsc_dc_temp_engine = engine_from_config(settings,"sqlalchemy.dc_temp.")    
+    # ucsc_dc_temp_engine = engine_from_config(settings,"sqlalchemy.dc_temp.")
     # DC_TEMP_DBSession.configure(bind=ucsc_dc_temp_engine)
 
-    
+
     config = Configurator(settings=settings)
-    config.add_static_view('finder/statics', 'cistromeprimerscanner:templates/static', cache_max_age=604800)
+    config.add_static_view('/statics', 'cistromeprimerscanner:templates/static', cache_max_age=604800)
 
-    config.add_route('CF_home', '/finder')
-    config.add_route('CF_datasets', '/finder/dataset/result')
+    config.add_route('CF_home', '/')
+    config.add_route('CF_datasets', '/dataset/result')
 
-    config.add_route('CF_sequence_config', '/finder/site/config')
-    config.add_route('CF_sequences', '/finder/site/result')
+    config.add_route('CF_sequence_config', '/site/config')
+    config.add_route('CF_sequences', '/site/result')
 
-    config.add_route('CF_factors',"/finder/factor")
-    config.add_route("CF_factor_result", "/finder/factor/result")
-    config.add_route("CF_google_webmaster", "/finder/google2e5d3e24ec0feb18.html")
-    config.add_route('CF_primer3_clone', '/finder/util/primer3')
-    config.add_route('CF_viewer_dcresult', '/finder/util/dc')
-    config.add_route('CF_viewer_summary', '/finder/util/summary')
-    config.add_route('CF_profile_UCSC_adapter',"/finder/util/UCSC")
-    config.add_route('CF_profile_provider',"/finder/util/temp_storage")
-    config.add_route('CF_meta',"/finder/util/meta")
-    config.add_route("CF_help", "/finder/help")
-    
+    config.add_route('CF_factors',"/factor")
+    config.add_route("CF_factor_result", "/factor/result")
+    config.add_route("CF_google_webmaster", "/google2e5d3e24ec0feb18.html")
+    config.add_route('CF_primer3_clone', '/util/primer3')
+    config.add_route('CF_viewer_dcresult', '/util/dc')
+    config.add_route('CF_viewer_summary', '/util/summary')
+    config.add_route('CF_profile_UCSC_adapter',"/util/UCSC")
+    config.add_route('CF_profile_provider',"/util/temp_storage")
+    config.add_route('CF_meta',"/util/meta")
+    config.add_route('CF_pure_meta',"/util/pure_meta")
+    config.add_route("CF_help", "/help")
+
     config.scan()
     return config.make_wsgi_app()
-

File cistromeprimerscanner/models.py

 class Dataset(Base):
     __tablename__ = "datacollection_datasets"
     id = Column(Integer, primary_key=True)
-    treatments = Column(String)
     summit_file = Column(String)
     treat_bw_file = Column(String)
     conservation_file = Column(String)
     summary_file = Column(String)
     ceas_file = Column(String)
-    
+
 class DatasetTreat(Base):
     __tablename__ = "datacollection_datasets_treats"
     id = Column(Integer, primary_key=True)
     samples_id = Column(Integer, ForeignKey("datacollection_samples.id"))
     dataset = relationship(Dataset, backref = 'control', order_by = "Dataset.id")
     sample = relationship(Sample, backref = 'control', order_by = "Sample.id")
-
-

File cistromeprimerscanner/scripts/peakretriever/__init__.py

             tss_path = tss_f.name
     else:
         tss_path = setting.tss_location[species]
-    print tss_path
+    # print tss_path
 
     p_tss_extract = Popen(slop_tss(tss_path, distance = d_TSS_to), stdout=PIPE)
 #    Region to extract peaks
     @type  command: str
     @param command: the command you want to run, for example, "ls -l"
     """
-    print "Run: %s" % command
+    # print "Run: %s" % command
     subpcall(command, shell=True)
     return
 

File cistromeprimerscanner/scripts/peakretriever/annoparser.py

 def preload_database(_session_):
     # results = _session_.query(RefGene.name,RefGene.txStart,
     #                           RefGene.txEnd,,RefGene.strand,RefGene.name2).all()
-    print _session_.bind
+    # print _session_.bind
     chroms = _session_.query(RefGene.chrom).all()
     chroms = set(chroms)
 
     return gene_anno
 
 def Info(infoStr):
-    print "[%s] %s" %(time.strftime('%H:%M:%S'), infoStr)
+    pass
+    # print "[%s] %s" %(time.strftime('%H:%M:%S'), infoStr)
 
 class PCA:
     # connect to sqlite, select genome.

File cistromeprimerscanner/templates/home_bindingsites.mako

 
 ##<h3 class="center">Current Page is for Dataset  ${did} (${request.GET.get("tf","")})</h3>
 <div id="wrap" class="clearfix">
-    <div id="nav" class="center">
-        <ul class="menu">
-            <li><a href="${request.route_path("CF_meta")}?did=${did}" class="lightbox">Check Meta Data</a>
-            <li><a href="${request.route_path("CF_viewer_summary")}?did=${did}" class="lightbox">Check QC report</a>
-            </li>
-            <li class="current"><a
-                    href="${request.route_path("CF_sequence_config")}?did=${did}&amp;tf=${request.GET.get('tf',"")}">Find
-                Binding Sites</a>
-            </li>
-        </ul>
-    </div>
+  <div id="nav" class="center">
+    <ul class="menu">
+      <li><a href="${request.route_path("CF_meta")}?did=${did}" class="lightbox">Check Meta Data</a>
+      <li><a href="${request.route_path("CF_viewer_summary")}?did=${did}" class="lightbox">Check QC report</a>
+      </li>
+      <li class="current"><a
+			     href="${request.route_path("CF_sequence_config")}?did=${did}&amp;tf=${request.GET.get('tf',"")}">Find
+          Binding Sites</a>
+      </li>
+      <li>
+	<form method='POST' action='http://cistrome.org/ap/tool_runner' id="BedtoCistrome" target="_blank">
+	  <input type='HIDDEN' value='cistrome_finder' name='tool_id' />
+	  <input type='HIDDEN' value='bed' name='data_type' />			
+	  <input type='HIDDEN' value='http://cistrome.org/finder/util/dc?did=${did}&type=summit_file', name='URL' />
+ 	  <input type='HIDDEN' value='${did}_summit.bed', name='name' />			
+	</form>
 
+	<a href="#" onclick="$('#BedtoCistrome').submit()">Send BED file to Cistrome</a>
+      </li>
+    </ul>
+  </div>
 
-    <div class="col_8" id="right_column">
-        <%block name="left_bindingsites">
-                <script>$("#right_column").addClass("visible")</script>
-                <br>
-                <br>
-                <br> <br> <br>
-                <br> <br>
-                <br>
-                <h4 class="center">Please choose the region you're interested in</h4>
-                <br>
-                <br>
-                <br>
-                <br>
-                <br>
-                <br>
-                <br>
-                <br>
 
-        </%block>
-    </div>
+  <div class="col_8" id="right_column">
+    <%block name="left_bindingsites">
+    <script>$("#right_column").addClass("visible")</script>
+    <br>
+    <br>
+    <br> <br> <br>
+    <br> <br>
+    <br>
+    <h4 class="center">Please choose the region you're interested in</h4>
+    <br>
+    <br>
+    <br>
+    <br>
+    <br>
+    <br>
+    <br>
+    <br>
 
-    <div class="col_4">
-        <%include file="right_bindingsites.mako" />
-        <%block name="right_bindingsites_bottom" />
-    </div>
+</%block>
+</div>
 
-    <%include file="footer.mako" />
+<div class="col_4">
+  <%include file="right_bindingsites.mako" />
+  <%block name="right_bindingsites_bottom" />
+</div>
+
+<%include file="footer.mako" />

File cistromeprimerscanner/templates/home_meta.mako

     <title>Meta Data for ${request.GET.get("did", None)}</title>
 </head>
 <body>
-<h4 class="center">Meta Data of Dataset ${qset.id}</h5>
-    <% treats = qset.treat %>
-    <% controls = qset.control %>
-
-    <table>
-        <thead>
-        <tr>
-            <th>
-                Group
-            </th>
-            <th>
-                Sample ID
-            </th>
-            <th>
-                Species
-            </th>
-            <th>
-                Factor
-            </th>
-            <th>
-                CellLine
-            </th>
-
-            <th>
-                CellType
-            </th>
-            <th>
-                CellPop
-            </th>
-            <th>
-                Tissue
-            </th>
-            <th>
-                Disease
-            </th>
-            <th>
-                Condition
-            </th>
-            <th>
-                Paper
-            </th>
-	    <th>
-	      Authors
-	    </th>
-            <th>
-                URL
-            </th>
-
-        </tr>
-        </thead>
-        <tbody>
-                % for a_treat in treats:
-                <% sample = a_treat.sample %>
-                    <%include file="meta_format.mako" args="sample=sample, group='Treatment'" />
-                % endfor
-
-                % for a_control in controls:
-                <% sample = a_control.sample %>
-                    <%include file="meta_format.mako" args="sample=sample, group='Control'" />
-                % endfor
-        </tbody>
-    </table>
+ <%include file="pure_meta.mako" />
 </body>
 </html>

File cistromeprimerscanner/templates/meta_format.mako

     <td>
             % if sample.paper:
             ${sample.paper.title}
-                <br>
+                <br />
                 PMID: ${sample.paper.pmid}
             % endif
     </td>

File cistromeprimerscanner/templates/result_comm.mako

                 <a href="${request.route_path('CF_sequence_config')}?did=${ds.id}&amp;tf=${request.GET.get('tf',None)}"
                    class="button blue tool-tip center normal"
                    title="Use this Dataset for Querying and Evaluating Binding Sites"
-                   target="_blank"> Use This Dataset </a>
+                   target="_blank"> Analysis Dataset </a>
+		   <br><br>
+	<form method='POST' action='http://cistrome.org/ap/tool_runner' id="BedtoCistrome_${ds.id}">
+	  <input type='HIDDEN' value='cistrome_finder' name='tool_id' />
+	  <input type='HIDDEN' value='bed' name='data_type' />			
+	  <input type='HIDDEN' value='http://cistrome.org/finder/util/dc?did=${ds.id}&type=summit_file', name='URL' />
+ 	  <input type='HIDDEN' value='${ds.id}_summit.bed', name='name' />			
+	</form>
+		   
+	<a href="#" onclick="$('#BedtoCistrome_${ds.id}').submit()" class="button tool-tip center normal"
+	title="Send the summit file to Cistrome"> Import to Cistrome </a>
 
 
             </td>

File cistromeprimerscanner/templates/static/html_ks/js/bindingsites.js

             $("#Gene_box").removeClass("error") } })
 
 
+
 });

File cistromeprimerscanner/views.py

     return Response("google-site-verification: google2e5d3e24ec0feb18.html")
 
 @view_config(route_name='CF_meta', renderer='home_meta.mako')
+@view_config(route_name='CF_pure_meta', renderer='pure_meta.mako')
 def cf_meta(request):
     did = request.GET.get("did", None)
     if not did:
                     return Response(content_type='application/pdf', body=open(dcresult_path).read())
                 except:
                     return Response("Sorry, we haven't run this file yet")
+            elif ftype == "summit_file":
+                try:
+                    return Response(content_type='plain/text',
+                                    body=open(dcresult_path).read(),
+                                    content_disposition='attachment; filename="%s_summit.bed"'%did
+                                    )
+                except:
+                    return Response("Sorry, we haven't run this file yet")                
             else:
                 try:
                     return Response(content_type='image/png', body=open(dcresult_path).read())