SmallWorld Documentation for Future Developer: Difference between revisions

From DISI
Jump to navigation Jump to search
No edit summary
Line 220: Line 220:
#If it works, then the new WAR File is located at '''/mnt/nfs/home/jjg/smallworld_build_from_source/smallworld-java-src/web/target/sw-ws-5.5.war'''
#If it works, then the new WAR File is located at '''/mnt/nfs/home/jjg/smallworld_build_from_source/smallworld-java-src/web/target/sw-ws-5.5.war'''


==Restarting Smallworld Instance(s)==
== Restarting Smallworld Instance(s) ==
# Ssh to abacus and become root
# Ssh to abacus and become root
# execute '''run_sw_on_reboot.sh''' to show restart all instances on the machine
# execute '''run_sw_on_reboot.sh''' to show restart all instances on the machine
Line 229: Line 229:
#: <source>
#: <source>
start_smallworld
start_smallworld
</source>
== Java Command Line ==
<source>
#!/bin/bash
smi_file=$1
library=$2
max_hits=$3
distance=$4
version="5.5"
sw_dir=/mnt/nfs/db3
sw='java -jar /nfs/db3/smallworld-'$version'/sw.jar'
public_dir=${sw_dir}/public_smallworld_5th_gen/
private_dir=${sw_dir}/private_smallworld_5th_gen/
public_maps=${public_dir}maps/*.anon.map
private_maps=${private_dir}maps/*.anon.map
if [ "$smi_file" = "-h" ] || [ "$smi_file" = "--help" ]
then
        printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
        echo "This script performs a similarity search on all databases in the public or private smallworld."
        printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
        echo "Usage: bash cmd_sim.sh <smiles text file> <library> <max_hits>  <distance>
        -- <smiles text file> | a text file of smiles in this format:
                <smiles> <name of molecule>
        -- <library> | public or private
        -- <max_hits> | needs an integer, putting 0 means show all results
        -- <distance> | needs an integer"
        printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
        echo "Example:
        bash cmd_sim.sh smiles.txt public 0 2"
        printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
else
while IFS= read -r line
do
        smiles=$(echo $line | awk '{print $1}')
        name=$(echo $line | awk '{print $2}')
        echo $name $smiles
        if [ $library == "public" ]
                then
                        export SWDIR=$public_dir
                        for maps in $public_maps
                                do
                                        echo $maps
                                        $sw sim -db $maps -v -n$max_hits -d$distance -score AtomAlignment:SMILES $smiles
                                done
        elif [ $library == "private" ]
                then
                        export SWDIR=$private_dir
                        for maps in $private_maps
                                do
                                        echo $maps
                                        $sw sim -db $maps -v -n$max_hits -d$distance -score AtomAlignment:SMILES $smiles
                                done
        else
                echo "Invalid Options"
        fi
done < $smi_file
fi
</source>
</source>

Revision as of 22:05, 9 February 2023

Introduction

Here is the link to Smallworld's manual

  • Username: ucsf@nextmovesoftware.com
  • Password: <Ask jjiteam@googlegroups.com>

All smallworld databases live in abacus' db3.

Smallworld frontend files are consolidated and located at /export/db3/smallworld_extract/.extract.

Execute command start_smallworld to see options on which smallworld instance to start/restart.

How to Download Smallworld

  1. Ssh to abacus and become root. Prepare directory
     mkdir /opt/nextmove/smallworld-<version> && cd /opt/nextmove/smallworld-<version>
  2. Download Software with this link
    • Username: ucsf@nextmovesoftware.com
    • Password: <Ask jjiteam@googlegroups.com>
  3. Go to releases. Look for smallworld-java-<version>.tar.gz and copy the link address.
  4. Download using wget
     wget --user ucsf@nextmovesoftware.com --password <Ask jjiteam@googlegroups.com> <link address>
  5. Decompress the file
    •  tar -xvf <file_name>

How to Launch Smallworld For The First Time

Prepare Files and Directories

  1. Ssh to abacus and become root
  2. Open a port in the firewall
    firewall-cmd --permanent --add-port=<port_number>/tcp 
    firewall-cmd --reload
  3. Go to smallworld databases directory
    cd /export/db3/
  4. Create a Smallworld directory and go to it
    mkdir <smallworld_dir> && cd <smallworld_dir>
  5. Inside that directory, create these
    • a symbolic link to the smallworld anon map
    ln -s /export/db2/smallworld_anon_21Q4 anon
    • a sub-directory called maps to store databases
    mkdir maps
    • a smallworld config file
    vim smallworld.cfg
    • Add this block of code inside the config file
    [WebApp]
    DepictionUrl=./depict/svg?w=%w&h=%h&smi=%s&qry=%q&cols=%c&cmap=%m
    ResolverUrl=./util/smi2mol?smi=%s
    SearchTimeOut=5000
    SearchAsYouDraw=true
    [Score]
    Name=Atom Alignment
    Description=Aligns and scores each hit relative to the query atom types, differences are categorised as MAJ, MIN, HYB, SUB 
    Class=com.nmsoftware.smallworld.score.SimpleAtomAlignment 
    EnabledByDefault=false
    MappingMode=EditMap
    [Score]
    Name=SMARTS Alignment
    Description=Treat input as SMARTS and align and score each hit relative to the query atom expressions in the input 
    Class=com.nmsoftware.smallworld.score.SmartsAtomAlignment 
    EnabledByDefault=false
    [Score]
    Name=ECFP4
    Description=Extended Connectivity Circular Fingerprint
    Class=com.nmsoftware.smallworld.score.EcfpTanimoto
    Radius=2
    EnabledByDefault=true
    [Score]
    Name=Daylight
    Description=Path based fingerprint
    Class=com.nmsoftware.smallworld.score.DaylightTanimoto
    EnabledByDefault=true
    • SearchTimeOut should be the only option you'll change in the future. It caps search time to lessen strain on machine.
  6. Place any *.anon.maps you've already compiled for testing into the maps sub-directory.

Start Smallworld Instance

  1. Go to smallworld extract directory
    cd /export/db3/smallworld_extract
  2. Create a screen
    screen -S <screen_name>
  3. Export the smallworld directory you've made
    export SWDIR=/export/db3/<smallworld_dir>
  4. Launch java
    java -jar /opt/nextmove/smallworld-<version>/sw-ws-<version>.jar --httpPort=<port_number>

How to Build Smallworld Maps/Databases

Consolidate smiles into /export/db3/temp_mapping.

Use the script located in that directory called smallworld_map_script.

Here is the content of the script:

#!/bin/csh -f
setenv SWDIR /export/db3/public_smallworld_4th_gen/

alias sw 'time java -jar /opt/nextmove/smallworld-5.1/sw.jar'

set target = '*.smi'

foreach i ($target)
	echo '(sw map' $i '-T tmp/ -o '${i}'.anon.map -u '${i}'.anon.unmapped) |& tee '${i}'_log'
	(sw map $i -T tmp/ -o ${i}.anon.map -u ${i}.anon.unmapped) |& tee ${i}_log
	echo 'sw blm -p 0.01 '${i}'.anon.map'
	sw blm -p 0.01 ${i}.anon.map
end

Command Details

setenv sets the environment where the anon master map is

java -jar /opt/nextmove/smallworld-5.1/sw.jar shortened to sw via alias

map will map the smiles based on the current anon master map.

  • -T stores temp files so /tmp does not get overloaded
  • -o output with custom name you like
  • -u will collect the unmapped molecules to send to Nextmove or to use swextend

tee will log the progress of the process

Splitting Databases

[Follow this page if John has asked you to split the database into smaller slices.]

Active Smallworld Instances

Caption text
Type URL Machine:Port Directory
Public http://sw.docking.org/ 10.20.0.5:5020 /nfs/db3/public_smallworld_4th_gen
Private http://swp.docking.org/ 10.20.0.5:8080 /nfs/db3/private_smallworld_4th_gen
Super Private http://swc.docking.org/ 10.20.0.5:5099 /nfs/db3/super_private_smallworld_4th_gen
SWBB http://swbb.docking.org/ 10.20.0.5:8081 /nfs/db3/swbb_5th_gen
SWCC http://swcc.docking.org/ 10.20.0.5:8082 /nfs/db3/swcc_5th_gen

Customize Smallworld FrontEnd To Our Needs (Smallworld 5.5)

These instructions only worked and compiled for me in the machine called epyc which is running Rocky 8 Linux operating system.

Summary of changes in swsearch.js:

  • Conditional hyperlinks attached to smallworld hits. Leads to zinc20, cartblanche22, or nothing.

Summary of changes in search.html:

  • Add 'Ask Questions' and contact info

Install Prerequisite Packages

  1. Install Apache Maven
    • dnf install maven -y
  2. In your home directory, create a new directory to hold the files for the upcoming procedures
    • mkdir /mnt/nfs/home/jjg/smallworld_build_from_source
  3. Download these latest Smallworlds and store them in 'smallworld_build_from_source/'. Here's how to download Smallworld.
    • smallworld-java-5.5.tar.gz
    • smallworld-java-src-5.5.tar.gz
  4. Extract contents from the tar.gz files
    • tar -xvf smallworld-java-5.5.tar.gz
      tar -xvf smallworld-java-src-5.5.tar.gz
  5. Install Apache Maven Smallworld Dependencies
    • cd /mnt/nfs/home/jjg/smallworld_build_from_source/smallworld-java/lib/
      bash mvn-install.sh

Customizing swsearch.js

Location: /mnt/nfs/home/jjg/smallworld_build_from_source/smallworld-java-src/web/src/main/webapp/WEB-INF/static/js/swsearch.js

Conditional Hyperlinks

  1. vim /mnt/nfs/home/jjg/smallworld_build_from_source/smallworld-java-src/web/src/main/webapp/WEB-INF/static/js/swsearch.js
  2. Search for this
    • ?div.append("<b>" + id + "</b>");
  3. Replace the inside of the else statement with these lines of code
    •                 if (id.substring(0,6) == "ZINC00") {
                              div.append("<b><a target='_blank' href='https://zinc20.docking.org/substances/"+id+"'>" + id + "</a></b>");
                      } else if(id.substring(0,4) == "ZINC" && id.substring(4,6) != "00") {
                              div.append("<b><a target='_blank' href='https://cartblanche22.docking.org/searchZinc/"+id+"'>" + id + "</a></b>");
                      } else {
                              div.append("<b>" + id + "</b>");
                      }

Customizing search.html

Location: /mnt/nfs/home/jjg/smallworld_build_from_source/smallworld-java-src/web/src/main/webapp/WEB-INF/static/search.html

Add 'Ask Questions'

  1. vim /mnt/nfs/home/jjg/smallworld_build_from_source/smallworld-java-src/web/src/main/webapp/WEB-INF/static/search.html
  2. Search 'Scoring Methods'
    ?Scoring Methods
  3. At the end of that big block of 'div', add this:
    <div class="section-head">
            Ask Questions
            <table class="swopt searchasyoudraw" style="width: 100%">
                    <th style="text-align: left">Email us: jjiteam@googlegroups.com</th>
            </table>
    </div>
  4. It should look like this
                <div class="section-head">
                    Scoring Methods
                </div>
                <table id="swscore">
    
                </table>
            </div>
            <div class="section-head">
                    Ask Questions
                    <table class="swopt searchasyoudraw" style="width: 100%">
                            <th style="text-align: left">Email us: jjiteam@googlegroups.com</th>
                    </table>
            </div>

Compile Code To Make WAR File

  1. Build WAR File
    cd /nfs/home/jjg/smallworld_build_from_source/smallworld-java-src/web
    mvn install -Pbootable
  2. If it works, then the new WAR File is located at /mnt/nfs/home/jjg/smallworld_build_from_source/smallworld-java-src/web/target/sw-ws-5.5.war

Restarting Smallworld Instance(s)

  1. Ssh to abacus and become root
  2. execute run_sw_on_reboot.sh to show restart all instances on the machine
    bash /root/run_arthors_on_reboot.sh
  3. execute start_smallworld to restart specific Smallworld instance. It will show you options to choose from.
    start_smallworld

Java Command Line

#!/bin/bash

smi_file=$1
library=$2
max_hits=$3
distance=$4

version="5.5"

sw_dir=/mnt/nfs/db3
sw='java -jar /nfs/db3/smallworld-'$version'/sw.jar'
public_dir=${sw_dir}/public_smallworld_5th_gen/
private_dir=${sw_dir}/private_smallworld_5th_gen/

public_maps=${public_dir}maps/*.anon.map
private_maps=${private_dir}maps/*.anon.map

if [ "$smi_file" = "-h" ] || [ "$smi_file" = "--help" ]
then
        printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
        echo "This script performs a similarity search on all databases in the public or private smallworld."
        printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
        echo "Usage: bash cmd_sim.sh <smiles text file> <library> <max_hits>  <distance>
        -- <smiles text file> | a text file of smiles in this format:
                <smiles> <name of molecule>
        -- <library> | public or private
        -- <max_hits> | needs an integer, putting 0 means show all results
        -- <distance> | needs an integer"
        printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
        echo "Example:
        bash cmd_sim.sh smiles.txt public 0 2"
        printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
else
while IFS= read -r line
do
        smiles=$(echo $line | awk '{print $1}')
        name=$(echo $line | awk '{print $2}')
        echo $name $smiles
        if [ $library == "public" ]
                then
                        export SWDIR=$public_dir
                        for maps in $public_maps
                                do
                                        echo $maps
                                        $sw sim -db $maps -v -n$max_hits -d$distance -score AtomAlignment:SMILES $smiles
                                done
        elif [ $library == "private" ]
                then
                        export SWDIR=$private_dir
                        for maps in $private_maps
                                do
                                        echo $maps
                                        $sw sim -db $maps -v -n$max_hits -d$distance -score AtomAlignment:SMILES $smiles
                                done
        else
                echo "Invalid Options"
        fi

done < $smi_file
fi