def _main(input_file_path): lines = [] with open(input_file_path, 'r') as input_file: lines = [l.strip() for l in input_file.readlines()] refs = refparse.parse_cse_refs(lines[1:]) for ref in refs: print ref
def run(self, input_file_path, input_format, levels, search_trials, perform_layout, output_file_path): input_file = codecs.open(input_file_path, 'r') input_lines = input_file.readlines() input_file.close() drug_name = input_lines[0].strip() self.net = litnet.LitNet(drug_name) self.net.g['method'] = 'topdown' self.net.g['levels'] = levels drug_index = self.net.add_v(type='drug', label=drug_name) if search_trials: trials = self.ct_client.search(drug_name) for trial in trials: trial_index = self.net.add_v(type='clinicaltrial', title=trial['title'], label=trial['nctid']) self.net.g.add_edge(drug_index, trial_index) refs = trial['biblio'] if refs: self._add_layer_of_refs(refs, trial_index, levels) if input_format == 'cse': fda_index = self.net.add_v(type='clinicaltrial', label='FDA') self.net.g.add_edge(drug_index, fda_index) fda_refs = refparse.parse_cse_refs(input_lines[1:]) self._add_layer_of_refs(fda_refs, fda_index, levels) elif input_format == 'pmid': refs = [{'pmid': pmid.strip()} for pmid in input_lines[1:]] self._add_layer_of_refs(refs, drug_index, levels) if self.verbose: self._print_counts() print self.net.ref_counts if self.verbose: print 'Postprocessing...', sys.stdout.flush() self.net.remove_dup_authors() self.net.propagate_pubdates() if self.verbose: print 'done.' if perform_layout: if self.verbose: print 'Performing layout...', sys.stdout.flush() self.net.layout() if self.verbose: print 'done.' if self.verbose: print 'Saving...', sys.stdout.flush() self.net.save(output_file_path) if self.verbose: print 'done.'