Ejemplo n.º 1
0
    def get_list_of_studies(self):
        studies = []
        h5files = fsutils.get_h5files_in_dir(self.search_path, self.trait_dir)
        for h5file in h5files:
            service = study_service.StudyService(h5file=h5file)
            studies.extend(service.list_studies())
            service.close_file()

        return sorted(studies)
Ejemplo n.º 2
0
 def get_list_of_studies_for_trait(self, trait):
     h5file = fsutils.create_h5file_path(self.search_path, self.trait_dir,
                                         trait)
     if not isfile(h5file):
         raise NotFoundError("Trait " + trait)
     service = study_service.StudyService(h5file=h5file)
     studies = service.list_studies()
     service.close_file()
     return sorted(studies)
Ejemplo n.º 3
0
 def get_trait_of_study(self, study_to_find):
     h5files = fsutils.get_h5files_in_dir(self.search_path, self.trait_dir)
     for h5file in h5files:
         service = study_service.StudyService(h5file=h5file)
         for trait_study in service.list_trait_study_pairs():
             if study_to_find == trait_study.split(":")[1]:
                 service.close_file()
                 return trait_study.split(":")[0]
         service.close_file()
     # study not found
     raise NotFoundError("Study " + study_to_find)
Ejemplo n.º 4
0
 def _find_h5file_study_group(self):
     """
     Traverse all the hdf5 file and find any with the study group of interest
     :return: dict of {h5file: studygroup path}
     """
     hf_study_dict = {}
     h5files = fsutils.get_h5files_in_dir(self.search_path, self.trait_dir)
     for h5file in h5files:
         service = study_service.StudyService(h5file=h5file)
         for study_group in service.get_study_groups():
             if self.study == study_group.get_name().split("/")[-1]:
                 hf_study_dict[h5file] = study_group.get_name()
         service.close_file()
     if any(hf_study_dict):
         return hf_study_dict
     else:
         logger.debug("Study %s not found in any trait!", self.study)
         raise NotFoundError("Study " + self.study)
Ejemplo n.º 5
0
    def __init__(self, trait, start, size, config_properties=None):
        self.trait = trait
        self.start = start
        self.size = size

        self.properties = properties_handler.get_properties(config_properties)
        self.search_path = properties_handler.get_search_path(self.properties)
        self.trait_dir = self.properties.trait_dir

        self.datasets = utils.create_dictionary_of_empty_dsets(TO_QUERY_DSETS)
        # index marker will be returned along with the datasets
        # it is the number that when added to the 'start' value that we started the query with
        # will pinpoint where the next search needs to continue from
        self.index_marker = 0

        self.h5file = fsutils.create_h5file_path(self.search_path,
                                                 dir_name=self.trait_dir,
                                                 file_name=trait)
        if not os.path.isfile(self.h5file):
            raise NotFoundError("Trait " + trait)
        self.service = study_service.StudyService(self.h5file)