lenaschimmel / sc2rf

SARS-Cov-2 Recombinant Finder for fasta sequences

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Way to pipe results to png, txt files

opened this issue · comments

This is a fantastic tool, and I've already put it to good use in Arkansas to research some strange lineages. Great work!

I do have to share the visuals, and I an wondering if there is a way to pipe the results to an outside file, such as png or txt. I am more of an applied researcher, so if I missed something, I would appreciate any directions.

Again, great tool already!

Thanks,

This program has no built-in support to save the results to text or image files. I think I will add something like this in the future, but it doesn't have a very high priority for me.

I just tested textimg, and after downloading it I ran:

./search_recombinants.py ../shared-sequences/ba1_ba2.aligned.fasta -s 1-10 | ~/bin/textimg -o test.png 

This is the output:

test

The result is okay-ish, but has two obvious issues:

  • The reverse coloring in the "genes" bar does not work. I think I can fix this with some changes in my code, without breaking the normal usage.
  • The letter spacing is a bit too dense (see magnified image below). Letters touch each other or even overlap. I tried with many different fonts and font sizes, but it did not solve the problem. I'm not sure if this is a problem specific to my system (MacOS) or a general problem of textimg.

Bildschirmfoto 2022-03-18 um 18 13 06

I suspect there may be other programs which work like textimg, this is just the first one I found.

By the way, I think I will add a way to remove the verbose output of the top, everything above "Potential recombinants between…" because I think you wouldn't want to have that in the image.

I just pushed some updates. This fixes the genes-color-bar issue and also omits the verbose stuff at the beginning, unless you provide the --verbose flag. Output looks like this now:

test

You might also try AnsiLove. I didn't try yet. Beware, the website has some example Ansi Art pictures that are not exactly "safe for work":

https://www.ansilove.org/

Thank you!

I just tried AnsiLove. It did not work out of the box, because my program outputs some UTF-8 characters but AnsiLove only supports the ASCII character set and a few code pages like Latin-1.

I know it's not an important feature, but seeing these old DOS fonts reminded me a lot of my childhood and made me feel a bit nostalgic. So now there's the --ansi option which makes the output compatible with AnsiLove. You just have to figure out the width of the output and provide it via -c to AnsiLove:

./search_recombinants.py ../shared-sequences/pot_rec.aligned.fasta -s 1-20 \
--primers primers/midnight.bed --ansi > test.ansi

ansilove -c 140 -b 9 test.ansi

This resulted in this png:

test ansi

You're welcome! Nice to hear that you already had success with it and thanks for mentioning this tool.

(When you sent this answer using email, GitHub failed to remove some lines, that's why I edited your comment)