Ejemplo n.º 1
0
    def _validate_inputs(self, root_dir, nfl_fa, N):
        """
        Check inputs, return
        (num_reads,
         number_reads_per_chunk,
         nfl_dir,
         [i-th_chunk_nfl_fa for i in [0...N-1]])
        """
        icef = IceFiles(prog_name="ice_partial_split",
                        root_dir=root_dir,
                        no_log_f=False)

        nfl_dir = icef.nfl_dir

        # root_dir/output/map_noFL/input.split_{0:02d}.fa
        splitted_nfl_fas = [icef.nfl_fa_i(i) for i in range(0, N)]

        mkdir(icef.nfl_dir)

        # Check if inputs exist.
        errMsg = ""
        if not nfs_exists(nfl_fa):
            errMsg = ("The input non-full-length reads fasta file " +
                      "{f} does not exists. ".format(f=nfl_fa))
        if len(errMsg) != 0:
            raise ValueError(errMsg)

        num_reads = num_reads_in_fasta(nfl_fa)
        reads_per_split = int(max(1, ceil(num_reads / N)))

        return (num_reads, reads_per_split, nfl_dir, splitted_nfl_fas)
Ejemplo n.º 2
0
    def _validate_inputs(self, root_dir, nfl_fa, N):
        """
        Check inputs, return
        (num_reads,
         number_reads_per_chunk,
         nfl_dir,
         [i-th_chunk_nfl_fa for i in [0...N-1]])
        """
        icef = IceFiles(prog_name="ice_partial_split", root_dir=root_dir, no_log_f=False)

        nfl_dir = icef.nfl_dir

        # root_dir/output/map_noFL/input.split_{0:02d}.fa
        splitted_nfl_fas = [icef.nfl_fa_i(i) for i in range(0, N)]

        mkdir(icef.nfl_dir)

        # Check if inputs exist.
        errMsg = ""
        if not nfs_exists(nfl_fa):
            errMsg = "The input non-full-length reads fasta file " + "{f} does not exists. ".format(f=nfl_fa)
        if len(errMsg) != 0:
            raise ValueError(errMsg)

        num_reads = num_reads_in_fasta(nfl_fa)
        reads_per_split = int(max(1, ceil(num_reads / N)))

        return (num_reads, reads_per_split, nfl_dir, splitted_nfl_fas)
Ejemplo n.º 3
0
    def _validate_inputs(self, root_dir, i, ccs_fofn, blasr_nproc):
        """
        Check inputs, write ice_partial.py i command to script_file
        and return (input_fasta, ref_fasta, sa_file, out_pickle, done_file)
        for the i-th chunk of nfl reads.
        """
        icef = IceFiles(prog_name="ice_partial_{i}".format(i=i),
                        root_dir=root_dir, no_log_f=False)

        # root_dir/output/final.consensus.fa
        ref_fasta = icef.final_consensus_fa
        ref_dazz = icef.final_dazz_db
        #sa_file = icef.final_consensus_sa

        # root_dir/output/map_noFL/input.split_{0:02d}.fa
        input_fasta = icef.nfl_fa_i(i)

        # root_dir/output/map_noFL/input.split_{0:02d}.fa.partial_uc.pickle
        out_pickle = icef.nfl_pickle_i(i)

        # root_dir/output/map_noFL/input.split_{0:02d}.fa.partial_uc.pickle.DONE
        done_file = icef.nfl_done_i(i)

        # root_dir/scripts/input.split_{0:02d}.fa.partial_uc.sh
        script_file = icef.nfl_script_i(i)

        # Check if inputs exist.
        errMsg = ""
        if not nfs_exists(input_fasta):
            errMsg = ("The {i}-th splitted non-full-length reads ".format(i=i) +
                      "fasta file {f} does not exist. ".format(f=input_fasta) +
                      "Please run ice_partial_split.py first.")
        elif not nfs_exists(ref_fasta):
            errMsg = ("The unpolished consensus isoforms fasta file " +
                      "{f} does not exist. ".format(f=ref_fasta) +
                      "Please make sure ICE is successfully done.")
        elif not nfs_exists(ref_dazz):
            errMsg = ("The dazz db " +
                      "{f} does not exist. ".format(f=ref_dazz) +
                      "Please make sure it is already built.")
#        elif not nfs_exists(sa_file):
#            errMsg = ("The suffix array of unpolished consensus isoforms " +
#                      "(i.e., final_consensus_sa) {f} does not exist.")
        if len(errMsg) != 0:
            raise ValueError(errMsg)

        # Save cmd to script_file.
        cmd = self._cmd_str(root_dir=root_dir, i=i,
                            ccs_fofn=ccs_fofn,
                            blasr_nproc=blasr_nproc)
        with open(script_file, 'w') as writer:
            writer.write(cmd + "\n")

        icef.add_log("Writing CMD to: {script_file}".
                     format(script_file=script_file))
        icef.close_log()

        return (input_fasta, ref_fasta, ref_dazz, out_pickle, done_file)
Ejemplo n.º 4
0
    def _validate_inputs(self, root_dir, i, ccs_fofn, blasr_nproc):
        """
        Check inputs, write ice_partial.py i command to script_file
        and return (input_fasta, ref_fasta, sa_file, out_pickle, done_file)
        for the i-th chunk of nfl reads.
        """
        icef = IceFiles(prog_name="ice_partial_{i}".format(i=i),
                        root_dir=root_dir, no_log_f=False)

        # root_dir/output/final.consensus.fa
        ref_fasta = icef.final_consensus_fa
        sa_file = icef.final_consensus_sa

        # root_dir/output/map_noFL/input.split_{0:02d}.fa
        input_fasta = icef.nfl_fa_i(i)

        # root_dir/output/map_noFL/input.split_{0:02d}.fa.partial_uc.pickle
        out_pickle = icef.nfl_pickle_i(i)

        # root_dir/output/map_noFL/input.split_{0:02d}.fa.partial_uc.pickle.DONE
        done_file = icef.nfl_done_i(i)

        # root_dir/scripts/input.split_{0:02d}.fa.partial_uc.sh
        script_file = icef.nfl_script_i(i)

        # Check if inputs exist.
        errMsg = ""
        if not nfs_exists(input_fasta):
            errMsg = ("The {i}-th splitted non-full-length reads ".format(i=i) +
                      "fasta file {f} does not exist. ".format(f=input_fasta) +
                      "Please run ice_partial_split.py first.")
        elif not nfs_exists(ref_fasta):
            errMsg = ("The unpolished consensus isoforms fasta file " +
                      "{f} does not exist. ".format(f=ref_fasta) +
                      "Please make sure ICE is successfully done.")
        elif not nfs_exists(sa_file):
            errMsg = ("The suffix array of unpolished consensus isoforms " +
                      "(i.e., final_consensus_sa) {f} does not exist.")
        if len(errMsg) != 0:
            raise ValueError(errMsg)

        # Save cmd to script_file.
        cmd = self._cmd_str(root_dir=root_dir, i=i,
                            ccs_fofn=ccs_fofn,
                            blasr_nproc=blasr_nproc)
        with open(script_file, 'w') as writer:
            writer.write(cmd + "\n")

        icef.add_log("Writing CMD to: {script_file}".
                     format(script_file=script_file))
        icef.close_log()

        return (input_fasta, ref_fasta, sa_file, out_pickle, done_file)