Permalink
Browse files

Bringing in the changes from the CMI repo

  • Loading branch information...
2 parents e93250d + 4c3ac4b commit dca30e699601d7d2545012e23af86ca1bb311111 @MauricioCarneiro MauricioCarneiro committed Dec 14, 2012
View
3 public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java
@@ -397,9 +397,6 @@ public int getSoftStart() {
else if (op != CigarOperator.HARD_CLIP)
break;
}
-
- if ( softStart < 1 )
- softStart = 1;
}
return softStart;
}
View
162 public/scala/src/org/broadinstitute/sting/queue/QCommandLine.scala
@@ -110,95 +110,103 @@ class QCommandLine extends CommandLineProgram with Logging {
* functions, and then builds and runs a QGraph based on the dependencies.
*/
def execute = {
- ClassFieldCache.parsingEngine = this.parser
-
- if (settings.qSettings.runName == null)
- settings.qSettings.runName = FilenameUtils.removeExtension(scripts.head.getName)
- if (IOUtils.isDefaultTempDir(settings.qSettings.tempDirectory))
- settings.qSettings.tempDirectory = IOUtils.absolute(settings.qSettings.runDirectory, ".queue/tmp")
- qGraph.initializeWithSettings(settings)
-
- for (commandPlugin <- allCommandPlugins) {
- loadArgumentsIntoObject(commandPlugin)
- }
-
- for (commandPlugin <- allCommandPlugins) {
- if (commandPlugin.statusMessenger != null)
- commandPlugin.statusMessenger.started()
- }
+ var success = false
+ var result = 1
+ try {
+ ClassFieldCache.parsingEngine = this.parser
- qGraph.messengers = allCommandPlugins.filter(_.statusMessenger != null).map(_.statusMessenger).toSeq
+ if (settings.qSettings.runName == null)
+ settings.qSettings.runName = FilenameUtils.removeExtension(scripts.head.getName)
+ if (IOUtils.isDefaultTempDir(settings.qSettings.tempDirectory))
+ settings.qSettings.tempDirectory = IOUtils.absolute(settings.qSettings.runDirectory, ".queue/tmp")
+ qGraph.initializeWithSettings(settings)
- // TODO: Default command plugin argument?
- val remoteFileConverter = (
- for (commandPlugin <- allCommandPlugins if (commandPlugin.remoteFileConverter != null))
- yield commandPlugin.remoteFileConverter
- ).headOption.getOrElse(null)
-
- if (remoteFileConverter != null)
- loadArgumentsIntoObject(remoteFileConverter)
-
- val allQScripts = qScriptPluginManager.createAllTypes()
- for (script <- allQScripts) {
- logger.info("Scripting " + qScriptPluginManager.getName(script.getClass.asSubclass(classOf[QScript])))
- loadArgumentsIntoObject(script)
- allCommandPlugins.foreach(_.initScript(script))
- // TODO: Pulling inputs can be time/io expensive! Some scripts are using the files to generate functions-- even for dry runs-- so pull it all down for now.
- //if (settings.run)
- script.pullInputs()
- script.qSettings = settings.qSettings
- try {
- script.script()
- } catch {
- case e: Exception =>
- throw new UserException.CannotExecuteQScript(script.getClass.getSimpleName + ".script() threw the following exception: " + e, e)
+ for (commandPlugin <- allCommandPlugins) {
+ loadArgumentsIntoObject(commandPlugin)
}
- if (remoteFileConverter != null) {
- if (remoteFileConverter.convertToRemoteEnabled)
- script.mkRemoteOutputs(remoteFileConverter)
+ for (commandPlugin <- allCommandPlugins) {
+ if (commandPlugin.statusMessenger != null)
+ commandPlugin.statusMessenger.started()
}
- script.functions.foreach(qGraph.add(_))
- logger.info("Added " + script.functions.size + " functions")
- }
- // Execute the job graph
- qGraph.run()
-
- val functionsAndStatus = qGraph.getFunctionsAndStatus
- val success = qGraph.success
+ qGraph.messengers = allCommandPlugins.filter(_.statusMessenger != null).map(_.statusMessenger).toSeq
- // walk over each script, calling onExecutionDone
- for (script <- allQScripts) {
- val scriptFunctions = functionsAndStatus.filterKeys(f => script.functions.contains(f))
- script.onExecutionDone(scriptFunctions, success)
- }
+ // TODO: Default command plugin argument?
+ val remoteFileConverter = (
+ for (commandPlugin <- allCommandPlugins if (commandPlugin.remoteFileConverter != null))
+ yield commandPlugin.remoteFileConverter
+ ).headOption.getOrElse(null)
+
+ if (remoteFileConverter != null)
+ loadArgumentsIntoObject(remoteFileConverter)
+
+ val allQScripts = qScriptPluginManager.createAllTypes()
+ for (script <- allQScripts) {
+ logger.info("Scripting " + qScriptPluginManager.getName(script.getClass.asSubclass(classOf[QScript])))
+ loadArgumentsIntoObject(script)
+ allCommandPlugins.foreach(_.initScript(script))
+ // TODO: Pulling inputs can be time/io expensive! Some scripts are using the files to generate functions-- even for dry runs-- so pull it all down for now.
+ //if (settings.run)
+ script.pullInputs()
+ script.qSettings = settings.qSettings
+ try {
+ script.script()
+ } catch {
+ case e: Exception =>
+ throw new UserException.CannotExecuteQScript(script.getClass.getSimpleName + ".script() threw the following exception: " + e, e)
+ }
+
+ if (remoteFileConverter != null) {
+ if (remoteFileConverter.convertToRemoteEnabled)
+ script.mkRemoteOutputs(remoteFileConverter)
+ }
+
+ script.functions.foreach(qGraph.add(_))
+ logger.info("Added " + script.functions.size + " functions")
+ }
+ // Execute the job graph
+ qGraph.run()
- logger.info("Script %s with %d total jobs".format(if (success) "completed successfully" else "failed", functionsAndStatus.size))
+ val functionsAndStatus = qGraph.getFunctionsAndStatus
- // write the final complete job report
- logger.info("Writing final jobs report...")
- qGraph.writeJobsReport()
+ // walk over each script, calling onExecutionDone
+ for (script <- allQScripts) {
+ val scriptFunctions = functionsAndStatus.filterKeys(f => script.functions.contains(f))
+ script.onExecutionDone(scriptFunctions, success)
+ }
- if (!success) {
- logger.info("Done with errors")
- qGraph.logFailed()
- for (commandPlugin <- allCommandPlugins)
- if (commandPlugin.statusMessenger != null)
- commandPlugin.statusMessenger.exit("Done with errors: %s".format(qGraph.formattedStatusCounts))
- 1
- } else {
- if (settings.run) {
- allQScripts.foreach(_.pushOutputs())
- for (commandPlugin <- allCommandPlugins)
- if (commandPlugin.statusMessenger != null) {
- val allInputs = allQScripts.map(_.remoteInputs)
- val allOutputs = allQScripts.map(_.remoteOutputs)
- commandPlugin.statusMessenger.done(allInputs, allOutputs)
- }
+ logger.info("Script %s with %d total jobs".format(if (success) "completed successfully" else "failed", functionsAndStatus.size))
+
+ // write the final complete job report
+ logger.info("Writing final jobs report...")
+ qGraph.writeJobsReport()
+
+ if (qGraph.success) {
+ if (settings.run) {
+ allQScripts.foreach(_.pushOutputs())
+ for (commandPlugin <- allCommandPlugins)
+ if (commandPlugin.statusMessenger != null) {
+ val allInputs = allQScripts.map(_.remoteInputs)
+ val allOutputs = allQScripts.map(_.remoteOutputs)
+ commandPlugin.statusMessenger.done(allInputs, allOutputs)
+ }
+ }
+ success = true
+ result = 0
+ }
+ } finally {
+ if (!success) {
+ logger.info("Done with errors")
+ qGraph.logFailed()
+ if (settings.run) {
+ for (commandPlugin <- allCommandPlugins)
+ if (commandPlugin.statusMessenger != null)
+ commandPlugin.statusMessenger.exit("Done with errors: %s".format(qGraph.formattedStatusCounts))
+ }
}
- 0
}
+ result
}
/**
View
27 public/scala/src/org/broadinstitute/sting/queue/QScript.scala
@@ -124,7 +124,7 @@ trait QScript extends Logging with PrimitiveOptionConversions with StringFileCon
}
/**
- * Pull all remote files to the local disk.
+ * Pull all remote files to the local disk
*/
def pullInputs() {
val inputs = ClassFieldCache.getFieldFiles(this, inputFields)
@@ -135,7 +135,7 @@ trait QScript extends Logging with PrimitiveOptionConversions with StringFileCon
}
/**
- * Push all remote files from the local disk.
+ * Push all remote files from the local disk
*/
def pushOutputs() {
val outputs = ClassFieldCache.getFieldFiles(this, outputFields)
@@ -145,28 +145,17 @@ trait QScript extends Logging with PrimitiveOptionConversions with StringFileCon
}
}
+ private def filterRemoteFiles(fields: Seq[File]): Seq[RemoteFile] =
+ fields.filter(field => field != null && field.isInstanceOf[RemoteFile]).map(_.asInstanceOf[RemoteFile])
/**
- * List out the remote outputs
- * @return the RemoteFile outputs by argument source
+ * @return the inputs or null if there are no inputs
*/
- def remoteInputs: Map[String, Seq[RemoteFile]] = tagMap(remoteFieldMap(inputFields))
+ def remoteInputs: AnyRef = null
/**
- * List out the remote outputs
- * @return the RemoteFile outputs by argument source
+ * @return the outputs or null if there are no outputs
*/
- def remoteOutputs: Map[String, Seq[RemoteFile]] = tagMap(remoteFieldMap(outputFields))
-
- private def tagMap(remoteFieldMap: Map[ArgumentSource, Seq[RemoteFile]]): Map[String, Seq[RemoteFile]] = {
- remoteFieldMap.collect{ case (k, v) => ClassFieldCache.fullName(k) -> v }.toMap
- }
-
- private def remoteFieldMap(fields: Seq[ArgumentSource]): Map[ArgumentSource, Seq[RemoteFile]] = {
- fields.map(field => (field -> filterRemoteFiles(ClassFieldCache.getFieldFiles(this, field)))).filter(tuple => !tuple._2.isEmpty).toMap
- }
-
- private def filterRemoteFiles(fields: Seq[File]): Seq[RemoteFile] =
- fields.filter(field => field != null && field.isInstanceOf[RemoteFile]).map(_.asInstanceOf[RemoteFile])
+ def remoteOutputs: AnyRef = null
/** The complete list of fields. */
def functionFields: Seq[ArgumentSource] = ClassFieldCache.classFunctionFields(this.getClass)
View
2 public/scala/src/org/broadinstitute/sting/queue/engine/QStatusMessenger.scala
@@ -7,7 +7,7 @@ import org.broadinstitute.sting.queue.util.RemoteFile
*/
trait QStatusMessenger {
def started()
- def done(inputs: Seq[Map[String, Seq[RemoteFile]]], outputs: Seq[Map[String, Seq[RemoteFile]]])
+ def done(inputs: Seq[_], outputs: Seq[_])
def exit(message: String)
def started(job: String)

0 comments on commit dca30e6

Please sign in to comment.