def parseInputs( argv ):
	numProc = NUMPROC
	binSize = BINSIZE
	outID = None
	parentLabelAr = ['mother', 'father',0]
	decoding = DECODE
	isUniform = UNIFORM
	startInd = 0

	for i in range(min(7,len(argv))):
		if argv[i].startswith( '-o=' ):
			outID = argv[i][3:]
			startInd += 1
		elif argv[i].startswith( '-b=' ):
			inStr = argv[i][3:]
			binSize = bth_util.strToDistance( inStr )
			if binSize == False:
				print( 'WARNING: cannot convert {:s} to bin size...using default {:s}'.format( inStr, bth_util.binSizeToStr(BINSIZE) ) )
				binSize = BINSIZE
			startInd += 1
		elif argv[i].startswith( '-p=' ):
			try:
				numProc = int( argv[i][3:] )
				startInd += 1
			except ValueError:
				print( 'WARNING: number of processors must be integer...using 1' )
				numProc = NUMPROC
		elif argv[i].startswith( '-m=' ):
			parentLabelAr[0] = argv[i][3:]
			parentLabelAr[2] += 1
			startInd += 1
		elif argv[i].startswith( '-f=' ):
			parentLabelAr[1] = argv[i][3:]
			parentLabelAr[2] += 2
			startInd += 1
		elif argv[i].startswith( '-d=' ):
			opt = argv[i][3:].lower()
			if opt == 'false' or opt == 'none' or opt== 'n':
				decoding = 'N'
			elif opt == 'viterbi' or opt == 'v':
				decoding = 'V';
			elif opt == 'forwardbackward' or opt == 'f' or opt == 'fb':
				decoding = 'F'
			elif opt == 'all' or opt == 'a':
				decoding = 'A'
			else:
				print( 'WARNING: decoding option {:s} not recognized...using default viterbi'.format(opt) )
			startInd += 1
		elif argv[i] == '-u':
			isUniform = True
			startInd += 1
		elif argv[i] in [ '-h', '--help', '-help']:
			printHelp()
			exit()
		elif argv[i].startswith( '-' ):
			print( 'ERROR: {:s} is not a valid option'.format( argv[i] ) )
			exit()
	# end for
	inFileStr = argv[startInd]
	processInputs( inFileStr, numProc, binSize, outID, parentLabelAr, decoding, isUniform )
def parseInputs(argv):
    numProc = NUMPROC
    binSize = BINSIZE
    outID = None
    parentLabelAr = ['mother', 'father', 0]
    isSmoothing = True
    isUniform = False
    startInd = 0

    for i in range(min(7, len(argv))):
        if argv[i].startswith('-o='):
            outID = argv[i][3:]
            startInd += 1
        elif argv[i].startswith('-b='):
            inStr = argv[i][3:]
            binSize = bth_util.strToDistance(inStr)
            if binSize == False:
                print(
                    'WARNING: cannot convert {:s} to bin size...using default {:s}'
                    .format(inStr, bth_util.binSizeToStr(BINSIZE)))
                binSize = BINSIZE
            startInd += 1
        elif argv[i].startswith('-p='):
            try:
                numProc = int(argv[i][3:])
                startInd += 1
            except ValueError:
                print(
                    'WARNING: number of processors must be integer...using 1')
                numProc = NUMPROC
        elif argv[i].startswith('-m='):
            parentLabelAr[0] = argv[i][3:]
            parentLabelAr[2] += 1
            startInd += 1
        elif argv[i].startswith('-f='):
            parentLabelAr[1] = argv[i][3:]
            parentLabelAr[2] += 2
            startInd += 1
        elif argv[i] == '-n':
            isSmoothing = False
            startInd += 1
        elif argv[i] == '-u':
            isUniform = True
            startInd += 1
        elif argv[i] in ['-h', '--help', '-help']:
            printHelp()
            exit()
        elif argv[i].startswith('-'):
            print('ERROR: {:s} is not a valid option'.format(argv[i]))
            exit()
    # end for
    inFileStr = argv[startInd]
    processInputs(inFileStr, numProc, binSize, outID, parentLabelAr,
                  isSmoothing, isUniform)
def parseInputs( argv ):
	numProc = NUMPROC
	binSize = BINSIZE
	outID = None
	parentLabelAr = ['mother', 'father',0]
	isSmoothing = True
	isUniform = False
	startInd = 0

	for i in range(min(7,len(argv))):
		if argv[i].startswith( '-o=' ):
			outID = argv[i][3:]
			startInd += 1
		elif argv[i].startswith( '-b=' ):
			inStr = argv[i][3:]
			binSize = bth_util.strToDistance( inStr )
			if binSize == False:
				print( 'WARNING: cannot convert {:s} to bin size...using default {:s}'.format( inStr, bth_util.binSizeToStr(BINSIZE) ) )
				binSize = BINSIZE
			startInd += 1
		elif argv[i].startswith( '-p=' ):
			try:
				numProc = int( argv[i][3:] )
				startInd += 1
			except ValueError:
				print( 'WARNING: number of processors must be integer...using 1' )
				numProc = NUMPROC
		elif argv[i].startswith( '-m=' ):
			parentLabelAr[0] = argv[i][3:]
			parentLabelAr[2] += 1
			startInd += 1
		elif argv[i].startswith( '-f=' ):
			parentLabelAr[1] = argv[i][3:]
			parentLabelAr[2] += 2
			startInd += 1
		elif argv[i] == '-n':
			isSmoothing = False
			startInd += 1
		elif argv[i] == '-u':
			isUniform = True
			startInd += 1
		elif argv[i] in [ '-h', '--help', '-help']:
			printHelp()
			exit()
		elif argv[i].startswith( '-' ):
			print( 'ERROR: {:s} is not a valid option'.format( argv[i] ) )
			exit()
	# end for
	inFileStr = argv[startInd]
	processInputs( inFileStr, numProc, binSize, outID, parentLabelAr, isSmoothing, isUniform )
def parseInputs( argv ):
	numProc = NUMPROC
	outID = None
	isStrand = False
	isCSSR = False
	cssrDist = CSSRDIST
	startInd = 0
	
	for i in range(min(4,len(argv))):
		if argv[i] == '-strand':
			isStrand = True
			startInd += 1
		elif argv[i].startswith('-cssr='):
			isCSSR = True
			cssrDist = bth_util.strToDistance( argv[i][6:] )
			if cssrDist == False:
				print( 'ERROR: cSSR distance specification is incorrect' )
				exit()
			startInd += 1
		elif argv[i] == '-cssr':
			isCSSR = True
			startInd += 1
		elif argv[i].startswith( '-o=' ):
			outID = argv[i][3:]
			startInd += 1
		elif argv[i].startswith( '-p=' ):
			try:
				numProc = int( argv[i][3:] )
				startInd += 1
			except ValueError:
				print( 'ERROR: number of processors must be integer' )
				exit()
		elif argv[i].startswith( '-' ):
			print( 'ERROR: {:s} is not a valid option'.format( argv[i] ) )
			exit()
	# end for
	regionFileStr = argv[startInd]
	bedFileAr = []
	for j in range(startInd+1, len(argv)):
		bedFileAr += [ argv[j] ]
	processInputs( regionFileStr, bedFileAr, numProc, isStrand, isCSSR, cssrDist, outID )
def parseInputs( argv ):
	numProc = NUMPROC
	binSize = BINSIZE
	outID = None
	parentLabelAr = ['mother', 'father', 0]
	decoding = DECODE
	classProbs = CLASSPROB
	combineBins = COMBINE
	isPrint = ISPRINT
	centromere=None
	startInd = 0
	
	for i in range( min(10, len(argv)-1) ):
		if argv[i].startswith( '-o=' ):
			outID = argv[i][3:]
			startInd += 1
		elif argv[i].startswith( '-b=' ):
			inStr = argv[i][3:]
			binSize = bth_util.strToDistance( inStr )
			if binSize == False:
				print( 'WARNING: cannot convert {:s} to bin size...using default {:s}'.format( inStr, bth_util.binSizeToStr(BINSIZE) ) )
				binSize = BINSIZE
			startInd += 1
		elif argv[i].startswith( '-p=' ):
			try:
				numProc = int( argv[i][3:] )
				startInd += 1
			except ValueError:
				print( 'WARNING: number of processors must be integer...using 1' )
				numProc = NUMPROC
		elif argv[i].startswith( '-c=' ):
			try:
				combineBins = int( argv[i][3:] )
				startInd += 1
			except ValueError:
				print( 'WARNING: combine bins must be integer...using default {:s}'.format(COMBINE) )
				combineBins = COMBINE
		elif argv[i].startswith( '-m=' ):
			parentLabelAr[0] = argv[i][3:]
			parentLabelAr[2] += 1
			startInd += 1
		elif argv[i].startswith( '-f=' ):
			parentLabelAr[1] = argv[i][3:]
			parentLabelAr[2] += 2
			startInd += 1
		elif argv[i].startswith( '-d=' ):
			opt = argv[i][3:].lower()
			if opt == 'false' or opt == 'none' or opt== 'n':
				decoding = 'N'
			elif opt == 'viterbi' or opt == 'v':
				decoding = 'V';
			elif opt == 'forwardbackward' or opt == 'f' or opt == 'fb':
				decoding = 'F'
			elif opt == 'all' or opt == 'a':
				decoding = 'A'
			elif opt == 'both' or opt == 'b':
				decoding = 'B'
			else:
				print( 'WARNING: decoding option {:s} not recognized...using default viterbi'.format(opt) )
			startInd += 1
		elif argv[i] == '-u':
			if classProbs != CLASSPROB:
				print( 'WARNING: cannot specify uniform and epiRIL class weights...using default' )
				classProbs = CLASSPROB
			else:
				classProbs = 'U'
			startInd += 1
		elif argv[i] == '-e':
			if classProbs != CLASSPROB:
				print( 'WARNING: cannot specify uniform and epiRIL class weights...using default' )
				classProbs = CLASSPROB
			else:
				classProbs = 'E'
			startInd += 1
		elif argv[i] == '-q':
			isPrint = False
			startInd += 1
		elif argv[i].startswith( '-t=' ):
			tmp = argv[i][3:].split(',')
			tmp2 = [ bth_util.strToDistance( x ) for x in tmp ]
			if len(tmp2) % 2 != 0 or (False in tmp2):
				print( 'WARNING: centromere coordinates bad...not using' )
			else:
				centromere = tmp2
			startInd += 1
		elif argv[i] in [ '-h', '--help', '-help']:
			printHelp()
			exit()
		elif argv[i].startswith( '-' ):
			print( 'ERROR: {:s} is not a valid option'.format( argv[i] ) )
			exit()
	# end for
	
	inFileStr = argv[startInd]
	processInputs( inFileStr, numProc, binSize, outID, parentLabelAr, decoding, classProbs, combineBins, centromere, isPrint )
Beispiel #6
0
def parseInputs(argv):
    numProc = NUMPROC
    binSize = BINSIZE
    outID = None
    parentLabelAr = ['mother', 'father', 0]
    decoding = DECODE
    isUniform = UNIFORM
    combineBins = COMBINE
    startInd = 0

    for i in range(min(7, len(argv) - 1)):
        if argv[i].startswith('-o='):
            outID = argv[i][3:]
            startInd += 1
        elif argv[i].startswith('-b='):
            inStr = argv[i][3:]
            binSize = bth_util.strToDistance(inStr)
            if binSize == False:
                print(
                    'WARNING: cannot convert {:s} to bin size...using default {:s}'
                    .format(inStr, bth_util.binSizeToStr(BINSIZE)))
                binSize = BINSIZE
            startInd += 1
        elif argv[i].startswith('-p='):
            try:
                numProc = int(argv[i][3:])
                startInd += 1
            except ValueError:
                print(
                    'WARNING: number of processors must be integer...using 1')
                numProc = NUMPROC
        elif argv[i].startswith('-c='):
            try:
                combineBins = int(argv[i][3:])
                startInd += 1
            except ValueError:
                print(
                    'WARNING: number of processors must be integer...using default {:s}'
                    .format(COMBINE))
                combineBins = COMBINE
        elif argv[i].startswith('-m='):
            parentLabelAr[0] = argv[i][3:]
            parentLabelAr[2] += 1
            startInd += 1
        elif argv[i].startswith('-f='):
            parentLabelAr[1] = argv[i][3:]
            parentLabelAr[2] += 2
            startInd += 1
        elif argv[i].startswith('-d='):
            opt = argv[i][3:].lower()
            if opt == 'false' or opt == 'none' or opt == 'n':
                decoding = 'N'
            elif opt == 'viterbi' or opt == 'v':
                decoding = 'V'
            elif opt == 'forwardbackward' or opt == 'f' or opt == 'fb':
                decoding = 'F'
            elif opt == 'all' or opt == 'a':
                decoding = 'A'
            else:
                print(
                    'WARNING: decoding option {:s} not recognized...using default viterbi'
                    .format(opt))
            startInd += 1
        elif argv[i] == '-u':
            isUniform = True
            startInd += 1
        elif argv[i] in ['-h', '--help', '-help']:
            printHelp()
            exit()
        elif argv[i].startswith('-'):
            print('ERROR: {:s} is not a valid option'.format(argv[i]))
            exit()
    # end for

    inFileStr = argv[startInd]
    processInputs(inFileStr, numProc, binSize, outID, parentLabelAr, decoding,
                  isUniform, combineBins)
def parseInputs(argv):
    numProc = NUMPROC
    binSize = BINSIZE
    outID = None
    parentLabelAr = ['mother', 'father', 0]
    decoding = DECODE
    classProbs = CLASSPROB
    combineBins = COMBINE
    isPrint = ISPRINT
    centromere = None
    scaleTransitions = SCALETRANS
    startInd = 0

    for i in range(min(10, len(argv) - 1)):
        if argv[i].startswith('-o='):
            outID = argv[i][3:]
            startInd += 1
        elif argv[i].startswith('-b='):
            inStr = argv[i][3:]
            binSize = bth_util.strToDistance(inStr)
            if binSize == False:
                print(
                    'WARNING: cannot convert {:s} to bin size...using default {:s}'
                    .format(inStr, bth_util.binSizeToStr(BINSIZE)))
                binSize = BINSIZE
            startInd += 1
        elif argv[i].startswith('-p='):
            try:
                numProc = int(argv[i][3:])
                startInd += 1
            except ValueError:
                print(
                    'WARNING: number of processors must be integer...using 1')
                numProc = NUMPROC
        elif argv[i].startswith('-c='):
            try:
                combineBins = int(argv[i][3:])
                startInd += 1
            except ValueError:
                print(
                    'WARNING: combine bins must be integer...using default {:s}'
                    .format(COMBINE))
                combineBins = COMBINE
        elif argv[i].startswith('-m='):
            parentLabelAr[0] = argv[i][3:]
            parentLabelAr[2] += 1
            startInd += 1
        elif argv[i].startswith('-f='):
            parentLabelAr[1] = argv[i][3:]
            parentLabelAr[2] += 2
            startInd += 1
        elif argv[i].startswith('-d='):
            opt = argv[i][3:].lower()
            if opt == 'false' or opt == 'none' or opt == 'n':
                decoding = 'N'
            elif opt == 'viterbi' or opt == 'v':
                decoding = 'V'
            elif opt == 'forwardbackward' or opt == 'f' or opt == 'fb':
                decoding = 'F'
            elif opt == 'all' or opt == 'a':
                decoding = 'A'
            elif opt == 'both' or opt == 'b':
                decoding = 'B'
            else:
                print(
                    'WARNING: decoding option {:s} not recognized...using default viterbi'
                    .format(opt))
            startInd += 1
        elif argv[i] == '-e':
            classProbs = 'E'
            startInd += 1
        elif argv[i] == '-s':
            scaleTransitions = True
            startInd += 1
        elif argv[i] == '-q':
            isPrint = False
            startInd += 1
        elif argv[i].startswith('-t='):
            tmp = argv[i][3:].split(',')
            tmp2 = [bth_util.strToDistance(x) for x in tmp]
            if len(tmp2) % 2 != 0 or (False in tmp2):
                print('WARNING: centromere coordinates bad...not using')
            else:
                centromere = tmp2
            startInd += 1
        elif argv[i] in ['-h', '--help', '-help']:
            printHelp()
            exit()
        elif argv[i].startswith('-'):
            print('ERROR: {:s} is not a valid option'.format(argv[i]))
            exit()
    # end for

    inFileStr = argv[startInd]
    processInputs(inFileStr, numProc, binSize, outID, parentLabelAr, decoding,
                  classProbs, combineBins, centromere, scaleTransitions,
                  isPrint)
def parseInputs( argv ):
	numProc = NUMPROC
	binSize = BINSIZE
	outID = None
	parentLabelAr = ['mother', 'father', 0]
	decoding = DECODE
	generation = GENERATION
	combineBins = COMBINE
	mpvCheck = MPVCHECK
	isPrint = ISPRINT
	tmOut = TMOUT
	centromere = None
	startInd = 0
	
	for i in range( min(11, len(argv)-1) ):
		if argv[i].startswith( '-o=' ):
			outID = argv[i][3:]
			startInd += 1
		elif argv[i].startswith( '-b=' ):
			inStr = argv[i][3:]
			binSize = bth_util.strToDistance( inStr )
			if binSize == False:
				print( 'WARNING: cannot convert {:s} to bin size...using default {:s}'.format( inStr, bth_util.binSizeToStr(BINSIZE) ) )
				binSize = BINSIZE
			startInd += 1
		elif argv[i].startswith( '-p=' ):
			try:
				numProc = int( argv[i][3:] )
			except ValueError:
				print( 'WARNING: number of processors must be integer...using', NUMPROC )
				numProc = NUMPROC
			startInd += 1
		elif argv[i].startswith( '-c=' ):
			try:
				combineBins = int( argv[i][3:] )
			except ValueError:
				print( 'WARNING: combine bins must be integer...using default', COMBINE )
				combineBins = COMBINE
			startInd += 1
		elif argv[i].startswith( '-m=' ):
			parentLabelAr[0] = argv[i][3:]
			parentLabelAr[2] += 1
			startInd += 1
		elif argv[i].startswith( '-f=' ):
			parentLabelAr[1] = argv[i][3:]
			parentLabelAr[2] += 2
			startInd += 1
		elif argv[i].startswith( '-d=' ):
			opt = argv[i][3:].lower()
			if opt == 'false' or opt == 'none' or opt== 'n':
				decoding = 'N'
			elif opt == 'viterbi' or opt == 'v':
				decoding = 'V';
			elif opt == 'forwardbackward' or opt == 'f' or opt == 'fb':
				decoding = 'F'
			elif opt == 'all' or opt == 'a':
				decoding = 'A'
			elif opt == 'both' or opt == 'b':
				decoding = 'B'
			else:
				print( 'WARNING: decoding option {:s} not recognized...using default both'.format(opt) )
			startInd += 1
		elif argv[i].startswith( '-g=' ):
			try:
				generation = int( argv[i][3:] )
			except ValueError:
				print( 'WARNING: generation must be integer...using default {:s}'.format(COMBINE) )
				generation = GENERATION
			startInd += 1
		elif argv[i] == '-q':
			isPrint = False
			startInd += 1
		elif argv[i] == '-n-mpv':
			mpvCheck = False
			startInd += 1
		elif argv[i] == '-t-out':
			tmOut = True
			startInd += 1
		elif argv[i].startswith( '-t=' ):
			tmp = argv[i][3:].split(',')
			tmp2 = [ bth_util.strToDistance( x ) for x in tmp ]
			if len(tmp2) % 2 != 0 or (False in tmp2):
				print( 'WARNING: centromere coordinates bad...not using' )
			else:
				centromere = tmp2
			startInd += 1
		elif argv[i] in [ '-h', '--help', '-help']:
			printHelp()
			exit()
		elif argv[i].startswith( '-' ):
			print( 'ERROR: {:s} is not a valid option'.format( argv[i] ) )
			exit()
	# end for
	
	inFileStr = argv[startInd]
	processInputs( inFileStr, numProc, binSize, outID, parentLabelAr, decoding, generation, combineBins, centromere, isPrint, mpvCheck, tmOut )
def parseInputs(argv):
    numProc = NUMPROC
    binSize = BINSIZE
    outID = None
    parentLabelAr = ['mother', 'father', 0]
    decoding = DECODE
    generation = GENERATION
    combineBins = COMBINE
    mpvCheck = MPVCHECK
    isPrint = ISPRINT
    tmOut = TMOUT
    centromere = None
    startInd = 0

    for i in range(min(11, len(argv) - 1)):
        if argv[i].startswith('-o='):
            outID = argv[i][3:]
            startInd += 1
        elif argv[i].startswith('-b='):
            inStr = argv[i][3:]
            binSize = bth_util.strToDistance(inStr)
            if binSize == False:
                print(
                    'WARNING: cannot convert {:s} to bin size...using default {:s}'
                    .format(inStr, bth_util.binSizeToStr(BINSIZE)))
                binSize = BINSIZE
            startInd += 1
        elif argv[i].startswith('-p='):
            try:
                numProc = int(argv[i][3:])
            except ValueError:
                print('WARNING: number of processors must be integer...using',
                      NUMPROC)
                numProc = NUMPROC
            startInd += 1
        elif argv[i].startswith('-c='):
            try:
                combineBins = int(argv[i][3:])
            except ValueError:
                print('WARNING: combine bins must be integer...using default',
                      COMBINE)
                combineBins = COMBINE
            startInd += 1
        elif argv[i].startswith('-m='):
            parentLabelAr[0] = argv[i][3:]
            parentLabelAr[2] += 1
            startInd += 1
        elif argv[i].startswith('-f='):
            parentLabelAr[1] = argv[i][3:]
            parentLabelAr[2] += 2
            startInd += 1
        elif argv[i].startswith('-d='):
            opt = argv[i][3:].lower()
            if opt == 'false' or opt == 'none' or opt == 'n':
                decoding = 'N'
            elif opt == 'viterbi' or opt == 'v':
                decoding = 'V'
            elif opt == 'forwardbackward' or opt == 'f' or opt == 'fb':
                decoding = 'F'
            elif opt == 'all' or opt == 'a':
                decoding = 'A'
            elif opt == 'both' or opt == 'b':
                decoding = 'B'
            else:
                print(
                    'WARNING: decoding option {:s} not recognized...using default both'
                    .format(opt))
            startInd += 1
        elif argv[i].startswith('-g='):
            try:
                generation = int(argv[i][3:])
            except ValueError:
                print(
                    'WARNING: generation must be integer...using default {:s}'.
                    format(COMBINE))
                generation = GENERATION
            startInd += 1
        elif argv[i] == '-q':
            isPrint = False
            startInd += 1
        elif argv[i] == '-n-mpv':
            mpvCheck = False
            startInd += 1
        elif argv[i] == '-t-out':
            tmOut = True
            startInd += 1
        elif argv[i].startswith('-t='):
            tmp = argv[i][3:].split(',')
            tmp2 = [bth_util.strToDistance(x) for x in tmp]
            if len(tmp2) % 2 != 0 or (False in tmp2):
                print('WARNING: centromere coordinates bad...not using')
            else:
                centromere = tmp2
            startInd += 1
        elif argv[i] in ['-h', '--help', '-help']:
            printHelp()
            exit()
        elif argv[i].startswith('-'):
            print('ERROR: {:s} is not a valid option'.format(argv[i]))
            exit()
    # end for

    inFileStr = argv[startInd]
    processInputs(inFileStr, numProc, binSize, outID, parentLabelAr, decoding,
                  generation, combineBins, centromere, isPrint, mpvCheck,
                  tmOut)
def parseInputs( argv ):
	numProc = NUMPROC
	binSize = BINSIZE
	outID = None
	parentLabelAr = ['mother', 'father', 0]
	decoding = DECODE
	isUniform = UNIFORM
	combineBins = COMBINE
	centromere=None
	scaleFactor = SCALE
	startInd = 0
	
	for i in range( min(9, len(argv)-1) ):
		if argv[i].startswith( '-o=' ):
			outID = argv[i][3:]
			startInd += 1
		elif argv[i].startswith( '-b=' ):
			inStr = argv[i][3:]
			binSize = bth_util.strToDistance( inStr )
			if binSize == False:
				print( 'WARNING: cannot convert {:s} to bin size...using default {:s}'.format( inStr, bth_util.binSizeToStr(BINSIZE) ) )
				binSize = BINSIZE
			startInd += 1
		elif argv[i].startswith( '-p=' ):
			try:
				numProc = int( argv[i][3:] )
				startInd += 1
			except ValueError:
				print( 'WARNING: number of processors must be integer...using 1' )
				numProc = NUMPROC
		elif argv[i].startswith( '-c=' ):
			try:
				combineBins = int( argv[i][3:] )
				startInd += 1
			except ValueError:
				print( 'WARNING: number of processors must be integer...using default {:s}'.format(COMBINE) )
				combineBins = COMBINE
		elif argv[i].startswith( '-m=' ):
			parentLabelAr[0] = argv[i][3:]
			parentLabelAr[2] += 1
			startInd += 1
		elif argv[i].startswith( '-f=' ):
			parentLabelAr[1] = argv[i][3:]
			parentLabelAr[2] += 2
			startInd += 1
		elif argv[i].startswith( '-d=' ):
			opt = argv[i][3:].lower()
			if opt == 'false' or opt == 'none' or opt== 'n':
				decoding = 'N'
			elif opt == 'viterbi' or opt == 'v':
				decoding = 'V';
			elif opt == 'forwardbackward' or opt == 'f' or opt == 'fb':
				decoding = 'F'
			elif opt == 'all' or opt == 'a':
				decoding = 'A'
			else:
				print( 'WARNING: decoding option {:s} not recognized...using default {:s}'.format(opt, DECODE) )
			startInd += 1
		elif argv[i] == '-u':
			isUniform = True
			startInd += 1
		elif argv[i].startswith( '-t=' ):
			tmp = argv[i][3:].split(',')
			tmp2 = [ bth_util.strToDistance( x ) for x in tmp ]
			if len(tmp2) != 2 or (False in tmp2):
				print( 'WARNING: centromere coordinates bad...not using' )
			else:
				centromere = tmp2
			startInd += 1
		elif argv[i].startswith( '-s=' ):
			try:
				scaleFactor = float( argv[i][3:] )
				startInd += 1
				if scaleFactor == 0:
					print( 'WARNING: scale factor must be greater than 0...using default', SCALE )
			except ValueError:
				print( 'WARNING: scale factor must be numeric...using default {:s}'.format(SCALE) )
				scaleFactor = SCALE		
		elif argv[i] in [ '-h', '--help', '-help']:
			printHelp()
			exit()
		elif argv[i].startswith( '-' ):
			print( 'ERROR: {:s} is not a valid option'.format( argv[i] ) )
			exit()
	# end for
	
	inFileStr = argv[startInd]
	processInputs( inFileStr, numProc, binSize, outID, parentLabelAr, decoding, isUniform, combineBins, centromere, scaleFactor )
def parseInputs(argv):
    numProc = NUMPROC
    binSize = BINSIZE
    outID = None
    parentLabelAr = ['mother', 'father', 0]
    decoding = DECODE
    isUniform = UNIFORM
    combineBins = COMBINE
    centromere = None
    scaleFactor = SCALE
    startInd = 0

    for i in range(min(9, len(argv) - 1)):
        if argv[i].startswith('-o='):
            outID = argv[i][3:]
            startInd += 1
        elif argv[i].startswith('-b='):
            inStr = argv[i][3:]
            binSize = bth_util.strToDistance(inStr)
            if binSize == False:
                print(
                    'WARNING: cannot convert {:s} to bin size...using default {:s}'
                    .format(inStr, bth_util.binSizeToStr(BINSIZE)))
                binSize = BINSIZE
            startInd += 1
        elif argv[i].startswith('-p='):
            try:
                numProc = int(argv[i][3:])
                startInd += 1
            except ValueError:
                print(
                    'WARNING: number of processors must be integer...using 1')
                numProc = NUMPROC
        elif argv[i].startswith('-c='):
            try:
                combineBins = int(argv[i][3:])
                startInd += 1
            except ValueError:
                print(
                    'WARNING: number of processors must be integer...using default {:s}'
                    .format(COMBINE))
                combineBins = COMBINE
        elif argv[i].startswith('-m='):
            parentLabelAr[0] = argv[i][3:]
            parentLabelAr[2] += 1
            startInd += 1
        elif argv[i].startswith('-f='):
            parentLabelAr[1] = argv[i][3:]
            parentLabelAr[2] += 2
            startInd += 1
        elif argv[i].startswith('-d='):
            opt = argv[i][3:].lower()
            if opt == 'false' or opt == 'none' or opt == 'n':
                decoding = 'N'
            elif opt == 'viterbi' or opt == 'v':
                decoding = 'V'
            elif opt == 'forwardbackward' or opt == 'f' or opt == 'fb':
                decoding = 'F'
            elif opt == 'all' or opt == 'a':
                decoding = 'A'
            else:
                print(
                    'WARNING: decoding option {:s} not recognized...using default {:s}'
                    .format(opt, DECODE))
            startInd += 1
        elif argv[i] == '-u':
            isUniform = True
            startInd += 1
        elif argv[i].startswith('-t='):
            tmp = argv[i][3:].split(',')
            tmp2 = [bth_util.strToDistance(x) for x in tmp]
            if len(tmp2) != 2 or (False in tmp2):
                print('WARNING: centromere coordinates bad...not using')
            else:
                centromere = tmp2
            startInd += 1
        elif argv[i].startswith('-s='):
            try:
                scaleFactor = float(argv[i][3:])
                startInd += 1
                if scaleFactor == 0:
                    print(
                        'WARNING: scale factor must be greater than 0...using default',
                        SCALE)
            except ValueError:
                print(
                    'WARNING: scale factor must be numeric...using default {:s}'
                    .format(SCALE))
                scaleFactor = SCALE
        elif argv[i] in ['-h', '--help', '-help']:
            printHelp()
            exit()
        elif argv[i].startswith('-'):
            print('ERROR: {:s} is not a valid option'.format(argv[i]))
            exit()
    # end for

    inFileStr = argv[startInd]
    processInputs(inFileStr, numProc, binSize, outID, parentLabelAr, decoding,
                  isUniform, combineBins, centromere, scaleFactor)
Beispiel #12
0
def parseInputs( argv ):
	numProc = NUMPROC
	numBins = -1
	binSize = -1
	overlapSize = 0
	labels = None
	calcType = 'n'
	outID = ''
	startInd = 0
	chrmList = None
	
	for i in range( min(7, len(argv)) ):
		if argv[i].startswith( '-p=' ):
			try:
				numProc = int( argv[i][3:] )
				startInd += 1
			except ValueError:
				print( 'ERROR: number of processors must be an integer' )
				exit()
		elif argv[i].startswith( '-b=' ):
			# check for previous '-s'
			if binSize != -1:
				print( 'ERROR: cannot specify -b and -s together' )
				exit()
			try:
				numBins = int( argv[i][3:] )
				startInd += 1
				isNumBins = True
			except ValueError:
				print( 'ERROR: number of bins must be an integer' )
				exit()
		elif argv[i].startswith( '-s=' ):
			# check previous '-b'
			if numBins != -1:
				print( 'ERROR: cannot specify -b and -s together' )
				exit()
			
			binStr = argv[i][3:]
			binSize = bth_util.strToDistance( binStr )
			if binSize == False:
				print( 'ERROR: cannot interpret bin size' )
				exit()
			startInd += 1
		elif argv[i].startswith( '-o=' ):
			outID = argv[i][3:]
			startInd += 1
		elif argv[i].startswith( '-c=' ):
			chrmList = argv[i][3:].split( ',' )
			startInd += 1
		elif argv[i].startswith( '-l=' ):
			labels = argv[i][3:].split( ',' )
			startInd += 1
		elif argv[i].startswith( '-t=' ):
			x = argv[i][3:]
			if x.lower() not in ['l','n']:
				print( 'ERROR: {:s} is not a valid calculation type'.format(x) )
				exit()
			calcType = x.lower()
			startInd += 1
		elif argv[i].startswith( '-' ):
			print( 'ERROR: {:s} is not a valid option'.format( argv[i] ) )
			eixt()
	# end
	
	if numBins == -1 and binSize == -1:
		numBins = NUMBINS
	fastaIndexStr = argv[startInd]
	
	gffFileStrAr = []
	for j in range( startInd+1, len(argv) ):
		gffFileStrAr += [ argv[j] ]
	
	if labels != None and (len(labels) != len(gffFileStrAr)):
		print( "ERROR: number of labels doesn't match number of input files" )
		exit()
	
	
	processInputs( gffFileStrAr, fastaIndexStr, labels, calcType, outID, chrmList, numProc, numBins, binSize )