Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a proper way to show a FASTA file in LaTeX?

So far I tried $'s or listings and TeXshade but this does not seems to work.

share

migration rejected from stackoverflow.com Mar 2 at 17:34

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as unclear what you're asking by Jubobs, Jesse, T. Verron, Sean Allred, Marco Daniel Mar 2 at 17:34

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
What exactly is your issue with TeXshade? This is the standard solution for typesetting nucleotide sequences and alignments. “does not seem to work” isn’t a good error description; please be more specific. –  Konrad Rudolph Oct 6 '11 at 12:23
    
Its gives alignments as far as I can tell. I just want to show an example of a FASTA file. Thus a proper.. >header ATGCAGCAG and sequence. This I could not find with TeXsha –  Jasper Oct 6 '11 at 12:58
4  
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. Also, please add information to your question by editing it instead of posting additional information as an answer. –  N.N. Oct 6 '11 at 13:34
    
Please register your accounts here and on stackoverflow.com, so that they can be connected and you receive ownership of the question again. Then you will be able to update it to provide more information as well as accept the best answer. Thanks. –  Martin Scharrer Oct 6 '11 at 22:38
    

1 Answer 1

Proper alignment using listings is possible by setting the font to typewriter (basicstyle=\ttfamily as optional parameter, or by using \lstset):

\documentclass{article}
\usepackage{filecontents}% http://ctan.org/pkg/filecontents
\usepackage{listings}% http://ctan.org/pkg/listings
​\begin{document}

% Taken from http://en.wikipedia.org/wiki/FASTA_format#Format
\begin{filecontents*}{fasta.txt}
>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
IENY
\end{filecontents*}

\lstinputlisting[basicstyle=\ttfamily]{fasta.txt}
\end{document}

FASTA file in LaTeX

If you want to remove the header from the file, specify firstline=2 or however many lines your header takes up. If you only want to include certain parts of the file, use linerange={<first>-<last>}, where <first> and <last> are also included in the output.

In the above example, the filecontents package supplies the means to write contents to an external file directly, at compile time, for inclusion in the listing. This keeps the document self-contained and portable, much like the .dtx package distribution.

share