phrace

Crates.iophrace
lib.rsphrace
version0.2.4
sourcesrc
created_at2023-10-08 19:09:05.007291
updated_at2023-12-03 14:22:43.3246
descriptionTerminal graph viewer for xvg files.
homepage
repositoryhttps://git.sr.ht/~ma3ke/phrace
max_upload_size
id997388
size1,021,331
Marieke Westendorp (ma3ke)

documentation

README

phrace

A bunch of terminal windows showing the tool in action. A Grace window is also shown displaying the same (energy minimization) potential energy data as the terminal that sits above it, for comparison.

A terminal viewer for .xvg files.

Gromacs tools can output xvg files to inspect a range of properties of molecular dynamics trajectories (e.g. gmx energy). These data files are commonly viewed with the Grace (xmgrace) tool.1

Installation

If you don't have Rust installed on your system, learn how to do it here. It is very easy.

To install the binary, run the following command.

cargo install phrace

Usage

Simply invoke with a path to an xvg file. The size of the plot will be inferred from the terminal size.

phrace example_data/potential_energy_em.xvg
                 GROMACS Energies                 
  ░                                               
                                                  
   ░                                              
                                                  
                                                  
                                                  
(                                                 
k  ░                                              
J  ░                                              
/  ░                                              
m  ░░                                             
o   ▒                                             
l    ▓░                                           
)     ▓▒                                          
       ░█▓▒                                       
          ▒▓██▒                                   
              ░▓▓█▓▓██                            
                      ▓██▓█▓▓█▓▓▓                 
                                ░▓▓█▓█▓█▓▓█▓▓██▓█▓
                                                 ░
                   Time (ps)                    
Summary:  393 items,  mean ± σ  -1512.5859 ± 54.731205,  min … max  -1565.1497 … -1111.5247

You can specify the width and/or height explicitly as well.

phrace -w 50 -h 25 example_data/ramachandran.xvg
                Ramachandran Plot                 
            ░░░░░░░░░            ░░ ░░░░░    ░  ░ 
  ░░░░░░░░░░░░░░░░░░░░░            ░ ░   ░        
   ░░░░░░░░░░░░░░░░░░░░░           ░  ░  ░ ░     ░
   ░░░ ░░░░░░░░░░░░░░░░                      ░   ░
    ░░░░░░░ ░░░░░░░░░                             
       ░░░░░░░░░░░░░               ░░             
   ░     ░ ░░░░░░░░ ░                             
             ░░░░░░░               ░░   ░         
P        ░ ░ ░░░░░░               ░ ░       ░  ░ ░
s  ░░░     ░░░░░░░░░             ░░ ░ ░    ░ ░░░░░
i  ░░░░   ░░░░░░░░░░░░            ░░░░░ ░ ░ ░░░░░░
   ░░░░ ░   ░░░░▒▓█▒░░░░          ░░░░░░░░ ░░ ░░░░
   ░░░░    ░  ░░░░▒░░░░░           ░░░ ░░░░░░░░ ░░
   ░░░░  ░ ░░░ ░░░░░░░             ░░  ░  ░░  ░░  
    ░░   ░ ░   ░ ░             ░░░░░ ░      ░ ░   
    ░░          ░            ░ ░░░░░░ ░░ ░ ░      
     ░░   ░    ░               ░░░░░░░░░          
   ░        ░  ░░░░           ░░ ░░░░░  ░     ░░░ 
     ░        ░░░░░░            ░░░░░░░░░   ░░░  ░
                                     ░            
                      Phi                       
Summary:  3618 items,  mean ± σ  8.999559 ± 90.19915,  min … max  -179.764 … 179.746

Rendering the plot with an ASCII style is also possible.

phrace --style ascii -w30 -h20 example_data/potential_energy_em.xvg
       GROMACS Energies       
  .                           
(  .                          
k                             
J  .                          
/  :                          
m  -=                         
o   =#*                       
l     :#%#%#@-                
)            +#%%#%#@#%#@#%#%#
                             .
         Time (ps)          
Summary:  393 items,  mean ± σ  -1512.5859 ± 54.731205,  min … max  -1565.1497 … -1111.5247

Future work

If I have some time, I want to add more options to change the viewport, add axis tick labels, ability to plot multiple columns at once. For now, it fits my needs, and I am putting it out there for others to use in case they find it useful in its current state.

I am interested in adding support for more data formats. Honestly, it would be pretty cool to add the ability to graph out some weird and esoteric formats, but maybe doing like... csv is cool too I guess. Get in touch if you have a particular need, and we can see whether we can pull some programming crimes together.

More plotting styles may also pop up if I feel inspired.

In other words: contributions and collaboration welcome.

Dependencies

Depends on the terminal_size crate for getting the width and height of the terminal. Depends on the lexopt crate for parsing command line arguments. No other dependencies.


By Ma3ke.

Footnotes

  1. By the way, insanely cool website. Check it out!

Commit count: 0

cargo fmt