Пример #1
0
    def _construct_links_of_interest(self):
        """Construct an iterator for all pairs of annotation terms to be
        tested.

        """
        if self.opts.selected_links:
            links, num_links = self.parse_selected_links(self.opts.selected_links)
        elif self.opts.selected_terms or self.opts.selected_terms_with_all:
            if self.opts.selected_terms:
                selected_terms_file_name = self.opts.selected_terms
            else:
                selected_terms_file_name = self.opts.selected_terms_with_all
            logger.info("Parsing selected terms file %s." % selected_terms_file_name)
            selected_terms_file = open(selected_terms_file_name, "rb")
            num_selected_terms = convutils.count_lines(selected_terms_file)
            selected_terms = parsers.parse_selected_terms_file(selected_terms_file)
            if self.opts.selected_terms:
                num_links = self._calc_num_links_selected_terms(num_selected_terms)
                links = self.make_selected_terms_links(selected_terms)
            else:
                num_links = self._calc_num_links_selected_with_all(num_selected_terms)
                links = self.make_selected_terms_links_with_all(selected_terms, self.annotations_dict)
        else:
            links, num_links = self.make_all_possible_links(self.annotations_dict)

        self.links, self.num_links = links, num_links
Пример #2
0
 def parse_selected_links(self, selected_links_file_name):
     logger.info("Parsing selected links file %s." % selected_links_file_name)
     selected_links_file = open(selected_links_file_name, "rb")
     num_links = convutils.count_lines(selected_links_file)
     # Reset the file to the beginning to parse it.
     selected_links_file.seek(0)
     links = parsers.parse_selected_links_file(selected_links_file)
     return links, num_links