Closed ababaian closed 6 years ago
Basic fasta syntax highlighting working in less
. Note: the limited color palette at the moment is limiting the ability to add amino-acid coloring support.
Most of .sam
is done for less along with detailed installation instructions for use in making the installer. I'll tweak this a bit more.
I've completely ported VCF to less and updated the installer instructions. I found another way to do robust column expression in this syntax language. VCF Files with long rows (100+ samples) take a long time to parse, about 3-4 lines per second. A better programmer then me should look into optimizing the regex code for faster coloring. It's well usable though.
With 1000genomes data (1000 columns in examples/vcf/test_1000genomes.vcf.gz
) it takes 15+ seconds to load a row! Needs work. If someone wants to do some heavy-lifting optimization-wise, don't lose any features and optimize the regex. @lazypanda10117 perhaps?
I was doing a little bit of work and I realized that I often would read fq files with less while streaming it from gzip (.fq.gz). So I've added .fq .fai .flagstat .bed .gtf
support for less so it's more complete now.
We should probably do .pdb
as well so it's "complete"
gtf-less
Two formats, .sam and .vcf, are often very large and cannot be opened quickly in
vim
or any other text editor without loading to memory (although vim is decent if you have enough memory). This can be sort of solved by usinghead
. The better solution is usingless
for .sam and .vcf. So can we have syntax highlighting there for these important formats?We can leverage the source-highlight package to accomplish this. I believe the syntax-language files may be shared with gedit which will save work on that end.
Installing
source-highlight
in less (Ubuntu)1) Install
source-highlight
to your system:2) Append these lines to your
~/.bashrc
and/or~/.zshrc
Note: On different systems the
/usr/share/source-highlight/src-hilite-lesspipe.sh
may be installed to a different directory. (i.e CentOS:export LESSOPEN="| /usr/bin/src-hilite-lesspipe.sh %s"
)Installing
bioSyntax
for less (Ubuntu)1) Update the
src-hilite-lesspipe.sh
script in the source-highlight directory.2) Copy over the
*.lang
,.outlang
and.syntax
files to the source-highlight directory.3) Restart your computer for the
rc
file to update in your terminal.Running bio-aware
less
1) Automatic detection of file-extensions when reading entire file
*.fa
,*.fasta
,*.sam
less hgr1.fa
2) Piping requires explicit use of
fa-less
,sam-less
orvcf-less
which can be combined in all the interesting ways you can come up with.samtools view -h accepted_hits.bam | sam-less
Developing language syntax files (ongoing)
Source-highlight
only has 17 colors defined in its colors.h file. We would have to re-compile it to add more color compatibility. Can do quite a bit with 17 colors; just not amino-acid coloring. 1) Syntax regex are defined in/usr/share/source-highlight/<Language>.lang
1b) and have an associated<Language>.style
2) Are piped into less-readable format byesc.outlang
3) Which is then made pretty by/usr/share/source-highlight/esc.style
4) Automatic file-extension recognition for less is performed insrc-hilite-lesspipe.sh
there is logic for runningsource-highlight
. At Line 11 insert:We define a single
<language>.lang
and<language>.style
per language &bioSyntax.outlang
file forfasta.lang
,sam.lang
andbioSyntax-vcf.outlang
forvcf.lang
file each to get less working.Known Bugs
less
looks like gibberish then chances are your terminal doesn't support 256 colors. Trytput colors
to tell how many colors are supported. Will add 8-color theme in the future.