コード例 #1
0
    def test_export_lig(self):

        ids = '19465464,18945920'.split(",")
        #ret = pubmed.exportReference(ids)
        sample_ris = fileutil.contentsOfFile("test/sample-medline.ris", False)
        #print "Sample %s" %sample_ris
        ret = pubmed.medline2ris(sample_ris)
        self.assertTrue(ret)
        fileutil.writeFile("tmp/output.ris", ret)
        print "##%s##" % ret
        self.assertIn('TY  - JOUR', ret)
コード例 #2
0
ファイル: tests.py プロジェクト: tjworks/precon
 def test_export_lig(self):
     
    
     ids='19465464,18945920'.split(",")
     #ret = pubmed.exportReference(ids)
     sample_ris = fileutil.contentsOfFile("test/sample-medline.ris", False)
     #print "Sample %s" %sample_ris
     ret = pubmed.medline2ris(sample_ris)
     self.assertTrue(ret)
     fileutil.writeFile("tmp/output.ris", ret)
     print "##%s##" %ret
     self.assertIn('TY  - JOUR', ret)
     
コード例 #3
0
ファイル: views.py プロジェクト: tjworks/precon
def persist(req):
    jsondata = req.REQUEST.get("data")
    initdata = json.loads(jsondata)
    logger.debug("Persisting")    
    logger.debug( "%s" % (initdata) )
    fileutil.writeFile("test1", jsondata)
        
    try:
        if(initdata['_id'][:4] == 'conn'):
            con = Connection(initdata)
            con.save()
            return SmartResponse(con._id, req)            
        else:    
            network = Network(initdata)
            network.save()
            index(network.name, network)
            return SmartResponse(network._id, req)    
    except Error as e:
        logger.error("Error saving data: %s" %traceback.format_exc())
        return SmartResponse(e, req)
コード例 #4
0
def persist(req):
    jsondata = req.REQUEST.get("data")
    initdata = json.loads(jsondata)
    logger.debug("Persisting")
    logger.debug("%s" % (initdata))
    fileutil.writeFile("test1", jsondata)

    try:
        if (initdata['_id'][:4] == 'conn'):
            con = Connection(initdata)
            con.save()
            return SmartResponse(con._id, req)
        else:
            network = Network(initdata)
            network.save()
            index(network.name, network)
            return SmartResponse(network._id, req)
    except Error as e:
        logger.error("Error saving data: %s" % traceback.format_exc())
        return SmartResponse(e, req)
コード例 #5
0
ファイル: pubmed.py プロジェクト: tjworks/precon
def exportReference(pubmed_ids):  

    #url = "http://togows.dbcls.jp/entry/pubmed/" 
    #url = 'http://www.ncbi.nlm.nih.gov/pubmed'
    #pubmed_ids = '19465464,18945920'.split(",")
    url="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&rettype=medline&retmode=text&id="    
    ids = ",".join(pubmed_ids)
    url += ids
    logger.debug(  "Loading %s" %url)
    r = requests.get(url)
    if r.status_code == 200:
        from django.utils.encoding import smart_str
        content = smart_str(r.text)
    else:
        raise Exception("Failed to open %s" %url)
    logger.debug(  "Writing raw data to tmp/raw-medline.ris")
    fileutil.writeFile("tmp/raw-medline.ris", content)
    #print content 
    #from myutil import fileutil
    #fileutil.writeFile("out.html", content)
    
    return medline2ris(content)
コード例 #6
0
ファイル: pubmed.py プロジェクト: linkai1208/precon
def exportReference(pubmed_ids):

    #url = "http://togows.dbcls.jp/entry/pubmed/"
    #url = 'http://www.ncbi.nlm.nih.gov/pubmed'
    #pubmed_ids = '19465464,18945920'.split(",")
    url = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&rettype=medline&retmode=text&id="
    ids = ",".join(pubmed_ids)
    url += ids
    logger.debug("Loading %s" % url)
    r = requests.get(url)
    if r.status_code == 200:
        from django.utils.encoding import smart_str
        content = smart_str(r.text)
    else:
        raise Exception("Failed to open %s" % url)
    logger.debug("Writing raw data to tmp/raw-medline.ris")
    fileutil.writeFile("tmp/raw-medline.ris", content)
    #print content
    #from myutil import fileutil
    #fileutil.writeFile("out.html", content)

    return medline2ris(content)