Example #1
0
    def __init__(self, dataset):
        self.dataset = dataset

        folder_path = PathResolver.output_path_for(self.MAPPINGS_FOLDER)
        PathResolver.assure_path_exists(folder_path)

        db_path = PathResolver.output_path_for(self.MAPPINGS_FOLDER,
                                               self.DB_FOLDER)
        PathResolver.assure_path_exists(db_path)
Example #2
0
    def perform(self):
        PathResolver.assure_path_exists(self._db_folder_path())

        all_vs_all_path = PathResolver.output_path_for(
            PathResolver.ALL_VS_ALL_FOLDER)
        PathResolver.assure_path_exists(all_vs_all_path)

        one_vs_all_path = PathResolver.output_path_for(
            PathResolver.ONE_VS_ALL_FOLDER)
        PathResolver.assure_path_exists(one_vs_all_path)

        self._make_databases()
        self._perform_blasts()
        self._make_one_vs_all_files()
Example #3
0
    def _make_one_vs_all_files(self):
        all_vs_all_path = PathResolver.output_path_for(
            PathResolver.ALL_VS_ALL_FOLDER)

        files = {}
        for f_path in glob.glob(all_vs_all_path +
                                '/*.%s' % self.BLAST_RESULT_EXT):
            left_org_id = os.path.splitext(
                os.path.basename(f_path))[0].split('_VS_')[0]

            if left_org_id not in files:
                files[left_org_id] = []
            files[left_org_id].append(f_path)

        for org_id, files in files.iteritems():
            org_file_name = org_id + '.' + self.BLAST_RESULT_EXT
            path = PathResolver.output_path_for(PathResolver.ONE_VS_ALL_FOLDER,
                                                org_file_name)

            if os.path.exists(path):
                os.remove(path)

            for f_path in files:
                subprocess.call('cat %s >> %s' % (f_path, path), shell=True)
Example #4
0
    def _perform_blast(self, left_path, right_path):
        command = 'blastn -query %s -db %s -out %s -outfmt "6 %s" -num_threads %s'

        right_org_name = os.path.splitext(os.path.basename(right_path))[0]
        left_org_name = os.path.splitext(os.path.basename(left_path))[0]
        db_path = self._db_folder_path(right_org_name)

        outfile_name = '%s_VS_%s.%s' % (left_org_name, right_org_name,
                                        self.BLAST_RESULT_EXT)
        output_path = PathResolver.output_path_for(
            PathResolver.ALL_VS_ALL_FOLDER, outfile_name)

        threads_cnt = Settings.winston.tools.blast.threads
        command = command % (left_path, db_path, output_path, self.COLUMNS,
                             threads_cnt)

        subprocess.call(command, shell=True)
Example #5
0
 def db_path(self):
     return PathResolver.output_path_for(self.MAPPINGS_FOLDER,
                                         self.DB_FOLDER)
Example #6
0
 def pileup_output_path(self):
     file_name = '%s_pileup.txt' % self.dataset.external_name
     return PathResolver.output_path_for(self.MAPPINGS_FOLDER, file_name)
Example #7
0
 def sam_file_path(self):
     file_name = '%s.sam' % self.dataset.external_name
     paths = [self.MAPPINGS_FOLDER, file_name]
     return PathResolver.output_path_for(*paths)
Example #8
0
 def _dict_file_path():
     return PathResolver.output_path_for(NameConverter.DICT_FILENAME)
Example #9
0
 def pair_types_path():
     return PathResolver.output_path_for(PathResolver.TYPES_FILENAME)
Example #10
0
 def _db_folder_path(self, *inner_path):
     return PathResolver.output_path_for(PathResolver.BLAST_DB_FOLDER,
                                         *inner_path)
 def _default_db_path():
     return PathResolver.output_path_for(
         DatabaseWorker.DEFAULT_DB_FILE_NAME)