Skip to content
  • PRELIMINARIES

    WARNING above is completely untested. Needs testing on macos and maybe linuxbrew. You can setup brew on macos, and linux, and in windows usising something like WSL (Windows Sub-system-for-Linux) like WSL or WSL2 (or maybe even cygwin).

    On linux, instead of brew you can do conda install rnastructure -c bioconda which as of Mar 2021 works only on linux and not macos (yet). See https://bioconda.github.io/recipes/rnastructure/README.html which also has docker info.

    $ conda activate
    $ conda install rnastructure -c bioconda
    $ export DATAPATH="$CONDA_PREFIX/share/rnastructure/data_tables/" # survives `conda update rnastructure` 

    Most of the commands in RNAstructure suite (in bin or exe folder) require you set DATAPATH to point to the data_tables folder. If using brew it should maintain a symlink to it here:

    $ ls -ld           $(brew --prefix)/share/rnastructure/data_tables/
    $ export DATAPATH="$(brew --prefix)/share/rnastructure/data_tables/"

    The symlink to it should get updated if you do brew switch rnafolder to switch between, say version 6.1 and 6.2.

    We don't expect data_tables to change much, but there actually is one new file in the 6.2 version:

    $ cd $(brew --prefix)/Cellar/rnastructure
    diff -r 6.2/data_tables/ 6.1/data_tables/
    Only in 6.2/data_tables/dists: DMSdist_nt.txt

    EXAMPLE

    Script adapted from https://rna.urmc.rochester.edu:81/mathews-lab/bootcamp/wikis/Shell-Scripting

    #!/bin/bash
    ## this is demo-part.sh 
    
    ### === snip === this snip not be needed unless data_tables was not moved to ./share/rnastructure/
    ### If data_tables folder was left in same parent folder as exe (or bin) folder 
    ### brew install coreutils (to get realpath). Assuming RNAstructure.jar is in bin or exe folder...
    # export HOMEBREW_PREFIX=$(brew --prefix)
    # RNAJARFILE=$(realpath $HOMEBREW_PREFIX/bin/RNAstructure.jar)
    # export DATAPATH="$(dirname $RNAJARFILE)//../data_tables"
    ### === end snip ===
    
    ### You may want to add the `export DATAPATH=...` line below to your ~/.bashrc  and/or ~/.zshrc
    
    export DATAPATH="$(brew --prefix)/share/rnastructure/data_tables/"
    echo "Note: DATAPATH size and location:"
    du -sh $DATAPATH
     
    
    echo "Adapted from https://rna.urmc.rochester.edu:81/mathews-lab/bootcamp/wikis/Shell-Scripting"
    
    # This script runs a partition function, followed by the prediction of
    # a maximum expected accuracy secondary structure
    
    # Define a path to a sequence file for the input
    seq_file="RD0500.seq"
    
    # Define a path to a structure file for the output
    ct_file="RD0500-demo.ct"
    
    # Calculate the partition function, the output will be saved to foo.pfs
    partition $seq_file foo.pfs
    
    # Predict a secondary structure from the pfs file
    MaxExpect foo.pfs $ct_file
    

    To run above script...

    bash-5.0$ cat RD0500.seq 
    ;
    RD0500
    GCCCGGGUGGUGUAGUGGCCCAUCAUACGACCCUGUCACGGUCGUGACGCGGGUUCgAAUCCCGCCUCGGGCGCCA1
    
    bash-5.0$ ./demo-part.sh 
    Note: DATAPATH size and location:
     14M	/usr/local/share/rnastructure/data_tables/
    The script is from https://rna.urmc.rochester.edu:81/mathews-lab/bootcamp/wikis/Shell-Scripting
    Initializing nucleic acids...done.
     92% [===============================================   ] \                     done.
    Single strand partition function complete.
    Initializing nucleic acids...done.
    Calculating maximum expected accuracy structures...done.
    Writing output ct file...done.
    Calculation of maximum expected accuracy structures complete.
    
    bash-5.0$ head RD0500-demo.ct 
       76  ENERGY = 6.2  RD0500
        1 G       0    2   72    1
        2 C       1    3   71    2
        3 C       2    4   70    3
        4 C       3    5   69    4
        5 G       4    6   68    5
        6 G       5    7   66    6
        7 G       6    8   65    7
        8 U       7    9   64    8
        9 G       8   10   63    9
    Edited by billday
  • TODO: add more info and examples here about python wrappers and/or functions to use RNAstructure like https://github.com/mmagnus/rna-tools/blob/master/rna_tools/rna_dot2ct.py (So you can write python scripts in addition to or instead of shell scripts ;-)

  • Self-tests can be run as follows.

    $ make unit-tests
    $ ./exe/unit-tests
    Unit test results are shown below.
    Tests are identified by line-number (in square brackets).
    PASSED TEST[218] Expected==Actual=="Hello" [5 char*]
    PASSED TEST[219] Expected==Actual=="Hello" [5 str]
    ### ... about 100 more lines of output ...
    PASSED TEST[204] Expected==Actual=="" [0 str]
    PASSED TEST[205] Expected==Actual=="" [0 str]
    PASSED TEST[206] Expected==Actual=="ENERGY = 3.6" [12 str]
    Done testing. Passed: 111 Failed: 0

    Example below shows how to run tests for just the dot2ct utility with dot2ct-tests.sh (which I keep in /usr/local/bin/) dot2ct-tests.sh Or instead of using script, just do: cd tests; ./scripts/test-runner.sh --serial dot2ct

    #!/usr/bin/env  bash
    ### dot2ct-tests.sh  runs tests of dot2ct utility
    ### see https://gitlab.oit.duke.edu/-/snippets/179
    ### TODO:  push dir before running and popdir when done.
    export HOMEBREW_PREFIX=$(brew --prefix)
    RNAJARFILE=$(realpath $HOMEBREW_PREFIX/bin/RNAstructure.jar)
    # export DATAPATH="$(dirname $RNAJARFILE)//../data_tables"
    RNAstructureHOME="$(dirname $RNAJARFILE)//../"
    echo "RNAstructureHOME =$RNAstructureHOME"
    echo "doing cd './tests/' subdir before running ./scripts/test-runner.sh"
    cd $RNAstructureHOME/tests/
    ./scripts/test-runner.sh --serial dot2ct 
    echo "For list of passed tests do:  tail  './!PASSED_TESTS.log' "
    cat << EOF
    If all tests passed then above file ends with lines similar to these:
    2021-03-24 13:12:40     dot2ct_without_options
    2021-03-24 13:12:40     dot2ct_all_structures
    2021-03-24 13:12:40     dot2ct_single_structure
    2021-03-24 13:12:40     dot2ct_format_multi
    2021-03-24 13:12:40     dot2ct_format_simple
    2021-03-24 13:12:40     dot2ct_format_side
    2021-03-24 13:12:40     dot2ct_pseudoknot
    EOF

    Below is output, which is colorized with green for passed tests when run in typical terminal

    bash-5.0$ dot2ct-tests.sh 
    RNAstructureHOME =/usr/local/Cellar/rnastructure/6.2/bin//../
    doing cd './tests/' subdir before running ./scripts/test-runner.sh
    Running Test Script scripts/dot2ct.sh
    Test Options: DumpErrors ShowOutput
    
    Beginning 'dot2ct' tests...
      Building executables for dot2ct tests...
        Making dot2ct...
      Done Building executables (0 errors).
      Test dot2ct 'without_options' started...
    Converting dot bracket file...Dot bracket file conversion complete.
      * Test Passed: dot2ct_without_options
      Test dot2ct 'all_structures' started...
    Converting dot bracket file...Dot bracket file conversion complete.
      * Test Passed: dot2ct_all_structures
      Test dot2ct 'single_structure' started...
    Converting dot bracket file...Dot bracket file conversion complete.
      * Test Passed: dot2ct_single_structure
      Test dot2ct 'format_multi' started...
    Converting dot bracket file...Dot bracket file conversion complete.
      * Test Passed: dot2ct_format_multi
      Test dot2ct 'format_simple' started...
    Converting dot bracket file...Dot bracket file conversion complete.
      * Test Passed: dot2ct_format_simple
      Test dot2ct 'format_side' started...
    Converting dot bracket file...Found side label: 'ENERGY = -33.6  RA7680'
    Found side label: 'ENERGY = -32.5  RA7680'
    Found side label: 'ENERGY = -31.9  RA7680'
    Found side label: 'ENERGY = -31.0  RA7680'
    Dot bracket file conversion complete.
      * Test Passed: dot2ct_format_side
      Test dot2ct 'pseudoknot' started...
    Converting dot bracket file...Dot bracket file conversion complete.
      * Test Passed: dot2ct_pseudoknot
    Completed 'dot2ct' tests.
    
    For list of passed tests do:  tail  './!PASSED_TESTS.log' 
    If all tests passed then above file ends with lines similar to these:
    2021-03-24 13:12:40     dot2ct_without_options
    2021-03-24 13:12:40     dot2ct_all_structures
    2021-03-24 13:12:40     dot2ct_single_structure
    2021-03-24 13:12:40     dot2ct_format_multi
    2021-03-24 13:12:40     dot2ct_format_simple
    2021-03-24 13:12:40     dot2ct_format_side
    2021-03-24 13:12:40     dot2ct_pseudoknot
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment