summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua')
-rw-r--r--Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua624
1 files changed, 362 insertions, 262 deletions
diff --git a/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua b/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua
index 59d500cc0c0..4919aeab702 100644
--- a/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua
+++ b/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua
@@ -6,7 +6,7 @@
--
-- pgfmolbio.dtx (with options: `pmb-chr-lua')
--
--- Copyright (C) 2011 by Wolfgang Skala
+-- Copyright (C) 2012 by Wolfgang Skala
--
-- This work may be distributed and/or modified under the
-- conditions of the LaTeX Project Public License, either version 1.3
@@ -18,27 +18,29 @@
--
module("pgfmolbio.chromatogram", package.seeall)
+
+if luatexbase then
+ luatexbase.provides_module{
+ name = "pgfmolbio.chromatogram",
+ version = 0.2,
+ date = "2012/10/01",
+ description = "DNA sequencing chromatograms",
+ author = "Wolfgang Skala",
+ copyright = "Wolfgang Skala",
+ license = "LPPL",
+ }
+end
+
local ALL_BASES = {"A", "C", "G", "T"}
local PGFKEYS_PATH = "/pgfmolbio/chromatogram/"
-local header, samples,
- peaks, parms,
- selectedPeaks,
- lastScfFile
-
-local function baseToSampleIndex (baseIndex)
- local result = tonumber(baseIndex)
- if result then
- return result
- else
- result = string.match(baseIndex, "base%s*(%d+)")
- if tonumber(result) then
- return peaks[tonumber(result)].offset
- end
- end
-end
+local stringToDim = pgfmolbio.stringToDim
+local dimToString = pgfmolbio.dimToString
+local packageError = pgfmolbio.packageError
+local packageWarning = pgfmolbio.packageWarning
+local getRange = pgfmolbio.getRange
-local function stdProbStyle (prob)
+local function stdProbStyle(prob)
local color = ""
if prob >= 0 and prob < 10 then
color = "black"
@@ -52,21 +54,85 @@ local function stdProbStyle (prob)
return "ultra thick, " .. color
end
-local function findBasesInStr (target)
+local function findBasesInStr(target)
if not target then return end
local result = {}
for _, v in ipairs(ALL_BASES) do
- if string.find(string.upper(target), v) then
+ if target:upper():find(v) then
table.insert(result, v)
end
end
return result
end
-function getMinMaxProbability ()
+local function readInt(file, n, offset)
+ if offset then file:seek("set", offset) end
+ local result = 0
+ for i = 1, n do
+ result = result * 0x100 + file:read(1):byte()
+ end
+ return result
+end
+
+Chromatogram = {}
+
+function Chromatogram:new()
+ newChromatogram = {
+ sampleMin = 1,
+ sampleMax = 500,
+ sampleStep = 1,
+ peakMin = -1,
+ peakMax = -1,
+ xUnit = stringToDim("0.2mm"),
+ yUnit = stringToDim("0.01mm"),
+ samplesPerLine = 500,
+ baselineSkip = stringToDim("3cm"),
+ canvasHeight = stringToDim("2cm"),
+ traceStyle = {
+ A = PGFKEYS_PATH .. "trace A style",
+ C = PGFKEYS_PATH .. "trace C style",
+ G = PGFKEYS_PATH .. "trace G style",
+ T = PGFKEYS_PATH .. "trace T style"
+ },
+ tickStyle = {
+ A = PGFKEYS_PATH .. "tick A style",
+ C = PGFKEYS_PATH .. "tick C style",
+ G = PGFKEYS_PATH .. "tick G style",
+ T = PGFKEYS_PATH .. "tick T style"
+ },
+ tickLength = stringToDim("1mm"),
+ baseLabelText = {
+ A = "\\pgfkeysvalueof{" .. PGFKEYS_PATH .. "base label A text}",
+ C = "\\pgfkeysvalueof{" .. PGFKEYS_PATH .. "base label C text}",
+ G = "\\pgfkeysvalueof{" .. PGFKEYS_PATH .. "base label G text}",
+ T = "\\pgfkeysvalueof{" .. PGFKEYS_PATH .. "base label T text}"
+ },
+ baseLabelStyle = {
+ A = PGFKEYS_PATH .. "base label A style",
+ C = PGFKEYS_PATH .. "base label C style",
+ G = PGFKEYS_PATH .. "base label G style",
+ T = PGFKEYS_PATH .. "base label T style"
+ },
+ showBaseNumbers = true,
+ baseNumberMin = -1,
+ baseNumberMax = -1,
+ baseNumberStep = 10,
+ probDistance = stringToDim("0.8cm"),
+ probStyle = stdProbStyle,
+ tracesDrawn = ALL_BASES,
+ ticksDrawn = "ACGT",
+ baseLabelsDrawn = "ACGT",
+ probabilitiesDrawn = "ACGT",
+ }
+ setmetatable(newChromatogram, self)
+ self.__index = self
+ return newChromatogram
+end
+
+function Chromatogram:getMinMaxProbability()
local minProb = 0
local maxProb = 0
- for _, currPeak in ipairs(selectedPeaks) do
+ for _, currPeak in ipairs(self.selectedPeaks) do
for __, currProb in pairs(currPeak.prob) do
if currProb > maxProb then maxProb = currProb end
if currProb < minProb then minProb = currProb end
@@ -75,232 +141,266 @@ function getMinMaxProbability ()
return minProb, maxProb
end
-local function getRange (rangeInput, regExp)
- local lower, upper = string.match(rangeInput, regExp)
- local step = string.match(rangeInput, "step%s*(%d*)")
- return lower, upper, step
-end
+function Chromatogram:getSampleAndPeakIndex(baseIndex, isLowerLimit)
+ local sampleId, peakId
-local function readInt (file, n, offset)
- if offset then file:seek("set", offset) end
- local result = 0
- for i = 1, n do
- result = result * 0x100 + string.byte(file:read(1))
+ sampleId = tonumber(baseIndex)
+ if sampleId then
+ for i, v in ipairs(self.peaks) do
+ if isLowerLimit then
+ if v.offset >= sampleId then
+ peakId = i
+ break
+ end
+ else
+ if v.offset == sampleId then
+ peakId = i
+ break
+ elseif v.offset > sampleId then
+ peakId = i - 1
+ break
+ end
+ end
+ end
+ else
+ peakId = tonumber(baseIndex:match("base%s*(%d+)"))
+ if peakId then
+ sampleId = self.peaks[peakId].offset
+ end
end
- return result
+ return sampleId, peakId
end
-local function evaluateScfFile (file)
- samples = {A = {}, C = {}, G = {}, T = {}}
- peaks = {}
- header = {
- magicNumber = readInt(file, 4, 0),
- samplesNumber = readInt(file, 4),
- samplesOffset = readInt(file, 4),
- basesNumber = readInt(file, 4),
- leftClip = readInt(file, 4),
- rightClip = readInt(file, 4),
- basesOffset = readInt(file, 4),
- comments = readInt(file, 4),
- commentsOffset = readInt(file, 4),
- version = readInt(file, 4),
- sampleSize = readInt(file, 4),
- codeSet = readInt(file, 4),
- privateSize = readInt(file, 4),
- privateOffset = readInt(file, 4)
- }
- if header.magicNumber ~= 0x2E736366 then
- tex.error("Magic number in scf file '" .. lastScfFile .. "' corrupt!")
- end
- if header.version ~= 0x332E3030 then
- tex.error("Scf file '" .. lastScfFile .. "' is not version 3.00!")
- end
-
- file:seek("set", header.samplesOffset)
- for baseIndex, baseName in ipairs(ALL_BASES) do
- for i = 1, header.samplesNumber do
- samples[baseName][i] = readInt(file, header.sampleSize)
+function Chromatogram:readScfFile(filename)
+ if filename ~= self.lastScfFile then
+ self.lastScfFile = filename
+ local scfFile, errorMsg = io.open(filename, "rb")
+ if not scfFile then packageError(errorMsg) end
+
+ self.samples = {A = {}, C = {}, G = {}, T = {}}
+ self.peaks = {}
+ self.header = {
+ magicNumber = readInt(scfFile, 4, 0),
+ samplesNumber = readInt(scfFile, 4),
+ samplesOffset = readInt(scfFile, 4),
+ basesNumber = readInt(scfFile, 4),
+ leftClip = readInt(scfFile, 4),
+ rightClip = readInt(scfFile, 4),
+ basesOffset = readInt(scfFile, 4),
+ comments = readInt(scfFile, 4),
+ commentsOffset = readInt(scfFile, 4),
+ version = readInt(scfFile, 4),
+ sampleSize = readInt(scfFile, 4),
+ codeSet = readInt(scfFile, 4),
+ privateSize = readInt(scfFile, 4),
+ privateOffset = readInt(scfFile, 4)
+ }
+ if self.header.magicNumber ~= 0x2E736366 then
+ packageError(
+ "Magic number in scf scfFile '" ..
+ self.lastScfFile ..
+ "' corrupt!"
+ )
end
+ if self.header.version ~= 0x332E3030 then
+ packageError(
+ "Scf scfFile '" ..
+ self.lastScfFile ..
+ "' is not version 3.00!"
+ )
+ end
+ scfFile:seek("set", self.header.samplesOffset)
+ for baseIndex, baseName in ipairs(ALL_BASES) do
+ for i = 1, self.header.samplesNumber do
+ self.samples[baseName][i] =
+ readInt(scfFile, self.header.sampleSize)
+ end
- for _ = 1, 2 do
- local preValue = 0
- for i = 1, header.samplesNumber do
- samples[baseName][i] = samples[baseName][i] + preValue
- if samples[baseName][i] > 0xFFFF then
- samples[baseName][i] = samples[baseName][i] - 0x10000
+ for _ = 1, 2 do
+ local preValue = 0
+ for i = 1, self.header.samplesNumber do
+ self.samples[baseName][i] = self.samples[baseName][i] + preValue
+ if self.samples[baseName][i] > 0xFFFF then
+ self.samples[baseName][i] = self.samples[baseName][i] - 0x10000
+ end
+ preValue = self.samples[baseName][i]
end
- preValue = samples[baseName][i]
end
end
- end
-
- for i = 1, header.basesNumber do
- peaks[i] = {
- offset = readInt(file, 4),
- prob = {A, C, G, T},
- base
- }
- end
+ for i = 1, self.header.basesNumber do
+ self.peaks[i] = {
+ offset = readInt(scfFile, 4),
+ prob = {A, C, G, T},
+ base
+ }
+ end
- for i = 1, header.basesNumber do
- peaks[i].prob.A = readInt(file, 1)
- end
+ for i = 1, self.header.basesNumber do
+ self.peaks[i].prob.A = readInt(scfFile, 1)
+ end
- for i = 1, header.basesNumber do
- peaks[i].prob.C = readInt(file, 1)
- end
+ for i = 1, self.header.basesNumber do
+ self.peaks[i].prob.C = readInt(scfFile, 1)
+ end
- for i = 1, header.basesNumber do
- peaks[i].prob.G = readInt(file, 1)
- end
+ for i = 1, self.header.basesNumber do
+ self.peaks[i].prob.G = readInt(scfFile, 1)
+ end
- for i = 1, header.basesNumber do
- peaks[i].prob.T = readInt(file, 1)
- end
+ for i = 1, self.header.basesNumber do
+ self.peaks[i].prob.T = readInt(scfFile, 1)
+ end
- for i = 1, header.basesNumber do
- peaks[i].base = string.char(readInt(file, 1))
- end
-end
+ for i = 1, self.header.basesNumber do
+ self.peaks[i].base = string.char(readInt(scfFile, 1))
+ end
-function readScfFile (filename)
- if filename ~= lastScfFile then
- lastScfFile = filename
- local scfFile, errorMsg = io.open(filename, "rb")
- if not scfFile then tex.error(errorMsg) end
- evaluateScfFile(scfFile)
scfFile:close()
end
end
-function setParameters (newParms)
- local sampleRangeMin, sampleRangeMax, sampleRangeStep =
- getRange(
- newParms.sampleRange or "1 to 500 step 1",
- "([base]*%s*%d+)%s*to%s*([base]*%s*%d+)"
- )
- local baseNumberRangeMin, baseNumberRangeMax, baseNumberRangeStep =
- getRange(
- newParms.baseNumberRange or "auto to auto step 10",
- "([auto%d]*)%s+to%s+([auto%d]*)"
- )
-
- parms = {
- sampleMin = baseToSampleIndex(sampleRangeMin) or 1,
- sampleMax = baseToSampleIndex(sampleRangeMax) or 500,
- sampleStep = sampleRangeStep or 1,
- xUnit = newParms.xUnit or dimen("0.2mm")[1],
- yUnit = newParms.yUnit or dimen("0.01mm")[1],
- samplesPerLine = newParms.samplesPerLine or 500,
- baselineSkip = newParms.baselineSkip or dimen("3cm")[1],
- canvasHeight= newParms.canvasHeight or dimen("2cm")[1],
- traceStyle = {
- A = PGFKEYS_PATH .. "trace A style@style",
- C = PGFKEYS_PATH .. "trace C style@style",
- G = PGFKEYS_PATH .. "trace G style@style",
- T = PGFKEYS_PATH .. "trace T style@style"
- },
- tickStyle = {
- A = PGFKEYS_PATH .. "tick A style@style",
- C = PGFKEYS_PATH .. "tick C style@style",
- G = PGFKEYS_PATH .. "tick G style@style",
- T = PGFKEYS_PATH .. "tick T style@style"
- },
- tickLength = newParms.tickLength or dimen("1mm")[1],
- baseLabelText = {
- A = "\\csname pmb@chr@base label A text\\endcsname",
- C = "\\csname pmb@chr@base label C text\\endcsname",
- G = "\\csname pmb@chr@base label G text\\endcsname",
- T = "\\csname pmb@chr@base label T text\\endcsname"
- },
- baseLabelStyle = {
- A = PGFKEYS_PATH .. "base label A style@style",
- C = PGFKEYS_PATH .. "base label C style@style",
- G = PGFKEYS_PATH .. "base label G style@style",
- T = PGFKEYS_PATH .. "base label T style@style"
- },
- showBaseNumbers = newParms.showBaseNumbers,
- baseNumberMin = tonumber(baseNumberRangeMin) or -1,
- baseNumberMax = tonumber(baseNumberRangeMax) or -1,
- baseNumberStep = tonumber(baseNumberRangeStep) or 10,
- probDistance = newParms.probDistance or dimen("0.8cm")[1],
- probStyle = newParms.probStyle or stdProbStyle,
- tracesDrawn = findBasesInStr(newParms.tracesDrawn) or ALL_BASES,
- ticksDrawn = newParms.ticksDrawn or "ACGT",
- baseLabelsDrawn = newParms.baseLabelsDrawn or "ACGT",
- probabilitiesDrawn = newParms.probabilitiesDrawn or "ACGT",
- coordUnit = "mm",
- coordFmtStr = "%s%s"
+function Chromatogram:setParameters(newParms)
+ local keyHash = {
+ sampleRange = function(v)
+ local sampleRangeMin, sampleRangeMax, sampleRangeStep =
+ getRange(
+ v:trim(),
+ "^([base]*%s*%d+)%s*%-",
+ "%-%s*([base]*%s*%d+)",
+ "step%s*(%d+)$"
+ )
+ self.sampleMin, self.peakMin =
+ self:getSampleAndPeakIndex(sampleRangeMin, true)
+ self.sampleMax, self.peakMax =
+ self:getSampleAndPeakIndex(sampleRangeMax, false)
+ if self.sampleMin >= self.sampleMax then
+ packageError("Sample range is smaller than 1.")
+ end
+ self.sampleStep = sampleRangeStep or self.sampleStep
+ end,
+ xUnit = stringToDim,
+ yUnit = stringToDim,
+ samplesPerLine = tonumber,
+ baselineSkip = stringToDim,
+ canvasHeight = stringToDim,
+ tickLength = stringToDim,
+ showBaseNumbers = function(v)
+ if v == "true" then return true else return false end
+ end,
+ baseNumberRange = function(v)
+ local baseNumberRangeMin, baseNumberRangeMax, baseNumberRangeStep =
+ getRange(
+ v:trim(),
+ "^([auto%d]*)%s+%-",
+ "%-%s+([auto%d]*$)"
+ )
+ if tonumber(baseNumberRangeMin) then
+ self.baseNumberMin = tonumber(baseNumberRangeMin)
+ else
+ self.baseNumberMin = self.peakMin
+ end
+ if tonumber(baseNumberRangeMax) then
+ self.baseNumberMax = tonumber(baseNumberRangeMax)
+ else
+ self.baseNumberMax = self.peakMax
+ end
+ if self.baseNumberMin >= self.baseNumberMax then
+ packageError("Base number range is smaller than 1.")
+ end
+ if self.baseNumberMin < self.peakMin then
+ self.baseNumberMin = self.peakMin
+ packageWarning("Lower base number range is smaller than lower sample range. It was adjusted to " .. self.baseNumberMin .. ".")
+ end
+ if self.baseNumberMax > self.peakMax then
+ self.baseNumberMax = self.peakMax
+ packageWarning("Upper base number range exceeds upper sample range. It was adjusted to " .. self.baseNumberMax .. ".")
+ end
+ self.baseNumberStep = tonumber(baseNumberRangeStep)
+ or self.baseNumberStep
+ end,
+ probDistance = stringToDim,
+ probStyle = function(v) return v end,
+ tracesDrawn = findBasesInStr,
+ ticksDrawn = function(v) return v end,
+ baseLabelsDrawn = function(v) return v end,
+ probabilitiesDrawn = function(v) return v end,
+ probStyle = function(v) return v end
}
+ for key, value in pairs(newParms) do
+ if keyHash[key] then
+ self[key] = keyHash[key](value)
+ end
+ end
end
-function printTikzChromatogram ()
- selectedPeaks = {}
+function Chromatogram:printTikzChromatogram()
+ if pgfmolbio.errorCatched then return end
+ self.selectedPeaks = {}
local tIndex = 1
- for rPeakIndex, currPeak in ipairs(peaks) do
- if currPeak.offset >= parms.sampleMin
- and currPeak.offset <= parms.sampleMax then
- selectedPeaks[tIndex] = {
- offset = currPeak.offset + 1 - parms.sampleMin,
+ for rPeakIndex, currPeak in ipairs(self.peaks) do
+ if currPeak.offset >= self.sampleMin
+ and currPeak.offset <= self.sampleMax then
+ self.selectedPeaks[tIndex] = {
+ offset = currPeak.offset + 1 - self.sampleMin,
base = currPeak.base,
prob = currPeak.prob,
baseIndex = rPeakIndex,
- probXRight = parms.sampleMax + 1 - parms.sampleMin
+ probXRight = self.sampleMax + 1 - self.sampleMin
}
if tIndex > 1 then
- selectedPeaks[tIndex-1].probXRight =
- (selectedPeaks[tIndex-1].offset
- + selectedPeaks[tIndex].offset) / 2
+ self.selectedPeaks[tIndex-1].probXRight =
+ (self.selectedPeaks[tIndex-1].offset
+ + self.selectedPeaks[tIndex].offset) / 2
end
tIndex = tIndex + 1
end
end
if tIndex > 1 then
- if parms.baseNumberMin == -1 then
- parms.baseNumberMin = selectedPeaks[1].baseIndex
+ if self.baseNumberMin == -1 then
+ self.baseNumberMin = self.selectedPeaks[1].baseIndex
end
- if parms.baseNumberMax == -1 then
- parms.baseNumberMax = selectedPeaks[tIndex-1].baseIndex
+ if self.baseNumberMax == -1 then
+ self.baseNumberMax = self.selectedPeaks[tIndex-1].baseIndex
end
end
- local samplesLeft = parms.sampleMax - parms.sampleMin + 1
+ local samplesLeft = self.sampleMax - self.sampleMin + 1
local currLine = 0
while samplesLeft > 0 do
- local yLower = -currLine * parms.baselineSkip
- local yUpper = -currLine * parms.baselineSkip + parms.canvasHeight
+ local yLower = -currLine * self.baselineSkip
+ local yUpper = -currLine * self.baselineSkip + self.canvasHeight
local xRight =
- (math.min(parms.samplesPerLine, samplesLeft) - 1) * parms.xUnit
+ (math.min(self.samplesPerLine, samplesLeft) - 1) * self.xUnit
tex.sprint(
- "\\draw[" .. PGFKEYS_PATH .. "canvas style@style] (" ..
- number.todimen(0, parms.coordUnit, parms.coordFmtStr) ..
+ "\n\t\\draw [" .. PGFKEYS_PATH .. "canvas style] (" ..
+ dimToString(0) ..
", " ..
- number.todimen(yLower, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(yLower) ..
") rectangle (" ..
- number.todimen(xRight, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(xRight) ..
", " ..
- number.todimen(yUpper, parms.coordUnit, parms.coordFmtStr) ..
- ");\n"
+ dimToString(yUpper) ..
+ ");"
)
- samplesLeft = samplesLeft - parms.samplesPerLine
+ samplesLeft = samplesLeft - self.samplesPerLine
currLine = currLine + 1
end
- for _, baseName in ipairs(parms.tracesDrawn) do
- tex.sprint("\\draw[" .. parms.traceStyle[baseName] .. "] ")
- local currSampleIndex = parms.sampleMin
+ for _, baseName in ipairs(self.tracesDrawn) do
+ tex.sprint("\n\t\\draw [" .. self.traceStyle[baseName] .. "] ")
+ local currSampleIndex = self.sampleMin
local sampleX = 1
local x = 0
local y = 0
local currLine = 0
local firstPointInLine = true
- while currSampleIndex <= parms.sampleMax do
- x = ((sampleX - 1) % parms.samplesPerLine) * parms.xUnit
- y = samples[baseName][currSampleIndex] * parms.yUnit
- - currLine * parms.baselineSkip
- if sampleX % parms.sampleStep == 0 then
+ while currSampleIndex <= self.sampleMax do
+ x = ((sampleX - 1) % self.samplesPerLine) * self.xUnit
+ y = self.samples[baseName][currSampleIndex] * self.yUnit
+ - currLine * self.baselineSkip
+ if sampleX % self.sampleStep == 0 then
if not firstPointInLine then
tex.sprint(" -- ")
else
@@ -308,20 +408,20 @@ function printTikzChromatogram ()
end
tex.sprint(
"(" ..
- number.todimen(x, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(x) ..
", " ..
- number.todimen(y, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(y) ..
")"
)
end
- if sampleX ~= parms.sampleMax + 1 - parms.sampleMin then
- if sampleX >= (currLine + 1) * parms.samplesPerLine then
+ if sampleX ~= self.sampleMax + 1 - self.sampleMin then
+ if sampleX >= (currLine + 1) * self.samplesPerLine then
currLine = currLine + 1
- tex.sprint(";\n\\draw[" .. parms.traceStyle[baseName] .. "] ")
+ tex.sprint(";\n\t\\draw [" .. self.traceStyle[baseName] .. "] ")
firstPointInLine = true
end
else
- tex.sprint(";\n")
+ tex.sprint(";")
end
sampleX = sampleX + 1
currSampleIndex = currSampleIndex + 1
@@ -332,127 +432,127 @@ function printTikzChromatogram ()
local lastProbX = 1
local probRemainder = false
- for _, currPeak in ipairs(selectedPeaks) do
- while currPeak.offset > (currLine + 1) * parms.samplesPerLine do
+ for _, currPeak in ipairs(self.selectedPeaks) do
+ while currPeak.offset > (currLine + 1) * self.samplesPerLine do
currLine = currLine + 1
end
- local x = ((currPeak.offset - 1) % parms.samplesPerLine) * parms.xUnit
- local yUpper = -currLine * parms.baselineSkip
- local yLower = -currLine * parms.baselineSkip - parms.tickLength
+ local x = ((currPeak.offset - 1) % self.samplesPerLine) * self.xUnit
+ local yUpper = -currLine * self.baselineSkip
+ local yLower = -currLine * self.baselineSkip - self.tickLength
local tickOperation = ""
- if string.find(string.upper(parms.ticksDrawn), currPeak.base) then
+ if self.ticksDrawn:upper():find(currPeak.base) then
tickOperation = "--"
end
tex.sprint(
- "\\draw[" ..
- parms.tickStyle[currPeak.base] ..
+ "\n\t\\draw [" ..
+ self.tickStyle[currPeak.base] ..
"] (" ..
- number.todimen(x, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(x) ..
", " ..
- number.todimen(yUpper, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(yUpper) ..
") " ..
tickOperation ..
" (" ..
- number.todimen(x, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(x) ..
", " ..
- number.todimen(yLower, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(yLower) ..
")"
)
- if string.find(string.upper(parms.baseLabelsDrawn), currPeak.base) then
+ if self.baseLabelsDrawn:upper():find(currPeak.base) then
tex.sprint(
- " node[" ..
- parms.baseLabelStyle[currPeak.base] ..
+ " node [" ..
+ self.baseLabelStyle[currPeak.base] ..
"] {" ..
- parms.baseLabelText[currPeak.base] ..
+ self.baseLabelText[currPeak.base] ..
"}"
)
end
- if parms.showBaseNumbers
- and currPeak.baseIndex >= parms.baseNumberMin
- and currPeak.baseIndex <= parms.baseNumberMax
- and (currPeak.baseIndex - parms.baseNumberMin)
- % parms.baseNumberStep == 0 then
+ if self.showBaseNumbers
+ and currPeak.baseIndex >= self.baseNumberMin
+ and currPeak.baseIndex <= self.baseNumberMax
+ and (currPeak.baseIndex - self.baseNumberMin)
+ % self.baseNumberStep == 0 then
tex.sprint(
- " node[" .. PGFKEYS_PATH .. "base number style@style] {\\strut " ..
+ " node [" ..
+ PGFKEYS_PATH ..
+ "base number style] {\\strut " ..
currPeak.baseIndex ..
"}"
)
end
- tex.sprint(";\n")
+ tex.sprint(";")
if probRemainder then
tex.sprint(probRemainder)
probRemainder = false
end
- local drawCurrProb = string.find(
- string.upper(parms.probabilitiesDrawn),
- currPeak.base
- )
- local xLeft = lastProbX - 1 - currLine * parms.samplesPerLine
+ local drawCurrProb =
+ self.probabilitiesDrawn:upper():find(currPeak.base)
+ local xLeft = lastProbX - 1 - currLine * self.samplesPerLine
if xLeft < 0 then
- local xLeftPrev = (parms.samplesPerLine + xLeft) * parms.xUnit
- local xRightPrev = (parms.samplesPerLine - 1) * parms.xUnit
- local yPrev = -(currLine-1) * parms.baselineSkip - parms.probDistance
+ local xLeftPrev = (self.samplesPerLine + xLeft) * self.xUnit
+ local xRightPrev = (self.samplesPerLine - 1) * self.xUnit
+ local yPrev = -(currLine-1) * self.baselineSkip - self.probDistance
if drawCurrProb then
tex.sprint(
- "\\draw[" ..
- parms.probStyle(currPeak.prob[currPeak.base]) ..
- " ] (" ..
- number.todimen(xLeftPrev, parms.coordUnit, parms.coordFmtStr) ..
+ "\n\t\\draw [" ..
+ self.probStyle(currPeak.prob[currPeak.base]) ..
+ "] (" ..
+ dimToString(xLeftPrev) ..
", " ..
- number.todimen(yPrev, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(yPrev) ..
") -- (" ..
- number.todimen(xRightPrev, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(xRightPrev) ..
", " ..
- number.todimen(yPrev, parms.coordUnit, parms.coordFmtStr) ..
- ");\n"
+ dimToString(yPrev) ..
+ ");"
)
end
xLeft = 0
else
- xLeft = xLeft * parms.xUnit
+ xLeft = xLeft * self.xUnit
end
- local xRight = currPeak.probXRight - 1 - currLine * parms.samplesPerLine
- if xRight >= parms.samplesPerLine then
+ local xRight = currPeak.probXRight - 1 - currLine * self.samplesPerLine
+ if xRight >= self.samplesPerLine then
if drawCurrProb then
- local xRightNext = (xRight - parms.samplesPerLine) * parms.xUnit
- local yNext = -(currLine+1) * parms.baselineSkip - parms.probDistance
+ local xRightNext = (xRight - self.samplesPerLine) * self.xUnit
+ local yNext = -(currLine+1) * self.baselineSkip - self.probDistance
probRemainder =
- "\\draw[" ..
- parms.probStyle(currPeak.prob[currPeak.base]) ..
- " ] (" ..
- number.todimen(0, parms.coordUnit, parms.coordFmtStr) ..
+ "\n\t\\draw [" ..
+ self.probStyle(currPeak.prob[currPeak.base]) ..
+ "] (" ..
+ dimToString(0) ..
", " ..
- number.todimen(yNext, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(yNext) ..
") -- (" ..
- number.todimen(xRightNext, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(xRightNext) ..
", " ..
- number.todimen(yNext, parms.coordUnit, parms.coordFmtStr) ..
- ");\n"
+ dimToString(yNext) ..
+ ");"
end
- xRight = (parms.samplesPerLine - 1) * parms.xUnit
+ xRight = (self.samplesPerLine - 1) * self.xUnit
else
- xRight = xRight * parms.xUnit
+ xRight = xRight * self.xUnit
end
- local y = -currLine * parms.baselineSkip - parms.probDistance
+ local y = -currLine * self.baselineSkip - self.probDistance
if drawCurrProb then
tex.sprint(
- "\\draw[" ..
- parms.probStyle(currPeak.prob[currPeak.base]) ..
- " ] (" ..
- number.todimen(xLeft, parms.coordUnit, parms.coordFmtStr) ..
+ "\n\t\\draw [" ..
+ self.probStyle(currPeak.prob[currPeak.base]) ..
+ "] (" ..
+ dimToString(xLeft) ..
", " ..
- number.todimen(y, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(y) ..
") -- (" ..
- number.todimen(xRight, parms.coordUnit, parms.coordFmtStr) ..
+ dimToString(xRight) ..
", " ..
- number.todimen(y, parms.coordUnit, parms.coordFmtStr) ..
- ");\n"
+ dimToString(y) ..
+ ");"
)
end
lastProbX = currPeak.probXRight