parameters: (self, taskPrefix="", dependencies=None)
return_statement: return nextStepWait
docstring: Run hypothesis generation on each SV locus
docstring_summary: Run hypothesis generation on each SV locus
docstring_tokens: Run hypothesis generation on each SV locus
function: def runHyGen(self, taskPrefix="", dependencies=None) :
      """
      Run hypothesis generation on each SV locus
      """
  
      import copy
  
      statsPath=self.paths.getStatsPath()
      graphPath=self.paths.getGraphPath()
      hygenDir=self.paths.getHyGenDir()
  
      makeHyGenDirCmd = getMkdirCmd() + [hygenDir]
      dirTask = self.addTask(preJoin(taskPrefix,"makeHyGenDir"), makeHyGenDirCmd, dependencies=dependencies, isForceLocal=True)
  
      isTumorNormal = (len(self.params.normalBamList) and len(self.params.tumorBamList))
      isTumorOnly = ((not isTumorNormal) and len(self.params.tumorBamList))
  
      hygenTasks=set()
      if self.params.isGenerateSupportBam :
          sortEvidenceBamTasks = set()
  
      self.candidateVcfPaths = []
      self.diploidVcfPaths = []
      self.somaticVcfPaths = []
      self.tumorVcfPaths = []
      self.rnaVcfPaths = []
  
      edgeRuntimeLogPaths = []
  
      if True:
          binId = 0
          binStr = str(binId).zfill(4)
          self.candidateVcfPaths.append(self.paths.getHyGenCandidatePath(binStr))
          if isTumorOnly :
              self.tumorVcfPaths.append(self.paths.getHyGenTumorPath(binStr))
          elif self.params.isRNA:
              self.rnaVcfPaths.append(self.paths.getHyGenRnaPath(binStr))
          else:
              self.diploidVcfPaths.append(self.paths.getHyGenDiploidPath(binStr))
              if isTumorNormal :
                  self.somaticVcfPaths.append(self.paths.getHyGenSomaticPath(binStr))
  
          hygenCmd = [ self.params.mantaHyGenBin ]
          hygenCmd.extend(["--threads", str(self.getNCores())])
          hygenCmd.extend(["--align-stats",statsPath])
          hygenCmd.extend(["--graph-file",graphPath])
          hygenCmd.extend(["--bin-index", str(binId)])
          hygenCmd.extend(["--bin-count", "1"])
          hygenCmd.extend(["--max-edge-count", str(self.params.graphNodeMaxEdgeCount)])
          hygenCmd.extend(["--min-candidate-sv-size", self.params.minCandidateVariantSize])
          hygenCmd.extend(["--min-candidate-spanning-count", self.params.minCandidateSpanningCount])
          hygenCmd.extend(["--min-scored-sv-size", self.params.minScoredVariantSize])
          hygenCmd.extend(["--ref",self.params.referenceFasta])
          hygenCmd.extend(["--candidate-output-file", self.candidateVcfPaths[-1]])
  
          # tumor-only mode
          if isTumorOnly :
              hygenCmd.extend(["--tumor-output-file", self.tumorVcfPaths[-1]])
          elif self.params.isRNA:
              hygenCmd.extend(["--rna-output-file", self.rnaVcfPaths[-1]])
          else:
              hygenCmd.extend(["--diploid-output-file", self.diploidVcfPaths[-1]])
              hygenCmd.extend(["--min-qual-score", self.params.minDiploidVariantScore])
              hygenCmd.extend(["--min-pass-qual-score", self.params.minPassDiploidVariantScore])
              hygenCmd.extend(["--min-pass-gt-score", self.params.minPassDiploidGTScore])
              # tumor/normal mode
              if isTumorNormal :
                  hygenCmd.extend(["--somatic-output-file", self.somaticVcfPaths[-1]])
                  hygenCmd.extend(["--min-somatic-score", self.params.minSomaticScore])
                  hygenCmd.extend(["--min-pass-somatic-score", self.params.minPassSomaticScore])
  
          # Setup remote read retrieval for insertions:
          def isEnableRemoteReadRetrieval() :
              if isTumorOnly or isTumorNormal :
                  return self.params.enableRemoteReadRetrievalForInsertionsInCancerCallingModes
              else :
                  return self.params.enableRemoteReadRetrievalForInsertionsInGermlineCallingModes
  
          if isEnableRemoteReadRetrieval() :
              hygenCmd.append("--enable-remote-read-retrieval")
  
          if self.params.isHighDepthFilter :
              hygenCmd.extend(["--chrom-depth", self.paths.getChromDepth()])
  
          edgeRuntimeLogPaths.append(self.paths.getHyGenEdgeRuntimeLogPath(binStr))
          hygenCmd.extend(["--edge-runtime-log", edgeRuntimeLogPaths[-1]])
  
          hygenCmd.extend(["--edge-stats-log", self.paths.getFinalEdgeStatsPath()])
          hygenCmd.extend(["--edge-stats-report", self.paths.getFinalEdgeStatsReportPath()])
  
          if self.params.isGenerateSupportBam :
              hygenCmd.extend(["--evidence-bam-stub", self.paths.getSupportBamStub(binStr)])
  
          for bamPath in self.params.normalBamList :
              hygenCmd.extend(["--align-file", bamPath])
          for bamPath in self.params.tumorBamList :
              hygenCmd.extend(["--tumor-align-file", bamPath])
  
          if self.params.isIgnoreAnomProperPair :
              hygenCmd.append("--ignore-anom-proper-pair")
  
          if self.params.useOverlapPairEvidence:
              hygenCmd.append("--use-overlapping-pair")
  
          if self.params.isRNA :
              hygenCmd.append("--rna")
              if self.params.isUnstrandedRNA :
                  hygenCmd.append("--unstranded")
  
          if self.params.isOutputContig :
              hygenCmd.append("--output-contigs")
  
          hygenTask = preJoin(taskPrefix,"generateCandidateSV_"+binStr)
          hygenTasks.add(self.addTask(hygenTask,hygenCmd,dependencies=dirTask, nCores=self.getNCores(), memMb=self.params.hyGenMemMb))
  
          if self.params.isGenerateSupportBam :
              # sort evidence bams
              #
              # TODO: if the bam is large, for efficiency, consider
              # 1) filtering the bin-specific bam first w.r.t. the final candidate vcf
              # 2) then sort the bin-specific bam and merge them
              # This would require moving the filter/sort bam jobs outside the hygen loop
              sortEvidenceBams(self, sortEvidenceBamTasks, taskPrefix=taskPrefix, binStr=binStr, dependencies=hygenTask)
  
      nextStepWait = copy.deepcopy(hygenTasks)
  
      vcfTasks = sortAllVcfs(self,taskPrefix=taskPrefix,dependencies=hygenTasks)
      nextStepWait = nextStepWait.union(vcfTasks)
  
      if self.params.isGenerateSupportBam :
          mergeBamTasks = set()
  
          # merge evidence bams
          mergeEvidenceBams(self, mergeBamTasks, taskPrefix=taskPrefix,
                            dependencies=sortEvidenceBamTasks)
  
          nextStepWait = nextStepWait.union(mergeBamTasks)
  
      #
      # sort the edge runtime logs
      #
      logListFile = self.paths.getEdgeRuntimeLogListPath()
      logListTask = preJoin(taskPrefix,"sortEdgeRuntimeLogsInputList")
      self.addWorkflowTask(logListTask,listFileWorkflow(logListFile,edgeRuntimeLogPaths),dependencies=hygenTasks)
  
      def getEdgeLogSortCmd(logListFile, outPath) :
          cmd  = [sys.executable, self.params.mantaSortEdgeLogs,"-f", logListFile,"-o",outPath]
          return cmd
  
      edgeSortCmd=getEdgeLogSortCmd(logListFile,self.paths.getSortedEdgeRuntimeLogPath())
      self.addTask(preJoin(taskPrefix,"sortEdgeRuntimeLogs"), edgeSortCmd, dependencies=logListTask, isForceLocal=True)
  
      if not self.params.isRetainTempFiles :
          # we could delete the temp hygenDir directory here, but it is used for debug so frequently it doesn't seem worth it at present.
          # rmDirCmd = getRmdirCmd() + [hygenDir]
          # rmDirTask=self.addTask(preJoin(taskPrefix,"removeTmpDir"),rmDirCmd,dependencies=TBD_XXX_MANY)
          pass
  
      return nextStepWait
function_tokens: def runHyGen ( self , taskPrefix = "" , dependencies = None ) : import copy statsPath = self . paths . getStatsPath ( ) graphPath = self . paths . getGraphPath ( ) hygenDir = self . paths . getHyGenDir ( ) makeHyGenDirCmd = getMkdirCmd ( ) + [ hygenDir ] dirTask = self . addTask ( preJoin ( taskPrefix , "makeHyGenDir" ) , makeHyGenDirCmd , dependencies = dependencies , isForceLocal = True ) isTumorNormal = ( len ( self . params . normalBamList ) and len ( self . params . tumorBamList ) ) isTumorOnly = ( ( not isTumorNormal ) and len ( self . params . tumorBamList ) ) hygenTasks = set ( ) if self . params . isGenerateSupportBam : sortEvidenceBamTasks = set ( ) self . candidateVcfPaths = [ ] self . diploidVcfPaths = [ ] self . somaticVcfPaths = [ ] self . tumorVcfPaths = [ ] self . rnaVcfPaths = [ ] edgeRuntimeLogPaths = [ ] if True : binId = 0 binStr = str ( binId ) . zfill ( 4 ) self . candidateVcfPaths . append ( self . paths . getHyGenCandidatePath ( binStr ) ) if isTumorOnly : self . tumorVcfPaths . append ( self . paths . getHyGenTumorPath ( binStr ) ) elif self . params . isRNA : self . rnaVcfPaths . append ( self . paths . getHyGenRnaPath ( binStr ) ) else : self . diploidVcfPaths . append ( self . paths . getHyGenDiploidPath ( binStr ) ) if isTumorNormal : self . somaticVcfPaths . append ( self . paths . getHyGenSomaticPath ( binStr ) ) hygenCmd = [ self . params . mantaHyGenBin ] hygenCmd . extend ( [ "--threads" , str ( self . getNCores ( ) ) ] ) hygenCmd . extend ( [ "--align-stats" , statsPath ] ) hygenCmd . extend ( [ "--graph-file" , graphPath ] ) hygenCmd . extend ( [ "--bin-index" , str ( binId ) ] ) hygenCmd . extend ( [ "--bin-count" , "1" ] ) hygenCmd . extend ( [ "--max-edge-count" , str ( self . params . graphNodeMaxEdgeCount ) ] ) hygenCmd . extend ( [ "--min-candidate-sv-size" , self . params . minCandidateVariantSize ] ) hygenCmd . extend ( [ "--min-candidate-spanning-count" , self . params . minCandidateSpanningCount ] ) hygenCmd . extend ( [ "--min-scored-sv-size" , self . params . minScoredVariantSize ] ) hygenCmd . extend ( [ "--ref" , self . params . referenceFasta ] ) hygenCmd . extend ( [ "--candidate-output-file" , self . candidateVcfPaths [ - 1 ] ] ) # tumor-only mode if isTumorOnly : hygenCmd . extend ( [ "--tumor-output-file" , self . tumorVcfPaths [ - 1 ] ] ) elif self . params . isRNA : hygenCmd . extend ( [ "--rna-output-file" , self . rnaVcfPaths [ - 1 ] ] ) else : hygenCmd . extend ( [ "--diploid-output-file" , self . diploidVcfPaths [ - 1 ] ] ) hygenCmd . extend ( [ "--min-qual-score" , self . params . minDiploidVariantScore ] ) hygenCmd . extend ( [ "--min-pass-qual-score" , self . params . minPassDiploidVariantScore ] ) hygenCmd . extend ( [ "--min-pass-gt-score" , self . params . minPassDiploidGTScore ] ) # tumor/normal mode if isTumorNormal : hygenCmd . extend ( [ "--somatic-output-file" , self . somaticVcfPaths [ - 1 ] ] ) hygenCmd . extend ( [ "--min-somatic-score" , self . params . minSomaticScore ] ) hygenCmd . extend ( [ "--min-pass-somatic-score" , self . params . minPassSomaticScore ] ) # Setup remote read retrieval for insertions: def isEnableRemoteReadRetrieval ( ) : if isTumorOnly or isTumorNormal : return self . params . enableRemoteReadRetrievalForInsertionsInCancerCallingModes else : return self . params . enableRemoteReadRetrievalForInsertionsInGermlineCallingModes if isEnableRemoteReadRetrieval ( ) : hygenCmd . append ( "--enable-remote-read-retrieval" ) if self . params . isHighDepthFilter : hygenCmd . extend ( [ "--chrom-depth" , self . paths . getChromDepth ( ) ] ) edgeRuntimeLogPaths . append ( self . paths . getHyGenEdgeRuntimeLogPath ( binStr ) ) hygenCmd . extend ( [ "--edge-runtime-log" , edgeRuntimeLogPaths [ - 1 ] ] ) hygenCmd . extend ( [ "--edge-stats-log" , self . paths . getFinalEdgeStatsPath ( ) ] ) hygenCmd . extend ( [ "--edge-stats-report" , self . paths . getFinalEdgeStatsReportPath ( ) ] ) if self . params . isGenerateSupportBam : hygenCmd . extend ( [ "--evidence-bam-stub" , self . paths . getSupportBamStub ( binStr ) ] ) for bamPath in self . params . normalBamList : hygenCmd . extend ( [ "--align-file" , bamPath ] ) for bamPath in self . params . tumorBamList : hygenCmd . extend ( [ "--tumor-align-file" , bamPath ] ) if self . params . isIgnoreAnomProperPair : hygenCmd . append ( "--ignore-anom-proper-pair" ) if self . params . useOverlapPairEvidence : hygenCmd . append ( "--use-overlapping-pair" ) if self . params . isRNA : hygenCmd . append ( "--rna" ) if self . params . isUnstrandedRNA : hygenCmd . append ( "--unstranded" ) if self . params . isOutputContig : hygenCmd . append ( "--output-contigs" ) hygenTask = preJoin ( taskPrefix , "generateCandidateSV_" + binStr ) hygenTasks . add ( self . addTask ( hygenTask , hygenCmd , dependencies = dirTask , nCores = self . getNCores ( ) , memMb = self . params . hyGenMemMb ) ) if self . params . isGenerateSupportBam : # sort evidence bams # # TODO: if the bam is large, for efficiency, consider # 1) filtering the bin-specific bam first w.r.t. the final candidate vcf # 2) then sort the bin-specific bam and merge them # This would require moving the filter/sort bam jobs outside the hygen loop sortEvidenceBams ( self , sortEvidenceBamTasks , taskPrefix = taskPrefix , binStr = binStr , dependencies = hygenTask ) nextStepWait = copy . deepcopy ( hygenTasks ) vcfTasks = sortAllVcfs ( self , taskPrefix = taskPrefix , dependencies = hygenTasks ) nextStepWait = nextStepWait . union ( vcfTasks ) if self . params . isGenerateSupportBam : mergeBamTasks = set ( ) # merge evidence bams mergeEvidenceBams ( self , mergeBamTasks , taskPrefix = taskPrefix , dependencies = sortEvidenceBamTasks ) nextStepWait = nextStepWait . union ( mergeBamTasks ) # # sort the edge runtime logs # logListFile = self . paths . getEdgeRuntimeLogListPath ( ) logListTask = preJoin ( taskPrefix , "sortEdgeRuntimeLogsInputList" ) self . addWorkflowTask ( logListTask , listFileWorkflow ( logListFile , edgeRuntimeLogPaths ) , dependencies = hygenTasks ) def getEdgeLogSortCmd ( logListFile , outPath ) : cmd = [ sys . executable , self . params . mantaSortEdgeLogs , "-f" , logListFile , "-o" , outPath ] return cmd edgeSortCmd = getEdgeLogSortCmd ( logListFile , self . paths . getSortedEdgeRuntimeLogPath ( ) ) self . addTask ( preJoin ( taskPrefix , "sortEdgeRuntimeLogs" ) , edgeSortCmd , dependencies = logListTask , isForceLocal = True ) if not self . params . isRetainTempFiles : # we could delete the temp hygenDir directory here, but it is used for debug so frequently it doesn't seem worth it at present. # rmDirCmd = getRmdirCmd() + [hygenDir] # rmDirTask=self.addTask(preJoin(taskPrefix,"removeTmpDir"),rmDirCmd,dependencies=TBD_XXX_MANY) pass return nextStepWait