#!/usr/bin/env python

"""
This script performs the full Sequence Quality Control step of the Cancer
Genome Variant pipeline, controlling the processes and
decision making for each step.
"""

import sys
import bioexcel_seqqc.runfastqc as rfqc
import bioexcel_seqqc.checkfastqc as cfqc
import bioexcel_seqqc.seqqcutils as sqcu

if __name__ == "__main__":

    description = ("This script performs the Sequence "
                "Quality Control step of the Cancer Genome Variant pipeline.")

    args = sqcu.parse_command_line(description)

    if args.printconfig:
        sqcu.print_config()
        print("Example configuration file created in current directory")
        sys.exit()

    args.files = sqcu.get_files(args)
    args.qcconf = sqcu.get_qcconfig(args.qcconf)

    ### Run FastQC
    pfqc = rfqc.run_fqc(args.files, args.fqcdir, args.tmpdir, args.threads)
    pfqc.wait()

    ### Check FastQC output, simple yes/no to quality trimming
    ### Output and resubmission of jobs handled by checkFastQC
    cfqc.check_qc(args.files, args.fqcdir, args.trimdir, args.tmpdir,
                    args.adaptseq, args.qcconf, args.threads, args.outdir)
