Is there a command line tool that can take an alignment fasta and input and outputs an image?
1
1
Entering edit mode
2.5 years ago

Hello!

I've been trying to find a software that does what the post title describes, but without luck. I tried installing JalView but it won't install for some reason "Installer User Interface Mode Not Supported".

I have hundreds of images to generate so going to a browser MSA viewer and manually saving is not feasible. Am I out of luck or just bad at googling?

Big thanks in advance!

alignment fasta image • 1.3k views
ADD COMMENT
4
Entering edit mode
2.5 years ago
Joe 19k

There’s a commandline version of Espript IIRC. That would probably work.

I also like the TeX package texshade for rendering MSAs, if you’re prepared to get your hands dirty with TeX.

I’ll post an example when I’m at a proper computer.

Finally at a computer, so here's an example of something you can do with TeXShade. You can of course run TeX from the commandline. It would probably be sufficient to write a wrapper script to inject the file names, or to actually write the source itself for you.

\documentclass[a4paper, oneside, 11pt]{report} % Doc Setup
\usepackage[left=1cm, right=1cm, top=1cm, bottom=1cm]{geometry}  % Doc Geometry
\usepackage{texshade}
\usepackage{lscape}

\begin{document}
\begin{landscape}

\begin{texshade}{/path/to/your/alignment.ext}
  \seqtype{P}
  \setfont{numbering}{tt}{md}{sc}{small}
  \setfont{names}{tt}{md}{up}{tiny}
  \setfont{residues}{tt}{md}{sc}{tiny}
  \setfont{ruler}{tt}{bf}{sc}{tiny}
  \shadingmode[allmatchspecial]{similar}
  \feature{top}{1}{25..25}{fill:$\downarrow$}{Hi, I'm an annotation}
  \feature{bottom}{1}{70..76}{brace}{So am I!}
\end{texshade}
\end{landscape}

\end{document}

This creates:

Screenshot-2019-06-17-at-10-39-39

It might not be a perfect solution, as you'd need to play with the sizing etc, or perhaps figure it out dynamically. I think Espript actually runs LaTeX behind the scenes anyway.

ADD COMMENT
0
Entering edit mode

I am very OK with TeXing. Looking into Espript in the meantime. Thank you!

ADD REPLY
0
Entering edit mode

Hey, I can't find a link to download Espript. It says in the FAQ that it's a web browser software? http://espript.ibcp.fr/ESPript/ESPript/esp_faq.php

ADD REPLY
0
Entering edit mode

Yup... I guess I'm terrible at searching, but to be fair it's a bit of a stretch to have to navigate through "Online and web" to find what is offline and not web. -_-

Big thanks though!!!

ADD REPLY
1
Entering edit mode

Yeah, I agree, they could certainly make it more obvious.

ADD REPLY
0
Entering edit mode

Don't forget to upvote comments/answers that have helped, and to Accept answers that fully address your question.

ADD REPLY
0
Entering edit mode

That is quite beautiful! I shall keep this one... and if Espript proves troublesome I know what to do. Big thanks!!

ADD REPLY
1
Entering edit mode

I encourage you to read the documentation, there's a hell of a lot of customisation achievable with TeXShade.

ADD REPLY
0
Entering edit mode

Hey, ESpript was interactive in the CLI so I had to resort to texshade. It's... almost working well. Wasted a few hours on that it couldn't handle special characters in the sequence IDs, amongst other things.

Anyway, now I only need to figure out how to properly center the image. Do you have any ideas? I've tried the \alignment{center} but it appears to do nothing. I tried enclosing the \texshade environment in a \begin{center} but that led to a crash...

ADD REPLY
1
Entering edit mode

Ahh, I didn't realise that, its been some time since I tried using it. That's a pain.

Without testing it, I would have expected \begin{center}... to work, it may be the landscape-ness of my example which is causing problems.

Here's one option you could consider, use of the memoir documentclass includes the \vplace{} environment:

\documentclass[a4paper, oneside, 11pt]{memoir} % Doc Setup
\usepackage[left=1cm, right=1cm, top=1cm, bottom=1cm]{geometry}  % Doc Geometry

\usepackage{texshade}
\usepackage{lscape}
\usepackage[active, tightpage]{preview}

\begin{document}
\begin{landscape}
\begin{preview}
\begin{vplace}
    \begin{texshade}{/path/to/sequences.aln}
        \seqtype{P}
        \alignment{center}
        \setfont{numbering}{tt}{md}{sc}{small}
        \setfont{names}{tt}{md}{up}{tiny}
        \setfont{residues}{tt}{md}{sc}{tiny}
        \setfont{ruler}{tt}{bf}{sc}{tiny}
        \shadingmode[allmatchspecial]{similar}
        \smallblockskip
        \feature{top}{1}{25..25}{fill:$\downarrow$}{Hi, I'm an annotation}
        \feature{bottom}{1}{70..76}{brace}{So am I!}
    \end{texshade}
\end{vplace}
\end{preview}
\end{landscape}
\end{document}

Combined with the preview package, the page can be made to dynamically fit the content. I haven't tested this with an alignment that runs over more than one line, but I think in theory at least, it should work.

I get:

Screenshot-2019-06-19-at-10-30-43-2

ADD REPLY
1
Entering edit mode

You are so helpful! Thank you :))

My code has the same structure as yours, but I'm getting silly results where you get nice ones. My alignments are not centered, wrap to multiple lines, and the output page is not landscape oriented. Hmm...

\documentclass[a4paper,oneside,12pt]{memoir}
\usepackage[left=0.1cm,right=0.1cm,top=0.1cm,bottom=0.1cm]{geometry}
\usepackage{texshade}
\usepackage[active,tightpage]{preview}
\usepackage{lscape}
\begin{document}
\begin{landscape}
\begin{preview}
\begin{vplace}
    \begin{texshade}{protGroup_3.aligned.straight.sorted.prepared}
    \seqtype{P}
    \alignment{center}
    \setfont{numbering}{tt}{md}{sc}{tiny}
    \setfont{names}{tgpagella}{md}{it}{tiny}
    \setfont{residues}{tt}{md}{sc}{tiny}
    \setfont{ruler}{tt}{bf}{sc}{tiny}
    \setfont{features}{tgpagella}{md}{sc}{tiny}
    \setfont{hideblock}{tgpagella}{md}{sc}{tiny}
    \setfont{legend}{tgpagella}{md}{sc}{tiny}
    \setfont{featurestyles}{tgpagella}{md}{sc}{tiny}
    \shadingmode[allmatchspecial]{similar}
    \smallblockskip
    \end{texshade}
\end{vplace}
\end{preview}
\end{landscape}
\end{document}
ADD REPLY
1
Entering edit mode

can you provide a link to your alignment, so I can try it with that data specifically?

Are you creating this document with latex or some of the other variants?

ADD REPLY
1
Entering edit mode

I'm creating a pdf with xelatex through latexmk because I need to use special fonts that weren't available in pdflatex. Pastebin fasta: https://pastebin.com/xgNxMMRv

I then convert the pdf to jpg but that's unimportant since the pdf is unsatisfactory: https://ibb.co/LNGHG7Y

I have to leave work now but know that I really appreciate your support! There is no active help channel for texshade according to my googling so without you I'd be quite lost ^_^

ADD REPLY
1
Entering edit mode

The developer of the package is reasonably respondent when I've spoken to him in the past.

I can reproduce weird formatting if I typeset with xelatex, though I confess this is where my TeX experience starts to run thin, as I've only ever worked with 'basic' LaTeX.

The actual texshade object can just be considered a box/figure like anything else in TeX though, so it should be manipulable in most if not all of the standard ways. I did experiment with putting it inside a minipage, but it seemed tedious and not very robust so quickly gave up on that approach.

I landed upon this thread: https://tex.stackexchange.com/a/299008/60232 and tried David Carlisle's approach, but that doesn't work in base latex. According to the comments it should work with xetex so maybe xelatex too? Worth a try perhaps.

Alternatively, you might have to experiment with making your fonts work with base latex instead....

Testing with your data, but via LaTeX does still produce the desired output (the length of each line can be controlled with \linewidth generally, and via specific options inside the TeXShade environment too):

Screenshot-2019-06-19-at-12-43-52

ADD REPLY
0
Entering edit mode

I'll see if I can get in touch with him then!

If I change back to LaTeX I can get it working OK, actually. Too bad... I thought XeTeX and LuaTeX were supposed to build on LaTeX, not diverge from it!? :(

I tried the solution by Carlisle but get this error regardless of whether I use LaTeX or XeLaTeX: ! Dimension too large. l.25 \pdfpagewidth=\wd0

Not knowledgeable enough to understand what is means.

I think I'll have to stick with your solution and base LaTeX. Perhaps there's some font similar enough to Palatino...

ADD REPLY
1
Entering edit mode

Yep thats the same error I got from David's suggestion, but I assumed that might have been a base LaTeX issue. Was above my head too, and I lacked the enthusiasm to delve in to every element of that answer to see what was going on!

I think you can use the fontspec package in base latex to add custom fonts. Its normally just a matter of pointing a filepath at the palatino.ttf file.

ADD REPLY
0
Entering edit mode

Yeah I have successfully used fontspec and eg tglpagella in a minimal Latex script, but when I use it inside the texshade environment everything goes bonkers. Do you have a fresh e-mail address to the writer of texshade? I only find old ones that cause a bounce...

ADD REPLY
1
Entering edit mode

Inside the TeXShade environment itself you may be limited, as the package works by measuring the M and g characters to calculate how wide the lines need to be etc. They would also need to be monospaced fonts for the alignments to render properly. You may have to toggle between font sets for the rest of the doc, and for the TeX environment. Alternatively, use the above solutions to render an image, and then pull that image in separately into a doc using Xe(La)TeX.

The last email I used (bearing in mind this was around 6 months ago) was: ebeitz [at] pharmazie [dot] uni-kiel [dot] de

(Obfuscated the email so that hopefully it doesn't get picked up by bots).

ADD REPLY
2
Entering edit mode

Heyo, I got in touch with him. Turns out if you put e.g. \usepackage{tglpagella} in the header, that becomes the 'default' font for the TexShade env, and the default font is called with 'rm', apparently (I thought 'rm' was for roman or something):

\setfont{names}{rm}{md}{up}{tiny}

And now it works perfectly!

I cropped the resulting images with imagemagick's convert -trim. I'm a jolly fellow now.

Thanks for everything, m8!

ADD REPLY
0
Entering edit mode

Perfect! LaTeX never ceases to amaze.

ADD REPLY
1
Entering edit mode

That email worked!

Thank you and I will let you know what he says about this :-]

ADD REPLY
0
Entering edit mode

Revisting this thread to remind myself (having just wasted the last half an hour chasing ghosts), that texshade will not cooperate with 'shorthand' file paths, so ensure you use the absolute path to the alignment (i.e. avoid ~).

ADD REPLY

Login before adding your answer.

Traffic: 1682 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6