Exemplo n.º 1
0
 def upload(self, network_name=None, network_file=None, annotations_file=None, type="public", email="*****@*****.**"):
     #cherrypy.log("Privacy: "+ type)
     #cherrypy.log("annotations: "+ repr(network_file))
     #cherrypy.log("network: "+ repr(annotations_file))
     if cherrypy.request.method == "GET":
         tmpl = lookup.get_template("upload_form.mako")
         return tmpl.render() 
     else:
         network_name = pinv.clean(network_name)
         solr_url = '%s/solr/%s'%(settings.SOLR_SERVER,network_name)
         time.sleep(2)
         inv = InteractionNetwork(network_name, "description text", network_file.file, annotations_file.file)
         time.sleep(2)
         message, result = pinv.create_new_solr(network_name)
         time.sleep(2)
         cherrypy.log("*** UPLOAD. Connecting to: "+ solr_url)
         si = sunburnt.SolrInterface(solr_url)
         time.sleep(2)
         inv.upload(si)
         inv.createClusters(si,3,7)
         cherrypy.log(str(inv.errors));
         view_key, delete_key = auth.save_key(network_name, email,type)
         if type == "private":
             view_url = "http://biosual.cbio.uct.ac.za/pinViewer.html?core=%(core)s&key=%(key)s" % {'core':network_name,'key':view_key}
             delete_url = "http://biosual.cbio.uct.ac.za/solr/admin/cores?action=UNLOAD&deleteIndex=true&core=%(core)s&key=%(key)s" % {'core':network_name,'key':delete_key}
         else:
             view_url = "http://biosual.cbio.uct.ac.za/pinViewer.html?core=%(core)s" % {'core':network_name}
             delete_url = "http://biosual.cbio.uct.ac.za/solr/admin/cores?action=UNLOAD&deleteIndex=true&core=%(core)s&key=%(key)s" % {'core':network_name,'key':delete_key}
         msg =auth.sendmail(email,view_url, delete_url,network_name)
         #cherrypy.log(msg);
         errormessage = "<br/>".join(inv.errors)
         tmpl = lookup.get_template("upload_result.mako")
         return tmpl.render(network_name=network_name, 
                            annotation_head="|".join(inv.ahead), 
                            annotation_count=len(inv.annotations),
                            annotation_file=annotations_file.filename,
                            network_head="|".join(inv.nhead), 
                            network_count=len(inv.network),
                            network_file=network_file.filename,
                            message="",
                            errors="<br/>".join(inv.errors))
Exemplo n.º 2
0
 def upload(self, network_name, network_file, annotations_file):
     out = """<html>
     <body>
         Network name: %s<br/><br/>
         
         Annotations columns: %s<br/>
         Annotations count: %i<br />
         Annotations filename: %s<br />
         
         Network head: %s<br />
         Network length: %i<br />
         Network filename: %s<br />
         
         %s
                 <br/>
                 Errors:<br/>
                 %s
     </body>
     </html>"""
     network_name = pinv.clean(network_name)
     if settings.TEST and not (network_file.file and annotations_file.file):
         network_file.file = open("../data/test.txt")
         annotations_file.file = open("../data/test_annot.txt")
     solr_url = settings.SOLR_URL
     solr_url = '%s/solr/%s' % (settings.SOLR_SERVER, network_name)
     time.sleep(2)
     inv = InteractionNetwork(network_name, "description text",
                              network_file.file, annotations_file.file)
     time.sleep(2)
     message, result = pinv.create_new_solr(network_name)
     time.sleep(2)
     print "--- UPLOAD. Connecting to:", solr_url
     si = sunburnt.SolrInterface(solr_url)
     time.sleep(2)
     inv.upload(si)
     errormessage = "<br/>".join(inv.errors)
     return out % (network_name, "|".join(inv.ahead), len(
         inv.annotations), repr(annotations_file.filename), "|".join(
             inv.nhead), len(inv.network), repr(
                 network_file.filename), message, errormessage)
Exemplo n.º 3
0
 def upload(self,
            network_name=None,
            network_file=None,
            annotations_file=None,
            type="public",
            email="*****@*****.**"):
     #cherrypy.log("Privacy: "+ type)
     #cherrypy.log("annotations: "+ repr(network_file))
     #cherrypy.log("network: "+ repr(annotations_file))
     if cherrypy.request.method == "GET":
         tmpl = lookup.get_template("upload_form.mako")
         return tmpl.render()
     else:
         network_name = pinv.clean(network_name)
         solr_url = '%s/solr/%s' % (settings.SOLR_SERVER, network_name)
         time.sleep(2)
         inv = InteractionNetwork(network_name, "description text",
                                  network_file.file, annotations_file.file)
         time.sleep(2)
         message, result = pinv.create_new_solr(network_name)
         time.sleep(2)
         cherrypy.log("*** UPLOAD. Connecting to: " + solr_url)
         si = sunburnt.SolrInterface(solr_url)
         time.sleep(2)
         inv.upload(si)
         inv.createClusters(si, 3, 7)
         cherrypy.log(str(inv.errors))
         view_key, delete_key = auth.save_key(network_name, email, type)
         if type == "private":
             view_url = "http://biosual.cbio.uct.ac.za/pinViewer.html?core=%(core)s&key=%(key)s" % {
                 'core': network_name,
                 'key': view_key
             }
             delete_url = "http://biosual.cbio.uct.ac.za/solr/admin/cores?action=UNLOAD&deleteIndex=true&core=%(core)s&key=%(key)s" % {
                 'core': network_name,
                 'key': delete_key
             }
         else:
             view_url = "http://biosual.cbio.uct.ac.za/pinViewer.html?core=%(core)s" % {
                 'core': network_name
             }
             delete_url = "http://biosual.cbio.uct.ac.za/solr/admin/cores?action=UNLOAD&deleteIndex=true&core=%(core)s&key=%(key)s" % {
                 'core': network_name,
                 'key': delete_key
             }
         msg = auth.sendmail(email, view_url, delete_url, network_name)
         #cherrypy.log(msg);
         errormessage = "<br/>".join(inv.errors)
         tmpl = lookup.get_template("upload_result.mako")
         return tmpl.render(network_name=network_name,
                            annotation_head="|".join(inv.ahead),
                            annotation_count=len(inv.annotations),
                            annotation_file=annotations_file.filename,
                            network_head="|".join(inv.nhead),
                            network_count=len(inv.network),
                            network_file=network_file.filename,
                            message="",
                            errors="<br/>".join(inv.errors))
Exemplo n.º 4
0
 def upload(self, network_name, network_file, annotations_file):
     out = """<html>
     <body>
         Network name: %s<br/><br/>
         
         Annotations columns: %s<br/>
         Annotations count: %i<br />
         Annotations filename: %s<br />
         
         Network head: %s<br />
         Network length: %i<br />
         Network filename: %s<br />
         
         %s
                 <br/>
                 Errors:<br/>
                 %s
     </body>
     </html>"""
     network_name = pinv.clean(network_name)
     if settings.TEST and not (network_file.file and annotations_file.file):
         network_file.file = open("../data/test.txt")
         annotations_file.file = open("../data/test_annot.txt")
     solr_url = settings.SOLR_URL
     solr_url = '%s/solr/%s'%(settings.SOLR_SERVER,network_name)
     time.sleep(2)
     inv = InteractionNetwork(network_name, "description text", network_file.file, annotations_file.file)
     time.sleep(2)
     message, result = pinv.create_new_solr(network_name)
     time.sleep(2)
     print "--- UPLOAD. Connecting to:", solr_url        
     si = sunburnt.SolrInterface(solr_url)
     time.sleep(2)
     inv.upload(si)
     errormessage = "<br/>".join(inv.errors)
     return out % (network_name,"|".join(inv.ahead), len(inv.annotations), repr(annotations_file.filename), 
                   "|".join(inv.nhead), len(inv.network), repr(network_file.filename),message,errormessage)