Example #1
0
    def setJellyfish(self):

        jellyfishpath, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Select jellyfish File", filter='jellyfish')

        if jellyfishpath:

            jfversion = jellyfish.jfversion(jfbin=jellyfishpath)

            QtWidgets.QMessageBox.information(self, "Jelly Fish", "Jelly Fish Version: %s" % jfversion)

            if jfversion == 'None':

                self.lineEdit_program_JFPath.setText(jellyfishpath)

                self.label_program_JFversion.setText(jfversion)

                self.label_program_JFversion.setStyleSheet("color:red")

            else:
                self.lineEdit_program_JFPath.setText(jellyfishpath)

                self.label_program_JFversion.setText(jfversion)

                self.label_program_JFversion.setStyleSheet("color:green")

                self.jellyfishpath = jellyfishpath
Example #2
0
    def setJellyfish(self):

        jellyfishpath, _ = QtWidgets.QFileDialog.getOpenFileName(
            self, "Select jellyfish File", filter='jellyfish')

        if jellyfishpath:

            jfversion = jellyfish.jfversion(jfbin=jellyfishpath)

            QtWidgets.QMessageBox.information(
                self, "Jelly Fish", "Jelly Fish Version: %s" % jfversion)

            if jfversion == 'None':

                self.lineEdit_program_JFPath.setText(jellyfishpath)

                self.label_program_JFversion.setText(jfversion)

                self.label_program_JFversion.setStyleSheet("color:red")

            else:
                self.lineEdit_program_JFPath.setText(jellyfishpath)

                self.label_program_JFversion.setText(jfversion)

                self.label_program_JFversion.setStyleSheet("color:green")

                self.jellyfishpath = jellyfishpath
Example #3
0
def check_options(parser):

    args = parser.parse_args()

    # Start check bwa
    if args.bwa:

        if not os.path.exists(args.bwa):

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

        bwaversion = bwa.bwaversion(args.bwa)

        if bwaversion == 'None':

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    else:

        bwapath = which('bwa')

        if bwapath:

            bwaversion = bwa.bwaversion(bwapath[0])

            if bwaversion == 'None':

                print("Can not locate bwa, please input full path of bwa\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.bwa = bwapath[0]

        else:

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    # End check bwa

    # Start check jellyfish
    if args.jellyfish:

        if not os.path.exists(args.jellyfish):

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

        jellyfishversion = jellyfish.jfversion(args.jellyfish)

        if jellyfishversion == 'None':

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

    else:

        jellyfishpath = which('jellyfish')

        if jellyfishpath:

            jellyfishversion = jellyfish.jfversion(jellyfishpath[0])

            if jellyfishversion == 'None':

                print("Can not locate jellyfish, please input full path of jellyfish\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.jellyfish = jellyfishpath[0]

        else:

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)
    # End check jellyfish

    if not os.path.exists(args.genome):

        print("Can not locate genome file, please input genome file.\n")

        parser.print_help()

        sys.exit(1)

    if not os.path.exists(args.input):

        print("Can not locate input file, please input input file.\n")

        parser.print_help()

        sys.exit(1)

    if args.homology > 100 or args.homology < 50:

        print("Please set homology between 50 and 100.\n")

        parser.print_help()

        sys.exit(1)

    if args.dtm > 37 or args.dtm < 0:

        print("Please set dtm between 0 and 37.\n")

        parser.print_help()

        sys.exit(1)

    if args.step < 1:

        print("step must >1.\n")

        parser.print_help()

        sys.exit(1)

    # Start check saved folder
    if os.path.exists(args.saved):

        if not args.docker:

            print(args.saved, "exists. Everything in this folder will be remove. Press Y or N to continue: ")

            while True:

                char = getch()

                if char.lower() in ("y", "n"):

                    print(char)

                    if char == 'n':

                        sys.exit(1)

                    break

    else:

        os.mkdir(args.saved)
    # End check saved folder

    # Print Checked information
    print("#"*40)

    print("bwa version:", args.bwa, bwaversion)

    print("jellyfish version:", args.jellyfish, jellyfishversion)

    print("genome file:", args.genome)

    print("input file:", args.input)

    print("5\' labeled R primer:", args.primer)

    print("result output folder:",  os.path.realpath(args.saved))

    print("threads number:", args.threads)

    print("homology:", args.homology)

    print("dtm:", args.dtm)

    print("#"*40)

    return args
Example #4
0
def check_options(parser):

    args = parser.parse_args()

    # Start check bwa
    if args.bwa:

        if not os.path.exists(args.bwa):

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

        bwaversion = bwa.bwaversion(args.bwa)

        if bwaversion == 'None':

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    else:

        bwapath = which('bwa')

        if bwapath:

            bwaversion = bwa.bwaversion(bwapath[0])

            if bwaversion == 'None':

                print("Can not locate bwa, please input full path of bwa\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.bwa = bwapath[0]

        else:

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    # End check bwa

    # Start check jellyfish
    if args.jellyfish:

        if not os.path.exists(args.jellyfish):

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

        jellyfishversion = jellyfish.jfversion(args.jellyfish)

        if jellyfishversion == 'None':

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

    else:

        jellyfishpath = which('jellyfish')

        if jellyfishpath:

            jellyfishversion = jellyfish.jfversion(jellyfishpath[0])

            if jellyfishversion == 'None':

                print("Can not locate jellyfish, please input full path of jellyfish\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.jellyfish = jellyfishpath[0]

        else:

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)
    # End check jellyfish

    if not os.path.exists(args.genome):

        print("Can not locate genome file, please input genome file.\n")

        parser.print_help()

        sys.exit(1)

    if not os.path.exists(args.input):

        print("Can not locate input file, please input input file.\n")

        parser.print_help()

        sys.exit(1)

    if args.homology > 100 or args.homology < 50:

        print("Please set homology between 50 and 100.\n")

        parser.print_help()

        sys.exit(1)

    if args.dtm > 37 or args.dtm < 0:

        print("Please set dtm between 0 and 37.\n")

        parser.print_help()

        sys.exit(1)

    if args.step < 1:

        print("step must >1.\n")

        parser.print_help()

        sys.exit(1)

    # Start check saved folder
    if os.path.exists(args.saved):

        if not args.docker:

            print(args.saved, "exists. Everything in this folder will be remove. Press Y or N to continue: ")

            while True:

                char = getch()

                if char.lower() in ("y", "n"):

                    print(char)

                    if char == 'n':

                        sys.exit(1)

                    break

    else:

        os.mkdir(args.saved)
    # End check saved folder

    # Print Checked information
    print("#"*40)

    print("bwa version:", args.bwa, bwaversion)

    print("jellyfish version:", args.jellyfish, jellyfishversion)

    print("genome file:", args.genome)

    print("input file:", args.input)

    print("5\' labeled R primer:", args.primer)

    print("result output folder:",  os.path.realpath(args.saved))

    print("threads number:", args.threads)

    print("homology:", args.homology)

    print("dtm:", args.dtm)

    print("#"*40)

    return args
Example #5
0
def check_options(parser):

    args = parser.parse_args()

    # Start check bwa
    if args.bwa:

        if not os.path.exists(args.bwa):

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

        bwaversion = bwa.bwaversion(args.bwa)

        if bwaversion == 'None':

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    else:

        bwapath = which('bwa')

        if bwapath:

            bwaversion = bwa.bwaversion(bwapath[0])

            if bwaversion == 'None':

                print("Can not locate bwa, please input full path of bwa\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.bwa = bwapath[0]

        else:

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    # End check bwa

    # Start check jellyfish
    if args.jellyfish:

        if not os.path.exists(args.jellyfish):

            print(
                "Can not locate jellyfish, please input full path of jellyfish\n"
            )

            parser.print_help()

            sys.exit(1)

        jellyfishversion = jellyfish.jfversion(args.jellyfish)

        if jellyfishversion == 'None':

            print(
                "Can not locate jellyfish, please input full path of jellyfish\n"
            )

            parser.print_help()

            sys.exit(1)

    else:

        jellyfishpath = which('jellyfish')

        if jellyfishpath:

            jellyfishversion = jellyfish.jfversion(jellyfishpath[0])

            if jellyfishversion == 'None':

                print(
                    "Can not locate jellyfish, please input full path of jellyfish\n"
                )

                parser.print_help()

                sys.exit(1)

            else:

                args.jellyfish = jellyfishpath[0]

        else:

            print(
                "Can not locate jellyfish, please input full path of jellyfish\n"
            )

            parser.print_help()

            sys.exit(1)
    # End check jellyfish

    if not os.path.exists(args.source):

        print(
            "Can not locate source genome (GenomeA) file, please input a source genome file.\n"
        )

        parser.print_help()

        sys.exit(1)

    if not os.path.exists(args.target):

        print(
            "Can not locate target genome (GenomeB) file, please input a target genome file.\n"
        )

        parser.print_help()

        sys.exit(1)

    if not os.path.exists(args.input):

        print("Can not locate input file, please input input file.\n")

        parser.print_help()

        sys.exit(1)

    # Start check saved folder
    if os.path.exists(args.saved):

        print(
            args.saved,
            "exists. Everything in this folder will be remove. Press Y or N to continue: "
        )

        while True:

            char = getch()

            if char.lower() in ("y", "n"):

                print(char)

                if char.lower() == 'n':

                    sys.exit(1)

                break

    else:

        os.mkdir(args.saved)
    # End check saved folder

    # Print Checked information
    print("#" * 40)

    print("bwa version:", os.path.abspath(os.path.expanduser(args.bwa)),
          bwaversion)

    print("jellyfish version:",
          os.path.abspath(os.path.expanduser(args.jellyfish)),
          jellyfishversion)

    print("source genome (GenomeA) file:",
          os.path.abspath(os.path.expanduser(args.source)))

    print("target genome (GenomeB) file:",
          os.path.abspath(os.path.expanduser(args.target)))

    print("input file:", os.path.abspath(os.path.expanduser(args.input)))

    print("result output folder:", os.path.realpath(args.saved))

    print("threads number:", args.threads)

    print("#" * 40)

    return args
Example #6
0
    def setprogramedefault(self):

        machine = platform.machine()

        system = platform.system()

        jellyfishpath = 'bin/jellyfish/' + machine + '-' + system + '/bin/' + 'jellyfish'

        bwapath = 'bin/bwa/' + machine + '-' + system + '/bwa'

        # set default jellyfish path
        if os.path.isfile(jellyfishpath):

            self.jfversion = jellyfish.jfversion(jellyfishpath)

            if not self.jfversion == 'None':
                self.label_program_JFversion.setText(self.jfversion)

                self.label_program_JFversion.setStyleSheet("color:green")

                self.lineEdit_program_JFPath.setText(jellyfishpath)

                self.jellyfishpath = jellyfishpath

        else:

            jellyfishpath = shutil.which("jellyfish")

            if jellyfishpath:

                self.jfversion = jellyfish.jfversion(jellyfishpath)

                if not self.jfversion == 'None':
                    self.label_program_JFversion.setText(self.jfversion)

                    self.label_program_JFversion.setStyleSheet("color:green")

                    self.lineEdit_program_JFPath.setText(jellyfishpath)

                    self.jellyfishpath = jellyfishpath

        # set default bwa path
        if os.path.isfile(bwapath):

            self.bwaversion = bwa.bwaversion(bwapath)

            print(bwapath, self.bwaversion)

            if not self.bwaversion == 'None':
                self.label_program_Alnversion.setText(self.bwaversion)

                self.lineEdit_program_AlnPath.setText(bwapath)

                self.alignerpath = bwapath

                self.aligner = 'BWA'

                self.label_program_Alnversion.setStyleSheet("color:green")
        else:

            bwapath = shutil.which("bwa")

            if bwapath:

                self.bwaversion = bwa.bwaversion(bwapath)

                print(bwapath, self.bwaversion)

                if not self.bwaversion == 'None':
                    self.label_program_Alnversion.setText(self.bwaversion)

                    self.lineEdit_program_AlnPath.setText(bwapath)

                    self.alignerpath = bwapath

                    self.aligner = 'BWA'

                    self.label_program_Alnversion.setStyleSheet("color:green")
Example #7
0
def check_options(parser):

    args = parser.parse_args()

    # Start check bwa
    if args.bwa:

        if not os.path.exists(args.bwa):

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

        bwaversion = bwa.bwaversion(args.bwa)

        if bwaversion == 'None':

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    else:

        bwapath = which('bwa')

        if bwapath:

            bwaversion = bwa.bwaversion(bwapath[0])

            if bwaversion == 'None':

                print("Can not locate bwa, please input full path of bwa\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.bwa = bwapath[0]

        else:

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    # End check bwa

    # Start check jellyfish
    if args.jellyfish:

        if not os.path.exists(args.jellyfish):

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

        jellyfishversion = jellyfish.jfversion(args.jellyfish)

        if jellyfishversion == 'None':

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

    else:

        jellyfishpath = which('jellyfish')

        if jellyfishpath:

            jellyfishversion = jellyfish.jfversion(jellyfishpath[0])

            if jellyfishversion == 'None':

                print("Can not locate jellyfish, please input full path of jellyfish\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.jellyfish = jellyfishpath[0]

        else:

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)
    # End check jellyfish

    if not os.path.exists(args.genome):

        print("Can not locate genome file, please input genome file.\n")

        parser.print_help()

        sys.exit(1)

    if not os.path.exists(args.input):

        print("Can not locate input file, please input input file.\n")

        parser.print_help()

        sys.exit(1)

    if args.homology > 100 or args.homology < 50:

        print("Please set homology between 50 and 100.\n")

        parser.print_help()

        sys.exit(1)

    if args.dtm > 37 or args.dtm < -1:
    # dtm = -1 skip calculate dtm
        print("Please set dtm between 0 and 37.\n")

        parser.print_help()

        sys.exit(1)

    if args.skipdtm == True:

        args.dtm = -1

        print("skip calculate dtm")

    if args.length > 50:

        args.dtm = -1

        print("oligo length longer than 50nt, skip calculate dtm")

    if args.step < 1:

        print("step must >1.\n")

        parser.print_help()

        sys.exit(1)

    # Start check saved folder
    if os.path.exists(args.saved):

        if not args.docker:
            print("The output folder ",args.saved, " already exists.")
            print('''
                Press Y to use it for output files. Everything in this folder will be removed.
                Press N and set -s/--saved to a different folder:
                ''')

            while True:

                char = getch()

                if char.lower() in ("y", "n"):

                    print(char)

                    if char.lower() == 'n':

                        sys.exit(1)

                    break

    else:

        os.mkdir(args.saved)
    # End check saved folder

    # Print Checked information
    print("#"*40)

    print("bwa version:", args.bwa, bwaversion)

    print("jellyfish version:", args.jellyfish, jellyfishversion)

    print("genome file:", args.genome)

    print("input file:", args.input)

    print("5\' labeled R primer:", args.primer)

    print("result output folder:",  os.path.realpath(args.saved))

    print("threads number:", args.threads)

    print("homology:", args.homology)

    print("dtm:", args.dtm)

    if args.dtm == -1:

        print("Warning: skip calculate dtm.")

    print("#"*40)

    return args
Example #8
0
def check_options(parser):

    args = parser.parse_args()

    # Start check jellyfish
    if args.jellyfish:

        if not os.path.exists(args.jellyfish):

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

        jellyfishversion = jellyfish.jfversion(args.jellyfish)

        if jellyfishversion == 'None':

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

    else:

        jellyfishpath = which('jellyfish')

        if jellyfishpath:

            jellyfishversion = jellyfish.jfversion(jellyfishpath[0])

            if jellyfishversion == 'None':

                print("Can not locate jellyfish, please input full path of jellyfish\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.jellyfish = jellyfishpath[0]

        else:

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)
    # End check jellyfish


    # check max min
    if args.maxk < args.mink:

        print("Error! Max kmer count is smaller than min kmer count!\n")

        parser.print_help()

        sys.exit(1)
    # End check max min

    # Check input file
    if not os.path.exists(args.input):

        print("Can not locate input file, please input input file.\n")

        parser.print_help()

        sys.exit(1)
    # End check input file
    return args
Example #9
0
def check_options(parser):

    args = parser.parse_args()

    if args.jellyfish:

        if not os.path.exists(args.jellyfish):
            print(
                "Can not locate jellyfish, please input full path of jellyfish\n"
            )

            parser.print_help()

            sys.exit(1)

        jellyfishversion = jellyfish.jfversion(args.jellyfish)

        if jellyfishversion == 'None':
            print(
                "Can not locate jellyfish, please input full path of jellyfish\n"
            )

            parser.print_help()

            sys.exit(1)

    else:

        jellyfishpath = which('jellyfish')

        if jellyfishpath:

            jellyfishversion = jellyfish.jfversion(jellyfishpath[0])

            if jellyfishversion == 'None':

                print(
                    "Can not locate jellyfish, please input full path of jellyfish\n"
                )

                parser.print_help()

                sys.exit(1)

            else:

                args.jellyfish = jellyfishpath[0]

        else:

            print(
                "Can not locate jellyfish, please input full path of jellyfish\n"
            )

            parser.print_help()

            sys.exit(1)

    if not os.path.exists(args.input):

        print("Can not input file, please input probe file.\n")

        parser.print_help()

        sys.exit(1)

    if args.mincount > args.maxcount:

        print("min count %s is larger than max count %s" %
              (args.mincount, args.maxcount))

        parser.print_help()

        sys.exit(1)

    print("jellyfish version:", args.jellyfish, jellyfishversion)

    print("input file:", args.input)

    print("min count %s, max count %s" % (args.mincount, args.maxcount))

    print("result output folder:", os.path.realpath(args.outfile))

    return args
Example #10
0
def check_options(parser):

    args = parser.parse_args()

    if args.jellyfish:

        if not os.path.exists(args.jellyfish):

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

        jellyfishversion = jellyfish.jfversion(args.jellyfish)

        if jellyfishversion == 'None':

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

    else:

        jellyfishpath = which('jellyfish')

        if jellyfishpath:

            jellyfishversion = jellyfish.jfversion(jellyfishpath[0])

            if jellyfishversion == 'None':

                print("Can not locate jellyfish, please input full path of jellyfish\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.jellyfish = jellyfishpath[0]

        else:

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)
    # End check jellyfish

    if not os.path.exists(args.genome):

        print("Can not locate genome file, please input genome file.\n")

        parser.print_help()

        sys.exit(1)

    if not os.path.exists(args.probe):

        print("Can not locate probe file, please input genome file.\n")

        parser.print_help()

        sys.exit(1)


    if args.input:

        inputfiles = args.input.split(',')

        for inputfile in inputfiles:

            if not os.path.exists(inputfile):

                print("Can not locate %s file.\n" % inputfile)

                parser.print_help()

                sys.exit(1)

    elif args.jfile:

        if not os.path.exists(args.jfile):

            print("Can not locate %s file.\n" % args.jfile)

            parser.print_help()

            sys.exit(1)

    else:

        print("Can not locate input or jellyfish index file, please input jellyfish index or input file.\n")

        parser.print_help()

        sys.exit(1)

    return args
Example #11
0
    def setprogramedefault(self):

        machine = platform.machine()

        system = platform.system()

        jellyfishpath = 'bin/jellyfish/' + machine + '-' + system + '/bin/' + 'jellyfish'

        bwapath = 'bin/bwa/' + machine + '-' + system + '/bwa'


        # set default jellyfish path
        if os.path.isfile(jellyfishpath):

            self.jfversion = jellyfish.jfversion(jellyfishpath)

            if not self.jfversion == 'None':
                self.label_program_JFversion.setText(self.jfversion)

                self.label_program_JFversion.setStyleSheet("color:green")

                self.lineEdit_program_JFPath.setText(jellyfishpath)

                self.jellyfishpath = jellyfishpath

        else:

            jellyfishpath = shutil.which("jellyfish")

            if jellyfishpath:

                self.jfversion = jellyfish.jfversion(jellyfishpath)

                if not self.jfversion == 'None':
                    self.label_program_JFversion.setText(self.jfversion)

                    self.label_program_JFversion.setStyleSheet("color:green")

                    self.lineEdit_program_JFPath.setText(jellyfishpath)

                    self.jellyfishpath = jellyfishpath

        # set default bwa path
        if os.path.isfile(bwapath):

            self.bwaversion = bwa.bwaversion(bwapath)

            print(bwapath, self.bwaversion)

            if not self.bwaversion == 'None':
                self.label_program_Alnversion.setText(self.bwaversion)

                self.lineEdit_program_AlnPath.setText(bwapath)

                self.alignerpath = bwapath

                self.aligner = 'BWA'

                self.label_program_Alnversion.setStyleSheet("color:green")
        else:

            bwapath = shutil.which("bwa")

            if bwapath:

                self.bwaversion = bwa.bwaversion(bwapath)

                print(bwapath, self.bwaversion)

                if not self.bwaversion == 'None':
                    self.label_program_Alnversion.setText(self.bwaversion)

                    self.lineEdit_program_AlnPath.setText(bwapath)

                    self.alignerpath = bwapath

                    self.aligner = 'BWA'

                    self.label_program_Alnversion.setStyleSheet("color:green")
Example #12
0
def check_options(parser):

    args = parser.parse_args()

    if args.bwa:

        if not os.path.exists(args.bwa):

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

        bwaversion = bwa.bwaversion(args.bwa)

        if bwaversion == 'None':

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    else:

        bwapath = subprocesspath.which('bwa')

        if bwapath:

            bwaversion = bwa.bwaversion(bwapath[0])

            if bwaversion == 'None':

                print("Can not locate bwa, please input full path of bwa\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.bwa = bwapath[0]

        else:

            print("Can not locate bwa, please input full path of bwa\n")

            parser.print_help()

            sys.exit(1)

    # End check bwa

    # Start check jellyfish
    if args.jellyfish:

        if not os.path.exists(args.jellyfish):

            print(
                "Can not locate jellyfish, please input full path of jellyfish\n"
            )

            parser.print_help()

            sys.exit(1)

        jellyfishversion = jellyfish.jfversion(args.jellyfish)

        if jellyfishversion == 'None':

            print(
                "Can not locate jellyfish, please input full path of jellyfish\n"
            )

            parser.print_help()

            sys.exit(1)

    else:

        jellyfishpath = subprocesspath.which('jellyfish')

        if jellyfishpath:

            jellyfishversion = jellyfish.jfversion(jellyfishpath[0])

            if jellyfishversion == 'None':

                print(
                    "Can not locate jellyfish, please input full path of jellyfish\n"
                )

                parser.print_help()

                sys.exit(1)

            else:

                args.jellyfish = jellyfishpath[0]

        else:

            print(
                "Can not locate jellyfish, please input full path of jellyfish\n"
            )

            parser.print_help()

            sys.exit(1)
    # End check jellyfish

    if args.samtools:

        if not os.path.exists(args.samtools):

            print(
                "Can not locate samtools, please input full path of samtools\n"
            )

            parser.print_help()

            sys.exit(1)

        samtoolsversion = bwa.samtoolsversion(args.samtools)

        if samtoolsversion == 'None':

            print(
                "Can not locate samtools, please input full path of samtools\n"
            )

            parser.print_help()

            sys.exit(1)

    else:

        samtoolspath = subprocesspath.which('samtools')

        if samtoolspath:

            samtoolsversion = bwa.samtoolsversion(samtoolspath[0])

            if samtoolsversion == 'None':

                print(
                    "Can not locate samtools, please input full path of samtools\n"
                )

                parser.print_help()

                sys.exit(1)

            else:

                args.samtools = samtoolspath[0]

        else:

            print(
                "Can not locate samtools, please input full path of samtools\n"
            )

            parser.print_help()

            sys.exit(1)

    if args.bcftools:

        if not os.path.exists(args.bcftools):

            print(
                "Can not locate bcftools, please input full path of bcftools\n"
            )

            parser.print_help()

            sys.exit(1)

        bcftoolsversion = bcftools.bcftoolsversion(args.bcftools)

        if bcftoolsversion == 'None':

            print(
                "Can not locate bcftools, please input full path of bcftools\n"
            )

            parser.print_help()

            sys.exit(1)

    else:

        bcftoolspath = subprocesspath.which('bcftools')

        if bcftoolspath:

            bcftoolsversion = bcftools.bcftoolsversion(bcftoolspath[0])

            if bcftoolsversion == 'None':

                print(
                    "Can not locate bcftools, please input full path of bcftools\n"
                )

                parser.print_help()

                sys.exit(1)

            else:

                args.bcftools = bcftoolspath[0]

        else:

            print(
                "Can not locate bcftools, please input full path of bcftools\n"
            )

            parser.print_help()

            sys.exit(1)

    if not os.path.exists(args.genome):

        print("Can not locate genome file, please input genome file.\n")

        parser.print_help()

        sys.exit(1)

    if not os.path.exists(args.probe):

        print(
            "Can not locate probe file, please input probe file which generate by Chorus2.\n"
        )

        parser.print_help()

        sys.exit(1)

    names = args.names.split(',')

    reads1 = args.reads1.split(',')

    reads2 = args.reads2.split(',')

    if len(names) != len(reads1):

        print("There are %s species (%s) but %s reads1 files (%s)" %
              (len(names), names, len(reads1), reads1))

    if len(names) != len(reads2):
        print("There are %s species (%s) but %s reads2 files (%s)" %
              (len(names), names, len(reads2), reads2))

    for read1 in reads1:
        # print(read1)
        if not os.path.exists(read1):

            print("Can not locate %s file.\n", read1)

            parser.print_help()

            sys.exit(1)

    for read2 in reads2:

        if not os.path.exists(read2):
            print("Can not locate %s file.\n", read2)

            parser.print_help()

            sys.exit(1)

    if os.path.exists(args.saved):
        args.saved = os.path.realpath(args.saved)

        print("The output folder ", args.saved, " already exists.")
        print('''
                Press Y to use it for output files. Everything in this folder will be removed.
                Press N and set -s/--saved to a different folder:
                ''')

        while True:

            char = getch()

            if char.lower() in ("y", "n"):

                print(char)

                if char.lower() == 'n':

                    sys.exit(1)

                break

    else:

        args.saved = os.path.realpath(args.saved)

        os.mkdir(args.saved)

    if args.tmp:

        tmpfolder = os.path.abspath(args.tmp)

    else:

        tmpfolder = os.path.abspath(os.path.join(args.saved, './tmp'))

    print("tmp", args.tmp, tmpfolder)

    args.tmp = tmpfolder

    if os.path.exists(tmpfolder):

        tmpfolder = os.path.realpath(tmpfolder)

        print("The output folder ", tmpfolder, " already exists.")
        print('''
                Press Y to use it for output files. Everything in this folder will be removed.
                Press N and set --tmp to a different folder:
                ''')

        while True:

            char = getch()

            if char.lower() in ("y", "n"):

                print(char)

                if char.lower() == 'n':

                    sys.exit(1)

                break

    else:

        args.tmp = tmpfolder

        os.mkdir(tmpfolder)

    print("#" * 40)

    print("bwa version:", args.bwa, bwaversion)

    print("jellyfish version:", args.jellyfish, jellyfishversion)

    print("samtools version:", args.samtools, samtoolsversion)

    print("bcftools version:", args.bcftools, bcftoolsversion)

    print("genome file:", args.genome)

    print("probe file:", args.probe)

    print("out put folder:", args.saved)

    for i in range(len(names)):

        print(names[i], reads1[i], reads2[i])

    return args
Example #13
0
def check_options(parser):

    args = parser.parse_args()

    if args.jellyfish:

        if not os.path.exists(args.jellyfish):
            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

        jellyfishversion = jellyfish.jfversion(args.jellyfish)

        if jellyfishversion == "None":
            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

    else:

        jellyfishpath = which("jellyfish")

        if jellyfishpath:

            jellyfishversion = jellyfish.jfversion(jellyfishpath[0])

            if jellyfishversion == "None":

                print("Can not locate jellyfish, please input full path of jellyfish\n")

                parser.print_help()

                sys.exit(1)

            else:

                args.jellyfish = jellyfishpath[0]

        else:

            print("Can not locate jellyfish, please input full path of jellyfish\n")

            parser.print_help()

            sys.exit(1)

    if not os.path.exists(args.input):

        print("Can not input file, please input probe file.\n")

        parser.print_help()

        sys.exit(1)

    if args.mincount > args.maxcount:

        print("min count %s is larger than max count %s" % (args.mincount, args.maxcount))

        parser.print_help()

        sys.exit(1)

    print("jellyfish version:", args.jellyfish, jellyfishversion)

    print("input file:", args.input)

    print("min count %s, max count %s" % (args.mincount, args.maxcount))

    print("result output folder:", os.path.realpath(args.outfile))

    return args