LaTeX package for fly genetics.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

339 lines
10 KiB

% \iffalse
%
% Copyright (C) 2013,2014 Damien Goutte-Gattat
%
% This work may be distributed and/or modified under the conditions of the
% LaTeX Project Public License, either version 1.3 of the license or (at
% your option) any later version. The latest version if 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
% 2003/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work is Damien Goutte-Gattat
% <d.goutte-gattat@iecb.u-bordeaux.fr>.
%
% This work consists of the file flygenet.dtx, and all files generated
% from it.
%
%<*batchfile>
\begingroup
\input docstrip
\keepsilent
\askforoverwritefalse
\preamble
Copyright (C) 2013,2014 Damien Goutte-Gattat
This file is part of a work distributed under the conditins of the
LaTeX Project Public License. See the source file from which this file
has been generated for details.
\endpreamble
\generate{
\file{flygenet.sty}{\from{flygenet.dtx}{package}}
}
\endgroup
%</batchfile>
%
%<*driver>
\ProvidesFile{flygenet.dtx}[2014/01/01 v0.3 Fly genetics notation]
\documentclass[a4paper]{ltxdoc}
\usepackage{hyperref}
\usepackage{flygenet}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{flygenet.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \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
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \DoNotIndex{\,}
% \DoNotIndex{\active}
% \DoNotIndex{\begingroup}
% \DoNotIndex{\catcode}
% \DoNotIndex{\DeclareOption,\def}
% \DoNotIndex{\else,\empty,\end,\endgroup,\ensuremath}
% \DoNotIndex{\fi,\frac}
% \DoNotIndex{\gdef}
% \DoNotIndex{\height,\hspace}
% \DoNotIndex{\if,\ifmmode,\ifx,\itshape}
% \DoNotIndex{\let}
% \DoNotIndex{\mars,\mathchoice,\mbox,\mercury}
% \DoNotIndex{\NeedsTeXFormat,\newif,\node,\normalsize}
% \DoNotIndex{\ProcessOptions,\ProvidesPackage}
% \DoNotIndex{\RequirePackage,\raisebox,\relax}
% \DoNotIndex{\text,\textsuperscript}
% \DoNotIndex{\venus}
%
% \changes{0.1}{2013/07/14}{Initial version.}
% \changes{0.2}{2013/10/09}{Remove limitations.}
% \changes{0.3}{2014/01/01}{Do not draw Y hook; add some helper macros.}
%
% \GetFileInfo{flygenet.dtx}
%
% \title{^^A
% The \textsf{flygenet} package\thanks{^^A
% This file has version number \fileversion, last revised \filedate.}}
% \author{^^A
% Damien Goutte-Gattat\thanks{^^A
% Institut Europ\'een de Chimie et Biologie,
% 2 rue Robert Escarpit, 33607 Pessac, France}\\
% \texttt{d.goutte-gattat@iecb.u-bordeaux.fr}}
% \date{\filedate}
% \let\ts\textsuperscript
%
% \maketitle
%
% \tableofcontents
%
% \section{Introduction}
%
% Fly geneticists conventionally denote fly genotypes using a math-like
% notation, as in the following example:
%
% $$
% \genotype{C(1)RM, y^2/Y; In(2LR)O, Cy cn^2 sp^2/Sco; ci^D/ey^D}
% $$
%
% Consequently, \LaTeX's math mode (and especially displayed math mode,
% as above) is well suited to typeset such notation.
%
% However, typesetting a genotype can be quite tedious, as it requires
% many calls to the |\frac| macro (or the |\over| primitive) and
% constant use of manual spacing to override \TeX's
% math-mode spacing.
%
% This package is intended to reduce the amount of code needed to
% typeset a genotype. For example, the genotype above is the result of
% the following code:
%
% \begin{verbatim}
% \genotype{C(1)RM, y^2/Y; In(2LR)O,Cy cn^2 sp^2/Sco; ci^D/ey^D}
% \end{verbatim}
%
% A complete genotype can thus be written in a very intuitive way, the
% only \TeX ism being the exponentiation character (which is redefined,
% inside the |\genotype| macro, as an alias to the |\allele| macro).
%
%
% \section{User interface}
%
% The main user-level macro is |\genotype|. It accepts a single argument
% which is the genotype to typeset, with semi-colons to separate
% chromosome pairs and slashes to separate the two chromosomes of a
% pair.
%
% A pair without any slash denotes a homozygous chromosome pair.
%
% The macros |\female|, |\male|, and |\virgin| are used in the same way
% and perform the same task as |\genotype|, but they insert a female
% (\venus), male (\mars), or virgin female (\mercury) symbol in front of
% the genotype:
%
% $$
% \female{cn bw/;TM2/tra}
% \quad
% \virgin{cn bw/;TM2/tra}
% \quad
% \male{FM7a/Y;In(2LR)O, Cy/+}
% $$
%
% The plural forms of these macros (|\females|, |\males|, and
% |\virgins|) are similar but insert \emph{two} symbols, thus denotating
% several individuals of the indicated genotype.
%
%
% ^^A Inserts the LPPL text.
% \providecommand{\LPPLsection}{\section}
% \providecommand{\LPPLsubsection}{\subsection}
% \MakePercentComment\input{lppl-1-3c}\MakePercentIgnore
%
%
% \StopEventually{\PrintChanges\PrintIndex}
%
%
% \section{The code}
%
% \subsection{Initialization code}
% We start by identifying the package.
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[2003/12/01]
\ProvidesPackage{flygenet}[2013/10/09 v0.2 Fly genetics notation]
% \end{macrocode}
%
% We load the |wasysym| package, that we will use to typeset the female
% (\venus), male (\mars) and virgin female (\mercury) symbols.
% \begin{macrocode}
\RequirePackage{wasysym}
% \end{macrocode}
%
% We load the |amstext| package, which provides the |\text| macro that
% we need to typeset gene names in math mode.
% \begin{macrocode}
\RequirePackage{amstext}
% \end{macrocode}
%
%
% \subsection{Helper macros}
%
% \begin{macro}{\FG@findslash}
% This macro determines whether its argument contains a forward slash,
% and sets the |\ifFG@foundslash| boolean accordingly.
% \begin{macrocode}
\newif\ifFG@foundslash\FG@foundslashfalse
\def\FG@findslash#1/#2\end{%
\def\FG@argii{#2}%
\ifx\FG@argii\empty\FG@foundslashfalse\else\FG@foundslashtrue\fi}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Typesetting chromosomes}
%
% \begin{macro}{\FGChromosome}
% This macro typesets a single chromosome.
% \begin{macrocode}
\def\FGChromosome#1{\ensuremath{\text{\itshape #1}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FGChrPair}
% This macro typesets a chromosome pair. If the second argument is
% non-empty, the genotype is typeset as a fraction; an empty second
% argument denotes a homozygous pair which is typeset on a single line.
% \begin{macrocode}
\def\FGChrPair#1#2{%
\def\FG@argii{#2}%
\ifx\FG@argii\empty\FGChromosome{#1}\else%
\ensuremath{\frac{\text{\itshape #1}}{\text{\itshape #2}}}
\fi}
% \end{macrocode}
% \end{macro}
%
% \subsection{Typesetting genotypes}
%
% \begin{macro}{\FG@printchromosome}
% This macro typesets a single chromosome pair, presented as delimited
% arguments.
% \begin{macrocode}
\def\FG@printchromosome#1/#2\end{\ensuremath{\FGChrPair{#1}{#2}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\FG@parsechromosome}
% This macro parses a genotype notation (chromosome pairs separated by
% semi-colons), and calls the |\FG@printchromosome| for each chromosome
% pair.
% \begin{macrocode}
\def\FG@parsechromosome#1;#2\end{%
\FG@findslash#1/\end%
\ifFG@foundslash\FG@printchromosome#1\end\else\FG@printchromosome#1/\end\fi%
\def\FG@argii{#2}%
\ifx\FG@argii\empty\else; \FG@parsechromosome#2\end\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\genotype}
% This macro is the main user interface to typeset a genotype. Its
% definition is a bit tricky because we redefine the \textasciicircum\ character as
% an alias to the |\allele| macro.
% \begin{macrocode}
\begingroup
\catcode`\^=\active
\gdef\genotype{%
\catcode`\^=\active%
\let^\allele%
\end@genotype}
\gdef\end@genotype#1{\FG@parsechromosome#1;\end}
\endgroup
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\allele}
% This macro typesets its argument as a superscript. It is intended to
% represent alleles of a gene.
% \begin{macrocode}
\def\allele#1{\hspace{.1em}\textsuperscript{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\transposon}
% This macro represents a transposable elements. Its first argument
% is the type of the transposon ends (e.g., ``P'' for a P-element), the
% second is the list of genes or gene constructs inside the transposable
% element.
% \begin{macrocode}
\def\transposon#1#2{#1\{#2\}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\foreigngene}
% This macro typesets a gene originating from a distinct species.
% \begin{macrocode}
\def\foreigngene#1#2{#1\textbackslash #2}
% \end{macrocode}
% \end{macro}
%
% \subsection{Gender symbols}
%
% \begin{macro}{\female}
% \begin{macro}{\male}
% \begin{macro}{\virgin}
% These macros typeset a genotype as |\genotype| does, but insert a
% female (\venus), male (\mars) or virgin female (\mercury) symbol at
% the beginning. This is intended as an abstraction layer above the
% |wasysym| package providing these symbols.
% \begin{macrocode}
\def\female{\venus\,\genotype}
\def\male{\mars\,\genotype}
\def\virgin{\mercury\,\genotype}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\females}
% \begin{macro}{\males}
% \begin{macro}{\virgins}
% These macros are similar to their singular forms above, but inserts
% two female, male or virgin female symbols at the beginning. By
% convention, this is used to represent several individuals of the
% indicated genotype.
% \begin{macrocode}
\def\females{\venus\venus\,\genotype}
\def\males{\mars\mars\,\genotype}
\def\virgins{\mercury\mercury\,\genotype}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \Finale
\endinput