def test_realignbam():
     'It test the GATK realigner'
     sam_test_dir = os.path.join(TEST_DATA_DIR, 'samtools')
     bam_path = os.path.join(sam_test_dir, 'seqs.bam')
     reference_path = os.path.join(sam_test_dir, 'reference.fasta')
     out_bam = NamedTemporaryFile(suffix='.bam')
     realign_bam(bam_path, reference_path, out_bam.name, threads=THREADS)
     out_bam.close()
Beispiel #2
0
    def run(self):
        '''It runs the analysis.'''
        self._log({'analysis_started':True})
        settings = self._project_settings
        project_path = settings['General_settings']['project_path']
        tmp_dir      = settings['General_settings']['tmpdir']

        inputs = self._get_input_fpaths()
        bam_path = inputs['bam']
        bam_fpath = bam_path.last_version
        reference_path = inputs['reference']

        #memory for the java programs
        osettings   = settings['Other_settings']
        java_mem    = osettings['java_memory']
        picard_path = osettings['picard_path']
        gatk_path = osettings['gatk_path']

        #we need a temporary path
        temp_bam = NamedTemporaryFile(suffix='.bam')
        temp_bam_fpath = temp_bam.name
        temp_bam.close()

        #do the realigment
        realign_bam(bam_fpath=bam_fpath,
                    reference_fpath=reference_path.last_version,
                    out_bam_fpath=temp_bam_fpath,
                    java_conf={'java_memory':java_mem,
                               'picard_path':picard_path,
                               'gatk_path':gatk_path},
                    threads=self.threads,
                    tmp_dir=tmp_dir)
        #a new version for the original bam
        out_bam_fpath = bam_path.next_version
        shutil.move(temp_bam_fpath, out_bam_fpath)
        self._log({'analysis_finished':True})