hrbrmstr / melting5jars

MELTING 5 jars
5 stars 1 forks source link

Capturing verbose mode output/ Verbose mode erratic output #1

Open aravind-j opened 6 years ago

aravind-j commented 6 years ago

Hi,

I am using melting5jars for my package (https://github.com/aravind-j/rmelting). The R to java interface is working great. I am able to get the basic values from the get_melting_results function. However I want to further get the data from the verbose mode in the melting5jars.

Verbose mode results in the output in the R console with additional details with respect to environment, method (approximate or nearest-neighbor) and ion correction (if any).

Using optionManager$createEnvironment(opts) I was able to get the environment parameters.

Any pointers on how to get the details of method and ion correction. It seems that it is through a logger function in optionManager.

I am using a modified version of get_melting_results in my package.

get_melting_results <- function(opts = c()) {

  Sys.setenv("NN_PATH"=system.file("extdata", "Data", package="melting5jars"))

  require(melting5jars)

  meltj <- new(J("melting.Main"))
  optionManager <- new(J("melting.configuration.OptionManagement"))

  results <- meltj$getMeltingResults(opts, optionManager)

  # Get environment
  env <- optionManager$createEnvironment(opts)
  envir_melt <- list(`Ion/agent` = env$getConcentrations()$toString(),
                     `Hybridization type` = env$getHybridization(),
                     `Nucleotide concentration` = env$getNucleotides(),
                     `Correction factor` = env$getFactor(),
                     `Self complementarity` = env$isSelfComplementarity(),
                     `Sequence` = env$getSequences()$getSequence(),
                     `Complementary sequence` = env$getSequences()$getComplementary())

  calculMethod <- results$getCalculMethod()

  # Fetch enthalpy and entropy for nearest-neighbour methods
  if (.jinstanceof(calculMethod, J("melting.nearestNeighborModel.NearestNeighborMode"))) {
    enthalpy_cal <- results$getEnthalpy()
    entropy_cal <- results$getEntropy()

    enthalpy_J <- entropy_J <- NULL
    enthalpy_J <- results$getEnergyValueInJ(enthalpy_cal)
    entropy_J <- results$getEnergyValueInJ(entropy_cal)
  } else {# NA for approximative methods
    enthalpy_cal <- NA_integer_
    entropy_cal <- NA_integer_
    enthalpy_J <- NA_integer_
    entropy_J <- NA_integer_
  }

  melting_temp_C <- results$getTm()

  # Get melting results
  results_melt <- list(`Enthalpy (cal)` = enthalpy_cal,
                       `Entropy (cal)` = entropy_cal,
                       `Enthalpy (J)` = enthalpy_J,
                       `Entropy (J)` = entropy_J,
                       `Melting temperature (C)` = melting_temp_C)

  out <- list(Environment = envir_melt,
              `Melting result` = results_melt)

  return(out)

}

Further in verbose mode there is erratic output with present output appending to previous ones after repeated runs.

aravind-j commented 6 years ago

Few examples for use:

# Nearest neighbour : "all97" (default)
opts <- c(
  "-S", "CAACTTGATATTATTA",
  "-H", "dnadna",
  "-P", 4e-4,
  "-E", paste("Na=", 1, sep = "")
)

# Nearest neighbour : "sug96"
opts <- c(
  "-S", "CAACTTGATATTATTA",
  "-H", "dnadna",
  "-P", 4e-4,
  "-E", paste("Na=", 1, sep = ""),
  "-nn", "sug96"
)

# Approximate : "ahs01"
opts <- c(
  "-S", "CAACTTGATATTATTA",
  "-H", "dnadna",
  "-P", 4e-4,
  "-E", paste("Na=", 1, sep = ""),
  "-am", "ahs01"
)

# Nearest neighbour : "all97" (default), verbose
opts <- c(
  "-S", "CAACTTGATATTATTA",
  "-H", "dnadna",
  "-P", 4e-4,
  "-E", paste("Na=", 1, sep = ""),
  "-v"
)

# Approximate : "ahs01", verbose
opts <- c(
  "-S", "CAACTTGATATTATTA",
  "-H", "dnadna",
  "-P", 4e-4,
  "-E", paste("Na=", 1, sep = ""),
  "-am", "ahs01",
  "-v"
)

# Nearest neighbour : "all97" (default), verbose
# SOdium correction :  "ash01"
opts <- c(
  "-S", "CAGTGAGACAGCAATGGTCG",
  "-H", "dnadna",
  "-P", 2e-06,
  "-E", paste("Na=", 1, sep = ""),
  "-ion", "ahs01",
  "-v"
)

# Nearest neighbour : "all97" (default), verbose
# SOdium correction :  "ash01"
opts <- c(
  "-S", "CAGTGAGACAGCAATGGTCG",
  "-H", "dnadna",
  "-P", 2e-06,
  "-E", paste("Na=", 1,":", "Mg=", 0.01, sep = ""),
  "-v"
)

get_melting_results(opts)
hrbrmstr commented 6 years ago

Rly glad the pkg has been helpful!

I've got some work-work projects to jump into this AM but I'll take a look ASAP.