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)
def on_filechooser_ok_button_clicked(self, *args): """ Get the active filename in the filechooser_window and load its data using xml_tools.load_annotated_xml function """ self._filechooser_window.hide() filename = self._filechooser_window.get_filename() self.current_open_file = filename data,tags = xml_tools.load_annotated_xml(filename) if not data: self.show_message("PubMed Tagger was not able to parse %s" %filename) return 0 self._update_interface(data, textbuffer=True) self.update_annotation_liststore(tags) self.tag_text(tags)