Пример #1
0
    def on_pmid_button_clicked(self, pmid,*args):
        """
        Given a PMID, resquest, download the abstract from NCBI, 
        save it in the current folder - as pmid_number.xml - 
        and load it on the interface for annotation
        """
        #TODO: this method could be better organized
        pmid = self._pmid_entry.get_text()
        pre_process = self._preprocess_checkbutton.get_active()
        parallel = self._parallel_checkbutton.get_active()
        #Check if the input has a valid PMID
        try:
            int(pmid)
        except:
            self.show_message("Ops! Check if you provided a valid PMID")
            return 0

        self.current_open_file = pmid + ".xml"
        raw_ncbi_xml= entrez.get_abstract_from_ncbi(pmid, self.current_open_file)
        data = xml_tools.get_data_from_ncbi_xml(self.current_open_file)

        #just display the raw abstract, withou any preprocessing
        if data and not pre_process:
            self._clear_interface() 
            self._update_interface(data)

        #automaticaly recognize MESH terms and display the annotated abstract
        elif data and pre_process:
            self.show_message("This can take a few seconds. Do not close the program")           
            #get mesh terms from database
            abstract_text = xml_tools.get_abstract_text_from_etree(data)
            abstract_text = tools.translate_greek2latin(abstract_text)

            #recognize MESH terms automatically
            annotated_filename = "annotated_" + self.current_open_file
            self.current_open_file = annotated_filename
            self.create_annotated_abstract_xml(raw_ncbi_xml,
                                               abstract_text, 
                                               annotated_filename,
                                               parallel)
            #load annotated xml          
            data,tags = xml_tools.load_annotated_xml(annotated_filename)

            if not data:
               self.show_message("PubMed Tagger was not able to parse %s" %annotated_filename)
               return 0

            self._clear_interface() 
            self._update_interface(data, textbuffer=True)       
            print tags.keys()
            self.tag_text(tags)
            self.update_annotation_liststore(tags)
Пример #2
0
    def _update_interface(self, data, textbuffer=False, *args):
        self._clear_interface()
        if textbuffer:
            self._abstract_textview.set_buffer(data["article_abstract"])
        else:
            text = xml_tools.get_abstract_text_from_etree(data) 
            self._set_textview_text(self._abstract_textview, text)

        self._set_textview_text(self._title_textview,
                               data["article_title"].text)
        self._pmid_label.set_text(data["pmid"])
        self._journal_label.set_text(data["journal_title"])
        self._year_label.set_text(data["publication_year"])