texlive[71551] Master/texmf-dist: pgfmolbio (17jun24)
commits+karl at tug.org
commits+karl at tug.org
Mon Jun 17 22:11:59 CEST 2024
Revision: 71551
https://tug.org/svn/texlive?view=revision&revision=71551
Author: karl
Date: 2024-06-17 22:11:59 +0200 (Mon, 17 Jun 2024)
Log Message:
-----------
pgfmolbio (17jun24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/README
trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.lua
trunk/Master/texmf-dist/source/lualatex/pgfmolbio/pgfmolbio.dtx
trunk/Master/texmf-dist/source/lualatex/pgfmolbio/pgfmolbio.ins
trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.tex
trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.convert.tex
trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.domains.tex
trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.sty
Added Paths:
-----------
trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/pgfmolbio-doc.pdf
trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.chromatogram.lua
trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.domains.lua
Removed Paths:
-------------
trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/pgfmolbio.pdf
trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua
trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.domains.lua
Modified: trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/README
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/README 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/README 2024-06-17 20:11:59 UTC (rev 71551)
@@ -1,18 +1,21 @@
-The pgfmolbio package v0.21
+The pgfmolbio package v0.21a
------------------------------------------------------------------------------
This package is released under the LaTeX Project Public License v1.3c or later
-(see http://www.latex-project.org/lppl.txt).
+(see https://www.latex-project.org/lppl.txt).
-The experimental package pgfmolbio draws graphs typically found in
+The package pgfmolbio draws graphs typically found in
molecular biology texts. Currently, the package contains modules
for drawing DNA sequencing chromatograms and protein domain diagrams.
-The package requires pgf/TikZ (http://tug.ctan.org/pkg/pgf)
-and LuaTeX (http://www.luatex.org).
+The package requires pgf/TikZ (https://ctan.org/pkg/pgf)
+and LuaTeX (https://www.luatex.org).
Installation: Run pgfmolbio.ins through LaTeX and follow the instructions.
+This package is unmaintained. If you want to volunteer to take over
+the maintenance, contact me at https://wolfgang.esser-skala.at/contact/ .
+
--
-Wolfgang Skala
-August 1st, 2013
+Wolfgang Esser-Skala
+2024-06-17
Added: trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/pgfmolbio-doc.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/pgfmolbio-doc.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/pgfmolbio-doc.pdf 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/pgfmolbio-doc.pdf 2024-06-17 20:11:59 UTC (rev 71551)
Property changes on: trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/pgfmolbio-doc.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Deleted: trunk/Master/texmf-dist/doc/lualatex/pgfmolbio/pgfmolbio.pdf
===================================================================
(Binary files differ)
Added: trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.chromatogram.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.chromatogram.lua (rev 0)
+++ trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.chromatogram.lua 2024-06-17 20:11:59 UTC (rev 71551)
@@ -0,0 +1,562 @@
+--
+-- This is file `pgfmolbio.chromatogram.lua',
+-- generated with the docstrip utility.
+--
+-- The original source files were:
+--
+-- pgfmolbio.dtx (with options: `pmb-chr-lua')
+--
+-- Copyright (C) 2024 by Wolfgang Esser-Skala
+--
+-- This work may be distributed and/or modified under the
+-- conditions of the LaTeX Project Public License, either version 1.3c
+-- of this license or (at your option) any later version.
+-- The latest version of this license is in
+-- https://www.latex-project.org/lppl.txt
+-- and version 1.3c or later is part of all distributions of LaTeX
+-- version 2008/05/04 or later.
+--
+module("pgfmolbio.chromatogram", package.seeall)
+
+
+if luatexbase then
+ luatexbase.provides_module{
+ name = "pgfmolbio.chromatogram",
+ version = "0.21a",
+ date = "2014/06/17",
+ description = "DNA sequencing chromatograms",
+ author = "Wolfgang Esser-Skala",
+ copyright = "Wolfgang Esser-Skala",
+ license = "LPPL",
+ }
+end
+
+local ALL_BASES = {"A", "C", "G", "T"}
+local PGFKEYS_PATH = "/pgfmolbio/chromatogram/"
+
+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 color = ""
+ if prob >= 0 and prob < 10 then
+ color = "black"
+ elseif prob >= 10 and prob < 20 then
+ color = "pmbTraceRed"
+ elseif prob >= 20 and prob < 30 then
+ color = "pmbTraceYellow"
+ else
+ color = "pmbTraceGreen"
+ end
+ return "ultra thick, " .. color
+end
+
+local function findBasesInStr(target)
+ if not target then return end
+ local result = {}
+ for _, v in ipairs(ALL_BASES) do
+ if target:upper():find(v) then
+ table.insert(result, v)
+ end
+ end
+ return result
+end
+
+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(self.selectedPeaks) do
+ for __, currProb in pairs(currPeak.prob) do
+ if currProb > maxProb then maxProb = currProb end
+ if currProb < minProb then minProb = currProb end
+ end
+ end
+ return minProb, maxProb
+end
+
+function Chromatogram:getSampleAndPeakIndex(baseIndex, isLowerLimit)
+ local sampleId, peakId
+
+ 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 sampleId, peakId
+end
+
+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, 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
+ end
+ 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, self.header.basesNumber do
+ self.peaks[i].prob.A = readInt(scfFile, 1)
+ end
+
+ for i = 1, self.header.basesNumber do
+ self.peaks[i].prob.C = readInt(scfFile, 1)
+ end
+
+ for i = 1, self.header.basesNumber do
+ self.peaks[i].prob.G = readInt(scfFile, 1)
+ end
+
+ for i = 1, self.header.basesNumber do
+ self.peaks[i].prob.T = readInt(scfFile, 1)
+ end
+
+ for i = 1, self.header.basesNumber do
+ self.peaks[i].base = string.char(readInt(scfFile, 1))
+ end
+
+ scfFile:close()
+ end
+end
+
+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 Chromatogram:printTikzChromatogram()
+ if pgfmolbio.errorCatched then return end
+ self.selectedPeaks = {}
+ local tIndex = 1
+ 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 = self.sampleMax + 1 - self.sampleMin
+ }
+ if tIndex > 1 then
+ 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 self.baseNumberMin == -1 then
+ self.baseNumberMin = self.selectedPeaks[1].baseIndex
+ end
+ if self.baseNumberMax == -1 then
+ self.baseNumberMax = self.selectedPeaks[tIndex-1].baseIndex
+ end
+ end
+
+ local samplesLeft = self.sampleMax - self.sampleMin + 1
+ local currLine = 0
+ while samplesLeft > 0 do
+ local yLower = -currLine * self.baselineSkip
+ local yUpper = -currLine * self.baselineSkip + self.canvasHeight
+ local xRight =
+ (math.min(self.samplesPerLine, samplesLeft) - 1) * self.xUnit
+ tex.sprint(
+ "\n\t\\draw [" .. PGFKEYS_PATH .. "canvas style] (" ..
+ dimToString(0) ..
+ ", " ..
+ dimToString(yLower) ..
+ ") rectangle (" ..
+ dimToString(xRight) ..
+ ", " ..
+ dimToString(yUpper) ..
+ ");"
+ )
+ samplesLeft = samplesLeft - self.samplesPerLine
+ currLine = currLine + 1
+ end
+
+ 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 <= 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
+ firstPointInLine = false
+ end
+ tex.sprint(
+ "(" ..
+ dimToString(x) ..
+ ", " ..
+ dimToString(y) ..
+ ")"
+ )
+ end
+ if sampleX ~= self.sampleMax + 1 - self.sampleMin then
+ if sampleX >= (currLine + 1) * self.samplesPerLine then
+ currLine = currLine + 1
+ tex.sprint(";\n\t\\draw [" .. self.traceStyle[baseName] .. "] ")
+ firstPointInLine = true
+ end
+ else
+ tex.sprint(";")
+ end
+ sampleX = sampleX + 1
+ currSampleIndex = currSampleIndex + 1
+ end
+ end
+
+ local currLine = 0
+ local lastProbX = 1
+ local probRemainder = false
+
+ for _, currPeak in ipairs(self.selectedPeaks) do
+ while currPeak.offset > (currLine + 1) * self.samplesPerLine do
+ currLine = currLine + 1
+ end
+
+ local x = ((currPeak.offset - 1) % self.samplesPerLine) * self.xUnit
+ local yUpper = -currLine * self.baselineSkip
+ local yLower = -currLine * self.baselineSkip - self.tickLength
+ local tickOperation = ""
+ if self.ticksDrawn:upper():find(currPeak.base) then
+ tickOperation = "--"
+ end
+
+ tex.sprint(
+ "\n\t\\draw [" ..
+ self.tickStyle[currPeak.base] ..
+ "] (" ..
+ dimToString(x) ..
+ ", " ..
+ dimToString(yUpper) ..
+ ") " ..
+ tickOperation ..
+ " (" ..
+ dimToString(x) ..
+ ", " ..
+ dimToString(yLower) ..
+ ")"
+ )
+ if self.baseLabelsDrawn:upper():find(currPeak.base) then
+ tex.sprint(
+ " node [" ..
+ self.baseLabelStyle[currPeak.base] ..
+ "] {" ..
+ self.baseLabelText[currPeak.base] ..
+ "}"
+ )
+ end
+
+ 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] {\\strut " ..
+ currPeak.baseIndex ..
+ "}"
+ )
+ end
+ tex.sprint(";")
+
+ if probRemainder then
+ tex.sprint(probRemainder)
+ probRemainder = false
+ end
+ local drawCurrProb =
+ self.probabilitiesDrawn:upper():find(currPeak.base)
+ local xLeft = lastProbX - 1 - currLine * self.samplesPerLine
+ if xLeft < 0 then
+ 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(
+ "\n\t\\draw [" ..
+ self.probStyle(currPeak.prob[currPeak.base]) ..
+ "] (" ..
+ dimToString(xLeftPrev) ..
+ ", " ..
+ dimToString(yPrev) ..
+ ") -- (" ..
+ dimToString(xRightPrev) ..
+ ", " ..
+ dimToString(yPrev) ..
+ ");"
+ )
+ end
+ xLeft = 0
+ else
+ xLeft = xLeft * self.xUnit
+ end
+
+ local xRight = currPeak.probXRight - 1 - currLine * self.samplesPerLine
+ if xRight >= self.samplesPerLine then
+ if drawCurrProb then
+ local xRightNext = (xRight - self.samplesPerLine) * self.xUnit
+ local yNext = -(currLine+1) * self.baselineSkip - self.probDistance
+ probRemainder =
+ "\n\t\\draw [" ..
+ self.probStyle(currPeak.prob[currPeak.base]) ..
+ "] (" ..
+ dimToString(0) ..
+ ", " ..
+ dimToString(yNext) ..
+ ") -- (" ..
+ dimToString(xRightNext) ..
+ ", " ..
+ dimToString(yNext) ..
+ ");"
+ end
+ xRight = (self.samplesPerLine - 1) * self.xUnit
+ else
+ xRight = xRight * self.xUnit
+ end
+
+ local y = -currLine * self.baselineSkip - self.probDistance
+ if drawCurrProb then
+ tex.sprint(
+ "\n\t\\draw [" ..
+ self.probStyle(currPeak.prob[currPeak.base]) ..
+ "] (" ..
+ dimToString(xLeft) ..
+ ", " ..
+ dimToString(y) ..
+ ") -- (" ..
+ dimToString(xRight) ..
+ ", " ..
+ dimToString(y) ..
+ ");"
+ )
+ end
+ lastProbX = currPeak.probXRight
+ end
+end
+--
+-- End of file `pgfmolbio.chromatogram.lua'.
Property changes on: trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.chromatogram.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.domains.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.domains.lua (rev 0)
+++ trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.domains.lua 2024-06-17 20:11:59 UTC (rev 71551)
@@ -0,0 +1,810 @@
+--
+-- This is file `pgfmolbio.domains.lua',
+-- generated with the docstrip utility.
+--
+-- The original source files were:
+--
+-- pgfmolbio.dtx (with options: `pmb-dom-lua')
+--
+-- Copyright (C) 2024 by Wolfgang Esser-Skala
+--
+-- This work may be distributed and/or modified under the
+-- conditions of the LaTeX Project Public License, either version 1.3c
+-- of this license or (at your option) any later version.
+-- The latest version of this license is in
+-- https://www.latex-project.org/lppl.txt
+-- and version 1.3c or later is part of all distributions of LaTeX
+-- version 2008/05/04 or later.
+--
+module("pgfmolbio.domains", package.seeall)
+
+
+if luatexbase then
+ luatexbase.provides_module({
+ name = "pgfmolbio.domains",
+ version = "0.21a",
+ date = "2014/06/17",
+ description = "Domain graphs",
+ author = "Wolfgang Esser-Skala",
+ copyright = "Wolfgang Esser-Skala",
+ license = "LPPL",
+ })
+end
+
+local stringToDim = pgfmolbio.stringToDim
+local dimToString = pgfmolbio.dimToString
+local packageError = pgfmolbio.packageError
+local packageWarning = pgfmolbio.packageWarning
+local getRange = pgfmolbio.getRange
+
+function printSequenceFeature(feature, xLeft, xRight, yMid, xUnit, yUnit)
+ xLeft = xLeft + 0.5
+ for currResidue in feature.sequence:gmatch(".") do
+ tex.sprint("\n\t\t\\def\\xMid{" .. dimToString(xLeft * xUnit) .. "}")
+ tex.sprint("\n\t\t\\def\\yMid{" .. dimToString(yMid * yUnit) .. "}")
+ tex.sprint("\n\t\t\\def\\currentResidue{" .. currResidue .. "}")
+ tex.sprint("\n\t\t\\pmbdomdrawfeature{other/sequence}")
+ xLeft = xLeft + 1
+ end
+end
+
+function printHelixFeature(feature, xLeft, xRight, yMid, xUnit, yUnit)
+ local residuesLeft, currX
+ tex.sprint("\n\t\t\\pgfmolbioset[domains]{current style}")
+
+ residuesLeft = feature.stop - feature.start + 1
+ currX = xLeft
+ tex.sprint("\n\t\t\\def\\xLeft{" .. dimToString(currX * xUnit) .. "}")
+ tex.sprint("\n\t\t\\def\\yMid{" .. dimToString(yMid * yUnit) .. "}")
+ tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/half upper back}")
+ residuesLeft = residuesLeft - 2
+ currX = currX + 2.5
+
+ while residuesLeft > 0 do
+ if residuesLeft == 1 then
+ tex.sprint(
+ "\n\t\t\\def\\xRight{" ..
+ dimToString((currX + 0.5) * xUnit) ..
+ "}"
+ )
+ tex.sprint("\n\t\t\\def\\yMid{" .. dimToString(yMid * yUnit) .. "}")
+ tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/half lower back}")
+ else
+ tex.sprint("\n\t\t\\def\\xMid{" .. dimToString(currX * xUnit) .. "}")
+ tex.sprint(
+ "\n\t\t\\def\\yLower{" ..
+ dimToString(yMid * yUnit - 1.5 * xUnit) ..
+ "}"
+ )
+ tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/full back}")
+ end
+ residuesLeft = residuesLeft - 2
+ currX = currX + 2
+ end
+
+ residuesLeft = feature.stop - feature.start
+ currX = xLeft + 1.5
+ while residuesLeft > 0 do
+ if residuesLeft == 1 then
+ tex.sprint(
+ "\n\t\t\\def\\xRight{" ..
+ dimToString((currX + 0.5) * xUnit) ..
+ "}"
+ )
+ tex.sprint("\n\t\t\\def\\yMid{" .. dimToString(yMid * yUnit) .. "}")
+ tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/half upper front}")
+ else
+ tex.sprint("\n\t\t\\def\\xMid{" .. dimToString(currX * xUnit) .. "}")
+ tex.sprint(
+ "\n\t\t\\def\\yLower{" ..
+ dimToString(yMid * yUnit - 1.5 * xUnit) ..
+ "}"
+ )
+ tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/full front}")
+ end
+ residuesLeft = residuesLeft - 2
+ currX = currX + 2
+ end
+end
+
+SpecialKeys = {}
+
+function SpecialKeys:new(parms)
+ parms = parms or {}
+ local newSpecialKeys = {
+ disulfideKeys = {},
+ featureStyles = {},
+ printFunctions = {}
+ }
+
+ for keyList, listContents in pairs(parms) do
+ for key, value in pairs(listContents) do
+ newSpecialKeys[keyList][key] = value
+ end
+ end
+
+ setmetatable(newSpecialKeys, self)
+ self.__index = self
+ return newSpecialKeys
+end
+
+function SpecialKeys:setKeys(keylist, keys, value)
+ for key in keys:gmatch("([^,]+)") do
+ key = key:trim()
+ self[keylist][key] = value
+ end
+end
+
+function SpecialKeys:setFeatureStyle(key, style)
+ local newStyleList, styleCycles, styleContents
+
+ newStyleList = {}
+ while style ~= "" do
+ styleCycles = 1
+ if style:sub(1,1) == "{" then
+ styleContents = style:match("%b{}")
+ style = style:match("%b{}(.*)")
+ elseif style:sub(1,1) == "*" then
+ styleCycles, styleContents = style:match("%*(%d*)(%b{})")
+ if styleCycles == "" then styleCycles = 1 end
+ style = style:match("%*%d*%b{}(.*)")
+ elseif style:sub(1,1) == "," or style:sub(1,1) == " " then
+ style = style:match("[,%s]+(.*)")
+ styleCycles, styleContents = nil, nil
+ else
+ styleContents = style:match("([^,]+),")
+ if not styleContents then
+ styleContents = style
+ style = ""
+ else
+ style = style:match("[^,]+,(.*)")
+ end
+ end
+ if styleCycles then
+ table.insert(
+ newStyleList,
+ {cycles = styleCycles, style = styleContents}
+ )
+ end
+ end
+ self.featureStyles[key] = newStyleList
+end
+
+function SpecialKeys:aliasFeatureStyle(newKey, oldKey)
+ self.featureStyles[newKey] = {alias = oldKey}
+end
+
+function SpecialKeys:getBaseKey(key)
+ if self.featureStyles[key] then
+ if self.featureStyles[key].alias then
+ return self.featureStyles[key].alias
+ end
+ end
+ return key
+end
+
+function SpecialKeys:clearKeys(keylist)
+ self[keylist] = {}
+end
+
+function SpecialKeys:selectStyleFromList(key, styleID)
+ local styleList
+
+ if not self.featureStyles[key] then
+ packageWarning(
+ "Feature style `" ..
+ key ..
+ "' unknown, using `default'."
+ )
+ styleList = self.featureStyles.default
+ elseif self.featureStyles[key].alias then
+ styleList = self.featureStyles[self.featureStyles[key].alias]
+ else
+ styleList = self.featureStyles[key]
+ end
+
+ while true do
+ for _, v in ipairs(styleList) do
+ styleID = styleID - v.cycles
+ if styleID < 1 then
+ return v.style
+ end
+ end
+ end
+end
+
+Protein = {}
+
+function Protein:new()
+ local newProtein = {
+ name = "",
+ sequenceLength = -1,
+ ft = {},
+ sequence = "",
+ xUnit = stringToDim("0.5mm"),
+ yUnit = stringToDim("6mm"),
+ residuesPerLine = 250,
+ residueRangeMin = 1,
+ residueRangeMax = 100,
+ residueNumbering = {},
+ revResidueNumbering = {},
+ baselineSkip = 3,
+ rulerRange = {},
+ defaultRulerStepSize = 50,
+ showRuler = true,
+ currentStyle = {},
+ specialKeys = SpecialKeys:new()
+ }
+ setmetatable(newProtein, self)
+ self.__index = self
+ return newProtein
+end
+
+function Protein:toAbsoluteResidueNumber(value)
+ local result = value:match("%b()")
+ if result then
+ result = tonumber(result:sub(2, -2))
+ else
+ result = self.revResidueNumbering[(value:gsub("[<>%?]", ""))]
+ end
+ if not result then
+ packageError("Bad or missing start/end point value: " .. value)
+ end
+ return result
+end
+
+function Protein:readUniprotFile(filename)
+ local uniprotFile, errorMsg = io.open(filename, "r")
+ if not uniprotFile then packageError(errorMsg) end
+
+ local sequence = {}
+ local inSequence = false
+ local featureTable = {}
+
+ for currLine in uniprotFile:lines() do
+ local lineCode = currLine:sub(1, 2)
+ local lineContents = currLine:sub(3)
+ if lineCode == "ID" then
+ local name, sequenceLength =
+ lineContents:match("%s*(%S+)%s*%a+;%s*(%d+)%s*AA%.")
+ self.name = name
+ self.sequenceLength = tonumber(sequenceLength)
+ self.residueRangeMax = self.sequenceLength
+ elseif lineCode == "FT" then
+ local key = currLine:sub(6, 13):trim()
+ local start, stop, description =
+ currLine:sub(15, 20), currLine:sub(22, 27), currLine:sub(35, 75)
+ if key ~= "" then
+ table.insert(featureTable, {
+ key = key,
+ start = "(" .. start .. ")",
+ stop = "(" .. stop .. ")",
+ description = description,
+ style = "",
+ kvList = ""
+ })
+ else
+ featureTable[#featureTable].description =
+ featureTable[#featureTable].description .. description
+ end
+ elseif lineCode == "SQ" then
+ inSequence = true
+ elseif lineCode == " " and inSequence then
+ table.insert(sequence, (lineContents:gsub("%s+", "")))
+ elseif lineCode == "\\\\" then
+ break
+ end
+ end
+ uniprotFile:close()
+ if next(sequence) then self.sequence = table.concat(sequence) end
+ for _, v in ipairs(featureTable) do self:addFeature(v) end
+end
+
+function Protein:readGffFile(filename)
+ local gffFile, errorMsg = io.open(filename, "r")
+ local lineContents, fields, lineNumber
+
+ if not gffFile then packageError(errorMsg) end
+ lineNumber = 1
+ for currLine in gffFile:lines() do
+ lineContents = currLine:gsub("#.*$", "")
+ fields = {}
+ if lineContents ~= "" then
+ for currField in lineContents:gmatch("([^\t]+)") do
+ table.insert(fields, currField)
+ end
+ if not fields[5] then
+ packageError("Bad line (" .. lineNumber .. ") in gff file '" ..
+ filename .. "':\n" .. currLine)
+ break
+ end
+ self:addFeature{
+ key = fields[3],
+ start = "(" .. fields[4] .. ")",
+ stop = "(" .. fields[5] .. ")",
+ description = fields[9] or "",
+ style = "",
+ kvList = ""
+ }
+ end
+ lineNumber = lineNumber + 1
+ end
+ gffFile:close()
+end
+
+function Protein:getParameters()
+ tex.sprint(
+ "\\pgfmolbioset[domains]{name={" ..
+ self.name ..
+ "},sequence={" ..
+ self.sequence ..
+ "},sequence length=" ..
+ self.sequenceLength ..
+ "}"
+ )
+end
+
+function Protein:setParameters(newParms)
+ local keyHash = {
+ sequenceLength = function(v)
+ v = tonumber(v)
+ if not v then return self.sequenceLength end
+ if v < 1 then
+ packageError("Sequence length must be larger than zero.")
+ end
+ return v
+ end,
+ residueNumbering = function(v)
+ local ranges = {}
+ local start, startNumber, startLetter, stop
+ self.revResidueNumbering = {}
+ if v:trim() == "auto" then
+ for i = 1, self.sequenceLength do
+ table.insert(ranges, tostring(i))
+ end
+ else --example list: `1-4,5,6A-D'
+ for _, value in ipairs(v:explode(",+")) do
+ value = value:trim()
+ start, stop = value:match("(%w*)%s*%-%s*(%w*)$")
+ if not start then
+ start = value:match("(%w*)")
+ end
+ if not start or start == "" then --invalid range
+ packageError("Unknown residue numbering range: " .. value)
+ end
+ if stop then
+ if tonumber(start) and tonumber(stop) then
+ --process range `1-4'
+ for currNumber = tonumber(start), tonumber(stop) do
+ table.insert(ranges, tostring(currNumber))
+ end
+ else --process range `6A-D'
+ startNumber, startLetter = start:match("(%d*)(%a)")
+ stop = stop:match("(%a)")
+ for currLetter = startLetter:byte(), stop:byte() do
+ table.insert(ranges,
+ startNumber .. string.char(currLetter))
+ end
+ end
+ else --process range `5'
+ table.insert(ranges, start)
+ end
+ end
+ end
+ for i, value in ipairs(ranges) do
+ if self.revResidueNumbering[value] then
+ packageError("The range value " .. value ..
+ " appears more than once.")
+ else
+ self.revResidueNumbering[value] = i
+ end
+ end
+ return ranges
+ end,
+ residueRange = function(v)
+ local num
+ local residueRangeMin, residueRangeMax =
+ getRange(v:trim(), "^([%w%(%)]+)%s*%-", "%-%s*([%w%(%)]+)$")
+ if residueRangeMin == "auto" then
+ self.residueRangeMin = 1
+ else
+ num = residueRangeMin:match("%b()")
+ if num then
+ self.residueRangeMin = tonumber(num:sub(2, -2))
+ elseif self.revResidueNumbering[residueRangeMin] then
+ self.residueRangeMin = self.revResidueNumbering[residueRangeMin]
+ else
+ packageError("Invalid residue range: " .. residueRangeMin)
+ end
+ end
+
+ if residueRangeMax == "auto" then
+ self.residueRangeMax = self.sequenceLength
+ else
+ num = residueRangeMax:match("%b()")
+ if num then
+ self.residueRangeMax = tonumber(num:sub(2, -2))
+ elseif self.revResidueNumbering[residueRangeMax] then
+ self.residueRangeMax = self.revResidueNumbering[residueRangeMax]
+ else
+ packageError("Invalid residue range: " .. residueRangeMax)
+ end
+ end
+
+ if self.residueRangeMin >= self.residueRangeMax then
+ packageError("Residue range is smaller than 1.")
+ end
+ end,
+ defaultRulerStepSize = tonumber,
+ name = tostring,
+ sequence = tostring,
+ xUnit = stringToDim,
+ yUnit = stringToDim,
+ residuesPerLine = tonumber,
+ baselineSkip = tonumber,
+ rulerRange = function(v)
+ local num
+ local ranges = {}
+ local rulerRangeMin, rulerRangeMax, rulerRangeStep
+ for _, value in ipairs(v:explode(",+")) do
+ rulerRangeMin, rulerRangeMax, rulerRangeStep =
+ getRange(value:trim(), "^([%w%(%)]+)",
+ "%-%s*([%w%(%)]+)", "step%s*(%d+)$")
+
+ if rulerRangeMin == "auto" then
+ rulerRangeMin = self.residueRangeMin
+ else
+ num = rulerRangeMin:match("%b()")
+ if num then
+ rulerRangeMin = tonumber(num:sub(2, -2))
+ elseif self.revResidueNumbering[rulerRangeMin] then
+ rulerRangeMin = self.revResidueNumbering[rulerRangeMin]
+ else
+ packageError("Invalid lower ruler range: " .. rulerRangeMin)
+ end
+ end
+
+ if rulerRangeMax then
+ if rulerRangeMax == "auto" then
+ rulerRangeMax = self.residueRangeMax
+ else
+ num = rulerRangeMax:match("%b()")
+ if num then
+ rulerRangeMax = tonumber(num:sub(2, -2))
+ elseif self.revResidueNumbering[rulerRangeMax] then
+ rulerRangeMax = self.revResidueNumbering[rulerRangeMax]
+ else
+ packageError("Invalid upper ruler range: " .. rulerRangeMax)
+ end
+ end
+
+ if rulerRangeMin >= rulerRangeMax then
+ packageError("Ruler range is smaller than 1.")
+ end
+ if rulerRangeMin < self.residueRangeMin then
+ rulerRangeMin = self.residueRangeMin
+ packageWarning(
+ "Lower ruler range is smaller than" ..
+ "lower residue range. It was adjusted to " ..
+ rulerRangeMin .. "."
+ )
+ end
+ if rulerRangeMax > self.residueRangeMax then
+ rulerRangeMax = self.residueRangeMax
+ packageWarning(
+ "Upper ruler range exceeds" ..
+ "upper residue range. It was adjusted to " ..
+ rulerRangeMax .. "."
+ )
+ end
+ else
+ rulerRangeMax = rulerRangeMin
+ end
+ rulerRangeStep = tonumber(rulerRangeStep)
+ or self.defaultRulerStepSize
+
+ for i = rulerRangeMin, rulerRangeMax, rulerRangeStep do
+ table.insert(
+ ranges,
+ {pos = i, number = self.residueNumbering[i]}
+ )
+ end
+ end
+ return ranges
+ end,
+ showRuler = function(v)
+ if v == "true" then return true else return false end
+ end
+ }
+ for key, value in pairs(newParms) do
+ if keyHash[key] then
+ self[key] = keyHash[key](value)
+ if pgfmolbio.errorCatched then return end
+ end
+ end
+end
+
+function Protein:addFeature(newFeature)
+ local baseKey, ftEntry
+
+ baseKey = self.specialKeys:getBaseKey(newFeature.key)
+ if self.currentStyle[baseKey] then
+ self.currentStyle[baseKey] = self.currentStyle[baseKey] + 1
+ else
+ self.currentStyle[baseKey] = 1
+ end
+
+ ftEntry = {
+ key = newFeature.key,
+ start = self:toAbsoluteResidueNumber(newFeature.start),
+ stop = self:toAbsoluteResidueNumber(newFeature.stop),
+ kvList = "style={" ..
+ self.specialKeys:selectStyleFromList(baseKey,
+ self.currentStyle[baseKey]) .. "}",
+ level = newFeature.level or nil
+ }
+ if newFeature.kvList ~= "" then
+ ftEntry.kvList = ftEntry.kvList .. "," .. newFeature.kvList
+ end
+ if newFeature.description then
+ ftEntry.kvList = ftEntry.kvList ..
+ ",description={" .. newFeature.description .. "}"
+ ftEntry.description = newFeature.description
+ end
+ table.insert(self.ft, newFeature.layer or #self.ft + 1, ftEntry)
+end
+
+function Protein:calculateDisulfideLevels()
+ if pgfmolbio.errorCatched then return end
+ local disulfideGrid, currLevel, levelFree
+ disulfideGrid = {}
+
+ for i, v in ipairs(self.ft) do
+ if self.specialKeys.disulfideKeys[v.key] then
+ if v.level then
+ if not disulfideGrid[v.level] then
+ disulfideGrid[v.level] = {}
+ end
+ for currPos = v.start, v.stop do
+ disulfideGrid[v.level][currPos] = true
+ end
+ else
+ currLevel = 1
+ repeat
+ levelFree = true
+ if disulfideGrid[currLevel] then
+ for currPos = v.start, v.stop do
+ levelFree = levelFree
+ and not disulfideGrid[currLevel][currPos]
+ end
+ if levelFree then
+ self.ft[i].level = currLevel
+ for currPos = v.start, v.stop do
+ disulfideGrid[currLevel][currPos] = true
+ end
+ end
+ else
+ self.ft[i].level = currLevel
+ disulfideGrid[currLevel] = {}
+ for currPos = v.start, v.stop do
+ disulfideGrid[currLevel][currPos] = true
+ end
+ levelFree = true
+ end
+ currLevel = currLevel + 1
+ until levelFree == true
+ end
+ end
+ end
+end
+
+function Protein:printTikzDomains()
+ if pgfmolbio.errorCatched then return end
+ local xLeft, xMid, xRight, yMid, xLeftClip, xRightClip,
+ currLine, residuesLeft, currStyle
+
+ for _, currFeature in ipairs(self.ft) do
+ currLine = 0
+ xLeft = currFeature.start - self.residueRangeMin -
+ currLine * self.residuesPerLine + 1
+ while xLeft > self.residuesPerLine do
+ xLeft = xLeft - self.residuesPerLine
+ currLine = currLine + 1
+ end
+ xLeft = xLeft - 1
+ xRight = currFeature.stop - self.residueRangeMin -
+ currLine * self.residuesPerLine + 1
+ residuesLeft = self.residueRangeMax - self.residueRangeMin -
+ currLine * self.residuesPerLine + 1
+ xLeftClip = stringToDim("-5cm")
+ xRightClip = self.residuesPerLine * self.xUnit
+
+ if currFeature.start <= self.residueRangeMax
+ and currFeature.stop >= self.residueRangeMin then
+ repeat
+ if residuesLeft <= self.residuesPerLine then
+ if residuesLeft < xRight then
+ xRightClip = residuesLeft * self.xUnit
+ else
+ xRightClip = xRight * self.xUnit + stringToDim("5cm")
+ end
+ else
+ if xRight <= self.residuesPerLine then
+ xRightClip = xRight * self.xUnit + stringToDim("5cm")
+ end
+ end
+ if xLeft < 0 then xLeftClip = stringToDim("0cm") end
+
+ xMid = (xLeft + xRight) / 2
+ yMid = -currLine * self.baselineSkip
+ if currFeature.level then
+ currFeature.kvList = currFeature.kvList ..
+ ",level=" .. currFeature.level
+ end
+ currFeature.sequence =
+ self.sequence:sub(currFeature.start, currFeature.stop)
+
+ tex.sprint("\n\t\\begin{scope}\\begin{pgfinterruptboundingbox}")
+ tex.sprint("\n\t\t\\def\\xLeft{" ..
+ dimToString(xLeft * self.xUnit) .. "}")
+ tex.sprint("\n\t\t\\def\\xMid{" ..
+ dimToString(xMid * self.xUnit) .. "}")
+ tex.sprint("\n\t\t\\def\\xRight{" ..
+ dimToString(xRight * self.xUnit) .. "}")
+ tex.sprint("\n\t\t\\def\\yMid{" ..
+ dimToString(yMid * self.yUnit) .. "}")
+ tex.sprint("\n\t\t\\def\\featureSequence{" ..
+ currFeature.sequence .. "}")
+ tex.sprint(
+ "\n\t\t\\clip (" ..
+ dimToString(xLeftClip) ..
+ ", \\yMid + " ..
+ dimToString(stringToDim("10cm")) ..
+ ") rectangle (" ..
+ dimToString(xRightClip) ..
+ ", \\yMid - " ..
+ dimToString(stringToDim("10cm")) ..
+ ");"
+ )
+ tex.sprint(
+ "\n\t\t\\pgfmolbioset[domains]{" ..
+ currFeature.kvList ..
+ "}"
+ )
+ if self.specialKeys.printFunctions[currFeature.key] then
+ self.specialKeys.printFunctions[currFeature.key](
+ currFeature, xLeft, xRight, yMid, self.xUnit, self.yUnit)
+ else
+ tex.sprint("\n\t\t\\pmbdomdrawfeature{" ..
+ currFeature.key .. "}")
+ end
+ tex.sprint("\n\t\\end{pgfinterruptboundingbox}\\end{scope}")
+
+ currLine = currLine + 1
+ xLeft = xLeft - self.residuesPerLine
+ xRight = xRight - self.residuesPerLine
+ residuesLeft = residuesLeft - self.residuesPerLine
+ until xRight < 1 or residuesLeft < 1
+ end
+ end
+
+ if self.showRuler then
+ currStyle = 1
+ tex.sprint("\n\t\\begin{scope}")
+ for _, currRuler in ipairs(self.rulerRange) do
+ currLine = 0
+ xMid = currRuler.pos - self.residueRangeMin -
+ currLine * self.residuesPerLine + 1
+ while xMid > self.residuesPerLine do
+ xMid = xMid - self.residuesPerLine
+ currLine = currLine + 1
+ end
+ xMid = xMid - 0.5
+ yMid = -currLine * self.baselineSkip
+ tex.sprint(
+ "\n\t\t\\pgfmolbioset[domains]{current style/.style={" ..
+ self.specialKeys:selectStyleFromList("other/ruler", currStyle) ..
+ "}}"
+ )
+ tex.sprint("\n\t\t\t\\def\\xMid{" ..
+ dimToString(xMid * self.xUnit) .. "}")
+ tex.sprint("\n\t\t\t\\let\\xLeft\\xMid\\let\\xRight\\xMid")
+ tex.sprint("\n\t\t\t\\def\\yMid{" ..
+ dimToString(yMid * self.yUnit) .. "}")
+ tex.sprint("\n\t\t\t\\def\\residueNumber{" ..
+ currRuler.number .. "}")
+ tex.sprint("\n\t\t\t\\pmbdomdrawfeature{other/ruler}")
+ currStyle = currStyle + 1
+ end
+ tex.sprint("\n\t\\end{scope}")
+ end
+
+ xMid =
+ math.min(
+ self.residuesPerLine,
+ self.residueRangeMax - self.residueRangeMin + 1
+ ) / 2
+ tex.sprint("\n\t\\begin{scope}")
+ tex.sprint(
+ "\n\t\t\\pgfmolbioset[domains]{current style/.style={" ..
+ self.specialKeys:selectStyleFromList("other/name", 1) ..
+ "}}"
+ )
+ tex.sprint("\n\t\t\\def\\xLeft{0mm}")
+ tex.sprint("\n\t\t\\def\\xMid{" .. dimToString(xMid * self.xUnit) .. "}")
+ tex.sprint("\n\t\t\\def\\xRight{" ..
+ dimToString(self.residuesPerLine * self.xUnit) .. "}")
+ tex.sprint("\n\t\t\\def\\yMid{0mm}")
+ tex.sprint("\n\t\t\\pmbdomdrawfeature{other/name}")
+ tex.sprint("\n\t\\end{scope}")
+
+ tex.sprint(
+ "\n\t\\pmbprotocolsizes{" ..
+ "\\pmbdomvalueof{enlarge left}}{\\pmbdomvalueof{enlarge top}}"
+ )
+ currLine =
+ math.ceil(
+ (self.residueRangeMax - self.residueRangeMin + 1) /
+ self.residuesPerLine
+ ) - 1
+ xRight =
+ math.min(
+ self.residuesPerLine,
+ self.residueRangeMax - self.residueRangeMin + 1
+ )
+ tex.sprint(
+ "\n\t\\pmbprotocolsizes{" ..
+ dimToString(xRight * self.xUnit) ..
+ " + \\pmbdomvalueof{enlarge right}}{" ..
+ dimToString(-currLine * self.baselineSkip * self.yUnit) ..
+ " + \\pmbdomvalueof{enlarge bottom}}"
+ )
+end
+
+function Protein:__tostring()
+ local result = {}
+ local currLine
+
+ currLine = "\\begin{pmbdomains}\n\t\t[name={" ..
+ self.name ..
+ "}"
+ if self.sequence ~= "" then
+ currLine = currLine ..
+ ",\n\t\tsequence=" ..
+ self.sequence
+ end
+ currLine = currLine ..
+ "]{" ..
+ self.sequenceLength ..
+ "}"
+ table.insert(result, currLine)
+
+ for i, v in ipairs(self.ft) do
+ if v.key ~= "other/main chain" then
+ currLine = "\t\\addfeature"
+ if self.includeDescription and v.description then
+ currLine =
+ currLine ..
+ "[description={" ..
+ v.description ..
+ "}]"
+ end
+ currLine =
+ currLine ..
+ "{" ..
+ v.key ..
+ "}{" ..
+ v.start ..
+ "}{" ..
+ v.stop ..
+ "}"
+ table.insert(result, currLine)
+ end
+ end
+ table.insert(result,
+ "\\end{pmbdomains}"
+ )
+ return table.concat(result, "\n")
+end
+--
+-- End of file `pgfmolbio.domains.lua'.
Property changes on: trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.domains.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.lua 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/scripts/pgfmolbio/pgfmolbio.lua 2024-06-17 20:11:59 UTC (rev 71551)
@@ -6,15 +6,15 @@
--
-- pgfmolbio.dtx (with options: `pgfmolbio-lua')
--
--- Copyright (C) 2013 by Wolfgang Skala
+-- Copyright (C) 2024 by Wolfgang Esser-Skala
--
-- This work may be distributed and/or modified under the
--- conditions of the LaTeX Project Public License, either version 1.3
+-- conditions of the LaTeX Project Public License, either version 1.3c
-- of this license or (at your option) any later version.
-- The latest version of this license is in
--- http://www.latex-project.org/lppl.txt
--- and version 1.3 or later is part of all distributions of LaTeX
--- version 2005/12/01 or later.
+-- https://www.latex-project.org/lppl.txt
+-- and version 1.3c or later is part of all distributions of LaTeX
+-- version 2008/05/04 or later.
--
module("pgfmolbio", package.seeall)
@@ -22,11 +22,11 @@
if luatexbase then
luatexbase.provides_module({
name = "pgfmolbio",
- version = 0.2,
- date = "2012/10/01",
+ version = "0.21a",
+ date = "2014/06/17",
description = "Molecular biology graphs wit LuaLaTeX",
- author = "Wolfgang Skala",
- copyright = "Wolfgang Skala",
+ author = "Wolfgang Esser-Skala",
+ copyright = "Wolfgang Esser-Skala",
license = "LPPL",
})
end
Modified: trunk/Master/texmf-dist/source/lualatex/pgfmolbio/pgfmolbio.dtx
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/pgfmolbio/pgfmolbio.dtx 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/source/lualatex/pgfmolbio/pgfmolbio.dtx 2024-06-17 20:11:59 UTC (rev 71551)
@@ -1,26 +1,26 @@
% \iffalse meta-comment
%
-% Copyright (C) 2013 by Wolfgang Skala
+% Copyright (C) 2024 by Wolfgang Esser-Skala
%
% This work may be distributed and/or modified under the
-% conditions of the LaTeX Project Public License, either version 1.3
+% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
-% http://www.latex-project.org/lppl.txt
-% and version 1.3 or later is part of all distributions of LaTeX
-% version 2005/12/01 or later.
+% https://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2008/05/04 or later.
%
% \fi
%
% \iffalse
-%<pgfmolbio-tex>\ProvidesPackage{pgfmolbio}[2013/08/01 v0.21 Molecular biology graphs with TikZ]
+%<pgfmolbio-tex>\ProvidesPackage{pgfmolbio}[2024/06/17 v0.21a Molecular biology graphs with TikZ]
%<pgfmolbio-tex>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<pgfmolbio-lua>module("pgfmolbio", package.seeall)
-%<pmb-chr-tex>\ProvidesFile{pgfmolbio.chromatogram.tex}[2013/08/01 v0.21 SCF chromatograms]
+%<pmb-chr-tex>\ProvidesFile{pgfmolbio.chromatogram.tex}[2024/06/17 v0.21a SCF chromatograms]
%<pmb-chr-lua>module("pgfmolbio.chromatogram", package.seeall)
-%<pmb-dom-tex>\ProvidesFile{pgfmolbio.domains.tex}[2013/08/01 v0.21 Protein domains]
+%<pmb-dom-tex>\ProvidesFile{pgfmolbio.domains.tex}[2024/06/17 v0.21a Protein domains]
%<pmb-dom-lua>module("pgfmolbio.domains", package.seeall)
-%<pmb-con-tex>\ProvidesFile{pgfmolbio.convert.tex}[2013/08/01 v0.21 pgfmolbio graph conversion]
+%<pmb-con-tex>\ProvidesFile{pgfmolbio.convert.tex}[2024/06/17 v0.21a pgfmolbio graph conversion]
%
%<*driver>
\documentclass[captions=tableheading,cleardoublepage=empty,titlepage=false]{scrreprt}
@@ -248,8 +248,8 @@
%</driver>
% \fi
%
-%
%
+%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -270,10 +270,10 @@
% \GetFileInfo{pgfmolbio.sty}
%
% \CheckSum{1254}
-%
+%
% \pagenumbering{roman}
% \title{The \texttt{pgfmolbio} package --\texorpdfstring{\\}{}Molecular Biology Graphs with \TikZ\texorpdfstring{\footnote{This document describes version \fileversion, dated \filedate.}}{}}
-% \author{\texorpdfstring{Wolfgang Skala\thanks{Division of Structural Biology, Department of Molecular Biology, University of Salzburg, Austria; \texttt{Wolfgang.Skala at stud.sbg.ac.at}}}{Wolfgang Skala}}
+% \author{\texorpdfstring{Wolfgang Esser-Skala\thanks{Computational Systems Biology Group, Department of Biosciences and Medical Biology, University of Salzburg, Austria; \texttt{Wolfgang.Esser-Skala at plus.ac.at}}}{Wolfgang Esser-Skala}}
% \date{\filedate}
% \maketitle
%
@@ -287,15 +287,15 @@
% \chapter{Introduction}
% \label{cha:Introduction}
% \pagenumbering{arabic}
-%
-%
+%
+%
% \section{About \texorpdfstring{\pkg{pgfmolbio}}{pgfmolbio}}
% \label{sec:IntroAbout}
-%
-% Over the decades, \TeX\ has gained popularity across a large number of disciplines. Although originally designed as a mere typesetting system, packages such as \pkg{pgf}\footnote{Tantau, T. (2010). The \TikZ\ and \textsc{pgf} packages. \url{http://ctan.org/tex-archive/graphics/pgf/}.} and \pkg{pstricks}\footnote{van Zandt, T., Niepraschk, R., and Voß, H. (2007). PSTricks: PostScript macros for Generic \TeX. \url{http://ctan.org/tex-archive/graphics/pstricks}.} have strongly extended its \textit{drawing} abilities. Thus, one can create complicated charts that perfectly integrate with the text.
-%
-% Texts on molecular biology include a range of special graphs, e.\,g. multiple sequence alignments, membrane protein topologies, DNA sequencing chromatograms, protein domain diagrams, plasmid maps and others. The \pkg{texshade}\footnote{Beitz, E. (2000). \TeX shade: shading and labeling multiple sequence alignments using \LaTeXe. \textit{Bioinformatics}~\textbf{16}(2), 135--139.\\\url{http://ctan.org/tex-archive/macros/latex/contrib/texshade}.} and \pkg{textopo}\footnote{Beitz, E. (2000). \TeX topo: shaded membrane protein topology plots in \LaTeXe. \textit{Bioinformatics} \textbf{16}(11), 1050--1051.\\\url{http://ctan.org/tex-archive/macros/latex/contrib/textopo}.} packages cover alignments and topologies, respectively, but packages dedicated to the remaining graphs are absent. Admittedly, one may create those images with various external programs and then include them in the \TeX\ document. Nevertheless, purists (like the author of this document) might prefer a \TeX-based approach.
-%
+%
+% Over the decades, \TeX\ has gained popularity across a large number of disciplines. Although originally designed as a mere typesetting system, packages such as \pkg{pgf}\footnote{\url{https://ctan.org/pkg/pgf}} and \pkg{pstricks}\footnote{\url{https://ctan.org/pkg/pstricks}} have strongly extended its \textit{drawing} abilities. Thus, one can create complicated charts that perfectly integrate with the text.
+%
+% Texts on molecular biology include a range of special graphs, e.\,g. multiple sequence alignments, membrane protein topologies, DNA sequencing chromatograms, protein domain diagrams, plasmid maps and others. The \pkg{texshade}\footnote{\url{https://ctan.org/pkg/texshade}} and \pkg{textopo}\footnote{\url{https://ctan.org/pkg/textopo}} packages cover alignments and topologies, respectively, but packages dedicated to the remaining graphs are absent. Admittedly, one may create those images with various external programs and then include them in the \TeX\ document. Nevertheless, purists (like the author of this document) might prefer a \TeX-based approach.
+%
% The \pkg{pgfmolbio} package aims at becoming such a purist solution. In the current development release, \pkg{pgfmolbio} is able to
% \begin{itemize}
% \item read DNA sequencing files in standard chromatogram format (\file{scf}) and draw the corresponding chromatogram;
@@ -302,17 +302,17 @@
% \item read protein domain information from Uniprot or general feature format files (\file{gff}) and draw domain diagrams.
% \end{itemize}
% To this end, \pkg{pgfmolbio} relies on routines from \pkg{pgf}'s \TikZ\ frontend and on the Lua scripting language implemented in Lua\TeX. Consequently, the package will not work directly with traditional engines like pdf\TeX. However, a converter module ensures a high degree of backward compatibility.
-%
+%
% Since this is a development release, \pkg{pgfmolbio} presumably includes a number of bugs, and its commands and features are likely to change in future versions. Moreover, the current version is far from complete, but since time is scarce, I am unable to predict when (and if) additional functions become available. Nevertheless, I would greatly appreciate any comments or suggestions.
-%
-%
+%
+%
% \section{Getting Started}
% \label{sec:IntroGettingStarted}
-%
+%
% Before you consider using \pkg{pgfmolbio}, please make sure that both your Lua\TeX\ (at least 0.70.2) and \pkg{pgf} (at least 2.10) installations are up-to-date. Once your \TeX\ system meets these requirements, just load \pkg{pgfmolbio} as usual, i.\,e. by
-%
+%
% \DescribeMacro\usepackage[<module>]{pgfmolbio}
-%
+%
% The package is divided into \textit{modules}, each of which produces a certain type of graph. Currently, three \ometa{module}s are available:
% \begin{itemize}
% \item \module{chromatogram} (chapter~\ref{cha:Chromatogram}) allows you to draw DNA sequencing chromatograms obtained by the Sanger sequencing method.
@@ -319,26 +319,26 @@
% \item \module{domains} (chapter~\ref{cha:Domains}) provides macros for drawing protein domain diagrams and is also able to read domain information from files in Uniprot or general feature format.
% \item Furthermore, \module{convert} (chapter~\ref{cha:Convert}) is used with one of the modules above and generates ``pure'' \TikZ\ code suitable for \TeX\ engines lacking Lua support.
% \end{itemize}
-%
+%
% \DescribeMacro\pgfmolbioset[<module>]{<key-value list>}
% Fine-tunes the graphs produced by each \pkg{pgfmolbio} module. The possible keys are described in the sections on the respective modules.
%
%
%
-%
+%
% \chapter{The \texorpdfstring{\module{chromatogram}}{chromatogram} module}
% \label{cha:Chromatogram}
-%
-%
+%
+%
% \section{Overview}
% \label{sec:ChrOverview}
-%
-% The \module{chromatogram} module draws DNA sequencing chromatograms stored in standard chromatogram format (\file{scf}), which was developed by Simon Dear and Rodger Staden\footnote{Dear, S. and Staden, R. (1992). A standard file format for data from DNA sequencing instruments. \textit{DNA Seq.} \textbf{3}(2), 107--110.}. The documentation for the Staden package\footnote{\url{http://staden.sourceforge.net/}} describes the current version of the \file{scf} format in detail. As far as they are crucial to understanding the Lua code, we will discuss some details of this file format in the documented source code (section~\ref{sec:DocChrLua}). Note that \pkg{pgfmolbio} only supports \file{scf} version 3.00.
-%
-%
+%
+% The \module{chromatogram} module draws DNA sequencing chromatograms stored in standard chromatogram format (\file{scf}), which was developed by Simon Dear and Rodger Staden\footnote{Dear, S. and Staden, R. (1992). A standard file format for data from DNA sequencing instruments. \textit{DNA Seq.} \textbf{3}(2), 107--110.}. The documentation for the Staden package\footnote{\url{https://staden.sourceforge.net/}} describes the current version of the \file{scf} format in detail. As far as they are crucial to understanding the Lua code, we will discuss some details of this file format in the documented source code (section~\ref{sec:DocChrLua}). Note that \pkg{pgfmolbio} only supports \file{scf} version 3.00.
+%
+%
% \section{Drawing Chromatograms}
% \label{sec:ChrDrawingChromatograms}
-%
+%
% \DescribeMacro\pmbchromatogram[<key-value list>]{<scf file>}
% The \module{chromatogram} module defines a single command, which reads a chromatogram from an \meta{scf file} and draws it with routines from \TikZ\ (Example~\ref{exa:ChrTikzpicture}). The options, which are set in the \ometa{key-value list}, configure the appearance of the chromatogram. The following sections will elaborate on the available keys.
% \begin{exampletable}
@@ -350,13 +350,13 @@
% \end{tikzpicture} % optional
% \end{examplecode}
% \end{exampletable}
-%
+%
% Although you will often put |\pmbchromatogram| into a |tikzpicture| environment, you may actually use the macro on its own. \pkg{pgfmolbio} checks whether the command is surrounded by a |tikzpicture| and adds this environment if necessary.
-%
-%
+%
+%
% \section{Displaying Parts of the Chromatogram}
% \label{sec:ChrDisplayingParts}
-%
+%
% \DescribeOption{chromatogram/}{sample range}{1-500 step 1}<lower>'-'<upper>[' step '<int>]\relax
% \opt{sample range} selects the part of the chromatogram which \pkg{pgfmolbio} should display. The value for this key consists of two or three parts, separated by the keywords |-| and |step|. The package will draw the chromatogram data between the \meta{lower} and \meta{upper} boundary. There are two ways of specifying these limits:
% \begin{enumerate}
@@ -371,7 +371,7 @@
% \item If you enter the keyword |base| followed by an optional space and a number, the chromatogram starts or stops at the peak corresponding to the respective base. The first detected base peak has index 1. Compare Examples~\ref{exa:ChrLimitsSamplePoints} and~\ref{exa:ChrLimitsBases} to see the difference.
% \end{enumerate}
% The optional third part of the value for \opt{sample range} orders the package to draw every \ometa{int}th sample point. If your document contains large chromatograms or a great number of them, drawing fewer sample points increases typesetting time at the cost of image quality (Example~\ref{exa:ChrSampleStep}). Nevertheless, the key may be especially useful while optimizing the layout of complex chromatograms.
-%
+%
% \begin{exampletable}[p]
% \caption{}
% \label{exa:ChrLimitsBases}
@@ -381,7 +381,7 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \begin{exampletable}[p]
% \caption{}
% \label{exa:ChrSampleStep}
@@ -402,11 +402,11 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
-%
+%
+%
% \section{General Layout}
% \label{sec:ChrGeneralLayout}
-%
+%
% \DescribeOption{chromatogram/}{x unit}{0.2mm}<dimension>
% \DescribeOption{chromatogram/}{y unit}{0.01mm}<dimension>
% These keys set the horizontal distance between two consecutive sample points and the vertical distance between two fluorescence intensity values, respectively. Example~\ref{exa:Chrxyunit} illustrates how you can enlarge a chromatogram twofold by doubling these values.
@@ -443,7 +443,7 @@
% \end{tikzpicture}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeOption[/.style=]{chromatogram/}{canvas style}{draw=none, fill=none}<style>\newpage
% \DescribeOption{chromatogram/}{canvas height}{2cm}<dimension>
%
@@ -459,11 +459,11 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
-%
+%
+%
% \section{Traces}
% \label{sec:ChrTraces}
-%
+%
% \DescribeOption[/.style=]{chromatogram/}{trace A style}{pmbTraceGreen}<style>
% \DescribeOption[/.style=]{chromatogram/}{trace C style}{pmbTraceBlue}<style>
% \DescribeOption[/.style=]{chromatogram/}{trace G style}{pmbTraceBlack}<style>
@@ -470,7 +470,7 @@
% \DescribeOption[/.style=]{chromatogram/}{trace T style}{pmbTraceRed}<style>
% \DescribeOption{chromatogram/}{trace style}{\textrm{(none)}}<style>
% The \textit{traces} indicate variations in fluorescence intensity during chromatography, and each trace corresponds to a base. The first four keys set the respective \meta{style} basewise, whereas \opt{trace style} changes all styles simultaneously. Note the syntax differences between \opt{trace style} and \opt{trace A style} etc. The standard styles simply color the traces; Table~\ref{tab:pmbColors} lists the color specifications.
-%
+%
% \begin{table}[h]
% \centering
% \caption{Colors defined by the \module{chromatogram} module.}
@@ -487,7 +487,7 @@
% \bottomrule
% \end{tabular}
% \end{table}
-%
+%
% In Example~\ref{exa:ChrTraceStyle}, we change the style of all traces to a thin line and then add some patterns and colors to the A and T trace.
% \begin{exampletable}[h]
% \caption{}
@@ -514,11 +514,11 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
-%
+%
+%
% \section{Ticks}
% \label{sec:ChrTicks}
-%
+%
% \DescribeOption[/.style=]{chromatogram/}{tick A style}{thin, pmbTraceGreen}<style>
% \DescribeOption[/.style=]{chromatogram/}{tick C style}{thin, pmbTraceBlue}<style>
% \DescribeOption[/.style=]{chromatogram/}{tick G style}{thin, pmbTraceBlack}<style>
@@ -536,7 +536,7 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeOption{chromatogram/}{tick length}{1mm}<dimension>
% This key determines the length of each tick. In Example~\ref{exa:ChrTickLength}, the ticks are twice as long as usual.
% \begin{exampletable}
@@ -549,7 +549,7 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeOption{chromatogram/}{ticks drawn}{ACGT}'A|C|G|T|'!\textrm{any combination thereof}!
% The value of this key governs which ticks appear in the chromatogram. Any combination of the single-letter abbreviations for the standard bases will work. Example~\ref{exa:ChrTicksDrawn} only displays the cytosine and guanine ticks.
% \begin{exampletable}
@@ -562,11 +562,11 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
-%
+%
+%
% \section{Base Labels}
% \label{sec:ChrBaseLabels}
-%
+%
% \DescribeOption{chromatogram/}{base label A text}{\cs{strut} A}<text>
% \DescribeOption{chromatogram/}{base label C text}{\cs{strut} C}<text>
% \DescribeOption{chromatogram/}{base label G text}{\cs{strut} G}<text>
@@ -583,7 +583,7 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeOption[/.style=]{chromatogram/}{base label A style}{below=4pt, font=\cs{ttfamily}\cs{footnotesize}, pmbTraceGreen}<style>
% \DescribeOption[/.style=]{chromatogram/}{base label C style}{below=4pt, font=\cs{ttfamily}\cs{footnotesize}, pmbTraceBlue}<style>
% \DescribeOption[/.style=]{chromatogram/}{base label G style}{below=4pt, font=\cs{ttfamily}\cs{footnotesize}, pmbTraceBlack}<style>
@@ -603,7 +603,7 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeOption{chromatogram/}{base labels drawn}{ACGT}'A|C|G|T|'!\textrm{any combination thereof}!
% The value of this key governs which base labels appear in the chromatogram. Any combination of the single-letter abbreviations for the standard bases will work. Example~\ref{exa:ChrBaseLabelsDrawn} only displays cytosine and guanine base labels.
% \begin{exampletable}[ht]
@@ -616,11 +616,11 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
-%
+%
+%
% \section{Base Numbers}
% \label{sec:ChrBaseNumbers}
-%
+%
% \DescribeOption{chromatogram/}{show base numbers}{true}<boolean>
% Turns the \textit{base numbers} on or off, which indicate the indices of the base peaks below the traces.
% \DescribeOption[/.style=]{chromatogram/}{base number style}{pmbTraceBlack, below=-3pt, font=\cs{sffamily}\cs{tiny}}<style>
@@ -636,7 +636,7 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeOption{chromatogram/}{base number range}{auto-auto step 10}<lower>'-'<upper>[' step '<interval>]
% This key decides that every \ometa{interval}th base number from \meta{lower} to \meta{upper} should show up in the output; the |step| part is optional. If you specify the keyword |auto| instead of a number for \meta{lower} or \meta{upper}, the base numbers start or finish at the leftmost or rightmost base peak shown, respectively. In Example~\ref{exa:ChrBaseNumberRange}, only peaks 42 to 46 receive a number.
% \begin{exampletable}
@@ -649,13 +649,13 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
-%
+%
+%
% \section{Probabilities}
% \label{sec:ChrProbabilities}
-%
+%
% Programs such as \file{phred}\footnote{Ewing, B., Hillier, L., Wendl, M.\,C., and Green, P. (1998). Base-calling of automated sequencer traces using phred. I. Accuracy assessment. \textit{Genome Res.} \textbf{8}(3), 175--185.} assign a \textit{probability} or \textit{quality value} $Q$ to each called base after chromatography. $Q$ is calculated from the error probability $P_e$ by $Q = -10 \log_{10} P_e$. For example, a $Q$ value of 20 means that 1 in 100 base calls is wrong.
-%
+%
% \DescribeOption{chromatogram/}{probability distance}{0.8cm}<dimension>
% Sets the distance between the base probability rules and the baseline.
% \DescribeOption{chromatogram/}{probabilities drawn}{ACGT}'A|C|G|T|'!\textrm{any combination thereof}!
@@ -671,7 +671,7 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeOption{chromatogram/}{probability style function}{nil}<Lua function name>
% By default, the probability rules are colored black, red, yellow and green for quality scores $<10$, $<20$, $<30$ and $\geq30$, respectively. However, you can override this behavior by providing a \meta{Lua function name} to \opt{probability style function}. This Lua function must read a single argument of type number and return a string appropriate for the optional argument of \TikZ's |\draw| command. For instance, the function shown in Example~\ref{exa:ChrProbStyleFunction} determines the lowest and highest probability and colors intermediate values according to a red--yellow--green gradient.
% \begin{exampletable}[htp]
@@ -702,7 +702,7 @@
%
% \section{Miscellaneous Keys}
% \label{sec:ChrMiscKeys}
-%
+%
% \DescribeOption{chromatogram/}{bases drawn}{ACGT}'A|C|G|T|'!\textrm{any combination thereof}!
% This key simultaneously sets \opt{traces drawn}, \opt{ticks drawn}, \opt{base labels drawn} and \opt{probabilities drawn} (see Example~\ref{exa:ChrBasesDrawn}).
% \begin{exampletable}[p]
@@ -715,38 +715,38 @@
% ]{SampleScf.scf}
% \end{examplecode}
% \end{exampletable}
-%
-%
-%
+%
+%
+%
% \chapter{The \texorpdfstring{\module{domains}}{domains} module}
% \label{cha:Domains}
-%
+%
% \section{Overview}
% \label{sec:DomOverview}
-%
-% Protein domain diagrams appear frequently in databases such as Pfam\footnote{Finn, R.\,D., Mistry, J. \textit{et al.} (2010). The Pfam protein families database. \textit{Nucleic Acids Res.} \textbf{38}, D211--D222.} or \textsc{prosite}\footnote{Sigrist, C.\,J.\,A., Cerutti, L. \textit{et al.} (2010). \textsc{prosite}, a protein domain database for functional characterization and annotation. \textit{Nucleic Acids Res.} \textbf{38}, D161--D166.}. Domain diagrams are often drawn using standard graphics software or tools such as \textsc{prosite}'s MyDomains image creator\footnote{\url{http://prosite.expasy.org/mydomains/}}. However, the \module{domains} module provides an integrated approach for generating domain diagrams from \TeX\ code or from external files.
-%
-%
+%
+% Protein domain diagrams appear frequently in databases such as Pfam\footnote{Finn, R.\,D., Mistry, J. \textit{et al.} (2010). The Pfam protein families database. \textit{Nucleic Acids Res.} \textbf{38}, D211--D222.} or \textsc{prosite}\footnote{Sigrist, C.\,J.\,A., Cerutti, L. \textit{et al.} (2010). \textsc{prosite}, a protein domain database for functional characterization and annotation. \textit{Nucleic Acids Res.} \textbf{38}, D161--D166.}. Domain diagrams are often drawn using standard graphics software or tools such as \textsc{prosite}'s MyDomains image creator\footnote{\url{https://prosite.expasy.org/mydomains/}}. However, the \module{domains} module provides an integrated approach for generating domain diagrams from \TeX\ code or from external files.
+%
+%
% \section{Domain Diagrams and Their Features}
% \label{sec:DomDiagrams}
-%
+%
% \DescribeEnv[\meta{features}]{pmbdomains}[<key-value list>]{<sequence length>}
% Draws a domain diagram with the \meta{features} given. The \ometa{key-value list} configures its appearance. \meta{sequence length} is the total number of residues in the protein. (Although you must eventually specify a sequence length, you may actually leave the mandatory argument empty and use the \opt{sequence length} key instead; see section~\ref{sec:DomFileInput}).
-%
+%
% You can put a |pmbdomains| environment into a |tikzpicture|, but you also may use the environment on its own. \pkg{pgfmolbio} checks whether it is surrounded by a |tikzpicture| and adds this environment if necessary.
%
% \DescribeOption{domains/}{name}{Protein}<text>
% The name of the protein, which usually appears centered above the diagram.
-%
+%
% \DescribeOption{domains/}{show name}{true}<boolean>
% Determines whether both the name and sequence length are shown.
-%
+%
% \DescribeMacro\addfeature[<key-value list>]{<type>}{<start>}{<stop>}
% Adds a feature of the given \meta{type} to the current domain diagram (only defined inside |pmbdomains|). The feature spans the residues from \meta{start} to \meta{stop}. These arguments are either numbers, which refer to residues in the relative numbering scheme, or numbers in parentheses, which refer to absolute residue numbers (see section~\ref{sec:DomGeneralLayout}).
-%
+%
% \DescribeOption{domains/}{description}{\textrm{(none)}}<text>
% Sets the feature description (Example~\ref{exa:DomTikzpicture}).
-%
+%
% \begin{exampletable}
% \caption{}
% \label{exa:DomTikzpicture}
@@ -769,13 +769,13 @@
%
% \DescribeOption{domains/}{x unit}{0.5mm}<dimension>
% The width of a single residue.
-%
+%
% \DescribeOption{domains/}{y unit}{6mm}<dimension>
% The height of a default \texttt{domain} feature.
%
% \DescribeOption{domains/}{residues per line}{200}<number>
% A new domain diagram ``line'' starts after \meta{number} residues.
-%
+%
% \DescribeOption{domains/}{baseline skip}{3}<factor>
% The baselines of consecutive lines (i.\,e., the main chain $y$-coordinates) are separated by \meta{factor} times the value of \opt{y unit}. In Example~\ref{exa:DomResiduesPerLine}, you see four lines, each of which contains up to 30~residues. Note how domains are correctly broken across lines. Furthermore, the baselines are $2 \times 4 = 8$~mm apart.
%
@@ -803,7 +803,7 @@
% \meta{start} := \MacroArgs<number>' | '<number><letter>\\
% \meta{end} := \MacroArgs<number>' | '<letter>
% \end{quote}
-%
+%
% Example~\ref{exa:DomResidueNumbering} shows a custom \meta{numbering scheme}, in this case for kallikrein-related peptidase 2 (KLK2), a chymotrypsin-like serine proteases. (In the following explanation, the subscripts `abs' and `rel' denote absolute and relative numbering, respectively).
% \begin{itemize}
% \item Residue 1\textsubscript{abs} is labeled 16\textsubscript{rel}, residue 2\textsubscript{abs} is labeled 17\textsubscript{rel} etc. until residue 24\textsubscript{abs}, which is labeled 39\textsubscript{rel} (range |16-39|).
@@ -812,7 +812,7 @@
% \item An insertion of 11 amino acids follows residue 95\textsubscript{rel}. These residues are numbered from 95A\textsubscript{rel} to 95K\textsubscript{rel}. Note that both |95A-K| and |95A-95K| are valid ranges.
% \item The number of the last residue is 245A\textsubscript{rel}(range |245A|).
% \end{itemize}
-%
+%
% \begin{exampletable}
% \caption{}
% \label{exa:DomResidueNumbering}
@@ -877,7 +877,7 @@
% background rectangle/.style={draw=red, thick}%
% }
% \pgfmolbioset[domains]{show name=false, y unit=1cm, show ruler=false}
-%
+%
% \begin{tikzpicture}[show background rectangle]
% \begin{pmbdomains}{80}
% \addfeature[description=Oops!]{domain}{20}{60}
@@ -895,13 +895,13 @@
% \section{Feature Styles and Shapes}
% \label{sec:DomFeatureStylesAndShapes}
%
-% Each (implicit and explicit) feature of a domain chart has a certain \textit{shape} and \textit{style}. For instance, you can see five different feature \textit{shapes} in Example~\ref{exa:DomTikzpicture}: We explicitly added two features of shape (and type) \texttt{disulfide} and three features of shape \texttt{domain}. Furthermore, the package implicitly included features of shape \texttt{other/name}, \texttt{other/main chain} and \texttt{other/ruler}.
-%
+% Each (implicit and explicit) feature of a domain chart has a certain \textit{shape} and \textit{style}. For instance, you can see five different feature \textit{shapes} in Example~\ref{exa:DomTikzpicture}: We explicitly added two features of shape (and type) \texttt{disulfide} and three features of shape \texttt{domain}. Furthermore, the package implicitly included features of shape \texttt{other/name}, \texttt{other/main chain} and \texttt{other/ruler}.
+%
% Although the three \texttt{domain} features agree in shape, they differ in color, or (more generally) \textit{style}. Since \pkg{pgfmolbio} distinguishes between shapes and styles, you may draw equally shaped features with different colors, strokes, shadings etc.
%
% \DescribeMacro\setfeaturestyle{<type>}{<style list>}
% Specifies a \meta{style list} for the given feature \meta{type}. The complete syntax ist
-%
+%
% \begin{quote}
% \meta{style list} := \MacroArgs{<style list item>[','<style list item>', ...']}\\
% \meta{style list item} := \MacroArgs<multiplier><style>\\
@@ -908,11 +908,11 @@
% \meta{multiplier} := \MacroArgs['*'<number>]\\
% \meta{style} := \MacroArgs<single key-value pair>' | '{<key-value list>}
% \end{quote}
-%
+%
% A style list item of the general form |*|\meta{n}|{|\meta{style}|}| instructs the package to repeat the \meta{style} \meta{n}-times. (This syntax is reminiscent of column specifications in a |tabular| environment. However, do \textit{not} enclose numbers with more than one digit in curly braces!) You may omit the trivial multiplier |*1|, but never forget the curly braces surrounding a \meta{style} that contains two or more key-value pairs. Furthermore, \pkg{pgfmolbio} loops over the style list until all features have been drawn.
-%
-% For instance, the style list in Example~\ref{exa:DomFeatureStyle} fills the first feature red, then draws a green one with a thick stroke, and finally draws two dashed blue features.
%
+% For instance, the style list in Example~\ref{exa:DomFeatureStyle} fills the first feature red, then draws a green one with a thick stroke, and finally draws two dashed blue features.
+%
% \begin{exampletable}
% \caption{}
% \label{exa:DomFeatureStyle}
@@ -946,7 +946,7 @@
% \endgroup
% \addfeature{domain}{71}{90} % the new style persists ...
% \end{pmbdomains}
-%
+%
% \begin{pmbdomains}[show name=false]{100}
% \addfeature{domain}{11}{30}
% \addfeature[style={thick, fill=red}]{domain}{41}{60}
@@ -960,7 +960,7 @@
%
% \DescribeMacro\setfeatureshape{<type>}{<TikZ code>}\relax
% Defines a new feature shape named \meta{type} or changes an existing one. \textbf{Caution:} If you change a shape within |pmbdomains|, you will also change the features of equal type that you already added. Thus, it is best to use |\setfeatureshape| only outside of this environment.
-%
+%
% \begin{exampletable}[p]
% \caption{}
% \label{exa:DomFeatureShape1}
@@ -971,7 +971,7 @@
% (\xRight, \yMid - .5 * \pmbdomvalueof{y unit});
% \node at (\xMid, \yMid) {\pmbdomvalueof{description}};
% }
-%
+%
% \begin{pmbdomains}[show name=false]{200}
% \addfeature[description=Domain 1]{domain}{30}{80}
% \addfeature[description=Domain 2]{domain}{93}{163}
@@ -996,7 +996,7 @@
% (\xLeft, \yMid - 2mm) --
% cycle;
% }
-%
+%
% \begin{pmbdomains}[show name=false]{200}
% \addfeature[description=Domain 1]{domain}{30}{80}
% \addfeature[description=Domain 2]{domain}{93}{163}
@@ -1017,12 +1017,12 @@
% color(75bp)=(bordercolor);
% color(100bp)=(bordercolor)
% }
-%
+%
% \tikzset{%
% domain middle color/.code=\colorlet{middlecolor}{#1},%
% domain border color/.code=\colorlet{bordercolor}{#1}%
% }
-%
+%
% \setfeatureshape{domain}{%
% \draw [shading=mydomain, rounded corners=2mm,
% /pgfmolbio/domains/current style]
@@ -1031,7 +1031,7 @@
% \node [above=3mm] at (\xMid, \yMid)
% {\pmbdomvalueof{domain font}{\pmbdomvalueof{description}}};
% }
-%
+%
% \begin{pmbdomains}[show name=false]{200}
% \setfeaturestyle{domain}{%
% {domain middle color=yellow!85!orange,%
@@ -1047,7 +1047,7 @@
% \end{pmbdomains}
% \end{examplecode}
% \end{exampletable}
-%
+%
% Several commands that are only available in the \meta{TikZ code} allow you to design generic feature shapes:
% \begin{itemize}
% \item |\xLeft|, |\xMid| and |\xRight| expand to the left, middle and right $x$-coordinate of the feature. The coordinates are in a format suitable for |\draw| and similar commands.
@@ -1062,7 +1062,7 @@
% \item |\currentResidue| expands to a single letter amino acid abbreviation. This macro is only available for shape \texttt{other/sequence} (see section~\ref{sec:DomSequences}).
% \end{itemize}
%
-% In Example~\ref{exa:DomFeatureShape1}, we develop a simple \texttt{domain} shape, which is a rectangle containing a centered label with the feature description. Example~\ref{exa:DomFeatureShape2} calculates an additional coordinate for a pentagonal domain shape and stores this coordinate in |\middlecorners|. Note that you have to insert ``pt'' after |\middlecorners| when using the stored coordinate. The domains in Example~\ref{exa:DomFeatureShape3} display a custom shading and inherit their style from the style list.
+% In Example~\ref{exa:DomFeatureShape1}, we develop a simple \texttt{domain} shape, which is a rectangle containing a centered label with the feature description. Example~\ref{exa:DomFeatureShape2} calculates an additional coordinate for a pentagonal domain shape and stores this coordinate in |\middlecorners|. Note that you have to insert ``pt'' after |\middlecorners| when using the stored coordinate. The domains in Example~\ref{exa:DomFeatureShape3} display a custom shading and inherit their style from the style list.
%
% \DescribeMacro\setfeatureshapealias{<new type>}{<existing type>}
% After calling this macro, the \meta{new type} and \meta{existing type} share a common shape, while they still differ in their styles.
@@ -1073,7 +1073,7 @@
%
% \section{Standard Features}
% \label{sec:DomStandardFeatures}
-%
+%
% \pkg{pgfmolbio} provides a range of standard features. This section explains simple features (i.\,e., those that support no or only few options), while later sections cover advanced ones. Some features include predefined aliases, which facilitate inclusion of external files (see section~\ref{sec:DomFileInput}).
%
% \DescribeFeature*{default}
@@ -1110,10 +1110,10 @@
%
% \DescribeFeature{signal peptide}{SIGNAL}
% Adds a signal peptide (Example~\ref{exa:DomFeatureProSignal}).
-%
+%
% \DescribeFeature{propeptide}{PROPEP}
% Adds a propeptide (Example~\ref{exa:DomFeatureProSignal}).
-%
+%
% \begin{exampletable}
% \caption{}
% \label{exa:DomFeatureProSignal}
@@ -1198,10 +1198,10 @@
%
% \DescribeOption{domains/}{level}{\textrm{(empty)}}<number>
% Manually sets the level of a disulfide feature.
-%
+%
% \DescribeOption{domains/}{disulfide base distance}{1}<number>
% The distance (as a multiple of $y$-units) between the main chain and the first level.
-%
+%
% \DescribeOption{domains/}{disulfide level distance}{.2}<number>
% The space (as a multiple of $y$-units) between levels (see the figure below).
%
@@ -1274,7 +1274,7 @@
% \end{pmbdomains}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \begin{DescribeMacros}
% \Macro\setdisulfidefeatures{<key list>}
% \Macro\adddisulfidefeatures{<key list>}
@@ -1281,7 +1281,7 @@
% \Macro\removedisulfidefeatures{<key list>}
% \end{DescribeMacros}
% These macros edit the list of ``disulfide-like'' features, i.\,e. those subject to the automatic stacking mechanism. |\setdisulfidefeatures| renews this list, replacing any previous contents. |\adddisulfidefeatures| adds the features in its \meta{key list} to an existing list, while |\removedisulfidefeatures| removes selected features. By default, there are three disulfide-like features: \texttt{disulfide}, \texttt{DISULFID} and \texttt{range}. Note that |\setfeaturealias| and its relatives do not influence the list.
-%
+%
% \DescribeFeature*{range}
% Indicates a range of residues. \texttt{range} features are disulfide-like in order to prevent them from overlapping.
%
@@ -1310,7 +1310,7 @@
%
% \DescribeFeature*{other/ruler}
% This feature is automatically added to the feature list at the end of each |pmbdomains| environment. It draws a ruler below the main chain, which indicates the residue numbers (Example~\ref{exa:DomFeatureRuler}). The following auxiliary commands are available for the feature style \TikZ\ code: |\xMid|, |\yMid|, |\residueNumber| and \opt{current style}.
-%
+%
% \DescribeOption{domains/}{show ruler}{true}<boolean>
% Determines whether the rule is drawn.
%
@@ -1329,10 +1329,10 @@
% \item a plain number (with an optional letter), which denotes a residue in the \textit{relative} numbering scheme set by \opt{residue numbering};
% \item a parenthesized number, which denotes a residue in the \textit{absolute} numbering scheme.
% \end{itemize}
-%
+%
% \DescribeOption{domains/}{default ruler step size}{50}<number>
% Step size for a \meta{ruler range} that lacks the optional |step| part.
-%
+%
% \DescribeOption{domains/}{ruler distance}{-.5}<factor>
% Separation (multiples of the $y$-unit) between ruler and main chain (Example~\ref{exa:DomFeatureRuler}).
%
@@ -1361,7 +1361,7 @@
%
% \DescribeFeature*{other/sequence}
% Displays a sequence which is vertically centered at the main chain. Since a residue is only 0.5~mm wide by default, you should increase the \opt{x unit} when showing \texttt{sequence} features (Example~\ref{exa:DomFeatureSequence}).
-%
+%
% \begin{exampletable}
% \caption{}
% \label{exa:DomFeatureSequence}
@@ -1400,10 +1400,10 @@
% \item performs all necessary calculations and defines all \TeX\ macros required by |\setfeatureshape|;
% \item may execute |\pmbdomdrawfeature| with the appropriate feature \meta{type} to draw the feature.
% \end{itemize}
-%
%
+%
% Example~\ref{exa:DomPrintFunction} devises a new print function, §printFunnySequence§ (lines 2--17). It is similar to the default print function for \texttt{other/sequence} features, but adds random values to the $y$-coordinate of the individual letters.
-%
+%
% §printFunnySequence§ is a function with six arguments (line 2). We add the width of half a residue to the left $x$-coordinate, §xLeft§ (line 3), since each letter should be horizontally centered. We iterate over each letter in the §sequence§ field of the §feature§ table (lines 4--16). In each loop, calculated coordinates are stored in the \TeX\ macros |\xMid| (lines 5--7) and |\yMid| (lines 8--10). The construction |\string\\...| is expanded to |\\...| when §tex.sprint§ passes its argument back to \TeX. §pgfmolbio.dimToString§ converts a number representing a dimension in scaled points to a string (e.\,g., 65536 to ``1pt'', see section~\ref{sec:DocPkgLua}). The letter of the current residue is stored in |\currentResidue| (lines 11--13). Finally, each letter is drawn by calling |\pmbdomdrawfeature{other/sequence}| (line 14), and the $x$-coordinate increases by one (line 15). Line 25 registers §printFunnySequence§ for \texttt{other/sequence} features.
%
% \begin{exampletable}
@@ -1428,7 +1428,7 @@
% end
% end
% }
-%
+%
% \begin{pmbdomains}[%
% sequence=MGSKRSVPSRHRSLTTYEVMFAVLFVILVALCAGLIAVSWLSIQGSVKDAAF,
% x unit=2mm, show name=false,
@@ -1440,16 +1440,16 @@
% \end{pmbdomains}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeFeature*{other/magnified sequence above}
% Displays its sequence as a single string above the main chain, with dashed lines indicating the sequence start and stop on the backbone. This feature allows you to show sequences without the need to increase the \opt{x unit}.
-%
+%
% \DescribeFeature*{other/magnified sequence below}
% Displays the sequence \textit{below} the backbone.
%
% \DescribeOption{domains/}{magnified sequence font}{\string\ttfamily\string\footnotesize}<font commands>
% The font used for a magnified sequence (Example~\ref{exa:DomFeatureMagnifiedSequence}).
-%
+%
% \begin{exampletable}
% \caption{}
% \label{exa:DomFeatureMagnifiedSequence}
@@ -1469,13 +1469,13 @@
%
% \section{Secondary Structure}
% \label{sec:DomSecondaryStructure}
-%
+%
% \DescribeOption{domains/}{show secondary structure}{false}<boolean>
% Determines whether the secondary structure is shown.
-%
+%
% \DescribeOption{domains/}{secondary structure distance}{1}<factor>
% Secondary structures appear along a thin line \meta{factor} times the value of \opt{y unit} above the main chain. In accordance with the categories established by the Dictionary of Protein Secondary Structure\footnote{Kabsch, W. and Sander, C. (1983). Dictionary of protein secondary structure: pattern recognition of hydrogen-bonded and geometrical features. \textit{Biopolymers} \textbf{22}(12), 2577--2637.}, \pkg{pgfmolbio} provides seven features for displaying secondary structure types (Example~\ref{exa:DomShowSecStructure}):
-%
+%
% \begin{exampletable}
% \caption{}
% \label{exa:DomShowSecStructure}
@@ -1501,28 +1501,28 @@
% \end{pmbdomains}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeFeature{alpha helix}{HELIX}
% Shows an $\alpha$-helix.
-%
+%
% \DescribeFeature*{pi helix}
% Shows a $\pi$-helix.
-%
+%
% \DescribeFeature*{310 helix}
% Shows a $3_{10}$-helix.
-%
+%
% \DescribeFeature{beta strand}{STRAND}
% Shows a $\beta$-strand.
-%
+%
% \DescribeFeature{beta turn}{TURN}
% Shows a $\beta$-turn.
-%
+%
% \DescribeFeature*{beta bridge}
% Shows a $\beta$-bridge.
-%
+%
% \DescribeFeature*{bend}
% Shows a bend.
-%
+%
% \begin{figure}
% \centering
% \caption{Shading colors of helix features.}
@@ -1573,7 +1573,7 @@
% -- (9.5, -.2);
% \end{tikzpicture}
% \end{figure}
-%
+%
% \begin{table}[p]
% \centering
% \caption{Customizing helices in the \module{domains} module.}
@@ -1592,7 +1592,7 @@
% \bottomrule
% \end{tabular}
% \end{table}
-%
+%
% \begin{exampletable}[p]
% \caption{}
% \label{exa:DomHelixColors}
@@ -1619,7 +1619,7 @@
% \end{pmbdomains}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \begin{exampletable}[p]
% \caption{}
% \label{exa:DomHelixHelperFeature}
@@ -1628,7 +1628,7 @@
% \pmbdomvalueof{secondary structure distance}
% * \pmbdomvalueof{y unit}%
% }
-%
+%
% \setfeatureshape{helix/half upper back}{%
% \draw [shading=helix half upper back]
% (\xLeft, \yMid + \yShift pt) --
@@ -1639,7 +1639,7 @@
% (\xLeft + \pmbdomvalueof{x unit}, \yMid + \yShift pt) --
% cycle;
% }
-%
+%
% \setfeatureshape{helix/half lower back}{%
% \draw [shading=helix half lower back]
% (\xRight, \yMid + \yShift pt) --
@@ -1650,7 +1650,7 @@
% (\xRight - \pmbdomvalueof{x unit}, \yMid + \yShift pt) --
% cycle;
% }
-%
+%
% \setfeatureshape{helix/full back}{%
% \draw [shading=helix full back]
% (\xMid, \yLower + \yShift pt) --
@@ -1660,7 +1660,7 @@
% \yLower + 3 * \pmbdomvalueof{x unit} + \yShift pt) --
% cycle;
% }
-%
+%
% \setfeatureshape{helix/half upper front}{%
% \draw [shading=helix half upper front]
% (\xRight, \yMid + \yShift pt) --
@@ -1671,7 +1671,7 @@
% (\xRight - \pmbdomvalueof{x unit}, \yMid + \yShift pt) --
% cycle;
% }
-%
+%
% \setfeatureshape{helix/full front}{%
% \draw [shading=helix full front]
% (\xMid, \yLower + \yShift pt) --
@@ -1681,7 +1681,7 @@
% \yLower + 3 * \pmbdomvalueof{x unit} + \yShift pt) --
% cycle;
% }
-%
+%
% \begin{pmbdomains}[%
% show name=false, sequence=MGSKRSVPSR,
% x unit=2.5mm, enlarge top=1.5cm,
@@ -1702,17 +1702,17 @@
% \item For each subfeature, there is a corresponding shading (Table~\ref{tab:DomHelixHelperFeatures}b; see section~\ref{ssc:DocDomTexSecondaryStructure} and section~83 of the \TikZ\ manual for their definitions).
% \item These shadings use six colors in total, three for front and three for back shadings (Figure~\ref{fig:DomHelixColors}). For each color, there is a key of the same name, so you can change helix colors in feature style lists (Example~\ref{exa:DomHelixColors}).
% \end{enumerate}
-%
-%
+%
+%
% \section{File Input}
% \label{sec:DomFileInput}
-%
+%
% \begin{DescribeMacros}
% \Macro\inputuniprot{<Uniprot file>}
% \Macro\inputgff{<gff file>}
% \end{DescribeMacros}
% Include the features defined in an \meta{Uniprot file} or \meta{gff file}, respectively (Example~\ref{exa:DomInputExternalFiles}). These macros are only defined in |pmbdomains|.
-%
+%
% \begin{exampletable}[hb]
% \caption{}
% \label{exa:DomInputExternalFiles}
@@ -1729,22 +1729,22 @@
% \end{pmbdomains}
% \end{examplecode}
% \end{exampletable}
-%
+%
% \DescribeOption{domains/}{sequence length}{\textrm{(empty)}}<number>
% Note that in Example~\ref{exa:DomInputExternalFiles}, we had to set a sequence length for the |pmbdomains| environment that contains the |\inputgff| macro. \file{gff} files lack a sequence length field. By contrast, \pkg{pgfmolbio} reads the sequence length from an Uniprot file, and thus the mandatory argument of |pmbdomains| may remain empty. In general, the sequence length is stored in the key of the same name.
-%
-%
-%
+%
+%
+%
% \chapter{The \texorpdfstring{\module{convert}}{convert} module}
% \label{cha:Convert}
-%
%
+%
% \section{Overview}
% \label{sec:ConOverview}
-%
+%
% The \module{convert} module supports users who wish to include \pkg{pgfmolbio} graphs, but who do not want to typeset their documents with a \TeX\ engine that implements Lua. To this end, the \module{convert} workflow comprises two steps: (1) Running Lua\LaTeX\ on an input file that contains at least one |\pmbchromatogram| or similar macros/environments. This will generate one \file{tex} file per graph macro/environment that contains only \TikZ\ commands. (2) Including this file in another \TeX\ document (via |\input|) which is then processed by any \TeX\ engine that supports \TikZ.
-%
-%
+%
+%
% \section{Converting Chromatograms}
% \label{sec:ConChromatograms}
%
@@ -1752,7 +1752,7 @@
% \begin{lstlisting}[style=latex-expl,gobble=2]
% \documentclass{article}
% \usepackage[chromatogram,convert]{pgfmolbio}
-%
+%
% \begin{document}
% \pmbchromatogram[sample range=base 50-base 60]{SampleScf.scf}
% \pmbchromatogram[/pgfmolbio/convert/output file name=mytikzfile]%
@@ -1761,11 +1761,11 @@
% \end{document}
% \end{lstlisting}
% The \module{convert} module disables \file{pdf} output and introduces the following keys:
-%
+%
% \DescribeOption{convert/}{output file name}{(auto)}<text>\relax
% \DescribeOption{convert/}{output file extension}{tex}<text>\relax
% With the default value for \opt{output file name} (``|(auto)|''), \pkg{pgfmolbio} creates files that are named \file{pmbconverted} and numbered consecutively (\file{pmbconverted0.tex}, \file{pmbconverted1.tex} etc.). Both keys can be changed locally (e.\,g., in the optional argument of |\pmbchromatogram|), but this turns off automatic numbering.
-%
+%
% The code above produces the files \file{pmbconverted0.tex}, \file{mytikzfile.tex} and \file{pmbconverted2.tex}. Below is an annotated excerpt from \file{pmbconverted0.tex}:
% \begin{lstlisting}[style=latex-expl,gobble=2,escapeinside=`',basicstyle=\ttfamily\scriptsize,breaklines]
% \begin{tikzpicture}
@@ -1787,15 +1787,15 @@
% `[more ticks, base labels and probability rules]'
% \end{tikzpicture}
% \end{lstlisting}
-%
+%
% You can change the format of the coordinates by the following keys:
-%
+%
% \DescribeOption{}{coordinate unit}{mm}<unit>
% \DescribeOption{}{coordinate format string}{\letterpercent s\letterpercent s}<format string>\relax
% \pkg{pgfmolbio} internally calculates dimensions in scaled points, but usually converts them before returning them to \TeX. To this end, it selects the \meta{unit} stored in \opt{coordinate unit} (any of the standard \TeX\ units of measurement: \texttt{bp}, \texttt{cc}, \texttt{cm}, \texttt{dd}, \texttt{in}, \texttt{mm}, \texttt{pc}, \texttt{pt} or \texttt{sp}). In addition, the package formats the dimension according to the \meta{format string} given by \opt{coordinate format string}. This string basically follows the syntax of C's \texttt{printf} function, as described in the Lua reference manual. (Note: Use |\letterpercent| instead of \texttt{\%}, since \TeX\ treats anything following a percent character as comment.)
-%
+%
% Depending on the values of \opt{coordinate unit} and \opt{coordinate format string}, dimensions will be printed in different ways (Table~\ref{tab:CoordFormat}).
-%
+%
% \begin{table}
% \centering
% \caption{Effects of \texttt{\color{opt}coordinate unit} and \texttt{\color{opt}coordinate format string} when converting an internal \pkg{pgfmolbio} dimension of 200000~[sp].}
@@ -1811,20 +1811,20 @@
% \bottomrule
% \end{tabularx}
% \end{table}
-%
+%
% \bigskip
% The output files can be included in a file which is processed by pdf\LaTeX:
% \begin{lstlisting}[style=latex-expl,gobble=2]
% \documentclass{article}
% \usepackage[chromatogram]{pgfmolbio}
-%
+%
% \begin{document}
% \input{pmbconverted.tex}
% \end{document}
% \end{lstlisting}
-%
+%
% Several keys of the \module{chromatogram} module must contain their final values before conversion, while others can be changed afterwards, i.\,e., before the generated file is loaded with |\input| (Table~\ref{tab:ConvertChrKeys}).
-%
+%
% \begin{table}[ht]
% \centering
% \caption{Keys of the \module{chromatogram} module that require final values prior to conversion.}
@@ -1845,19 +1845,19 @@
% \bottomrule
% \end{tabular}
% \end{table}
-%
-%
+%
+%
% \section{Converting Domain Diagrams}
% \label{sec:ConDomains}
-%
+%
% \DescribeOption{convert/}{output code}{tikz}'pgfmolbio | tikz'
% In principle, domain diagrams are converted like sequencing chromatograms (section~\ref{sec:ConChromatograms}). However, \opt{output code} lets you choose the kind of code \module{convert} writes to the output file: |pgfmolbio| generates a |pmbdomains| environment containing |\addfeature| commands, |tikz| produces \TikZ\ code.
-%
+%
% ``Converting'' one |pmbdomains| environment in the input file to another one in the output file might seem pointless. Nonetheless, this conversion mechanism can be highly useful for extracting features from a Uniprot or \file{gff} file. For example, consider the following input file:
% \begin{lstlisting}[style=latex-expl,gobble=2]
% \documentclass{article}
% \usepackage[domains,convert]{pgfmolbio}
-%
+%
% \begin{document}
% \pgfmolbioset[convert]{output code=pgfmolbio}
% \begin{pmbdomains}{}
@@ -1885,7 +1885,7 @@
% \end{pmbdomains}
% \end{lstlisting}
% Obviously, this method is particularly suitable for Uniprot files containing many features.
-%
+%
% \DescribeOption{convert/}{include description}{true}<boolean>
% Decides whether the feature description obtained from the input should appear in the output. Since the description field in FT entries of Uniprot files can be quite long, you may not wish to show it in the output. For example, the output of the example above with \opt{include description}|=false| looks like
% \begin{lstlisting}[style=latex-expl,gobble=2,escapeinside=`']
@@ -1898,7 +1898,7 @@
% `[...]'
% \end{pmbdomains}
% \end{lstlisting}
-%
+%
% \bigskip
% With \opt{output code}|=tikz|, we obtain the following (annotated) output file:
% \begin{lstlisting}[style=latex-expl,gobble=2,escapeinside=`',basicstyle=\ttfamily\scriptsize,breaklines]
@@ -1969,9 +1969,9 @@
% \pmbprotocolsizes{100mm + \pmbdomvalueof{enlarge right}}{-0mm + \pmbdomvalueof{enlarge bottom}}
% \end{tikzpicture}
% \end{lstlisting}
-%
+%
% Several keys of the \module{domains} module must contain their final values before conversion, and some macros can't be used afterwards (Table~\ref{tab:ConvertDomKeysAndMacros}).
-%
+%
% \begin{table}[ht]
% \caption{Keys and macros of the \module{domain} module that require final values prior to conversion or can't be used afterwards, respectively.}
% \label{tab:ConvertDomKeysAndMacros}\small
@@ -2003,8 +2003,8 @@
% \bottomrule
% \end{tabular}\hspace*{-53pt}
% \end{table}
-%
-%
+%
+%
% \StopEventually{}
% \chapter{Implementation}
% \label{cha:Implementation}
@@ -2105,11 +2105,11 @@
%</pgfmolbio-tex>
%<*pgfmolbio-lua>
% \fi
-%
-%
+%
+%
% \section{\texorpdfstring{\file{pgfmolbio.lua}}{pgfmolbio.lua}}
% \label{sec:DocPkgLua}
-%
+%
% \def\ydoclistingssettings{\lstset{style=lua-doc}}\setcounter{lstnumber}{1}
% Identification of the Lua module.
% \begin{macrocode}
@@ -2116,11 +2116,11 @@
if luatexbase then
luatexbase.provides_module({
name = "pgfmolbio",
- version = 0.2,
- date = "2012/10/01",
+ version = "0.21a",
+ date = "2014/06/17",
description = "Molecular biology graphs wit LuaLaTeX",
- author = "Wolfgang Skala",
- copyright = "Wolfgang Skala",
+ author = "Wolfgang Esser-Skala",
+ copyright = "Wolfgang Esser-Skala",
license = "LPPL",
})
end
@@ -2201,7 +2201,7 @@
%
% \def\ydoclistingssettings{\lstset{style=latex-doc}}\setcounter{lstnumber}{1}
% Since the Lua script of the \module{chromatogram} module does the bulk of the work, we can keep the \TeX\ file relatively short.
-%
+%
% \begin{macrocode}
\ifluatex
\RequireLuaModule{pgfmolbio.chromatogram}
@@ -2417,16 +2417,16 @@
% \label{sec:DocChrLua}
%
% \def\ydoclistingssettings{\lstset{style=lua-doc}}\setcounter{lstnumber}{1}
-% This Lua script is the true workhorse of the \module{chromatogram} module. Remember that the documentation for the Staden package\footnote{\url{http://staden.sourceforge.net/}} is the definite source for information on the \file{scf} file format.
+% This Lua script is the true workhorse of the \module{chromatogram} module. Remember that the documentation for the Staden package\footnote{\url{https://staden.sourceforge.net/}} is the definite source for information on the \file{scf} file format.
% \begin{macrocode}
if luatexbase then
luatexbase.provides_module{
name = "pgfmolbio.chromatogram",
- version = 0.2,
- date = "2012/10/01",
+ version = "0.21a",
+ date = "2014/06/17",
description = "DNA sequencing chromatograms",
- author = "Wolfgang Skala",
- copyright = "Wolfgang Skala",
+ author = "Wolfgang Esser-Skala",
+ copyright = "Wolfgang Esser-Skala",
license = "LPPL",
}
end
@@ -2497,10 +2497,10 @@
end
% \end{macrocode}
-%
+%
% \subsection{The \texorpdfstring{\texttt{Chromatogram}}{Chromatogram} Class}
% \label{ssc:DocChrLuaClass}
-%
+%
% The §Chromatogram§ class (table) represents a single \file{scf} chromatogram. The constructor §Chromatogram:new§ returns a new instance and initializes its variables, which store the values of \module{chromatogram} keys. Most variables are self-explanatory, since their name is similar to their corresponding key.
% \begin{macrocode}
Chromatogram = {}
@@ -2578,7 +2578,7 @@
% \begin{macrocode}
function Chromatogram:getSampleAndPeakIndex(baseIndex, isLowerLimit)
local sampleId, peakId
-
+
sampleId = tonumber(baseIndex)
if sampleId then
for i, v in ipairs(self.peaks) do
@@ -2610,7 +2610,7 @@
%
% \subsection{Read the \texorpdfstring{\file{scf}}{scf} File}
% \label{ssc:DocChrLuaReadScfFile}
-%
+%
% §Chromatogram:readScfFile§ introduces three further fields to §Chromatogram§:
% \begin{itemize}
% \item §header§: A table of 14 named number fields that save the information in the \file{scf} header.
@@ -2622,7 +2622,7 @@
% \item §base§: A string that states the base represented by the current peak.
% \end{itemize}
% \end{itemize}
-%
+%
% §Chromatogram:readScfFile§ checks whether the requested \file{scf} file ``§filename§'' corresponds to the most recently opened one (via §lastScfFile§). In this case, the variables §peaks§ and §samples§ already contain the relevant data, so we can refrain from re-reading the file. Otherwise, the program tries to open and evaluate the specified file, raising an error on failure.
% \begin{macrocode}
function Chromatogram:readScfFile(filename)
@@ -2725,7 +2725,7 @@
for i = 1, self.header.basesNumber do
self.peaks[i].base = string.char(readInt(scfFile, 1))
end
-
+
scfFile:close()
end
end
@@ -2815,7 +2815,7 @@
end
% \end{macrocode}
-%
+%
% \subsection{Print the Chromatogram}
% \label{ssc:DocChrLuaPrint}
%
@@ -2856,7 +2856,7 @@
tIndex = tIndex + 1
end
end
-
+
% \end{macrocode}
% Furthermore, we adjust §baseNumberMin§ and §baseNumberMax§ if any peak was detected in the displayed part of the chromatogram. The value §-1§, which indicates the keyword |auto|, is replaced by the index of the first or last peak, respectively.
% \begin{macrocode}
@@ -2868,7 +2868,7 @@
self.baseNumberMax = self.selectedPeaks[tIndex-1].baseIndex
end
end
-
+
% \end{macrocode}
% \paragraph{(2) Canvas} For each line, we draw a rectangle in \opt{canvas style} whose left border coincides with the $y$-axis.\\
% §yLower§, §yUpper§, §xRight§: rectangle coordinates;\\
@@ -2896,7 +2896,7 @@
samplesLeft = samplesLeft - self.samplesPerLine
currLine = currLine + 1
end
-
+
% \end{macrocode}
% \paragraph{(3) Traces} The traces in §tracesDrawn§ are drawn sequentially.\\
% §currSampleIndex§: original $x$-coordinate of a sample point;\\
@@ -2913,7 +2913,7 @@
local y = 0
local currLine = 0
local firstPointInLine = true
-
+
% \end{macrocode}
% We iterate over each sample point. As long as the current sample point is within the selected range, we calculate the real coordinates of the sample point; add the lineto operator |--| if at least one sample point has already appeared in the current line; and write the point to the \TeX\ input stream.
% \begin{macrocode}
@@ -2951,7 +2951,7 @@
currSampleIndex = currSampleIndex + 1
end
end
-
+
% \end{macrocode}
% \paragraph{(4) Annotations} We iterate over each selected peak and start by finding the line in which the first peak resides.\\
% §currLine§: current line, starting at 0;\\
@@ -2976,7 +2976,7 @@
if self.ticksDrawn:upper():find(currPeak.base) then
tickOperation = "--"
end
-
+
% \end{macrocode}
% \paragraph{(4a) Ticks and labels} Having calculated all coordinates, we draw the tick and the base label, given the latter has been specified by \opt{base labels drawn}.
% \begin{macrocode}
@@ -3022,9 +3022,9 @@
)
end
tex.sprint(";")
-
+
% \end{macrocode}
-% \paragraph{(4c) Probabilities} First, we draw the remainder of the last probability rule. Such a remainder has been stored in §probRemainder§ if the last rule had protruded into the right margin (see below). Furthermore, we determine if a probability rule should appear beneath the current peak.
+% \paragraph{(4c) Probabilities} First, we draw the remainder of the last probability rule. Such a remainder has been stored in §probRemainder§ if the last rule had protruded into the right margin (see below). Furthermore, we determine if a probability rule should appear beneath the current peak.
% \begin{macrocode}
if probRemainder then
tex.sprint(probRemainder)
@@ -3059,7 +3059,7 @@
else
xLeft = xLeft * self.xUnit
end
-
+
% \end{macrocode}
% \textit{Secondly}, the probability rule ends in the right margin of the current line (i.\,e., §xRight§ at least equals §samplesPerLine§). This means that the part protruding into the right margin must instead appear at the start of the following line. Therefore, we calculate the coordinates of this part (storing them in §xRightNext§ and §yNext§) and save the drawing command in §probRemainder§ (whose contents were printed above). Since the remainder of the rule necessarily ends at the right border of the current line, we set §xRight§ to this coordinate.
% \begin{macrocode}
@@ -3085,7 +3085,7 @@
else
xRight = xRight * self.xUnit
end
-
+
% \end{macrocode}
% \textit{Thirdly}, the probability rule starts and ends within the boundaries of the current line. In this lucky case, the $y$-coordinate is the only one missing, since we previously calculated §xLeft§ (case~1) and §xRight§ (case~2). Drawing of the probability rule proceeds as usual.
% \begin{macrocode}
@@ -3113,11 +3113,11 @@
%</pmb-chr-lua>
%<*pmb-dom-tex>
% \fi
-%
-%
+%
+%
% \section{\texorpdfstring{\file{pgfmolbio.domains.tex}}{pgfmolbio.domains.tex}}
% \label{sec:DocDomTex}
-%
+%
% \def\ydoclistingssettings{\lstset{style=latex-doc}}\setcounter{lstnumber}{1}
% \begin{macrocode}
\ProvidesFile{pgfmolbio.domains.tex}[2012/10/01 v0.2 Protein Domains]
@@ -3131,10 +3131,10 @@
\fi
% \end{macrocode}
-%
+%
% \subsection{Keys}
% \label{ssc:DocDomTexKeys}
-%
+%
% \begin{macro}{\@pmb at dom@keydef}[2]{\meta{key} name}{default \meta{value}}
% |\@pmb at dom@keydef| declares a \meta{key} in path |/pgfmolbio/domains| and assigns a default \meta{value}.
% \begin{macrocode}
@@ -3224,10 +3224,10 @@
\@pmb at dom@keydef{@layer}{}
% \end{macrocode}
-%
+%
% \subsection{Feature Shapes}
% \label{ssc:DocDomTexFeatureShapes}
-%
+%
% \begin{macro}{\setfeatureshape}[2]{Shape \meta{name}.}{\TikZ\ \meta{code}.}
% Stores the \meta{code} for a shape in the macro |\@pmb at dom@feature@|\meta{name}|@shape|.
% \begin{macrocode}
@@ -3411,7 +3411,7 @@
}%
\pgfmathsetmacro\xUpperLeft{\xMid - \pmb at magnifiedsequence@width / 2}
\pgfmathsetmacro\xUpperRight{\xMid + \pmb at magnifiedsequence@width / 2}
-
+
\draw [/pgfmolbio/domains/current style]
(\xLeft, \yMid) --
(\xLeft, \yMid + \pmbdomvalueof{y unit} / 6) --
@@ -3435,7 +3435,7 @@
}%
\pgfmathsetmacro\xLowerLeft{\xMid - \pmb at magnifiedsequence@width / 2}
\pgfmathsetmacro\xLowerRight{\xMid + \pmb at magnifiedsequence@width / 2}
-
+
\draw [/pgfmolbio/domains/current style]
(\xLeft, \yMid) --
(\xLeft, \yMid - \pmbdomvalueof{y unit} / 6) --
@@ -3452,10 +3452,10 @@
% \end{macrocode}
-%
+%
% \subsection{Secondary Structure Elements}
% \label{ssc:DocDomTexSecondaryStructure}
-%
+%
% \begin{macro}{\@pmb at dom@helixsegment}[1]{Scale factor for \TikZ's \texttt{svg} action.}
% Draws a full helix segment at the current canvas position. We use the (unusual) \file{svg} syntax since the helix segment was designed in Inkscape, and the \file{svg} commands were copied from the resulting vector graphics file.
% \begin{macrocode}
@@ -3743,10 +3743,10 @@
% \end{macrocode}
-%
+%
% \subsection{Adding Features}
% \label{ssc:DocDomTexAddingFeatures}
-%
+%
% \begin{macro}{\pmb at dom@inputuniprot}[1]{The \meta{name} of a Uniprot file.}
% |\pmb at dom@inputuniprot| reads some attributes and all features from a Uniprot file (§readUniprotFile§, section~\ref{ssc:DocDomLuaReadFiles}). It then updates some keys of the \module{domains} module (§getParameters§, section~\ref{ssc:DocDomLuaParameters}) and then passes the value of \opt{residue numbering} to the §pmbProtein§ object.
% \begin{macrocode}
@@ -3798,10 +3798,10 @@
% \end{macrocode}
% \end{macro}
-%
+%
% \subsection{The Main Environment}
% \label{ssc:DocDomTexMainEnvironment}
-%
+%
% % \begin{environment}{pmbdomains}[2]{A \ometa{key-value list} that configures the domain diagram.}{The \meta{sequence length}.}
% If |pmbdomains| appears outside of a |tikzpicture|, we implicitly start this environment, otherwise we begin a new group. ``Within a |tikzpicture|'' means that |\useasboundingbox| is defined. The \ometa{key-value list} is processed.
% \begin{macrocode}
@@ -3914,10 +3914,10 @@
% \end{macrocode}
% \end{environment}
-%
+%
% \subsection{Feature Styles}
% \label{ssc:DocDomTexFeatureStyles}
-%
+%
% \begin{macro}{\setdisulfidefeatures}[1]{A list of \meta{features}.}
% Clears the list of disulfide-like features and adds the \meta{features} to the empty list. Disulfide-like features are arranged in non-overlapping layers (section~\ref{sec:DomDisulfides}). Depending on whether this macro appears inside a |pmbdomains| environment or not, the appropriate methods of either §pmbProtein.specialKeys§ or §pmbSpecialKeys§ are called, respectively.
% \begin{macrocode}
@@ -4008,7 +4008,7 @@
{pgfmolbio.domains.printHelixFeature}
% \end{macrocode}
-%
+%
% \begin{macro}{\setfeaturestyle}[2]{A \meta{feature} name.}{A \meta{style list}.}
% Sets the style of a \meta{feature} to the style described in the \meta{style list}. Note that the contents of \meta{style list} are passed to the Lua function without expansion (via the token register |\@pmb at toksa|).
% \begin{macrocode}
@@ -4071,27 +4071,27 @@
\setfeaturestyle{beta bridge}{*1{fill=MediumBlue}}
\setfeaturestyle{bend}{*1{draw=magenta, thick}}
% \end{macrocode}
-%
+%
% \iffalse
%</pmb-dom-tex>
%<*pmb-dom-lua>
% \fi
-%
-%
-%
+%
+%
+%
% \section{\texorpdfstring{\file{pgfmolbio.domains.lua}}{pgfmolbio.domains.lua}}
% \label{sec:DocDomLua}
-%
+%
% \def\ydoclistingssettings{\lstset{style=lua-doc}}\setcounter{lstnumber}{1}
% \begin{macrocode}
if luatexbase then
luatexbase.provides_module({
name = "pgfmolbio.domains",
- version = 0.2,
- date = "2012/10/01",
+ version = "0.21a",
+ date = "2014/06/17",
description = "Domain graphs",
- author = "Wolfgang Skala",
- copyright = "Wolfgang Skala",
+ author = "Wolfgang Esser-Skala",
+ copyright = "Wolfgang Esser-Skala",
license = "LPPL",
})
end
@@ -4106,10 +4106,10 @@
local getRange = pgfmolbio.getRange
% \end{macrocode}
-%
+%
% \subsection{Predefined Feature Print Functions}
% \label{ssc:DocDomLuaPrintFunctions}
-%
+%
% §printSequenceFeature§ prints the letters of a sequence between the $x$-coordinates §xLeft§ and §xRight§.
% \begin{macrocode}
function printSequenceFeature(feature, xLeft, xRight, yMid, xUnit, yUnit)
@@ -4124,13 +4124,13 @@
end
% \end{macrocode}
-%
+%
% §printHelixFeature§ prints a helix feature between the $x$-coordinates §xLeft§ and §xRight§.
% \begin{macrocode}
function printHelixFeature(feature, xLeft, xRight, yMid, xUnit, yUnit)
local residuesLeft, currX
tex.sprint("\n\t\t\\pgfmolbioset[domains]{current style}")
-
+
% \end{macrocode}
% \textit{Firstly}, three different background parts are drawn: one \texttt{half upper back} at the left, zero or more \texttt{full back} in the middle and possibly one \texttt{half lower back} at the right.
% \begin{macrocode}
@@ -4141,7 +4141,7 @@
tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/half upper back}")
residuesLeft = residuesLeft - 2
currX = currX + 2.5
-
+
while residuesLeft > 0 do
if residuesLeft == 1 then
tex.sprint(
@@ -4163,7 +4163,7 @@
residuesLeft = residuesLeft - 2
currX = currX + 2
end
-
+
% \end{macrocode}
% \textit{Secondly}, two different foreground parts are drawn: at least one \texttt{full front} at the left and in the middle, and possibly one \texttt{half upper front} at the right.
% \begin{macrocode}
@@ -4193,12 +4193,12 @@
end
% \end{macrocode}
-%
+%
% \subsection{The \texorpdfstring{\texttt{SpecialKeys}}{SpecialKeys} Class}
% \label{ssc:DocDomLuaSpecialKeysClass}
-%
+%
% The §SpecialKeys§ class contains three member variables: §disulfideKeys§ (a list of keys that indicate disulfide-like features, like \texttt{disulfide}), §featureStyles§ (a list of feature styles) and §printFunctions§ (a list of keys associated with a feature print function, like \texttt{alpha helix}). Furthermore, it provides methods to manipulate these fields.
-%
+%
% The constructor §SpecialKeys:new§ generates a new §SpecialKeys§ object and initializes it with values from §parms§.
% \begin{macrocode}
SpecialKeys = {}
@@ -4210,13 +4210,13 @@
featureStyles = {},
printFunctions = {}
}
-
+
for keyList, listContents in pairs(parms) do
for key, value in pairs(listContents) do
newSpecialKeys[keyList][key] = value
end
end
-
+
setmetatable(newSpecialKeys, self)
self.__index = self
return newSpecialKeys
@@ -4233,12 +4233,12 @@
end
% \end{macrocode}
-%
+%
% §SpecialKeys:setFeatureStyle§ parses the style list §style§ and associates it with a certain §key§. In Lua, a style list is an array of tables. Each table contains the fields §cycles§ and §style§. §cycles§ determines how often the §style§ (a string suitable for the mandatory argument of |\pgfmolbioset|) is to be used. In addition, an optional field §alias§ contains a reference to another key, if the current key is an alias of it (see below).
% \begin{macrocode}
function SpecialKeys:setFeatureStyle(key, style)
local newStyleList, styleCycles, styleContents
-
+
newStyleList = {}
while style ~= "" do
styleCycles = 1
@@ -4333,7 +4333,7 @@
%
% \subsection{The \texorpdfstring{\texttt{Protein}}{Protein} Class}
% \label{ssc:DocDomLuaProteinClass}
-%
+%
% The §Protein§ class represents a domain diagram in Lua. Its member variables largely correspond to the keys of the \module{domains} module. In detail:
% \begin{itemize}
% \item §sequenceLength§: A value of §-1§ indicates that the sequence length has not been properly set.
@@ -4351,7 +4351,7 @@
% \item §currentStyle§: A table whose field names equal feature keys. Each field denotes the index of the style that was last selected from that feature's style list.
% \item §includeDescription§: This boolean field remains uninitialized. Instead, it is directly set in \file{pgfmolbio.domains.tex} if the \module{convert} module is loaded and the user requests a string representation of a §Protein§ object (section~\ref{ssc:DocDomLuaTostring}).
% \end{itemize}
-%
+%
% The constructor §Protein:new§ initializes the member variables with default values.
% \begin{macrocode}
Protein = {}
@@ -4398,11 +4398,11 @@
end
% \end{macrocode}
-%
+%
% \subsection{Uniprot and GFF Files}
% \label{ssc:DocDomLuaReadFiles}
-%
-% §Protein:readUniprotFile§ reads the relevant parts of Uniprot file §filename§\footnote{For a detailed description of this format, see \url{http://web.expasy.org/docs/userman.html}.}.
+%
+% §Protein:readUniprotFile§ reads the relevant parts of Uniprot file §filename§\footnote{For a detailed description of this format, see \url{https://web.expasy.org/docs/userman.html}.}.
% \begin{macrocode}
function Protein:readUniprotFile(filename)
local uniprotFile, errorMsg = io.open(filename, "r")
@@ -4476,12 +4476,12 @@
end
% \end{macrocode}
-% §Protein:readGffFile§ reads the relevant parts of General Feature Format file §filename§\footnote{For a detailed description of this format, see \url{http://http://www.sanger.ac.uk/resources/software/gff/spec.html}.}.
+% §Protein:readGffFile§ reads the relevant parts of General Feature Format file §filename§\footnote{\url{https://en.wikipedia.org/wiki/General_feature_format}}.
% \begin{macrocode}
function Protein:readGffFile(filename)
local gffFile, errorMsg = io.open(filename, "r")
local lineContents, fields, lineNumber
-
+
if not gffFile then packageError(errorMsg) end
% \end{macrocode}
% Each line in a \file{gff} file describes a feature and consists of up to 9 tabulator-separated fields, of which only fields 3 (key), 4 (start) and 5 (end) are required for the \module{domains} module. Everything following the comment sign (|#|) on a line is ignored.
@@ -4514,10 +4514,10 @@
end
% \end{macrocode}
-%
+%
% \subsection{Getter and Setter Methods}
% \label{ssc:DocDomLuaParameters}
-%
+%
% §Protein:getParameters§ informs \TeX\ of the protein name, sequence and sequence length. This method is called after reading a Uniprot file (section~\ref{ssc:DocDomTexAddingFeatures}).
% \begin{macrocode}
function Protein:getParameters()
@@ -4617,7 +4617,7 @@
packageError("Invalid residue range: " .. residueRangeMin)
end
end
-
+
if residueRangeMax == "auto" then
self.residueRangeMax = self.sequenceLength
else
@@ -4630,7 +4630,7 @@
packageError("Invalid residue range: " .. residueRangeMax)
end
end
-
+
if self.residueRangeMin >= self.residueRangeMax then
packageError("Residue range is smaller than 1.")
end
@@ -4656,7 +4656,7 @@
rulerRangeMin, rulerRangeMax, rulerRangeStep =
getRange(value:trim(), "^([%w%(%)]+)",
"%-%s*([%w%(%)]+)", "step%s*(%d+)$")
-
+
if rulerRangeMin == "auto" then
rulerRangeMin = self.residueRangeMin
else
@@ -4669,7 +4669,7 @@
packageError("Invalid lower ruler range: " .. rulerRangeMin)
end
end
-
+
if rulerRangeMax then
if rulerRangeMax == "auto" then
rulerRangeMax = self.residueRangeMax
@@ -4683,7 +4683,7 @@
packageError("Invalid upper ruler range: " .. rulerRangeMax)
end
end
-
+
if rulerRangeMin >= rulerRangeMax then
packageError("Ruler range is smaller than 1.")
end
@@ -4708,7 +4708,7 @@
end
rulerRangeStep = tonumber(rulerRangeStep)
or self.defaultRulerStepSize
-
+
for i = rulerRangeMin, rulerRangeMax, rulerRangeStep do
table.insert(
ranges,
@@ -4737,15 +4737,15 @@
end
% \end{macrocode}
-%
+%
% \subsection{Adding Feature}
% \label{ssc:DocDomLuaAddFeature}
-%
+%
% §Protein:addFeature§ converts raw feature information to the format of §ft§ fields (described in section~\ref{ssc:DocDomLuaProteinClass}). Firstly, the method determines the index of the style that should be used for the current feature.
% \begin{macrocode}
function Protein:addFeature(newFeature)
local baseKey, ftEntry
-
+
baseKey = self.specialKeys:getBaseKey(newFeature.key)
if self.currentStyle[baseKey] then
self.currentStyle[baseKey] = self.currentStyle[baseKey] + 1
@@ -4780,10 +4780,10 @@
end
% \end{macrocode}
-%
+%
% \subsection{Calculate Disulfide Levels}
% \label{ssc:DocDomLuaDisulfideLevels}
-%
+%
% §Protein:calculateDisulfideLevels§ arranges disulfide-like features in non-\hskip0ptoverlapping levels.
% \begin{macrocode}
function Protein:calculateDisulfideLevels()
@@ -4790,7 +4790,7 @@
if pgfmolbio.errorCatched then return end
local disulfideGrid, currLevel, levelFree
disulfideGrid = {}
-
+
for i, v in ipairs(self.ft) do
if self.specialKeys.disulfideKeys[v.key] then
% \end{macrocode}
@@ -4840,10 +4840,10 @@
end
% \end{macrocode}
-%
+%
% \subsection{Print Domains}
% \label{ssc:DocDomLuaPrintTikzDomains}
-%
+%
% §Protein:printTikzDomains§ is the heart of the Lua script, since it converts a §Protein§ object to \TeX\ code.
% \begin{macrocode}
function Protein:printTikzDomains()
@@ -4850,7 +4850,7 @@
if pgfmolbio.errorCatched then return end
local xLeft, xMid, xRight, yMid, xLeftClip, xRightClip,
currLine, residuesLeft, currStyle
-
+
% \end{macrocode}
% \paragraph{(1) Features (excluding \texttt{other/ruler} and \texttt{other/name})} For each feature in the feature table, we first calculate its coordinates (§xLeft§, §xMid§, §xRight§ and §yMid§) and clipped areas (§xLeftClip§, §xRightClip§).
% \begin{macrocode}
@@ -4869,7 +4869,7 @@
currLine * self.residuesPerLine + 1
xLeftClip = stringToDim("-5cm")
xRightClip = self.residuesPerLine * self.xUnit
-
+
if currFeature.start <= self.residueRangeMax
and currFeature.stop >= self.residueRangeMin then
repeat
@@ -4885,7 +4885,7 @@
end
end
if xLeft < 0 then xLeftClip = stringToDim("0cm") end
-
+
xMid = (xLeft + xRight) / 2
yMid = -currLine * self.baselineSkip
% \end{macrocode}
@@ -4897,7 +4897,7 @@
end
currFeature.sequence =
self.sequence:sub(currFeature.start, currFeature.stop)
-
+
% \end{macrocode}
% Each feature appears within its own |scope|. A |pgfinterruptboundingbox| ensures that the bounding box of the picture ignores the feature, since the |\clip| macro would enlarge it too much. Auxiliary macros for |\setfeatureshape| are defined (section~\ref{sec:DomFeatureStylesAndShapes}).
% \begin{macrocode}
@@ -4939,7 +4939,7 @@
currFeature.key .. "}")
end
tex.sprint("\n\t\\end{pgfinterruptboundingbox}\\end{scope}")
-
+
% \end{macrocode}
% Calculate coordinates for the next line of the feature.
% \begin{macrocode}
@@ -4950,7 +4950,7 @@
until xRight < 1 or residuesLeft < 1
end
end
-
+
% \end{macrocode}
% \paragraph{(2) Feature \texttt{other/ruler}} The ruler requires special treatment, buth the algorithm is actually simple: For each marker, calculate its coordinates, select its style and print it.
% \begin{macrocode}
@@ -4984,7 +4984,7 @@
end
tex.sprint("\n\t\\end{scope}")
end
-
+
% \end{macrocode}
% \paragraph{(3) Feature \texttt{other/name}} Similarly, we calculate the coordinates of the name and print it.
% \begin{macrocode}
@@ -5006,7 +5006,7 @@
tex.sprint("\n\t\t\\def\\yMid{0mm}")
tex.sprint("\n\t\t\\pmbdomdrawfeature{other/name}")
tex.sprint("\n\t\\end{scope}")
-
+
% \end{macrocode}
% \paragraph{(4) Set bounding box} The bounding box is determined manually in order to prevent excessive enlargement due to clipping. The top left corner of the bounding box is the coordinate (|enlarge left|, |enlarge top|).
% \begin{macrocode}
@@ -5031,22 +5031,22 @@
"\n\t\\pmbprotocolsizes{" ..
dimToString(xRight * self.xUnit) ..
" + \\pmbdomvalueof{enlarge right}}{" ..
- dimToString(-currLine * self.baselineSkip * self.yUnit) ..
+ dimToString(-currLine * self.baselineSkip * self.yUnit) ..
" + \\pmbdomvalueof{enlarge bottom}}"
)
end
% \end{macrocode}
-%
+%
% \subsection{Converting a \texorpdfstring{\texttt{Protein}}{Protein} to a String}
% \label{ssc:DocDomLuaTostring}
-%
+%
% §Protein:__tostring§ is required by the \module{convert} module and returns a |pmbdomains| environment that contains all the information stored in the §Protein§ object (section~\ref{sec:ConDomains}). Firstly, we start the environment.
% \begin{macrocode}
function Protein:__tostring()
local result = {}
local currLine
-
+
currLine = "\\begin{pmbdomains}\n\t\t[name={" ..
self.name ..
"}"
@@ -5055,7 +5055,7 @@
",\n\t\tsequence=" ..
self.sequence
end
- currLine = currLine ..
+ currLine = currLine ..
"]{" ..
self.sequenceLength ..
"}"
@@ -5095,17 +5095,17 @@
return table.concat(result, "\n")
end
% \end{macrocode}
-%
+%
% \iffalse
%</pmb-dom-lua>
%<*pmb-con-tex>
% \fi
-%
-%
-%
+%
+%
+%
% \section{\texorpdfstring{\file{pgfmolbio.convert.tex}}{pgfmolbio.convert.tex}}
% \label{sec:DocConTex}
-%
+%
% \def\ydoclistingssettings{\lstset{style=latex-doc}}\setcounter{lstnumber}{1}
% The code for the \module{convert} module is short: We only need to declare four options and set |\pdfdraftmode| to 1 in order to prevent pdf\TeX\ from producing any \file{pdf} output.
% \begin{macrocode}
@@ -5132,4 +5132,4 @@
% \fi
%
% \Finale
-\endinput
\ No newline at end of file
+\endinput
Modified: trunk/Master/texmf-dist/source/lualatex/pgfmolbio/pgfmolbio.ins
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/pgfmolbio/pgfmolbio.ins 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/source/lualatex/pgfmolbio/pgfmolbio.ins 2024-06-17 20:11:59 UTC (rev 71551)
@@ -1,19 +1,17 @@
% pgfmolbio.ins
%%
-%% Copyright (C) 2013 by Wolfgang Skala
+%% Copyright (C) 2024 by Wolfgang Esser-Skala
%%
%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either version 1.3
+%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of LaTeX
-%% version 2005/12/01 or later.
+%% https://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008/05/04 or later.
%%
-%% This work has the LPPL maintenance status `maintained'.
+%% This work has the LPPL maintenance status `unmaintained'.
%%
-%% The Current Maintainer of this work is Wolfgang Skala.
-%%
%% This work consists of the files pgfmolbio.dtx and pgfmolbio.ins
%% and the derived files pgfmolbio.sty, pgfmolbio.chromatogram.tex
%% and pgfmolbio.chromatogram.lua.
@@ -25,15 +23,15 @@
\preamble
-Copyright (C) 2013 by Wolfgang Skala
+Copyright (C) 2024 by Wolfgang Esser-Skala
This work may be distributed and/or modified under the
-conditions of the LaTeX Project Public License, either version 1.3
+conditions of the LaTeX Project Public License, either version 1.3c
of this license or (at your option) any later version.
The latest version of this license is in
- http://www.latex-project.org/lppl.txt
-and version 1.3 or later is part of all distributions of LaTeX
-version 2005/12/01 or later.
+ https://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2008/05/04 or later.
\endpreamble
@@ -43,15 +41,15 @@
-- generated with the docstrip utility.^^J%
\ReferenceLines%
--^^J%
--- Copyright (C) 2013 by Wolfgang Skala^^J%
+-- Copyright (C) 2024 by Wolfgang Esser-Skala^^J%
--^^J%
-- This work may be distributed and/or modified under the^^J%
--- conditions of the LaTeX Project Public License, either version 1.3^^J%
+-- conditions of the LaTeX Project Public License, either version 1.3c^^J%
-- of this license or (at your option) any later version.^^J%
-- The latest version of this license is in^^J%
--- \space\space http://www.latex-project.org/lppl.txt^^J%
--- and version 1.3 or later is part of all distributions of LaTeX^^J%
--- version 2005/12/01 or later.^^J%
+-- \space\space https://www.latex-project.org/lppl.txt^^J%
+-- and version 1.3c or later is part of all distributions of LaTeX^^J%
+-- version 2008/05/04 or later.^^J%
--}
\edef\luapostamble{%
Deleted: trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.lua 2024-06-17 20:11:59 UTC (rev 71551)
@@ -1,562 +0,0 @@
---
--- This is file `pgfmolbio.chromatogram.lua',
--- generated with the docstrip utility.
---
--- The original source files were:
---
--- pgfmolbio.dtx (with options: `pmb-chr-lua')
---
--- Copyright (C) 2013 by Wolfgang Skala
---
--- This work may be distributed and/or modified under the
--- conditions of the LaTeX Project Public License, either version 1.3
--- of this license or (at your option) any later version.
--- The latest version of this license is in
--- http://www.latex-project.org/lppl.txt
--- and version 1.3 or later is part of all distributions of LaTeX
--- version 2005/12/01 or later.
---
-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 stringToDim = pgfmolbio.stringToDim
-local dimToString = pgfmolbio.dimToString
-local packageError = pgfmolbio.packageError
-local packageWarning = pgfmolbio.packageWarning
-local getRange = pgfmolbio.getRange
-
-local function stdProbStyle(prob)
- local color = ""
- if prob >= 0 and prob < 10 then
- color = "black"
- elseif prob >= 10 and prob < 20 then
- color = "pmbTraceRed"
- elseif prob >= 20 and prob < 30 then
- color = "pmbTraceYellow"
- else
- color = "pmbTraceGreen"
- end
- return "ultra thick, " .. color
-end
-
-local function findBasesInStr(target)
- if not target then return end
- local result = {}
- for _, v in ipairs(ALL_BASES) do
- if target:upper():find(v) then
- table.insert(result, v)
- end
- end
- return result
-end
-
-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(self.selectedPeaks) do
- for __, currProb in pairs(currPeak.prob) do
- if currProb > maxProb then maxProb = currProb end
- if currProb < minProb then minProb = currProb end
- end
- end
- return minProb, maxProb
-end
-
-function Chromatogram:getSampleAndPeakIndex(baseIndex, isLowerLimit)
- local sampleId, peakId
-
- 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 sampleId, peakId
-end
-
-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, 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
- end
- 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, self.header.basesNumber do
- self.peaks[i].prob.A = readInt(scfFile, 1)
- end
-
- for i = 1, self.header.basesNumber do
- self.peaks[i].prob.C = readInt(scfFile, 1)
- end
-
- for i = 1, self.header.basesNumber do
- self.peaks[i].prob.G = readInt(scfFile, 1)
- end
-
- for i = 1, self.header.basesNumber do
- self.peaks[i].prob.T = readInt(scfFile, 1)
- end
-
- for i = 1, self.header.basesNumber do
- self.peaks[i].base = string.char(readInt(scfFile, 1))
- end
-
- scfFile:close()
- end
-end
-
-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 Chromatogram:printTikzChromatogram()
- if pgfmolbio.errorCatched then return end
- self.selectedPeaks = {}
- local tIndex = 1
- 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 = self.sampleMax + 1 - self.sampleMin
- }
- if tIndex > 1 then
- 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 self.baseNumberMin == -1 then
- self.baseNumberMin = self.selectedPeaks[1].baseIndex
- end
- if self.baseNumberMax == -1 then
- self.baseNumberMax = self.selectedPeaks[tIndex-1].baseIndex
- end
- end
-
- local samplesLeft = self.sampleMax - self.sampleMin + 1
- local currLine = 0
- while samplesLeft > 0 do
- local yLower = -currLine * self.baselineSkip
- local yUpper = -currLine * self.baselineSkip + self.canvasHeight
- local xRight =
- (math.min(self.samplesPerLine, samplesLeft) - 1) * self.xUnit
- tex.sprint(
- "\n\t\\draw [" .. PGFKEYS_PATH .. "canvas style] (" ..
- dimToString(0) ..
- ", " ..
- dimToString(yLower) ..
- ") rectangle (" ..
- dimToString(xRight) ..
- ", " ..
- dimToString(yUpper) ..
- ");"
- )
- samplesLeft = samplesLeft - self.samplesPerLine
- currLine = currLine + 1
- end
-
- 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 <= 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
- firstPointInLine = false
- end
- tex.sprint(
- "(" ..
- dimToString(x) ..
- ", " ..
- dimToString(y) ..
- ")"
- )
- end
- if sampleX ~= self.sampleMax + 1 - self.sampleMin then
- if sampleX >= (currLine + 1) * self.samplesPerLine then
- currLine = currLine + 1
- tex.sprint(";\n\t\\draw [" .. self.traceStyle[baseName] .. "] ")
- firstPointInLine = true
- end
- else
- tex.sprint(";")
- end
- sampleX = sampleX + 1
- currSampleIndex = currSampleIndex + 1
- end
- end
-
- local currLine = 0
- local lastProbX = 1
- local probRemainder = false
-
- for _, currPeak in ipairs(self.selectedPeaks) do
- while currPeak.offset > (currLine + 1) * self.samplesPerLine do
- currLine = currLine + 1
- end
-
- local x = ((currPeak.offset - 1) % self.samplesPerLine) * self.xUnit
- local yUpper = -currLine * self.baselineSkip
- local yLower = -currLine * self.baselineSkip - self.tickLength
- local tickOperation = ""
- if self.ticksDrawn:upper():find(currPeak.base) then
- tickOperation = "--"
- end
-
- tex.sprint(
- "\n\t\\draw [" ..
- self.tickStyle[currPeak.base] ..
- "] (" ..
- dimToString(x) ..
- ", " ..
- dimToString(yUpper) ..
- ") " ..
- tickOperation ..
- " (" ..
- dimToString(x) ..
- ", " ..
- dimToString(yLower) ..
- ")"
- )
- if self.baseLabelsDrawn:upper():find(currPeak.base) then
- tex.sprint(
- " node [" ..
- self.baseLabelStyle[currPeak.base] ..
- "] {" ..
- self.baseLabelText[currPeak.base] ..
- "}"
- )
- end
-
- 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] {\\strut " ..
- currPeak.baseIndex ..
- "}"
- )
- end
- tex.sprint(";")
-
- if probRemainder then
- tex.sprint(probRemainder)
- probRemainder = false
- end
- local drawCurrProb =
- self.probabilitiesDrawn:upper():find(currPeak.base)
- local xLeft = lastProbX - 1 - currLine * self.samplesPerLine
- if xLeft < 0 then
- 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(
- "\n\t\\draw [" ..
- self.probStyle(currPeak.prob[currPeak.base]) ..
- "] (" ..
- dimToString(xLeftPrev) ..
- ", " ..
- dimToString(yPrev) ..
- ") -- (" ..
- dimToString(xRightPrev) ..
- ", " ..
- dimToString(yPrev) ..
- ");"
- )
- end
- xLeft = 0
- else
- xLeft = xLeft * self.xUnit
- end
-
- local xRight = currPeak.probXRight - 1 - currLine * self.samplesPerLine
- if xRight >= self.samplesPerLine then
- if drawCurrProb then
- local xRightNext = (xRight - self.samplesPerLine) * self.xUnit
- local yNext = -(currLine+1) * self.baselineSkip - self.probDistance
- probRemainder =
- "\n\t\\draw [" ..
- self.probStyle(currPeak.prob[currPeak.base]) ..
- "] (" ..
- dimToString(0) ..
- ", " ..
- dimToString(yNext) ..
- ") -- (" ..
- dimToString(xRightNext) ..
- ", " ..
- dimToString(yNext) ..
- ");"
- end
- xRight = (self.samplesPerLine - 1) * self.xUnit
- else
- xRight = xRight * self.xUnit
- end
-
- local y = -currLine * self.baselineSkip - self.probDistance
- if drawCurrProb then
- tex.sprint(
- "\n\t\\draw [" ..
- self.probStyle(currPeak.prob[currPeak.base]) ..
- "] (" ..
- dimToString(xLeft) ..
- ", " ..
- dimToString(y) ..
- ") -- (" ..
- dimToString(xRight) ..
- ", " ..
- dimToString(y) ..
- ");"
- )
- end
- lastProbX = currPeak.probXRight
- end
-end
---
--- End of file `pgfmolbio.chromatogram.lua'.
Modified: trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.tex
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.tex 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.chromatogram.tex 2024-06-17 20:11:59 UTC (rev 71551)
@@ -6,17 +6,17 @@
%%
%% pgfmolbio.dtx (with options: `pmb-chr-tex')
%%
-%% Copyright (C) 2013 by Wolfgang Skala
+%% Copyright (C) 2024 by Wolfgang Esser-Skala
%%
%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either version 1.3
+%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of LaTeX
-%% version 2005/12/01 or later.
+%% https://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008/05/04 or later.
%%
-\ProvidesFile{pgfmolbio.chromatogram.tex}[2013/08/01 v0.21 SCF chromatograms]
+\ProvidesFile{pgfmolbio.chromatogram.tex}[2024/06/17 v0.21a SCF chromatograms]
\ifluatex
Modified: trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.convert.tex
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.convert.tex 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.convert.tex 2024-06-17 20:11:59 UTC (rev 71551)
@@ -6,17 +6,17 @@
%%
%% pgfmolbio.dtx (with options: `pmb-con-tex')
%%
-%% Copyright (C) 2013 by Wolfgang Skala
+%% Copyright (C) 2024 by Wolfgang Esser-Skala
%%
%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either version 1.3
+%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of LaTeX
-%% version 2005/12/01 or later.
+%% https://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008/05/04 or later.
%%
-\ProvidesFile{pgfmolbio.convert.tex}[2013/08/01 v0.21 pgfmolbio graph conversion]
+\ProvidesFile{pgfmolbio.convert.tex}[2024/06/17 v0.21a pgfmolbio graph conversion]
\pdfdraftmode1
Deleted: trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.domains.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.domains.lua 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.domains.lua 2024-06-17 20:11:59 UTC (rev 71551)
@@ -1,810 +0,0 @@
---
--- This is file `pgfmolbio.domains.lua',
--- generated with the docstrip utility.
---
--- The original source files were:
---
--- pgfmolbio.dtx (with options: `pmb-dom-lua')
---
--- Copyright (C) 2013 by Wolfgang Skala
---
--- This work may be distributed and/or modified under the
--- conditions of the LaTeX Project Public License, either version 1.3
--- of this license or (at your option) any later version.
--- The latest version of this license is in
--- http://www.latex-project.org/lppl.txt
--- and version 1.3 or later is part of all distributions of LaTeX
--- version 2005/12/01 or later.
---
-module("pgfmolbio.domains", package.seeall)
-
-
-if luatexbase then
- luatexbase.provides_module({
- name = "pgfmolbio.domains",
- version = 0.2,
- date = "2012/10/01",
- description = "Domain graphs",
- author = "Wolfgang Skala",
- copyright = "Wolfgang Skala",
- license = "LPPL",
- })
-end
-
-local stringToDim = pgfmolbio.stringToDim
-local dimToString = pgfmolbio.dimToString
-local packageError = pgfmolbio.packageError
-local packageWarning = pgfmolbio.packageWarning
-local getRange = pgfmolbio.getRange
-
-function printSequenceFeature(feature, xLeft, xRight, yMid, xUnit, yUnit)
- xLeft = xLeft + 0.5
- for currResidue in feature.sequence:gmatch(".") do
- tex.sprint("\n\t\t\\def\\xMid{" .. dimToString(xLeft * xUnit) .. "}")
- tex.sprint("\n\t\t\\def\\yMid{" .. dimToString(yMid * yUnit) .. "}")
- tex.sprint("\n\t\t\\def\\currentResidue{" .. currResidue .. "}")
- tex.sprint("\n\t\t\\pmbdomdrawfeature{other/sequence}")
- xLeft = xLeft + 1
- end
-end
-
-function printHelixFeature(feature, xLeft, xRight, yMid, xUnit, yUnit)
- local residuesLeft, currX
- tex.sprint("\n\t\t\\pgfmolbioset[domains]{current style}")
-
- residuesLeft = feature.stop - feature.start + 1
- currX = xLeft
- tex.sprint("\n\t\t\\def\\xLeft{" .. dimToString(currX * xUnit) .. "}")
- tex.sprint("\n\t\t\\def\\yMid{" .. dimToString(yMid * yUnit) .. "}")
- tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/half upper back}")
- residuesLeft = residuesLeft - 2
- currX = currX + 2.5
-
- while residuesLeft > 0 do
- if residuesLeft == 1 then
- tex.sprint(
- "\n\t\t\\def\\xRight{" ..
- dimToString((currX + 0.5) * xUnit) ..
- "}"
- )
- tex.sprint("\n\t\t\\def\\yMid{" .. dimToString(yMid * yUnit) .. "}")
- tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/half lower back}")
- else
- tex.sprint("\n\t\t\\def\\xMid{" .. dimToString(currX * xUnit) .. "}")
- tex.sprint(
- "\n\t\t\\def\\yLower{" ..
- dimToString(yMid * yUnit - 1.5 * xUnit) ..
- "}"
- )
- tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/full back}")
- end
- residuesLeft = residuesLeft - 2
- currX = currX + 2
- end
-
- residuesLeft = feature.stop - feature.start
- currX = xLeft + 1.5
- while residuesLeft > 0 do
- if residuesLeft == 1 then
- tex.sprint(
- "\n\t\t\\def\\xRight{" ..
- dimToString((currX + 0.5) * xUnit) ..
- "}"
- )
- tex.sprint("\n\t\t\\def\\yMid{" .. dimToString(yMid * yUnit) .. "}")
- tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/half upper front}")
- else
- tex.sprint("\n\t\t\\def\\xMid{" .. dimToString(currX * xUnit) .. "}")
- tex.sprint(
- "\n\t\t\\def\\yLower{" ..
- dimToString(yMid * yUnit - 1.5 * xUnit) ..
- "}"
- )
- tex.sprint("\n\t\t\\pmbdomdrawfeature{helix/full front}")
- end
- residuesLeft = residuesLeft - 2
- currX = currX + 2
- end
-end
-
-SpecialKeys = {}
-
-function SpecialKeys:new(parms)
- parms = parms or {}
- local newSpecialKeys = {
- disulfideKeys = {},
- featureStyles = {},
- printFunctions = {}
- }
-
- for keyList, listContents in pairs(parms) do
- for key, value in pairs(listContents) do
- newSpecialKeys[keyList][key] = value
- end
- end
-
- setmetatable(newSpecialKeys, self)
- self.__index = self
- return newSpecialKeys
-end
-
-function SpecialKeys:setKeys(keylist, keys, value)
- for key in keys:gmatch("([^,]+)") do
- key = key:trim()
- self[keylist][key] = value
- end
-end
-
-function SpecialKeys:setFeatureStyle(key, style)
- local newStyleList, styleCycles, styleContents
-
- newStyleList = {}
- while style ~= "" do
- styleCycles = 1
- if style:sub(1,1) == "{" then
- styleContents = style:match("%b{}")
- style = style:match("%b{}(.*)")
- elseif style:sub(1,1) == "*" then
- styleCycles, styleContents = style:match("%*(%d*)(%b{})")
- if styleCycles == "" then styleCycles = 1 end
- style = style:match("%*%d*%b{}(.*)")
- elseif style:sub(1,1) == "," or style:sub(1,1) == " " then
- style = style:match("[,%s]+(.*)")
- styleCycles, styleContents = nil, nil
- else
- styleContents = style:match("([^,]+),")
- if not styleContents then
- styleContents = style
- style = ""
- else
- style = style:match("[^,]+,(.*)")
- end
- end
- if styleCycles then
- table.insert(
- newStyleList,
- {cycles = styleCycles, style = styleContents}
- )
- end
- end
- self.featureStyles[key] = newStyleList
-end
-
-function SpecialKeys:aliasFeatureStyle(newKey, oldKey)
- self.featureStyles[newKey] = {alias = oldKey}
-end
-
-function SpecialKeys:getBaseKey(key)
- if self.featureStyles[key] then
- if self.featureStyles[key].alias then
- return self.featureStyles[key].alias
- end
- end
- return key
-end
-
-function SpecialKeys:clearKeys(keylist)
- self[keylist] = {}
-end
-
-function SpecialKeys:selectStyleFromList(key, styleID)
- local styleList
-
- if not self.featureStyles[key] then
- packageWarning(
- "Feature style `" ..
- key ..
- "' unknown, using `default'."
- )
- styleList = self.featureStyles.default
- elseif self.featureStyles[key].alias then
- styleList = self.featureStyles[self.featureStyles[key].alias]
- else
- styleList = self.featureStyles[key]
- end
-
- while true do
- for _, v in ipairs(styleList) do
- styleID = styleID - v.cycles
- if styleID < 1 then
- return v.style
- end
- end
- end
-end
-
-Protein = {}
-
-function Protein:new()
- local newProtein = {
- name = "",
- sequenceLength = -1,
- ft = {},
- sequence = "",
- xUnit = stringToDim("0.5mm"),
- yUnit = stringToDim("6mm"),
- residuesPerLine = 250,
- residueRangeMin = 1,
- residueRangeMax = 100,
- residueNumbering = {},
- revResidueNumbering = {},
- baselineSkip = 3,
- rulerRange = {},
- defaultRulerStepSize = 50,
- showRuler = true,
- currentStyle = {},
- specialKeys = SpecialKeys:new()
- }
- setmetatable(newProtein, self)
- self.__index = self
- return newProtein
-end
-
-function Protein:toAbsoluteResidueNumber(value)
- local result = value:match("%b()")
- if result then
- result = tonumber(result:sub(2, -2))
- else
- result = self.revResidueNumbering[(value:gsub("[<>%?]", ""))]
- end
- if not result then
- packageError("Bad or missing start/end point value: " .. value)
- end
- return result
-end
-
-function Protein:readUniprotFile(filename)
- local uniprotFile, errorMsg = io.open(filename, "r")
- if not uniprotFile then packageError(errorMsg) end
-
- local sequence = {}
- local inSequence = false
- local featureTable = {}
-
- for currLine in uniprotFile:lines() do
- local lineCode = currLine:sub(1, 2)
- local lineContents = currLine:sub(3)
- if lineCode == "ID" then
- local name, sequenceLength =
- lineContents:match("%s*(%S+)%s*%a+;%s*(%d+)%s*AA%.")
- self.name = name
- self.sequenceLength = tonumber(sequenceLength)
- self.residueRangeMax = self.sequenceLength
- elseif lineCode == "FT" then
- local key = currLine:sub(6, 13):trim()
- local start, stop, description =
- currLine:sub(15, 20), currLine:sub(22, 27), currLine:sub(35, 75)
- if key ~= "" then
- table.insert(featureTable, {
- key = key,
- start = "(" .. start .. ")",
- stop = "(" .. stop .. ")",
- description = description,
- style = "",
- kvList = ""
- })
- else
- featureTable[#featureTable].description =
- featureTable[#featureTable].description .. description
- end
- elseif lineCode == "SQ" then
- inSequence = true
- elseif lineCode == " " and inSequence then
- table.insert(sequence, (lineContents:gsub("%s+", "")))
- elseif lineCode == "\\\\" then
- break
- end
- end
- uniprotFile:close()
- if next(sequence) then self.sequence = table.concat(sequence) end
- for _, v in ipairs(featureTable) do self:addFeature(v) end
-end
-
-function Protein:readGffFile(filename)
- local gffFile, errorMsg = io.open(filename, "r")
- local lineContents, fields, lineNumber
-
- if not gffFile then packageError(errorMsg) end
- lineNumber = 1
- for currLine in gffFile:lines() do
- lineContents = currLine:gsub("#.*$", "")
- fields = {}
- if lineContents ~= "" then
- for currField in lineContents:gmatch("([^\t]+)") do
- table.insert(fields, currField)
- end
- if not fields[5] then
- packageError("Bad line (" .. lineNumber .. ") in gff file '" ..
- filename .. "':\n" .. currLine)
- break
- end
- self:addFeature{
- key = fields[3],
- start = "(" .. fields[4] .. ")",
- stop = "(" .. fields[5] .. ")",
- description = fields[9] or "",
- style = "",
- kvList = ""
- }
- end
- lineNumber = lineNumber + 1
- end
- gffFile:close()
-end
-
-function Protein:getParameters()
- tex.sprint(
- "\\pgfmolbioset[domains]{name={" ..
- self.name ..
- "},sequence={" ..
- self.sequence ..
- "},sequence length=" ..
- self.sequenceLength ..
- "}"
- )
-end
-
-function Protein:setParameters(newParms)
- local keyHash = {
- sequenceLength = function(v)
- v = tonumber(v)
- if not v then return self.sequenceLength end
- if v < 1 then
- packageError("Sequence length must be larger than zero.")
- end
- return v
- end,
- residueNumbering = function(v)
- local ranges = {}
- local start, startNumber, startLetter, stop
- self.revResidueNumbering = {}
- if v:trim() == "auto" then
- for i = 1, self.sequenceLength do
- table.insert(ranges, tostring(i))
- end
- else --example list: `1-4,5,6A-D'
- for _, value in ipairs(v:explode(",+")) do
- value = value:trim()
- start, stop = value:match("(%w*)%s*%-%s*(%w*)$")
- if not start then
- start = value:match("(%w*)")
- end
- if not start or start == "" then --invalid range
- packageError("Unknown residue numbering range: " .. value)
- end
- if stop then
- if tonumber(start) and tonumber(stop) then
- --process range `1-4'
- for currNumber = tonumber(start), tonumber(stop) do
- table.insert(ranges, tostring(currNumber))
- end
- else --process range `6A-D'
- startNumber, startLetter = start:match("(%d*)(%a)")
- stop = stop:match("(%a)")
- for currLetter = startLetter:byte(), stop:byte() do
- table.insert(ranges,
- startNumber .. string.char(currLetter))
- end
- end
- else --process range `5'
- table.insert(ranges, start)
- end
- end
- end
- for i, value in ipairs(ranges) do
- if self.revResidueNumbering[value] then
- packageError("The range value " .. value ..
- " appears more than once.")
- else
- self.revResidueNumbering[value] = i
- end
- end
- return ranges
- end,
- residueRange = function(v)
- local num
- local residueRangeMin, residueRangeMax =
- getRange(v:trim(), "^([%w%(%)]+)%s*%-", "%-%s*([%w%(%)]+)$")
- if residueRangeMin == "auto" then
- self.residueRangeMin = 1
- else
- num = residueRangeMin:match("%b()")
- if num then
- self.residueRangeMin = tonumber(num:sub(2, -2))
- elseif self.revResidueNumbering[residueRangeMin] then
- self.residueRangeMin = self.revResidueNumbering[residueRangeMin]
- else
- packageError("Invalid residue range: " .. residueRangeMin)
- end
- end
-
- if residueRangeMax == "auto" then
- self.residueRangeMax = self.sequenceLength
- else
- num = residueRangeMax:match("%b()")
- if num then
- self.residueRangeMax = tonumber(num:sub(2, -2))
- elseif self.revResidueNumbering[residueRangeMax] then
- self.residueRangeMax = self.revResidueNumbering[residueRangeMax]
- else
- packageError("Invalid residue range: " .. residueRangeMax)
- end
- end
-
- if self.residueRangeMin >= self.residueRangeMax then
- packageError("Residue range is smaller than 1.")
- end
- end,
- defaultRulerStepSize = tonumber,
- name = tostring,
- sequence = tostring,
- xUnit = stringToDim,
- yUnit = stringToDim,
- residuesPerLine = tonumber,
- baselineSkip = tonumber,
- rulerRange = function(v)
- local num
- local ranges = {}
- local rulerRangeMin, rulerRangeMax, rulerRangeStep
- for _, value in ipairs(v:explode(",+")) do
- rulerRangeMin, rulerRangeMax, rulerRangeStep =
- getRange(value:trim(), "^([%w%(%)]+)",
- "%-%s*([%w%(%)]+)", "step%s*(%d+)$")
-
- if rulerRangeMin == "auto" then
- rulerRangeMin = self.residueRangeMin
- else
- num = rulerRangeMin:match("%b()")
- if num then
- rulerRangeMin = tonumber(num:sub(2, -2))
- elseif self.revResidueNumbering[rulerRangeMin] then
- rulerRangeMin = self.revResidueNumbering[rulerRangeMin]
- else
- packageError("Invalid lower ruler range: " .. rulerRangeMin)
- end
- end
-
- if rulerRangeMax then
- if rulerRangeMax == "auto" then
- rulerRangeMax = self.residueRangeMax
- else
- num = rulerRangeMax:match("%b()")
- if num then
- rulerRangeMax = tonumber(num:sub(2, -2))
- elseif self.revResidueNumbering[rulerRangeMax] then
- rulerRangeMax = self.revResidueNumbering[rulerRangeMax]
- else
- packageError("Invalid upper ruler range: " .. rulerRangeMax)
- end
- end
-
- if rulerRangeMin >= rulerRangeMax then
- packageError("Ruler range is smaller than 1.")
- end
- if rulerRangeMin < self.residueRangeMin then
- rulerRangeMin = self.residueRangeMin
- packageWarning(
- "Lower ruler range is smaller than" ..
- "lower residue range. It was adjusted to " ..
- rulerRangeMin .. "."
- )
- end
- if rulerRangeMax > self.residueRangeMax then
- rulerRangeMax = self.residueRangeMax
- packageWarning(
- "Upper ruler range exceeds" ..
- "upper residue range. It was adjusted to " ..
- rulerRangeMax .. "."
- )
- end
- else
- rulerRangeMax = rulerRangeMin
- end
- rulerRangeStep = tonumber(rulerRangeStep)
- or self.defaultRulerStepSize
-
- for i = rulerRangeMin, rulerRangeMax, rulerRangeStep do
- table.insert(
- ranges,
- {pos = i, number = self.residueNumbering[i]}
- )
- end
- end
- return ranges
- end,
- showRuler = function(v)
- if v == "true" then return true else return false end
- end
- }
- for key, value in pairs(newParms) do
- if keyHash[key] then
- self[key] = keyHash[key](value)
- if pgfmolbio.errorCatched then return end
- end
- end
-end
-
-function Protein:addFeature(newFeature)
- local baseKey, ftEntry
-
- baseKey = self.specialKeys:getBaseKey(newFeature.key)
- if self.currentStyle[baseKey] then
- self.currentStyle[baseKey] = self.currentStyle[baseKey] + 1
- else
- self.currentStyle[baseKey] = 1
- end
-
- ftEntry = {
- key = newFeature.key,
- start = self:toAbsoluteResidueNumber(newFeature.start),
- stop = self:toAbsoluteResidueNumber(newFeature.stop),
- kvList = "style={" ..
- self.specialKeys:selectStyleFromList(baseKey,
- self.currentStyle[baseKey]) .. "}",
- level = newFeature.level or nil
- }
- if newFeature.kvList ~= "" then
- ftEntry.kvList = ftEntry.kvList .. "," .. newFeature.kvList
- end
- if newFeature.description then
- ftEntry.kvList = ftEntry.kvList ..
- ",description={" .. newFeature.description .. "}"
- ftEntry.description = newFeature.description
- end
- table.insert(self.ft, newFeature.layer or #self.ft + 1, ftEntry)
-end
-
-function Protein:calculateDisulfideLevels()
- if pgfmolbio.errorCatched then return end
- local disulfideGrid, currLevel, levelFree
- disulfideGrid = {}
-
- for i, v in ipairs(self.ft) do
- if self.specialKeys.disulfideKeys[v.key] then
- if v.level then
- if not disulfideGrid[v.level] then
- disulfideGrid[v.level] = {}
- end
- for currPos = v.start, v.stop do
- disulfideGrid[v.level][currPos] = true
- end
- else
- currLevel = 1
- repeat
- levelFree = true
- if disulfideGrid[currLevel] then
- for currPos = v.start, v.stop do
- levelFree = levelFree
- and not disulfideGrid[currLevel][currPos]
- end
- if levelFree then
- self.ft[i].level = currLevel
- for currPos = v.start, v.stop do
- disulfideGrid[currLevel][currPos] = true
- end
- end
- else
- self.ft[i].level = currLevel
- disulfideGrid[currLevel] = {}
- for currPos = v.start, v.stop do
- disulfideGrid[currLevel][currPos] = true
- end
- levelFree = true
- end
- currLevel = currLevel + 1
- until levelFree == true
- end
- end
- end
-end
-
-function Protein:printTikzDomains()
- if pgfmolbio.errorCatched then return end
- local xLeft, xMid, xRight, yMid, xLeftClip, xRightClip,
- currLine, residuesLeft, currStyle
-
- for _, currFeature in ipairs(self.ft) do
- currLine = 0
- xLeft = currFeature.start - self.residueRangeMin -
- currLine * self.residuesPerLine + 1
- while xLeft > self.residuesPerLine do
- xLeft = xLeft - self.residuesPerLine
- currLine = currLine + 1
- end
- xLeft = xLeft - 1
- xRight = currFeature.stop - self.residueRangeMin -
- currLine * self.residuesPerLine + 1
- residuesLeft = self.residueRangeMax - self.residueRangeMin -
- currLine * self.residuesPerLine + 1
- xLeftClip = stringToDim("-5cm")
- xRightClip = self.residuesPerLine * self.xUnit
-
- if currFeature.start <= self.residueRangeMax
- and currFeature.stop >= self.residueRangeMin then
- repeat
- if residuesLeft <= self.residuesPerLine then
- if residuesLeft < xRight then
- xRightClip = residuesLeft * self.xUnit
- else
- xRightClip = xRight * self.xUnit + stringToDim("5cm")
- end
- else
- if xRight <= self.residuesPerLine then
- xRightClip = xRight * self.xUnit + stringToDim("5cm")
- end
- end
- if xLeft < 0 then xLeftClip = stringToDim("0cm") end
-
- xMid = (xLeft + xRight) / 2
- yMid = -currLine * self.baselineSkip
- if currFeature.level then
- currFeature.kvList = currFeature.kvList ..
- ",level=" .. currFeature.level
- end
- currFeature.sequence =
- self.sequence:sub(currFeature.start, currFeature.stop)
-
- tex.sprint("\n\t\\begin{scope}\\begin{pgfinterruptboundingbox}")
- tex.sprint("\n\t\t\\def\\xLeft{" ..
- dimToString(xLeft * self.xUnit) .. "}")
- tex.sprint("\n\t\t\\def\\xMid{" ..
- dimToString(xMid * self.xUnit) .. "}")
- tex.sprint("\n\t\t\\def\\xRight{" ..
- dimToString(xRight * self.xUnit) .. "}")
- tex.sprint("\n\t\t\\def\\yMid{" ..
- dimToString(yMid * self.yUnit) .. "}")
- tex.sprint("\n\t\t\\def\\featureSequence{" ..
- currFeature.sequence .. "}")
- tex.sprint(
- "\n\t\t\\clip (" ..
- dimToString(xLeftClip) ..
- ", \\yMid + " ..
- dimToString(stringToDim("10cm")) ..
- ") rectangle (" ..
- dimToString(xRightClip) ..
- ", \\yMid - " ..
- dimToString(stringToDim("10cm")) ..
- ");"
- )
- tex.sprint(
- "\n\t\t\\pgfmolbioset[domains]{" ..
- currFeature.kvList ..
- "}"
- )
- if self.specialKeys.printFunctions[currFeature.key] then
- self.specialKeys.printFunctions[currFeature.key](
- currFeature, xLeft, xRight, yMid, self.xUnit, self.yUnit)
- else
- tex.sprint("\n\t\t\\pmbdomdrawfeature{" ..
- currFeature.key .. "}")
- end
- tex.sprint("\n\t\\end{pgfinterruptboundingbox}\\end{scope}")
-
- currLine = currLine + 1
- xLeft = xLeft - self.residuesPerLine
- xRight = xRight - self.residuesPerLine
- residuesLeft = residuesLeft - self.residuesPerLine
- until xRight < 1 or residuesLeft < 1
- end
- end
-
- if self.showRuler then
- currStyle = 1
- tex.sprint("\n\t\\begin{scope}")
- for _, currRuler in ipairs(self.rulerRange) do
- currLine = 0
- xMid = currRuler.pos - self.residueRangeMin -
- currLine * self.residuesPerLine + 1
- while xMid > self.residuesPerLine do
- xMid = xMid - self.residuesPerLine
- currLine = currLine + 1
- end
- xMid = xMid - 0.5
- yMid = -currLine * self.baselineSkip
- tex.sprint(
- "\n\t\t\\pgfmolbioset[domains]{current style/.style={" ..
- self.specialKeys:selectStyleFromList("other/ruler", currStyle) ..
- "}}"
- )
- tex.sprint("\n\t\t\t\\def\\xMid{" ..
- dimToString(xMid * self.xUnit) .. "}")
- tex.sprint("\n\t\t\t\\let\\xLeft\\xMid\\let\\xRight\\xMid")
- tex.sprint("\n\t\t\t\\def\\yMid{" ..
- dimToString(yMid * self.yUnit) .. "}")
- tex.sprint("\n\t\t\t\\def\\residueNumber{" ..
- currRuler.number .. "}")
- tex.sprint("\n\t\t\t\\pmbdomdrawfeature{other/ruler}")
- currStyle = currStyle + 1
- end
- tex.sprint("\n\t\\end{scope}")
- end
-
- xMid =
- math.min(
- self.residuesPerLine,
- self.residueRangeMax - self.residueRangeMin + 1
- ) / 2
- tex.sprint("\n\t\\begin{scope}")
- tex.sprint(
- "\n\t\t\\pgfmolbioset[domains]{current style/.style={" ..
- self.specialKeys:selectStyleFromList("other/name", 1) ..
- "}}"
- )
- tex.sprint("\n\t\t\\def\\xLeft{0mm}")
- tex.sprint("\n\t\t\\def\\xMid{" .. dimToString(xMid * self.xUnit) .. "}")
- tex.sprint("\n\t\t\\def\\xRight{" ..
- dimToString(self.residuesPerLine * self.xUnit) .. "}")
- tex.sprint("\n\t\t\\def\\yMid{0mm}")
- tex.sprint("\n\t\t\\pmbdomdrawfeature{other/name}")
- tex.sprint("\n\t\\end{scope}")
-
- tex.sprint(
- "\n\t\\pmbprotocolsizes{" ..
- "\\pmbdomvalueof{enlarge left}}{\\pmbdomvalueof{enlarge top}}"
- )
- currLine =
- math.ceil(
- (self.residueRangeMax - self.residueRangeMin + 1) /
- self.residuesPerLine
- ) - 1
- xRight =
- math.min(
- self.residuesPerLine,
- self.residueRangeMax - self.residueRangeMin + 1
- )
- tex.sprint(
- "\n\t\\pmbprotocolsizes{" ..
- dimToString(xRight * self.xUnit) ..
- " + \\pmbdomvalueof{enlarge right}}{" ..
- dimToString(-currLine * self.baselineSkip * self.yUnit) ..
- " + \\pmbdomvalueof{enlarge bottom}}"
- )
-end
-
-function Protein:__tostring()
- local result = {}
- local currLine
-
- currLine = "\\begin{pmbdomains}\n\t\t[name={" ..
- self.name ..
- "}"
- if self.sequence ~= "" then
- currLine = currLine ..
- ",\n\t\tsequence=" ..
- self.sequence
- end
- currLine = currLine ..
- "]{" ..
- self.sequenceLength ..
- "}"
- table.insert(result, currLine)
-
- for i, v in ipairs(self.ft) do
- if v.key ~= "other/main chain" then
- currLine = "\t\\addfeature"
- if self.includeDescription and v.description then
- currLine =
- currLine ..
- "[description={" ..
- v.description ..
- "}]"
- end
- currLine =
- currLine ..
- "{" ..
- v.key ..
- "}{" ..
- v.start ..
- "}{" ..
- v.stop ..
- "}"
- table.insert(result, currLine)
- end
- end
- table.insert(result,
- "\\end{pmbdomains}"
- )
- return table.concat(result, "\n")
-end
---
--- End of file `pgfmolbio.domains.lua'.
Modified: trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.domains.tex
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.domains.tex 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.domains.tex 2024-06-17 20:11:59 UTC (rev 71551)
@@ -6,17 +6,17 @@
%%
%% pgfmolbio.dtx (with options: `pmb-dom-tex')
%%
-%% Copyright (C) 2013 by Wolfgang Skala
+%% Copyright (C) 2024 by Wolfgang Esser-Skala
%%
%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either version 1.3
+%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of LaTeX
-%% version 2005/12/01 or later.
+%% https://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008/05/04 or later.
%%
-\ProvidesFile{pgfmolbio.domains.tex}[2013/08/01 v0.21 Protein domains]
+\ProvidesFile{pgfmolbio.domains.tex}[2024/06/17 v0.21a Protein domains]
\ProvidesFile{pgfmolbio.domains.tex}[2012/10/01 v0.2 Protein Domains]
Modified: trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.sty 2024-06-17 20:10:40 UTC (rev 71550)
+++ trunk/Master/texmf-dist/tex/lualatex/pgfmolbio/pgfmolbio.sty 2024-06-17 20:11:59 UTC (rev 71551)
@@ -6,17 +6,17 @@
%%
%% pgfmolbio.dtx (with options: `pgfmolbio-tex')
%%
-%% Copyright (C) 2013 by Wolfgang Skala
+%% Copyright (C) 2024 by Wolfgang Esser-Skala
%%
%% This work may be distributed and/or modified under the
-%% conditions of the LaTeX Project Public License, either version 1.3
+%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
-%% http://www.latex-project.org/lppl.txt
-%% and version 1.3 or later is part of all distributions of LaTeX
-%% version 2005/12/01 or later.
+%% https://www.latex-project.org/lppl.txt
+%% and version 1.3c or later is part of all distributions of LaTeX
+%% version 2008/05/04 or later.
%%
-\ProvidesPackage{pgfmolbio}[2013/08/01 v0.21 Molecular biology graphs with TikZ]
+\ProvidesPackage{pgfmolbio}[2024/06/17 v0.21a Molecular biology graphs with TikZ]
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
More information about the tex-live-commits
mailing list.