\documentclass[12pt]{scrartcl}

\usepackage{comment}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{catchfile}
\pagestyle{fancy}

\CatchFileDef{\RGFAver}{version}{}

\usepackage{array}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\rhead{\bfseries RGFA \RGFAver Cheatsheet (\thepage/\pageref{LastPage})
\hspace{1.1cm}}
\lfoot{\tiny \ \ \ \ \ \ \ \ Copyright (c) 2016, Giorgio Gonnella, ZBH, University of
Hamburg, Germany. This document is under CC-BY-SA license.}

\newcounter{cstablecounter}
\setlength{\footskip}{0in}
\usepackage[top=1in, bottom=0.25in, left=0.1in, right=0.1in]{geometry}

\newcommand{\cstablestart}{
\begin{center}
%  \large
%  \textbf{RGFA: Cheatsheet
%  (\refstepcounter{cstablecounter}\arabic{cstablecounter}/2)
%  }\\
%\end{center}
%\vspace*{\fill}
%\begin{table}[h]
\centering
}
\setlength{\baselineskip}{0pt}
\setlength{\textfloatsep}{0pt plus 0pt minus 0pt}
\setlength{\intextsep}{0pt plus 0pt minus 0pt}
\setlength{\floatsep}{0pt plus 0pt minus 0pt}
\newcommand{\cstableend}{
\end{center}
  %\end{table}
%\vspace*{\fill}
%\newpage
}

\begin{document}

\cstablestart

\begin{tabular}{|l|>{\ttfamily}l|}
  \hline
  Create graph & RGFA.new \\
  \ldots from GFA file & RGFA.from\_file("filename")\\
  \ldots from string & string.to\_rgfa \\
  \ldots from string array (e.g.) & \verb/["H\tVN:i:1.0",/ \\
    & \hspace{2.3mm}\verb/"S\tA\t*\tLN:i:1200"].to_rgfa/ \\
  \hline
  Write GFA to file & gfa.to\_file(filename) \\
  Write GFA to standard output & puts gfa \\
  Create deep copy & gfa.clone \\
  Output statistics (normal/compact) & puts gfa.info; puts gfa.info(true) \\
  \hline
  Turn off validations & gfa.turn\_off\_validations \\
  Validate line references & gfa.validate! \\
  Enable progress logging & gfa.enable\_progress\_logging \\
  \hline
  Name of all segments & gfa.segment\_names \\
  Name of all paths & gfa.path\_names \\
  All segments, links, paths, etc & gfa.segments; gfa.links; gfa.paths; \ldots \\
  Iterate over segments, links, etc & gfa.segments.each \verb/{|s|...}/ \\
  \hline
  Find segment & gfa.segment(segment\_name) \\
  \ldots exception if does not exist  & gfa.segment!(segment\_name) \\
  \hline
  Find path & gfa.path(path\_name) \textrm{(or: }path!\textrm{)} \\
  All paths through segment & gfa.paths\_with(segment\_name) \\
  \hline
  Find link & gfa.link(\verb/[:S1,:E]/,\verb/[:S2,:B]/) \textrm{(or: }link!\textrm{)} \\
  (or, if multiple may exist) & gfa.links\_between(\verb/[:S1,:E]/,\verb/[:S2,:B]/) \\
  All links of segment end & gfa.links\_of(\verb/[:S1,:E]/) \\
  (also segment instead of name) &
  gfa.links\_of(\verb/[segment!(:S1),:E]/) \\
  Target of all links & gfa.neighbours(\verb/[:S1,:E]/) \\
  \hline
  Find containment  & gfa.containment(container,~contained)\\
                    & gfa.containment!(container,~contained)\\
  (or, if multiple may exist)  & gfa.containments\_between(c\_ner,~c\_ned)\\
  All containments for a segment & gfa.containing(contained)\\
                                 & gfa.contained\_in(container)\\
  \hline
  Add line (examples)        & gfa << "H\verb/\t/VZ:i:1.0" \\
                             & gfa << "S\verb/\t/a\verb/\t/*\verb/\t/LN:i:1200" \\
  Rename segment or path & gfa.rename(:old, :new) \\
  \hline
  Segment coverage & s.coverage\\
  Segment coverage (more accurate) & s.coverage(unit\_length:~avreadlen)\\
  Segment K-mer coverage & s.coverage(count\_tag:~:KC)\\
  Segment length & s.length\\
  Other end of a link & link.other\_end([s1,:E])\\
  Other end of other end of link &
  link.other\_end([s1,:E])\\
  & \hspace{2.8cm}.revert\_end\_type\\
  \hline
  Read req.field/tag value & segment.from; segment.LN \\
  \ldots raise if tag not available & segment.LN! \\
  \ldots tag string & segment.field\_to\_s(:LN) \\
  \hline
  Set/create custom tag (ab, Z type) & segment.ab = "value" \\
  \ldots of i or B/i type & s.ab = 12; \ \ \ s.ab = [1,2,3]\\
  \ldots of f or B/f type & s.ab = 12.0; \ s.ab = [1.2,2.3,3.0] \\
  \ldots of J type (hash/array) & s.ab = \{"a" => 12\}; s.ab = ["a","b",1] \\
  \hline

\end{tabular}

\cstableend

\cstablestart

\begin{tabular}{|l|>{\ttfamily}l|}
  \hline
  Delete segment (and its links, etc) & gfa.rm("a") \\
  Delete path & gfa.rm("path1") \\
  Delete link/containment  & gfa.rm(gfa.link(\ldots)) \\
  Delete all headers & gfa.rm(:headers) \\
  Delete sequences (set all to \texttt{*}) & gfa.rm(:sequences) \\
  \hline
  \textit{(rm with a method)} &\\
  Delete links of segment end & gfa.rm(\verb/:links_of,[:S1,"E]/) \\
  Delete link targets  & gfa.rm(\verb/:neighbours,[:S1,"E]/) \\
  Delete paths of segment & gfa.rm(\verb/:paths_with,:S1/) \\
  Delete segments contained in s & gfa.rm(\verb/:contained_in,:s/) \\
  Delete s1-E links except to s2-B & gfa.delete\_other\_links(\verb/[s1,:E],[s2,:B]/)\\
  \hline
  Access headers field & gfa.header.xx \\
  Add new header field & gfa.header.add(:xx, 12)\\
  \hline
  Sum of read counts & \verb/gfa.segments.map(&:RC).inject(:+)/ \\
  Highest coverage & \verb/gfa.segments.map(&:coverage).max/ \\
  Delete low coverage segments & \verb/gfa.rm(gfa.segments.select {|s|/ \\
                               & \hspace{2.7cm}\verb/s.coverage < mincov })/ \\
  Delete isolated segments & \verb/gfa.rm(gfa.segments.select {|s|/ \\
                      & \hspace{1cm}\verb/gfa.connectivity(s) == [0,0] })/ \\
  \hline
  Muliply segment & gfa.multiply("A", 4) \\
  Detect linear paths & gfa.linear\_paths \\
  Detect and merge linear paths & gfa.merge\_linear\_paths \\
  Compute connected components & gfa.connected\_components \\
  Component of a segment & gfa.segment\_connected\_component(s) \\
  Split components & gfa.split\_connected\_components \\
  Number of dead ends & gfa.n\_dead\_ends \\
  \hline
  \textit{(require "rgfatools")} & \\
  Muliply segment, distribute links & gfa.multiply("A", 4) \\
  Compute copy numbers & gfa.compute\_copy\_numbers \\
  Apply copy numbers & gfa.apply\_copy\_numbers \\
  Orient invertible segments & gfa.randomly\_orient\_invertibles \\
  Enforce mandatory links & gfa.enforce\_mandatory\_links \\
  Remove p-bubbles & gfa.remove\_p\_bubbles \\
  Remove small components & gfa.remove\_small\_components(minlen) \\
  \hline
  \textit{(Command line tools)} & \\
  Compare two GFA files & gfadiff 1.gfa 2.gfa \\
  \ldots only segments and links & gfadiff -s -l 1.gfa 2.gfa \\
  \ldots output as ruby script & gfadiff -script 1.gfa 2.gfa \\
  Merge linear paths in graph & rgfa-mergelinear 2.gfa > 3.gfa \\
  \hline
  \textit{(Case studies CLI tools)} & \\
  Simulate de Bruijn graph & rgfa-simdebruijn 27 gnm.fas > 1.gfa \\
  \ldots and find CRISPRs candidates & rgfa-findcrisprs 1.gfa \\
  \hline
\end{tabular}

\cstableend

\end{document}

