def doCreateSBML(self):
    
        try:

            print "doNetworkReconstruction"

	    curDirectory = os.getcwd()
	    os.chdir(ScriptsDir.ReconstructionScripts)
        
            orgListFile_fh = open(self.networkReconstructionOrgList)

            for orgLine in orgListFile_fh:
                
                organismID = orgLine.strip()
		
		print "Network reconstruction for: " + organismID

                intAccept2 = "%.9f" % (self.intAaccept)
                intReject2 = "%.9f" % (self.intReject)
            
		call = "bash " +  ScriptsDir.ReconstructionScripts_reco_dir_postprocess + " " + self.modelTrainingModelDir + " " + intAccept2 + " " + intReject2 + " " + organismID  + " " + ScriptsDir.ReconstructionScripts +  " " +  self.keggDataDir  + " " + self.taxonomy  + " " + self.bounds + " " + self.ec2rxnFile  + " " + "3" +" " + self.rxnNamesFile + " " + self.pathwayFile

		NGS_Util.executeCall(call)

            orgListFile_fh.close() 
     

	    os.chdir(curDirectory)

        except Exception:
            
            print traceback.print_exc()
            
        return ""
    def doNetworkReconstruction(self):
    
        try:

            print "doNetworkReconstruction"

	    curDirectory = os.getcwd()
	    os.chdir(ScriptsDir.ReconstructionScripts)
        
            orgListFile_fh = open(self.networkReconstructionOrgList)

            for orgLine in orgListFile_fh:
                
                organismID = orgLine.strip()
		
		print "Network reconstruction for: " + organismID

		call = "bash " +  ScriptsDir.ReconstructionScripts_reco_dir + " " + self.modelTrainingModelDir + " " + str(self.intAaccept) + " " + str(self.intReject) + " " + organismID  + " " + ScriptsDir.ReconstructionScripts +  " " +  self.keggDataDir  + " " + self.taxonomy  
		
		NGS_Util.executeCall(call)

            orgListFile_fh.close() 
     

	    os.chdir(curDirectory)

        except Exception:
            
            print traceback.print_exc()
            
        return ""
    def makeBlastDB(self, organismName):
    
        try:

            print "Make Blast Database: " + organismName
            
            org_fasta    = NGS_Util.createFilePath(self.orgFastaDir, organismName+".faa")
            
            org_dust     = NGS_Util.createFilePath(self.orgBlastDustDir, organismName+"_dust.asnb")
            
            org_blast_db = NGS_Util.createFilePath(self.orgBlastDBDir, organismName)
            
            if os.path.exists(org_fasta):

                if not os.path.exists(org_blast_db + ".phd") and not os.path.exists(org_blast_db + ".psq"):
                
                    self.ngsBlast.makeProteinBlastDBFromDustFile(org_fasta,org_dust,org_blast_db)
                
                return org_blast_db
            
        except Exception:
            
            print traceback.print_exc()
        
        return ""
    def doMCLClustering(self, pfamID, abcFile, mclClusteringDir):

        try:

            mciFile, tabFile = self.makeClusterInputFiles(
                pfamID, abcFile, mclClusteringDir)

            I = 1.2

            for index in range(1, 10):

                output = NGS_Util.createFilePath(
                    mclClusteringDir,
                    pfamID + ".mci." + str(I).replace(".", ""))

                call = "mcl " + mciFile + " -I " + str(
                    I) + " -use-tab " + tabFile + " -o " + output

                I += 0.4

                print call

                NGS_Util.executeCall(call)

        except Exception:

            print traceback.print_exc()
    def runClusterIPRScan(self, organismName):
    
        try:
           
            splitFasta = MetabolicReconstructionPipeline_SplitFasta.MetabolicReconstructionPipeline_SplitFasta()
           
            #numberOfFragments = 10
                       
            ###############################################################################################################################################

            org_fasta = NGS_Util.createFilePath(self.orgFastaDir, organismName+".faa")

            splitFasta.splitOrganismDataFile(organismName, org_fasta, self.numberOfFragments)

            ###################################################################################################################################
            
            clusterArrayCall =  "qsub -t 1-" + str(self.numberOfFragments) + ":1 " +  ScriptsDir.ClusterIprscan
            
            iprscan = NGS_Util.createFilePath(ScriptsDir.IprscanDir,"interproscan.sh ")
            
            splitFile = splitFasta.organismSplitDataDir + organismName
            
            ipr_raw_file_split = NGS_Util.createFilePath(self.orgIPRScanDir, organismName + "_split" )
                           
            call = clusterArrayCall + " "  + iprscan  + " "  + splitFile + " " + ipr_raw_file_split
            
            NGS_Util.executeCall(call)
            
    
        except Exception:
            
            print traceback.print_exc()
            
        return ""
    def rawIPRScan(self, organismName, org_ipr_split_dir):
    
        try:
        
            print "rawIPRScan: " + organismName

	    
            for fragment in range(self.numberOfFragments):

		org_ipr_split_file = NGS_Util.createFilePath(self.splitFasta.organismSplitDataDir,organismName + "_" +  str(fragment+1) )

		self.raw_split_IPRScan(organismName, org_ipr_split_file, str(fragment+1))


            ipr_raw_file_split = NGS_Util.createFilePath(self.orgIPRScanDir, organismName + "_split_*")
            
            ipr_raw_file = NGS_Util.createFilePath(self.orgIPRScanDir, organismName + ".ipr.raw")
            
            call = "cat " + ipr_raw_file_split + " > " + ipr_raw_file

	    NGS_Util.executeCall(call)

            return ipr_raw_file
        
        except Exception:
            
            print traceback.print_exc()
        
        return ""
    def run_Org_vs_Uniprot_ClusterBlast(self, organismName):
    
        try:
              
            splitFasta = MetabolicReconstructionPipeline_SplitFasta.MetabolicReconstructionPipeline_SplitFasta()
           
            ###############################################################################################################################################

            org_fasta = NGS_Util.createFilePath(self.orgFastaDir, organismName+".faa")

            splitFasta.splitOrganismDataFile(organismName, org_fasta, self.numberOfFragments)

            ###################################################################################################################################
            
            clusterArrayCall =  "qsub -t 1-" + str(self.numberOfFragments) + ":1 " + ScriptsDir.ClusterBlast
            
            blastP = NGS_Util.createFilePath(ScriptsDir.BlastDir,"blastp")
            
            outfmt = str(6)
            
            splitFile = splitFasta.organismSplitDataDir + organismName 

            org_vs_UniprotBlastDB =  NGS_Util.createFilePath(self.orgBlastResDir, organismName + "-vs-up" )
                

            call = clusterArrayCall + " "  + blastP  + " "  + self.uniprot_blast_db + " "  + splitFile + " " + outfmt + " " + org_vs_UniprotBlastDB  + " " + str(self.blastEValue)
                

            NGS_Util.executeCall(call)



        except Exception:
            
            print traceback.print_exc()
    def blast_org_vs_nr40_blast_formatted_11(self, organismName):
    
        try:
           
            org_fasta = NGS_Util.createFilePath(self.orgFastaDir, organismName+".faa")

            clusterArrayCall =  "qsub -t 1-1 " + ScriptsDir.ClusterGTGBlast
            
            blastP = NGS_Util.createFilePath(ScriptsDir.BlastDir,"blastp")
            
            outfmt = str(11)
            
            org_vs_nr40BlastDB_f11 = NGS_Util.createFilePath(self.orgGTGBlastResDir, organismName + ".nrdb40_v2.txt")    

            call = clusterArrayCall + " "  + blastP  + " "  + self.nrdb40_blast_db + " "  + org_fasta + " " + outfmt + " " + org_vs_nr40BlastDB_f11  + " " + str(self.blastEValue)
                
            NGS_Util.executeCall(call)


            return org_vs_nr40BlastDB_f11
            	    
    
        except Exception:
            
            print traceback.print_exc()
            
        return ""
Example #9
0
    def makeBlastDB(self, organismName):

        try:

            print "Make Blast Database: " + organismName

            org_fasta = NGS_Util.createFilePath(self.orgFastaDir,
                                                organismName + ".faa")

            org_dust = NGS_Util.createFilePath(self.orgBlastDustDir,
                                               organismName + "_dust.asnb")

            org_blast_db = NGS_Util.createFilePath(self.orgBlastDBDir,
                                                   organismName)

            if os.path.exists(org_fasta):

                if not os.path.exists(org_blast_db +
                                      ".phd") and not os.path.exists(
                                          org_blast_db + ".psq"):

                    self.ngsBlast.makeProteinBlastDBFromDustFile(
                        org_fasta, org_dust, org_blast_db)

                return org_blast_db

        except Exception:

            print traceback.print_exc()

        return ""
    def copySequenceFiles(self, srcDataDir):
    
        try:
                
            print("Copy Fasta Files from %s to %s" %(srcDataDir,self.orgFastaDir))

            orgListFile_fh = open(self.orgListFile)

	    for line in orgListFile_fh:

                organismNameID, organismName = line.strip().split()

 		if not os.path.exists( NGS_Util.createFilePath(self.orgFastaDir, organismName + ".faa") ):

 		    orgFasta = NGS_Util.createFilePath(srcDataDir, organismName + ".faa")
		
		    NGS_Util.copyFile(orgFasta, self.orgFastaDir)		    
                    print("Copied fasta file for %s" % (organismName))
                else:
                    print("\tDoing nothing (files already copied) for %s" % (organismName))
                

            orgListFile_fh.close() 
     
        except Exception:
            
            print traceback.print_exc()
 def concatenate_Org_vs_Uniprot_ClusterBlast_results(self, organismName):
 
     try:
         
         clusterProcessing = True
         
         for fragment in range(self.numberOfFragments):
                                        
             org_vs_UniprotBlastDB =  NGS_Util.createFilePath(self.orgBlastResDir, organismName + "-vs-up_" + str(fragment+1) + ".blast" )
             
             if not os.path.exists(org_vs_UniprotBlastDB):
                 clusterProcessing = False
                 break
                 
                
         if (clusterProcessing):
                                
             org_vs_UniprotBlastDB =  NGS_Util.createFilePath(self.orgBlastResDir, organismName + "-vs-up.blast" )
 
             call = "cat " + NGS_Util.createFilePath(self.orgBlastResDir, organismName + "-vs-up_*") + " > " + org_vs_UniprotBlastDB
 
             NGS_Util.executeCall(call)
             
             
             return org_vs_UniprotBlastDB
         
         else:
             print organismName + "-vs-Uniprot BLAST incomplete"
         
 
     except Exception:
         
         print traceback.print_exc()
         
     return ""
    def moveGTGResults(self):
    
        try:
                
            print "moveGTGResults"

            orgListFile_fh = open(self.orgListFile)


            NGS_Util.zipDirectory(self.orgGTGBlastResDir)

	    NGS_Util.moveDirectoryFiles(self.orgGTGBlastResDir,self.moveToDir_orgGTGBlastResDir)

            NGS_Util.zipDirectory(self.GTGBestHitsDir)

	    NGS_Util.moveDirectoryFiles(self.GTGBestHitsDir,self.moveToDir_GTGBestHitsDir)
	    
	    
	    for line in orgListFile_fh:

                organismNameID, organismName = line.strip().split()

		org_gtg_knn_final        = NGS_Util.createFilePath(self.GTGKNNDir, organismNameID + ".gtg.knn")
		moveto_org_gtg_knn_final = NGS_Util.createFilePath(self.moveToDir_GTGKNNDir, organismNameID + ".gtg.knn")

		self.moveFile_createLink(org_gtg_knn_final,moveto_org_gtg_knn_final)
		    

            orgListFile_fh.close() 
     
        except Exception:
            
            print traceback.print_exc()
Example #13
0
    def runModelTrainingAlgo(self):
       
        try:
        
            print "runModelTrainingAlgo"

	    curDirectory = os.getcwd()

	    os.chdir(ScriptsDir.ModelTrainingScripts)

	    self.extract_IPR_EC_Values()
	    
	    self.computeBlastPvalues()    
	    
	    self.computeMergedScores()

	    self.computeECscores()
	    
	    self.computeProbabilityDensityScores()	

	    self.combineProbabilityDensityScores()

	    self.computeTreeProbabilityDensityScore()

	    self.runBashScript()

	    NGS_Util.executeCall("rm *.Rout")
	    NGS_Util.executeCall("rm *.RData")
	    
	    os.chdir(curDirectory)

        except Exception:
            
            print traceback.print_exc()
Example #14
0
    def makeProteinBlastDB(self, inputFasta,blastDB):
        
        try:

            call = self.makeblastdb + " -in " + inputFasta + " -input_type fasta -dbtype prot -parse_seqids -hash_index " + " -out " +  blastDB

            NGS_Util.executeCall(call)
                  
        except Exception:
            print traceback.print_exc()
Example #15
0
    def convert_raw_xml(self, inputFile, outputFile):

        try:

            call = self.converter + " -format xml -input " + inputFile + " -output " + outputFile

            NGS_Util.executeCall(call)

        except Exception:

            print traceback.print_exc()
    def protein_iprscan5_to_xml_output(self, inputFile, outputFile):
        
        try:

            call = self.iprscan5 + " -i "   + inputFile + " -o " + outputFile + " -f XML -goterms -iprlookup "

            NGS_Util.executeCall(call)

                  
        except Exception:
            print traceback.print_exc()
 def convert_iprscan5_xml_raw(self, inputFile, outputFile):
     
     try:
         
         call = self.iprscan5 + " -mode convert -i " + inputFile + " -f RAW -o " + outputFile
         
         NGS_Util.executeCall(call)
         
     except Exception:
         
         print traceback.print_exc()
Example #18
0
    def blastP_with_Database_Size(self, blastDB, queryFastaFile, outfmt, blastResultFile, eValue, uniprotDBSize ):
        
        try:
            
            call = self.blastp + " -db " + blastDB + " -query " + queryFastaFile + " -outfmt " + str(outfmt)  + " -out " + blastResultFile + " -evalue " + str(eValue) + " " +   self.numThreads + " -dbsize " + str(uniprotDBSize)

            NGS_Util.executeCall(call)
            
        except Exception:
            
            print traceback.print_exc()
Example #19
0
    def blastFormatter(self, archive, outfmt, formattedFile):
        	    
        try:
            
            call = self.blast_formatter + " -archive " + archive + " -outfmt " + str(outfmt)  + " -out " + formattedFile

            NGS_Util.executeCall(call)
            
        except Exception:
            
            print traceback.print_exc()
Example #20
0
    def blastP(self, blastDB, queryFastaFile, outfmt, blastResultFile, eValue ):
        
        try:
            
            call = self.blastp + " -db " + blastDB + " -query " + queryFastaFile + " -outfmt " + str(outfmt)  + " -out " + blastResultFile + " -evalue " + str(eValue) + " " +   self.numThreads

            NGS_Util.executeCall(call)
            
        except Exception:
            
            print traceback.print_exc()
Example #21
0
    def hmmpress(self, pfamFile):

        try:

            call = "hmmpress " + pfamFile

            NGS_Util.executeCall(call)

        except Exception:

            print traceback.print_exc()
Example #22
0
    def blastP(self, blastDB, queryFastaFile, outfmt, blastResultFile, eValue ):
        
        try:
            
            call = self.blastp + " -db " + blastDB + " -query " + queryFastaFile + " -outfmt " + str(outfmt)  + " -out " + blastResultFile + " -evalue " + str(eValue) + " " +   self.numThreads

            NGS_Util.executeCall(call)
            
        except Exception:
            
            print traceback.print_exc()
Example #23
0
    def blastFormatter(self, archive, outfmt, formattedFile):
        	    
        try:
            
            call = self.blast_formatter + " -archive " + archive + " -outfmt " + str(outfmt)  + " -out " + formattedFile

            NGS_Util.executeCall(call)
            
        except Exception:
            
            print traceback.print_exc()
Example #24
0
    def blastP_with_Database_Size(self, blastDB, queryFastaFile, outfmt, blastResultFile, eValue, uniprotDBSize ):
        
        try:
            
            call = self.blastp + " -db " + blastDB + " -query " + queryFastaFile + " -outfmt " + str(outfmt)  + " -out " + blastResultFile + " -evalue " + str(eValue) + " " +   self.numThreads + " -dbsize " + str(uniprotDBSize)

            NGS_Util.executeCall(call)
            
        except Exception:
            
            print traceback.print_exc()
Example #25
0
    def makeProteinBlastDBFromDustFile(self, inputFasta, dustFile, blastDB):

        try:

            call = self.segmasker + " -in " + inputFasta + " -infmt fasta -parse_seqids -outfmt maskinfo_asn1_bin -out " + dustFile
            call = self.makeblastdb + " -in " + inputFasta + " -input_type fasta -dbtype prot -parse_seqids -mask_data " + dustFile + " -out " + blastDB

            NGS_Util.executeCall(call)

        except Exception:
            print traceback.print_exc()
 def convert_raw_xml(self, inputFile, outputFile):
     
     try:
         
         call = self.converter + " -format xml -input " + inputFile + " -output " + outputFile
         
         NGS_Util.executeCall(call)
         
     except Exception:
         
         print traceback.print_exc()
    def getBlastScore(self, mode):
    
            try:

                print "getBlastScores"

                orgListFile_fh = open(self.orgListFile)
    
                for line in orgListFile_fh:
                    
                    organismNameID, organismName = line.strip().split()
                    
                    orgJointBlast   = NGS_Util.createFilePath(self.orgBlastResDir, organismName + ".joint.blast")
                    orgRectifyBlast = NGS_Util.createFilePath(self.jointBlastDir, organismName + ".joint.blast")
                    
                    print "getBlastScore:" + organismName
                    if not os.path.exists(orgRectifyBlast):
                        
                        if os.path.exists(orgJointBlast):

                            orgRectifyBlast = self.rectifyBlast(organismName, orgJointBlast)
                        
                        else:

                            if (mode == 1):                                                        
                                
                                org_blast_db = self.makeBlastDB(organismName)
                                                       
                                self.run_Org_vs_Uniprot_ClusterBlast(organismName)
                                
                                time.sleep(1800) #wait for 15 minutes
                                    
                                self.run_Uniprot_vs_Org_ClusterBlast(organismName)

                                time.sleep(2400) #wait for 20 minutes

                            elif (mode == 2):
                                
                                org_vs_UniprotBlastDB = self.concatenate_Org_vs_Uniprot_ClusterBlast_results(organismName)
                                Uniprot_vs_orgBlastDB = self.concatenate_Uniprot_vs_Org_ClusterBlast_results(organismName)
                            
                                if (org_vs_UniprotBlastDB != "" and Uniprot_vs_orgBlastDB != ""):
                                    orgJointBlast = self.combineBlast(organismName, org_vs_UniprotBlastDB, Uniprot_vs_orgBlastDB)
                                
                                    if (orgJointBlast != ""):
                                        orgRectifyBlast = self.rectifyBlast(organismName, orgJointBlast)
                              
                orgListFile_fh.close() 
         
            except Exception:
                
                print traceback.print_exc()
                
            return ""
Example #28
0
    def hmmfetch(self, pfamFile, pfam, output):

        try:

            call = "hmmfetch " + pfamFile + " " + pfam + " > " + output

            NGS_Util.executeCall(call)

        except Exception:

            print traceback.print_exc()
Example #29
0
    def protein_iprscan_to_xml_output(self, inputFile, outputFile):

        try:

            call = self.iprscan + " -i " + inputFile + " -o " + outputFile + " -goterms -iprlookup "

            NGS_Util.executeCall(call)

#            NGS_Util.executeThreadedCall(call)

        except Exception:
            print traceback.print_exc()
    def protein_iprscan_to_raw_output(self, inputFile, outputFile):
        
        try:

            call = self.iprscan + " -i "   + inputFile + " -o " + outputFile + " -format raw -goterms -iprlookup "

            NGS_Util.executeCall(call)

#            NGS_Util.executeThreadedCall(call)
                  
        except Exception:
            print traceback.print_exc()
Example #31
0
    def computeProbabilityDensityScores(self):
       
        try:
        
            print "computeProbabilityDensityScores"

	    call = "python " + ScriptsDir.ModelTrainingScripts_estimate_cpds_wrapper + " " + self.seq_org_list + " " + self.modelTraining_EC_Scores_Dir  + " " + self.modelTraining_IPR_EC_Dir  + " " + self.modelTrainingProbabilityDensityScoreDir
	    
	    NGS_Util.executeCall(call)
	    
        except Exception:
            
            print traceback.print_exc()
Example #32
0
    def combineProbabilityDensityScores(self):
       
        try:
        
            print "combineProbabilityDensityScores"

	    call = "python " + ScriptsDir.ModelTrainingScripts_combined_density + " " + self.modelTrainingProbabilityDensityScoreDir
	    
	    NGS_Util.executeCall(call)
	    
        except Exception:
            
            print traceback.print_exc()
Example #33
0
    def computeECscores(self):
       
        try:
        
            print "computeECscores"

	    call = "python " + ScriptsDir.ModelTrainingScripts_computeECscores + " " + self.modelTraining_EC_Scores_Dir 
	    
	    NGS_Util.executeCall(call)
	    
        except Exception:
            
            print traceback.print_exc()
Example #34
0
    def extract_IPR_EC_Values(self):
       
        try:
        
            print "extract_IPR_EC_Values" 
	    
	    call = "python " + ScriptsDir.ModelTrainingScripts_extract_ecs_from_iprscan + " " + self.fungi_InterProScan_result  + " " + self.modelTraining_IPR_EC_Dir
	    
	    NGS_Util.executeCall(call)
	    

        except Exception:
            
            print traceback.print_exc()
Example #35
0
    def computeBlastPvalues(self):
       
        try:
        
            print "computeBlastPvalues"

	    call = "python " + ScriptsDir.ModelTrainingScripts_computeBlastPvalues + " " + self.jointBlastDir + " " + self.modelTrainingBlastPVDir
	    
	    NGS_Util.executeCall(call)
	    

        except Exception:
            
            print traceback.print_exc()
Example #36
0
    def computeTreeProbabilityDensityScore(self):
       
        try:
        
            print "computeTreeProbabilityDensityScore"

	    call = "python " + ScriptsDir.ModelTrainingScripts_estimate_mutation_probability + " " + self.modelTraining_IPR_EC_Dir  + " " + self.phylogeneticTreeFile   + " " +  self.modelTrainingTreeDir
	    NGS_Util.executeCall(call)

	    self.treeCPDS = NGS_Util.createFilePath(self.modelTrainingTreeDir,"tree.cpds")

        except Exception:
            
            print traceback.print_exc()
    def moveIPRScanResults(self):
    
        try:
                
            print "moveIPRScanResults"

            orgListFile_fh = open(self.orgListFile)

            NGS_Util.zipDirectory(self.orgIPRScanDir)
	    NGS_Util.moveDirectoryFiles(self.orgIPRScanDir,self.moveToDir_orgIPRScanDir)

            for line in orgListFile_fh:

                organismNameID, organismName = line.strip().split()

		organism_raw_final        = NGS_Util.createFilePath(self.InterProScan_EC_RAW_results, organismName + ".faa.raw.txt")
		moveto_organism_raw_final = NGS_Util.createFilePath(self.moveToDir_InterProScan_EC_RAW_results, organismName + ".faa.raw.txt")

		self.moveFile_createLink(organism_raw_final,moveto_organism_raw_final)


		organism_IPR_final        = NGS_Util.createFilePath(self.InterProScan_EC_RAW_results, organismName + ".faa.IPR.final.txt")
		moveto_organism_IPR_final = NGS_Util.createFilePath(self.moveToDir_InterProScan_EC_RAW_results, organismName + ".faa.IPR.final.txt")
		
		self.moveFile_createLink(organism_IPR_final,moveto_organism_IPR_final)
		    

            orgListFile_fh.close() 
     
        except Exception:
            
            print traceback.print_exc()
            
        return ""
Example #38
0
    def makeProteinBlastDBFromDustFile(self, inputFasta, dustFile, blastDB):
        
        try:

            if not os.path.exists(dustFile):
                call = self.segmasker + " -in "   + inputFasta + " -infmt fasta -parse_seqids -outfmt maskinfo_asn1_bin -out " + dustFile
                NGS_Util.executeCall(call)

            call = self.makeblastdb + " -in " + inputFasta + " -input_type fasta -dbtype prot -parse_seqids -hash_index -mask_data "   + dustFile + " -out " +  blastDB

            NGS_Util.executeCall(call)
                  
        except Exception:
            print traceback.print_exc()
Example #39
0
    def computeMergedScores(self):
       
        try:
        
            print "computeMergedScores"

	    call = "python " + ScriptsDir.ModelTrainingScripts_computeMergedScores + " " + self.seq_org_list + " " + self.modelTrainingBlastPVDir + " " + self.GTGFungiKNNDir  + " " + self.modelTraining_EC_Scores_Dir 

	    
	    NGS_Util.executeCall(call)
	    
        except Exception:
            
            print traceback.print_exc()
Example #40
0
    def preprocess_EC_UniprotSprot_data_files(self):

        try:

            print "preprocess_EC_UniprotSprot_data_files"

            if not os.path.exists(self.ec_files) and os.path.exists(
                    self.uniprot_sprot_dat):

                call = "python " + ScriptsDir.BlastScripts_getEcs + " " + self.uniprot_sprot_dat + " " + self.ec_files + ": AC, ID, EC"

                NGS_Util.executeCall(call)

        except Exception:
            print traceback.print_exc()
Example #41
0
    def runBashScript(self):
       
        try:
        
            print "runBashScript"


	    call = "bash " + ScriptsDir.ModelTrainingScripts_run_job + " " + self.modelTrainingDir  + " " + self.modelTrainingModelDir  + " " + self.modelTraining_EC_Scores_Dir   + " " + self.modelTrainingProbabilityDensityScoreDir+"all" + " " + self.seq_org_list +  " " + self.phylogeneticTreeFile + " " + self.modelTraining_IPR_EC_Dir  + " " + self.treeCPDS
	    
	    NGS_Util.executeCall(call)

    
        except Exception:
            
            print traceback.print_exc()
    def preprocess_EC_UniprotSprot_data_files(self):
    
        try:
        
            print "preprocess_EC_UniprotSprot_data_files"

            if not os.path.exists( self.ec_files ) and os.path.exists(self.uniprot_sprot_dat):
    
                call = "python " + ScriptsDir.BlastScripts_getEcs + " " + self.uniprot_sprot_dat+ " " + self.ec_files +": AC, ID, EC"
            
                NGS_Util.executeCall(call)
        
    
        except Exception:
            print traceback.print_exc()
Example #43
0
    def generateKeggData(self):

        try:

            print "generateKeggData"

            if not os.path.exists(self.keggAtomMapsDataDir):

                call = "bash " + ScriptsDir.keggParsingScripts_build_kegg_no_general

                NGS_Util.executeCall(call)

        except Exception:

            print traceback.print_exc()
    def generateKeggData(self):

        try:

            print "generateKeggData"

            if not os.path.exists(self.keggAtomMapsDataDir):

                call = "bash " + ScriptsDir.keggParsingScripts_build_kegg_no_general

                NGS_Util.executeCall(call)

        except Exception:

            print traceback.print_exc()
Example #45
0
    def gettNormalizedBlastBitScoreMatrix(self, pfamID, bitScoreMatrix, blastResultFile):
    
        try:

            print "gettNormalizedBlastBitScoreMatrix"
            
                        
            normalizedBitScoreMatrix = self.createBlastBitScoreMatrix(blastResultFile)
            
            for sequenceId, matchingSequenceIDsList in bitScoreMatrix.iteritems():
        
                for matchingSequenceID in matchingSequenceIDsList:
                    
                    sum = bitScoreMatrix[sequenceId][sequenceId] + bitScoreMatrix[matchingSequenceID][matchingSequenceID] - bitScoreMatrix[sequenceId][matchingSequenceID]
                    
                    normalizedBitScoreMatrix[sequenceId][matchingSequenceID] = bitScoreMatrix[sequenceId][matchingSequenceID] / sum


            normalizedBitScoreMatrixFile = NGS_Util.createFilePath(self.pfamBlastStaticticsDir, pfamID + "_NormalizedBitScores.txt")
            self.writeMatrixToFile(normalizedBitScoreMatrix, normalizedBitScoreMatrixFile)
            
            return normalizedBitScoreMatrix
     
        except Exception:
            
            print traceback.print_exc()
            
        return ""
    def combineBlast(self, organismName, org_vs_UniprotBlastDB, Uniprot_vs_orgBlastDB):
    
        try:
        
            print "Combine Blast: " + organismName
            
            orgJointBlast            = NGS_Util.createFilePath(self.orgBlastResDir, organismName + ".joint.blast")
            
            org_vs_UniprotBlastDB_fh = open(org_vs_UniprotBlastDB)
            
            Uniprot_vs_orgBlastDB_fh = open(Uniprot_vs_orgBlastDB)
            
            ec_files_fh              = open(self.ec_files)
            
            orgJointBlast_fh         = open(orgJointBlast, "w")
            

            combineBlasts(ec_files_fh, org_vs_UniprotBlastDB_fh, Uniprot_vs_orgBlastDB_fh, orgJointBlast_fh)

            
            org_vs_UniprotBlastDB_fh.close()
            Uniprot_vs_orgBlastDB_fh.close()
            ec_files_fh.close()
            orgJointBlast_fh.close()
            
 
            return orgJointBlast
        
        except Exception:
            
            print traceback.print_exc()
            
        return ""
Example #47
0
def generatePics(currentRunDir):

    try:

        print "generatePics"

        call = "cat " + projectBinDir + "r_analyseClustering.R | R --slave --args " + currentRunDir

        NGS_Util.executeCall(call)

        picsDir = NGS_Util.createDirectoryPath(currentRunDir, "PicsTables")

        epsFile = NGS_Util.createFilePath(picsDir, "SenSpeVsInfAll.eps")

        pngFile = NGS_Util.createFilePath(picsDir, "SenSpeVsInfAll.png")

        call = "convert " + epsFile + " " + pngFile

        NGS_Util.executeCall(call)

    except Exception:

        print traceback.print_exc()

    return ""
Example #48
0
    def makeClusterInputFiles(self, pfamID, abcFile, mclClusteringDir):

        try:

            mciFile = NGS_Util.createFilePath(mclClusteringDir,
                                              pfamID + ".mci")
            tabFile = NGS_Util.createFilePath(mclClusteringDir,
                                              pfamID + ".tab")

            call = "mcxload -abc " + abcFile + " --stream-mirror --stream-neg-log10 -stream-tf 'ceil(200)' -o " + mciFile + "  -write-tab " + tabFile

            NGS_Util.executeCall(call)

            return mciFile, tabFile

        except Exception:

            print traceback.print_exc()
Example #49
0
    def map_ipr_to_specific_ecs(self,organismName, organism_ipr2go):
    
        try:
        
            print "map_ipr_to_specific_ecs: " + organismName

	    organism_ipr2ec = NGS_Util.createFilePath(self.orgIPRScanDir, organismName + "_ipr2ec.txt")
	    
	    call = "python " + ScriptsDir.IPRScanScripts_get_interpro_ecs + " " + self.ec2go + " " + organism_ipr2go + " " + organism_ipr2ec
	    
	    NGS_Util.executeCall(call)
	    
	    return organism_ipr2ec

        except Exception:
            
            print traceback.print_exc()
        
        return ""
    def reform_knn(self, organismName, org_gtg_knn): # (9) Add org and ecs

        try:
        
            print "reform_knn: " + organismName

	    org_gtg_knn_final = NGS_Util.createFilePath(self.GTGKNNDir, organismName + ".gtg.knn")
	    
            call = "python " + ScriptsDir.GTGScripts_reform_knn + " " +self.seq_org_list + " " + self.ec_files + " " + org_gtg_knn + " " + org_gtg_knn_final

	    NGS_Util.executeCall(call)
	    
	    return org_gtg_knn_final
	
        except Exception:
            
            print traceback.print_exc()
        
        return ""
    def extract_combine_seq_start_len_fmt11(self, organismName, org_vs_nr40BlastDB_f11_part1, org_vs_nr40BlastDB_f11_part2): #(4) combine the result from previous two steps
    
        try:
        
            print "extract_combine_seq_start_len_fmt11: " + organismName

	    org_vs_nr40BlastDB_f11_part1_part2_result = NGS_Util.createFilePath(self.orgGTGBlastResDir, organismName + ".nrdb40_v2.part1.part2.result")

	    call = "python " + ScriptsDir.GTGScripts_extract_combine_seq_start_len_fmt11 + " " + org_vs_nr40BlastDB_f11_part1 + " " + org_vs_nr40BlastDB_f11_part2 + " " + org_vs_nr40BlastDB_f11_part1_part2_result
	    
	    NGS_Util.executeCall(call)
	    
	    return org_vs_nr40BlastDB_f11_part1_part2_result
	    
	except Exception:    

            print traceback.print_exc()
        
        return ""
Example #52
0
    def extract_ipr2go_based_on_xml(self,organismName, ipr_xml_file):
    
        try:
        
            print "extract_ipr2go_based_on_xml: " + organismName

	    organism_ipr2go = NGS_Util.createFilePath(self.orgIPRScanDir, organismName + "_ipr2go.txt")
	    
	    call = "python " + ScriptsDir.IPRScanScripts_ipr2go + " " + ipr_xml_file + " " + organism_ipr2go
	    
	    NGS_Util.executeCall(call)
	    
	    return organism_ipr2go

        except Exception:
            
            print traceback.print_exc()
        
        return ""