Beispiel #1
0
	def test_conv_align2GRmat_bl8_2(self):
		currentdir = os.path.dirname(os.path.abspath(__file__))
		ali_file = currentdir + os.sep + 'data' + os.sep + 'ex2.bl8'
		aliFormat = 2
		(U, NU, genomes, reads) = PathoID.conv_align2GRmat(ali_file,self.scoreCutoff,aliFormat)
		print U, NU, genomes, reads
		score = 7036818.21 #Expected score from the alignment file
		expectedU = {}
		self.assertEquals(expectedU, U, "Failed bl8 Example 2 Unique Reads Assertion")
		expectedNU = {0: [[0, 1], [score, score], [0.5, 0.5], score], 
			1: [[0, 1], [score, score], [0.5, 0.5], score], 
			2: [[2, 1], [score, score], [0.5, 0.5], score], 
			3: [[2, 1], [score, score], [0.5, 0.5], score], 
			4: [[2, 0, 1], [score, score, score], [0.3333, 0.3333, 0.3333], score], 
			5: [[2, 0, 1], [score, score, score], [0.3333, 0.3333, 0.3333], score], 
			6: [[2, 0, 1], [score, score, score], [0.3333, 0.3333, 0.3333], score]}
		self.assertEquals(len(expectedNU), len(NU), "Failed bl8 Example 1 Non-Unique Reads length Assertion")
		for read in expectedNU:
			self.assertEquals(expectedNU[read][0], NU[read][0], 
				"Failed bl8 Example 2 Non-Unique Read %d genome mapping Assertion" %read)
			for j in range(len(expectedNU[read][1])):
				self.assertAlmostEquals(expectedNU[read][1][j], NU[read][1][j], 2, 
					"Failed bl8 Example 2 Non-Unique Read %d score Assertion" %read)
			for j in range(len(expectedNU[read][2])):
				self.assertAlmostEquals(NU[read][2][j], expectedNU[read][2][j], 4, 
					"Failed bl8 Example 2 Non-Unique Read %d proportion Assertion" %read)
			self.assertAlmostEquals(expectedNU[read][3], NU[read][3], 2, 
				"Failed bl8 Example 1 Non-Unique Read %d weight Assertion" %read)
		expectedGenomes = ['genome2', 'genome1', 'genome3']
		self.assertEquals(expectedGenomes, genomes, "Failed bl8 Example 2 Genomes Assertion")
		expectedReads = ['read1_12', 'read2_12', 'read3_13', 'read4_13', 'read5_123', 'read6_123', 'read7_123']
		self.assertEquals(expectedReads, reads, "Failed bl8 Example 2 Reads Assertion")
Beispiel #2
0
	def test_pathoscope_em_4(self):
		scaledScore = 2.6881171418161356e+43 #Expected Re-scaled score
		U = {2: [0, scaledScore]}
		NU = {0: [[0, 1], [scaledScore, scaledScore], [0.5, 0.5], scaledScore], 
			1: [[1, 0], [scaledScore, scaledScore], [0.5, 0.5], scaledScore], 
			3: [[2, 3], [scaledScore, scaledScore], [0.5, 0.5], scaledScore], 
			4: [[2, 1], [scaledScore, scaledScore], [0.5, 0.5], scaledScore]}
		### Genome hash
		genomes = {0:"genome4", 1:"genome3", 2:"genome1", 3:"genome2"}
		(initPi, pi, theta, NU) = PathoID.pathoscope_em(U, NU, genomes, 
			self.maxIter, self.emEpsilon, self.verbose, self.piPrior, self.thetaPrior)
		print initPi, pi, theta, NU
		expectedInitPi = [0.4, 0.3, 0.2, 0.1]
		for j in range(len(expectedInitPi)):
			self.assertAlmostEquals(initPi[j], expectedInitPi[j], 4, "Failed EM Example 4 Initial PI Assertion j=%d" %j)
		expectedPi = [0.20, 0.57, 0.23, 0.0]
		for j in range(len(expectedPi)):
			self.assertAlmostEquals(pi[j], expectedPi[j], 2, "Failed EM Example 4 PI Assertion")
		expectedTheta = [0.0, 0.72, 0.28, 0.0]
		for j in range(len(expectedTheta)):
			self.assertAlmostEquals(theta[j], expectedTheta[j], 2, "Failed EM Example 4 Theta Assertion")
		expectedNU = {0: [[0, 1], [scaledScore, scaledScore], [0.0, 1.0], scaledScore], 
			1: [[1, 0], [scaledScore, scaledScore], [1.0, 0.0], scaledScore], 
			3: [[2, 3], [scaledScore, scaledScore], [1.0, 0.0], scaledScore], 
			4: [[2, 1], [scaledScore, scaledScore], [0.14, 0.86], scaledScore]}
		for read in expectedNU:
			self.assertEquals(NU[read][0], expectedNU[read][0], 
				"Failed EM Example 4 Non-Unique Read %d genome mapping Assertion" %read)
			self.assertEquals(NU[read][1], expectedNU[read][1], 
				"Failed EM Example 4 Non-Unique Read %d score Assertion" %read)
			for j in range(len(expectedNU[read][2])):
				self.assertAlmostEquals(NU[read][2][j], expectedNU[read][2][j], 2, 
					"Failed EM Example 4 Non-Unique Read %d proportion Assertion" %read)
Beispiel #3
0
	def test_conv_align2GRmat_sam_4(self):
		currentdir = os.path.dirname(os.path.abspath(__file__))
		ali_file = currentdir + os.sep + 'data' + os.sep + 'ex4.sam'
		aliFormat = 1
		(U, NU, genomes, reads) = PathoID.conv_align2GRmat(ali_file,self.scoreCutoff,aliFormat)
		print U, NU, genomes, reads
		scaledScore = 2.6881171418161356e+43 #Expected Re-scaled score
		expectedU = {2: [0, scaledScore]}
		self.assertEquals(len(expectedU), len(U), "Failed sam Example 4 Unique Reads length Assertion")
		for read in expectedU:
			self.assertEquals(expectedU[read][0], U[read][0], 
				"Failed sam Example 4 Unique Read %d genome mapping Assertion" %read)
			self.assertAlmostEquals(expectedU[read][1], U[read][1], 2, 
				"Failed sam Example 4 Unique Read %d score Assertion" %read)
		expectedNU = {0: [[0, 1], [scaledScore, scaledScore], [0.5, 0.5], scaledScore], 
			1: [[1, 0], [scaledScore, scaledScore], [0.5, 0.5], scaledScore], 
			3: [[2, 3], [scaledScore, scaledScore], [0.5, 0.5], scaledScore], 
			4: [[2, 1], [scaledScore, scaledScore], [0.5, 0.5], scaledScore]}
		self.assertEquals(len(expectedNU), len(NU), "Failed sam Example 4 Non-Unique Reads length Assertion")
		for read in expectedNU:
			self.assertEquals(expectedNU[read][0], NU[read][0], 
				"Failed sam Example 4 Non-Unique Read %d genome mapping Assertion" %read)
			for j in range(len(expectedNU[read][1])):
				self.assertAlmostEquals(expectedNU[read][1][j], NU[read][1][j], 2, 
					"Failed sam Example 4 Non-Unique Read %d score Assertion" %read)
			for j in range(len(expectedNU[read][2])):
				self.assertAlmostEquals(NU[read][2][j], expectedNU[read][2][j], 4, 
					"Failed sam Example 4 Non-Unique Read %d proportion Assertion" %read)
			self.assertAlmostEquals(expectedNU[read][3], NU[read][3], 2, 
				"Failed sam Example 4 Non-Unique Read %d weight Assertion" %read)
		expectedGenomes = ['genome4', 'genome3', 'genome1', 'genome2']
		self.assertEquals(expectedGenomes, genomes, "Failed sam Example 4 Genomes Assertion")
		expectedReads = ['read1_34', 'read2_34', 'read3_4', 'read4_12', 'read5_13']
		self.assertEquals(expectedReads, reads, "Failed sam Example 4 Reads Assertion")
Beispiel #4
0
	def test_conv_align2GRmat_gsam_3(self):
		currentdir = os.path.dirname(os.path.abspath(__file__))
		ali_file = currentdir + os.sep + 'data' + os.sep + 'ex3.g.sam'
		aliFormat = 0
		(U, NU, genomes, reads) = PathoID.conv_align2GRmat(ali_file,self.scoreCutoff,aliFormat)
		print U, NU, genomes, reads
		expectedU = {0: [0, 1.0], 1: [0, 1.0], 2: [0, 1.0], 3: [1, 1.0], 4: [1, 1.0]} 
		self.assertEquals(len(expectedU), len(U), "Failed gnusam Example 3 Unique Reads length Assertion")
		for read in expectedU:
			self.assertEquals(expectedU[read][0], U[read][0], 
				"Failed gnusam Example 3 Unique Read %d genome mapping Assertion" %read)
			self.assertAlmostEquals(expectedU[read][1], U[read][1], 2, 
				"Failed gnusam Example 3 Unique Read %d score Assertion" %read)
		expectedNU = {5: [[0, 1, 2], [0.33, 0.33, 0.33], [0.3333, 0.3333, 0.3333], 0.33], 
			6: [[0, 1, 2], [0.33, 0.33, 0.33], [0.3333, 0.3333, 0.3333], 0.33], 
			7: [[0, 1, 2], [0.33, 0.33, 0.33], [0.3333, 0.3333, 0.3333], 0.33]}
		self.assertEquals(len(expectedNU), len(NU), "Failed gnusam Example 3 Non-Unique Reads length Assertion")
		for read in expectedNU:
			self.assertEquals(expectedNU[read][0], NU[read][0], 
				"Failed gnusam Example 3 Non-Unique Read %d genome mapping Assertion" %read)
			for j in range(len(expectedNU[read][1])):
				self.assertAlmostEquals(expectedNU[read][1][j], NU[read][1][j], 2, 
					"Failed gnusam Example 3 Non-Unique Read %d score Assertion" %read)
			for j in range(len(expectedNU[read][2])):
				self.assertAlmostEquals(NU[read][2][j], expectedNU[read][2][j], 4, 
					"Failed gnusam Example 3 Non-Unique Read %d proportion Assertion" %read)
			self.assertAlmostEquals(expectedNU[read][3], NU[read][3], 2, 
				"Failed gnusam Example 3 Non-Unique Read %d weight Assertion" %read)
		expectedGenomes = ['genome1', 'genome2', 'genome3']
		self.assertEquals(expectedGenomes, genomes, "Failed gnusam Example 3 Genomes Assertion")
		expectedReads = ['read1_1', 'read2_1', 'read3_1', 'read4_3', 'read5_2', 'read6_123', 'read7_123', 'read8_123']
		self.assertEquals(expectedReads, reads, "Failed gnusam Example 3 Reads Assertion")
    def test_pathoscope_em_2(self):
        ### 3 unique reads: 2 reads to genome1 and 1 read to genome4
        U = {}
        ### non-unique reads: 3 total reads  1:[[genomes],[qij],[xij]]
        NU = {
            0: [[0, 3], [0.5, 0.5], [0.5, 0.5], 0.5],
            1: [[0, 3], [0.5, 0.5], [0.5, 0.5], 0.5],
            2: [[0, 2, 3], [0.4, 0.2, 0.4], [0.33, 0.33, 0.33], 0.4],
            3: [[0, 2, 3], [0.4, 0.4, 0.2], [0.33, 0.33, 0.33], 0.4],
            4: [[0, 2, 3], [0.4, 0.4, 0.2], [0.33, 0.33, 0.33], 0.4]
        }
        ### Genome hash
        genomes = {0: "ecoli", 1: "strep", 2: "anthrax", 3: "plague"}
        (initPi, pi, theta,
         NU) = PathoID.pathoscope_em(U, NU, genomes, self.maxIter,
                                     self.emEpsilon, self.verbose,
                                     self.piPrior, self.thetaPrior)
        print initPi, pi, theta, NU
        expectedInitPi = [0.44, 0.0, 0.2, 0.36]
        expectedPi = [1.0, 0.0, 0.0, 0.0]
        expectedTheta = [1.0, 0.0, 0.0, 0.0]
        expectedNU0 = [1.0, 0.0]
        expectedNU1 = [1.0, 0.0]
        expectedNU2 = [1.0, 0.0, 0.0]
        expectedNU3 = [1.0, 0.0, 0.0]
        expectedNU4 = [1.0, 0.0, 0.0]
        diffInitPi = [abs(a - b) for a, b in zip(initPi, expectedInitPi)]
        diffPi = [abs(a - b) for a, b in zip(pi, expectedPi)]
        diffTheta = [abs(a - b) for a, b in zip(theta, expectedTheta)]
        diffNU0 = [abs(a - b) for a, b in zip(NU[2][2], expectedNU0)]
        diffNU1 = [abs(a - b) for a, b in zip(NU[3][2], expectedNU1)]
        diffNU2 = [abs(a - b) for a, b in zip(NU[2][2], expectedNU2)]
        diffNU3 = [abs(a - b) for a, b in zip(NU[3][2], expectedNU3)]
        diffNU4 = [abs(a - b) for a, b in zip(NU[4][2], expectedNU4)]
        delta = [0.01] * 4
        self.assertTrue(diffInitPi < delta, "Failed initPi Assertion")
        self.assertTrue(diffPi < delta, "Failed Pi Assertion")
        self.assertTrue(diffTheta < delta, "Failed Theta Assertion")

        delta = [0.0001] * 2
        self.assertTrue(diffNU0 < delta, "Failed Non-Unique Read 3 Assertion")
        self.assertTrue(diffNU1 < delta, "Failed Non-Unique Read 4 Assertion")
        delta = [0.0001] * 3
        self.assertTrue(diffNU2 < delta, "Failed Non-Unique Read 2 Assertion")
        self.assertTrue(diffNU3 < delta, "Failed Non-Unique Read 2 Assertion")
        self.assertTrue(diffNU4 < delta, "Failed Non-Unique Read 2 Assertion")
Beispiel #6
0
	def test_pathoscope_em_x1(self):
	### 2 unique reads: 2 reads to genome1
		U = {0: [0, 0.5], 1: [0, 0.5]}
	### 0 non-unique reads: 0 total reads  readnum:[[genomes],[qij],[xij]]
		NU = {}
	### Genome hash
		genomes = {0:"genome1", 1:"genome2", 2:"genome3", 3:"genome4"}
		(initPi, pi, theta, NU) = PathoID.pathoscope_em(U, NU, genomes, 
			self.maxIter, self.emEpsilon, self.verbose, self.piPrior, self.thetaPrior)
		print initPi, pi, theta, NU
		expectedInitPi = [1.0, 0.0, 0.0, 0.0]
		expectedPi = [1.0, 0.0, 0.0, 0.0]
		expectedTheta = [0.0, 0.0, 0.0, 0.0]
		diffInitPi = [abs(a - b) for a, b in zip(initPi, expectedInitPi)]
		diffPi = [abs(a - b) for a, b in zip(pi, expectedPi)]
		diffTheta = [abs(a - b) for a, b in zip(theta, expectedTheta)]
		delta = [0.0001]*4
		self.assertTrue(diffInitPi < delta, "Failed initPi Assertion")
		self.assertTrue(diffPi < delta, "Failed Pi Assertion")
		self.assertTrue(diffTheta < delta, "Failed Theta Assertion")
Beispiel #7
0
def main():
	# parse some argument lists
	inputArgs = parser.parse_args()
	
	#### PathoID modules ####
	
	start = time();
	
	if (inputArgs.subcommand=='LIB'):
		################################################$
		#append taxon id in the front of sequence header
		################################################$
		NAs = 'X'
		if inputArgs.lib_dbuser!=NAs and inputArgs.lib_dbpasswd==NAs:
			print 'if you want to use mysql, make sure that you install pathoDB and '
			'also specify the corresponding mysql password correctly '
			'(Ask your mysql admin to access the database).'
		MysqlConf=(inputArgs.lib_dbhost,inputArgs.lib_dbport,inputArgs.lib_dbuser,inputArgs.lib_dbpasswd,inputArgs.lib_db)
		taxon_ids=pathoLib.parse_input_app_build_nt_tgt(inputArgs.lib_taxon_ids)
		exclude_taxon_ids=pathoLib.parse_input_app_build_nt_tgt(inputArgs.lib_exclude_taxon_ids)
		(ncbiNt_ti,ncbiNt_invalid) = pathoLib.append_ti_into_fasta_app(inputArgs.lib_reference,
			taxon_ids, exclude_taxon_ids, inputArgs.lib_subtax,MysqlConf, 
			not(inputArgs.lib_nodesc), inputArgs.lib_online_search, inputArgs.lib_outprefix, 
			inputArgs.lib_outdir)
	
	if (inputArgs.subcommand=='MAP'):
		pathoMapOptions = PathoMapA.PathoMapOptions()
		pathoMapOptions.verbose = inputArgs.verbose
		pathoMapOptions.outDir = inputArgs.map_outdir
		pathoMapOptions.indexDir = inputArgs.map_indexdir
		pathoMapOptions.outAlignFile = inputArgs.map_outalign
		pathoMapOptions.inReadFile = inputArgs.map_inputread
		pathoMapOptions.inReadFilePair1 = inputArgs.map_inputread1
		pathoMapOptions.inReadFilePair2 = inputArgs.map_inputread2
		pathoMapOptions.targetAlignParameters = inputArgs.map_targetalignparams
		pathoMapOptions.filterAlignParameters = inputArgs.map_filteralignparams
		if (len(inputArgs.map_targetref)>0):
			pathoMapOptions.targetRefFiles = inputArgs.map_targetref.split(",")
		if (len(inputArgs.map_filterref)>0):
			pathoMapOptions.filterRefFiles = inputArgs.map_filterref.split(",")
		if (len(inputArgs.map_targetindex)>0):
			pathoMapOptions.targetIndexPrefixes = inputArgs.map_targetindex.split(",")
		if (len(inputArgs.map_filterindex)>0):
			pathoMapOptions.filterIndexPrefixes = inputArgs.map_filterindex.split(",")
		if (len(inputArgs.map_targetalign)>0):
			pathoMapOptions.targetAlignFiles = inputArgs.map_targetalign.split(",")
		if (len(inputArgs.map_filteralign)>0):
			pathoMapOptions.filterAlignFiles = inputArgs.map_filteralign.split(",")
		pathoMapOptions.btHome = inputArgs.map_bthome
		pathoMapOptions.numThreads = inputArgs.map_numthreads
		pathoMapOptions.exp_tag = inputArgs.map_exp_tag + "-"
		PathoMapA.processPathoMap(pathoMapOptions)
	
	if (inputArgs.subcommand=='ID'):
		pathoIdOptions = PathoID.PathoIdOptions(inputArgs.id_ali_file)
		pathoIdOptions.ali_format = inputArgs.id_ali_format
		pathoIdOptions.verbose = inputArgs.verbose
		pathoIdOptions.out_matrix_flag = inputArgs.id_out_matrix
		pathoIdOptions.score_cutoff = inputArgs.id_score_cutoff
		pathoIdOptions.exp_tag = inputArgs.id_exp_tag
		pathoIdOptions.outdir = inputArgs.id_outdir
		pathoIdOptions.emEpsilon = inputArgs.id_emEpsilon
		pathoIdOptions.maxIter = inputArgs.id_maxIter
		pathoIdOptions.piPrior = inputArgs.id_piPrior
		pathoIdOptions.thetaPrior = inputArgs.id_thetaPrior
		pathoIdOptions.noalign = inputArgs.id_noalign
		pathoIdOptions.noCutOff = inputArgs.id_nocutoff
		PathoID.pathoscope_reassign(pathoIdOptions)
	
	if (inputArgs.subcommand=='REP'):
		pathoReportOptions = PathoReportA.PathoReportOptions(inputArgs.rep_ali_file)
		pathoReportOptions.verbose = inputArgs.verbose
		pathoReportOptions.contigFlag = inputArgs.rep_contig_flag
		pathoReportOptions.outDir = inputArgs.rep_outdir
		pathoReportOptions.samtoolsHome = inputArgs.rep_samtoolshome
		pathoReportOptions.noCutOff = inputArgs.rep_nocutoff
		mysqlConf=(inputArgs.rep_dbhost,inputArgs.rep_dbport,inputArgs.rep_dbuser,
			inputArgs.rep_dbpasswd,inputArgs.rep_db)
		pathoReportOptions.mysqlConf = mysqlConf
		PathoReportA.processPathoReport(pathoReportOptions)
	
	if (inputArgs.subcommand=='QC'):
		qcargs = sys.argv[2:]
		pathoqcdir = pathoscopedir + os.path.sep + 'pathoscope' + os.path.sep + 'pathoqc'
		pathoqcfile = pathoqcdir + os.path.sep + 'pathoqc.py'
		if os.path.exists(pathoqcfile):
			cmd = sys.executable
			cmd += " " + pathoqcfile + " "
			cmd += " ".join(qcargs)
			print(cmd)
			os.system(cmd)
		else:
			print("PathoQC (" + pathoqcfile + ") not found. Please download pathoqc_vXXX.tar.gz and "
			"install it ("+pathoqcdir+") from http://sourceforge.net/projects/pathoscope/")
	
	elapsed = time() - start;
	if inputArgs.verbose:
		print "Total Elapsed Time: %d" % (elapsed)
Beispiel #8
0
def main():
    # parse some argument lists
    inputArgs = parser.parse_args()

    #### PathoID modules ####

    start = time()

    if (inputArgs.subcommand == 'LIB'):
        ################################################$
        #append taxon id in the front of sequence header
        ################################################$
        NAs = 'X'
        if inputArgs.lib_dbuser != NAs and inputArgs.lib_dbpasswd == NAs:
            print 'if you want to use mysql, make sure that you install pathoDB and '
            'also specify the corresponding mysql password correctly '
            '(Ask your mysql admin to access the database).'
        MysqlConf = (inputArgs.lib_dbhost, inputArgs.lib_dbport,
                     inputArgs.lib_dbuser, inputArgs.lib_dbpasswd,
                     inputArgs.lib_db)
        taxon_ids = pathoLib.parse_input_app_build_nt_tgt(
            inputArgs.lib_taxon_ids)
        exclude_taxon_ids = pathoLib.parse_input_app_build_nt_tgt(
            inputArgs.lib_exclude_taxon_ids)
        (ncbiNt_ti, ncbiNt_invalid) = pathoLib.append_ti_into_fasta_app(
            inputArgs.lib_reference, taxon_ids, exclude_taxon_ids,
            inputArgs.lib_subtax, MysqlConf, not (inputArgs.lib_nodesc),
            inputArgs.lib_online_search, inputArgs.lib_outprefix,
            inputArgs.lib_outdir)

    if (inputArgs.subcommand == 'MAP'):
        pathoMapOptions = PathoMapA.PathoMapOptions()
        pathoMapOptions.verbose = inputArgs.verbose
        pathoMapOptions.outDir = inputArgs.map_outdir
        pathoMapOptions.indexDir = inputArgs.map_indexdir
        pathoMapOptions.outAlignFile = inputArgs.map_outalign
        pathoMapOptions.inReadFile = inputArgs.map_inputread
        pathoMapOptions.inReadFilePair1 = inputArgs.map_inputread1
        pathoMapOptions.inReadFilePair2 = inputArgs.map_inputread2
        pathoMapOptions.targetAlignParameters = inputArgs.map_targetalignparams
        pathoMapOptions.filterAlignParameters = inputArgs.map_filteralignparams
        if (len(inputArgs.map_targetref) > 0):
            pathoMapOptions.targetRefFiles = inputArgs.map_targetref.split(",")
        if (len(inputArgs.map_filterref) > 0):
            pathoMapOptions.filterRefFiles = inputArgs.map_filterref.split(",")
        if (len(inputArgs.map_targetindex) > 0):
            pathoMapOptions.targetIndexPrefixes = inputArgs.map_targetindex.split(
                ",")
        if (len(inputArgs.map_filterindex) > 0):
            pathoMapOptions.filterIndexPrefixes = inputArgs.map_filterindex.split(
                ",")
        if (len(inputArgs.map_targetalign) > 0):
            pathoMapOptions.targetAlignFiles = inputArgs.map_targetalign.split(
                ",")
        if (len(inputArgs.map_filteralign) > 0):
            pathoMapOptions.filterAlignFiles = inputArgs.map_filteralign.split(
                ",")
        pathoMapOptions.btHome = inputArgs.map_bthome
        pathoMapOptions.numThreads = inputArgs.map_numthreads
        pathoMapOptions.exp_tag = inputArgs.map_exp_tag + "-"
        PathoMapA.processPathoMap(pathoMapOptions)

    if (inputArgs.subcommand == 'ID'):
        pathoIdOptions = PathoID.PathoIdOptions(inputArgs.id_ali_file)
        pathoIdOptions.ali_format = inputArgs.id_ali_format
        pathoIdOptions.verbose = inputArgs.verbose
        pathoIdOptions.out_matrix_flag = inputArgs.id_out_matrix
        pathoIdOptions.score_cutoff = inputArgs.id_score_cutoff
        pathoIdOptions.exp_tag = inputArgs.id_exp_tag
        pathoIdOptions.outdir = inputArgs.id_outdir
        pathoIdOptions.emEpsilon = inputArgs.id_emEpsilon
        pathoIdOptions.maxIter = inputArgs.id_maxIter
        pathoIdOptions.piPrior = inputArgs.id_piPrior
        pathoIdOptions.thetaPrior = inputArgs.id_thetaPrior
        pathoIdOptions.noalign = inputArgs.id_noalign
        pathoIdOptions.noCutOff = inputArgs.id_nocutoff
        PathoID.pathoscope_reassign(pathoIdOptions)

    if (inputArgs.subcommand == 'REP'):
        pathoReportOptions = PathoReportA.PathoReportOptions(
            inputArgs.rep_ali_file)
        pathoReportOptions.verbose = inputArgs.verbose
        pathoReportOptions.contigFlag = inputArgs.rep_contig_flag
        pathoReportOptions.outDir = inputArgs.rep_outdir
        pathoReportOptions.samtoolsHome = inputArgs.rep_samtoolshome
        pathoReportOptions.noCutOff = inputArgs.rep_nocutoff
        mysqlConf = (inputArgs.rep_dbhost, inputArgs.rep_dbport,
                     inputArgs.rep_dbuser, inputArgs.rep_dbpasswd,
                     inputArgs.rep_db)
        pathoReportOptions.mysqlConf = mysqlConf
        PathoReportA.processPathoReport(pathoReportOptions)

    if (inputArgs.subcommand == 'QC'):
        qcargs = sys.argv[2:]
        pathoqcdir = pathoscopedir + os.path.sep + 'pathoscope' + os.path.sep + 'pathoqc'
        pathoqcfile = pathoqcdir + os.path.sep + 'pathoqc.py'
        if os.path.exists(pathoqcfile):
            cmd = sys.executable
            cmd += " " + pathoqcfile + " "
            cmd += " ".join(qcargs)
            print(cmd)
            os.system(cmd)
        else:
            print(
                "PathoQC (" + pathoqcfile +
                ") not found. Please download pathoqc_vXXX.tar.gz and "
                "install it (" + pathoqcdir +
                ") from http://sourceforge.net/projects/pathoscope/")

    elapsed = time() - start
    if inputArgs.verbose:
        print "Total Elapsed Time: %d" % (elapsed)
Beispiel #9
0
        pathoMapOptions.targetIndexPrefixes = inputArgs.map_targetindex.split(
            ",")
    if (len(inputArgs.map_filterindex) > 0):
        pathoMapOptions.filterIndexPrefixes = inputArgs.map_filterindex.split(
            ",")
    if (len(inputArgs.map_targetalign) > 0):
        pathoMapOptions.targetAlignFiles = inputArgs.map_targetalign.split(",")
    if (len(inputArgs.map_filteralign) > 0):
        pathoMapOptions.filterAlignFiles = inputArgs.map_filteralign.split(",")
    pathoMapOptions.btHome = inputArgs.map_bthome
    pathoMapOptions.numThreads = inputArgs.map_numthreads
    pathoMapOptions.exp_tag = inputArgs.map_exp_tag + "-"
    PathoMapA.processPathoMap(pathoMapOptions)

if (inputArgs.subcommand == 'ID'):
    pathoIdOptions = PathoID.PathoIdOptions(inputArgs.id_ali_file)
    pathoIdOptions.ali_format = inputArgs.id_ali_format
    pathoIdOptions.verbose = inputArgs.verbose
    pathoIdOptions.out_matrix_flag = inputArgs.id_out_matrix
    pathoIdOptions.score_cutoff = inputArgs.id_score_cutoff
    pathoIdOptions.exp_tag = inputArgs.id_exp_tag
    pathoIdOptions.outdir = inputArgs.id_outdir
    pathoIdOptions.emEpsilon = inputArgs.id_emEpsilon
    pathoIdOptions.maxIter = inputArgs.id_maxIter
    pathoIdOptions.piPrior = inputArgs.id_piPrior
    pathoIdOptions.thetaPrior = inputArgs.id_thetaPrior
    pathoIdOptions.noalign = inputArgs.id_noalign
    PathoID.pathoscope_reassign(pathoIdOptions)

if (inputArgs.subcommand == 'REP'):
    pathoReportOptions = PathoReportA.PathoReportOptions(
                    default='testset',
                    dest='exp_tag',
                    help='Experiment tag')
parser.add_argument('-outdir',
                    action='store',
                    default='.',
                    dest='outdir',
                    help='Output Directory')
parser.add_argument('--version', action='version', version='%(prog)s 1.0')
parser.add_argument('-t',
                    action='store',
                    default='sam',
                    dest='ali_format',
                    help='Alignment Format: sam/bl8/gnu-sam')
parser.add_argument('-f',
                    action='store',
                    dest='ali_file',
                    required=True,
                    help='Alignment file path')

inputArgs = parser.parse_args()
start = time()
PathoID.pathoscope_reassign(inputArgs.out_matrix, inputArgs.verbose,
                            inputArgs.score_cutoff, inputArgs.exp_tag,
                            inputArgs.ali_format, inputArgs.ali_file,
                            inputArgs.outdir, inputArgs.emEpsilon,
                            inputArgs.maxIter, not (inputArgs.noalign))
elapsed = time() - start
if inputArgs.verbose:
    print "EM Elapsed Time: %d" % (elapsed)
Beispiel #11
0
parser.add_argument('-o', action='store_true', default=False, dest='out_matrix',
					help='Output alignment matrix')
parser.add_argument('-noUpdatedAlignFile', action='store_true', default=False, dest='noalign',
					help='Do not generate an updated alignment file')
parser.add_argument('-verbose', action='store_true', default=False, dest='verbose',
					help='Prints verbose text while running')
parser.add_argument('-s', action='store', default=0.01, type=float,
					dest='score_cutoff', help='Score Cutoff')
parser.add_argument('-emEpsilon', action='store', default=1e-7, type=float,
					dest='emEpsilon', help='EM Algorithm Epsilon cutoff')
parser.add_argument('-maxIter', action='store', default=50, type=int,
					dest='maxIter', help='EM Algorithm maximum iterations')
parser.add_argument('-e', action='store', default='testset', dest='exp_tag',
					help='Experiment tag')
parser.add_argument('-outdir', action='store', default='.', dest='outdir',
					help='Output Directory')
parser.add_argument('--version', action='version', version=VERSION)
parser.add_argument('-t', action='store', default='sam', dest='ali_format',
					help='Alignment Format: sam/bl8/gnu-sam')
parser.add_argument('-f', action='store', dest='ali_file', required=True,
					help='Alignment file path')

inputArgs = parser.parse_args()
start = time();
PathoID.pathoscope_reassign(inputArgs.out_matrix, inputArgs.verbose, 
	inputArgs.score_cutoff, inputArgs.exp_tag, inputArgs.ali_format, inputArgs.ali_file,
	inputArgs.outdir, inputArgs.emEpsilon, inputArgs.maxIter, not(inputArgs.noalign))
elapsed = time() - start;
if inputArgs.verbose:
	print "EM Elapsed Time: %d" % (elapsed)
Beispiel #12
0
	PathoMapA.processPathoMap(pathoMapOptions)

if (inputArgs.subcommand=='ID'):
	pathoIdOptions = PathoID.PathoIdOptions(inputArgs.id_ali_file)
	pathoIdOptions.ali_format = inputArgs.id_ali_format
	pathoIdOptions.verbose = inputArgs.verbose
	pathoIdOptions.out_matrix_flag = inputArgs.id_out_matrix
	pathoIdOptions.score_cutoff = inputArgs.id_score_cutoff
	pathoIdOptions.exp_tag = inputArgs.id_exp_tag
	pathoIdOptions.outdir = inputArgs.id_outdir
	pathoIdOptions.emEpsilon = inputArgs.id_emEpsilon
	pathoIdOptions.maxIter = inputArgs.id_maxIter
	pathoIdOptions.piPrior = inputArgs.id_piPrior
	pathoIdOptions.thetaPrior = inputArgs.id_thetaPrior
	pathoIdOptions.noalign = inputArgs.id_noalign
	PathoID.pathoscope_reassign(pathoIdOptions)

if (inputArgs.subcommand=='REP'):
	pathoReportOptions = PathoReportA.PathoReportOptions(inputArgs.rep_ali_file)
	pathoReportOptions.verbose = inputArgs.verbose
	pathoReportOptions.contigFlag = inputArgs.rep_contig_flag
	pathoReportOptions.outDir = inputArgs.rep_outdir
	pathoReportOptions.samtoolsHome = inputArgs.rep_samtoolshome
	mysqlConf=(inputArgs.rep_dbhost,inputArgs.rep_dbport,inputArgs.rep_dbuser,
		inputArgs.rep_dbpasswd,inputArgs.rep_db)
	pathoReportOptions.mysqlConf = mysqlConf
	PathoReportA.processPathoReport(pathoReportOptions)

elapsed = time() - start;
if inputArgs.verbose:
	print "Total Elapsed Time: %d" % (elapsed)