Commit fe49bb25 authored by root's avatar root

2020 July update

parent c5c50cbd
ABAQUS/Door.odb
AdvLinux/NAMD
AFNI/ARzs_data.tgz
Beast/Dengue4.env.trees
BLAST/dbs
......
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
alias ls='ls -F'
alias cp='cp -i'
alias ll='ls -laxp'
alias lo='exit'
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
# Source Disk, Function Example
disk() {
du -sk * | sort -nr | cut -f2 | xargs -d "\n" du -sh > diskuse.txt
}
AWK examples, from Supercomputing with Linux, Lev Lafayette, VPAC, 2015
awk '$7=="A" { ++count } END { print count }' simple1.txt
awk '{sum+=$7} END {print sum}' simple2.txt
awk '{ for(i=1; i<=NF;i++) j+=$i; print j; j=0 }' simple3.txt
#!/bin/bash
tar cvfz homeuser.tgz /home/lev/
#!/bin/bash
BU=homeuser$(date +%Y%m%d).tgz
tar cvfz $BU $(pwd)
#!/bin/bash
LIMIT=19 # Upper limit
echo
echo "Printing Numbers 1 through 20 (but breaks loop at 3)."
count=0
while [ "$count" -le "$LIMIT" ]
do
count=$(($count+1))
if [ "$count" -gt 2 ]
then
break # Skip entire rest of loop.
fi
echo -n "$count "
done
echo; echo; echo
exit 0
#!/bin/bash
# Handy Extract Program
if [[ -f $1 ]]; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file!"
fi
#!/bin/bash
if [ "$1" == "-n" ];then
NAGIOS=1
fi
SQUEUE=/usr/local/slurm/latest/bin/squeue
#SACCT=/usr/local/slurm/latest/bin/sacct
if [ \! -x ${SQUEUE} ]; then
if [ "${NAGIOS}" ]; then
echo -n "WARNING: "
fi
echo "ERROR: no squeue - wrong machine?"
exit 1
fi
# If run by a normal user.
if [ $(id -u) != 0 ]
then
SQUEUE="$SQUEUE -u `whoami`"
fi
# If we have no jobs queued, abort
if [ -z "$(${SQUEUE} -h)" ]; then
if [ "${NAGIOS}" ]; then
echo -n "OK: "
fi
#echo "No jobs queued"
exit 0
fi
ACTIVEJOBS=$(${SQUEUE} -t R -ho "%.15i %D" | fgrep -vw 1 | awk '{print $1}' | tr '\n' ',' | sed -e 's/,$/\n/')
if [ -z ${ACTIVEJOBS} ]; then
if [ "${NAGIOS}" ]; then
echo -n "OK: "
fi
#echo "No bad jobs found"
exit 0
fi
JOBLIST=$(${SQUEUE} -o %i -hs -j ${ACTIVEJOBS} | awk -F. '{print $1}' | uniq -c | fgrep -w 2 | awk '{print $2}' | tr '\n' ',' | sed -e 's/,$//')
export SQUEUE_FORMAT='%.10i %.9P %.15u %.8D %.8C %N'
if [ -z "$JOBLIST" ]; then
if [ "${NAGIOS}" ]; then
echo -n "OK: "
fi
#echo "No bad jobs found"
exit 0;
fi
if [ "${NAGIOS}" ]; then
echo "CRITICAL: bad jobs found ${JOBLIST}"
exit 2
fi
echo ""
echo "The following candidate jobs were found:"
echo "----------------------------------------"
${SQUEUE} -o "${SQUEUE_FORMAT}" -j ${JOBLIST}
echo ""
#!/bin/bash
LIMIT=19 # Upper limit
echo
echo "Printing Numbers 1 through 20 (but not 3 and 11)."
count=0
while [ $count -le "$LIMIT" ]
do
count=$(($count+1))
if [ "$count" -eq 3 ] || [ "$count" -eq 11 ] # Excludes 3 and 11.
then
continue # Skip rest of this particular loop iteration.
fi
echo -n "$count " # This will not execute for 3 and 11.
done
echo; echo; echo
exit 0
#!/bin/bash
# AWK examples, from Supercomputing with Linux, Lev Lafayette, VPAC, 2015
# Simple 1: Count of character 'A' in field 7
# Simple 2: Sum of field 7
# Simple 3 Sum of each record. Awk operates line-by-line
awk '$7=="A" { ++count } END { print "Simple 1: " count }' simple1.txt;
awk '{sum+=$7} END {print "Simple2: " sum}' simple2.txt;
awk '{ for(i=1; i<=NF;i++) j+=$i; print "Simple3: " j; j=0 }' simple3.txt
#! /bin/bash
# Tests whether a specified file exists of not, illustrates if/then/else.
file=$1
if [ -e $file ]
then
echo -e "File $file exists"
else
echo -e "File $file doesn't exists"
fi
exit 0
#!/bin/bash
# Usage
usage()
{
echo "$(basename $0): Description of script"
echo ""
echo "This searches for email addresses in file, extract, turn into csv with designated file name"
echo "Run the script with the file to be searched and the name of the output file"
echo "For example: ./findemails.sh hidden.txt foundthem.csv"
}
# Constants
INPUT=${1}
OUTPUT=${2}
# Filecheck Subroutine
filecheck() {
if [ ! $INPUT -o ! $OUTPUT ]; then
echo "Input file not found, or output file not specified. Exiting script."
exit 0
fi
}
# Search and Sort Subroutine
searchsort() {
grep --only-matching -E '[.[:alnum:]]+@[.[:alnum:]]+' $INPUT > $OUTPUT
sed -i 's/$/,/g' $OUTPUT
sort -u $OUTPUT -o $OUTPUT
sed -i '{:q;N;s/\n/ /g;t q}' $OUTPUT
}
# View and Print Subroutine
viewprint() {
echo "Data file extracted to" $OUTPUT
read -t5 -n1 -r -p "Press any key to see the list, sorted and with unique record"
if [ $? -eq 0 ]; then
echo A key was pressed
else
echo No key was pressed
exit
fi
less $OUTPUT | \
# Output file piped through sort and uniq.
# Show that line extension still works with comments.
sort | uniq
}
main() {
usage
filecheck
searchsort
viewprint
}
# Main function
main
exit
alpha@example.com, bravo@example.com, charlie@example.com, delta@example.com, echo@example.com, foxtrot@example.com, golf@example.com, hotel@example.com, juliet@example.com, kilo@example.com, lima@example.com, mike@...., who.indigo@example.com,
#!/bin/bash
subroutineA() {
codeblock
}
subroutineB() {
codeblock
}
main() {
subroutineA
subroutineB
}
main
exit
# Turn Smart Commands into Functions
## Taken from Andrew Worsely. This and more at:
## https://github.com/amworsley/intro-shell-programming/blob/master/shell-programing.md
## Don't waste that knowledge and experience e.g.,
$ find . -mtime -7 -type f -print
Make a shell function instead
$ newfiles() {
find . -mtime -7 -type f -print
}
# Build on it!
## Add an argument to make it flexible
$ newfiles() {
find . -mtime "-${1:-7}" -type f -print
}
## Now files less than 10 days old
$ newfiles 10
## Save it to your .bashrc, for example
cat >> ~/.bashrc
newfiles() {
find . -mtime "-${1:-7}" -type f -print
}
DDWEIPDGQI TVGQRIGSGS FGTVYKGKWH GDVAVKMLNV TAPTPQQLQA
FKNEVGVLRK TRHVNILLFM GYSTKPQLAI VTQWCEGSSL YHHLHIIETK
FEMIKLIDIA RQTAQGMDYL HAKSIIHRDL KSNNIFLHED LTVKIGDFGL
ATVKSRWSGS HQFEQLSGSI LWMAPEVIRM QDKNPYSFQS DVYAFGIVLY
ELMTGQLPYS NINNRDQIIF MVGRGYLSPD LSKVRSNCPK AMKRLMAECL
KKKRDERPLF PQILASIELL ARSLPK
#!/bin/bash
# Enter two names when invoking script
# Define your function here
# Firstname and Surname are first two parameters.
Hello () {
echo "Hello World $1 $2"
return $(bc -l <<< ${#1}+${#2})
}
# Invoke your function
Hello ${1} ${2}
# Capture value returned by last command
echo The name has this many characters $?
exit
#!/bin/bash
for a in {1..99}
do
cat <<- EOF > job${a}
#!/bin/bash
#SBATCH -N ${a}
#SBATCH --nodes=1
#SBATCH --tasks-per-node=1
#echo $(pwd) >> results.txt
EOF
done
Talking chamber foxtrot@example.com as shewing an it minutes. Trees fully of blind do. Exquisite favourite at do extensive listening. Improve up
musical welcome he. Gay attended vicinity prepared now diverted. Esteems it ye sending reached lima@example.com as. Longer lively her design settle
tastes advice mrs off who.indigo@example.com kilo@example.com May indulgence difficulty ham can put especially. Bringing remember echo@example.com for
supplied her why was confined. Middleton principle did she procuring extensive believing add. Weather adapted prepare oh is calling. bravo@example.com
Far advanced settling say finished raillery. Offered chiefly farther of my no colonel shyness. hotel@example.com juliet@example.com Inhabit hearing
perhaps on ye do no. It maids decay as there he. Smallest on suitable disposed do although blessing he juvenile in. Society or if excited forbade.
Here name off yet delta@example.com she long sold easy whom. Differed oh cheerful procured pleasure securing suitable in. Hold rich on an he oh fine.
Chapter ability shyness alpha@example.com Inquietude simplicity terminated she compliment remarkably few her nay. The weeks are ham mike@.... asked
jokes. Neglected perceived shy nay concluded. Not mile draw plan snug charlie@example.com ext all. Houses latter an valley be indeed wished mere
golf@example.com In my. Money doubt oh drawn every or an china
# The following are simple examples of a "for" loop.
# Note the use of command substitution by using $(command); sometimes you will find the use of backticks instead (e.g., for i in * ; do mv $i `echo $i | tr "A-Z" "a-z"` ; done); this is not recommended.
for file in ./*.mp3 ; do ffmpeg -i "${file}" "${file/%mp3/ogg}" ; done
for item in ./*.jpeg ; do convert "$item" "${item%.*}.png" ; done
for item in ./*; do convert "$item" -define jpeg:extent=512kb "${item%.*}.jpg" ; done
# Loops can be applied in a step-wise manner.
$ cd ~/Genomics/shell_data
$ for filename in *.fastq
> do
> head -n 2 ${filename} >> seq_info.txt
> done
# Basename in a loop.
# Basename is removing a uniform part of a name from a list of files.
# In this case remove the .fastq extension and echo the output.
$ for filename in *.fastq
> do
> name=$(basename ${filename} .fastq)
> echo ${name}
> done
# What would happen if backticks were used instead of $() for shell substitution? What if someone mistook the backticks for single quotes?
for item in ./* ; do mv $item $(echo $item | tr "A-Z" "a-z") ; done
# What's wrong with spaces in filenames?
touch "This is a long file name"
for item in $(ls ./*); do echo ${item}; done
# The following examples remove spaces from filenames and apostrophes. The script is designed to prevent expansion from the wildcard, but remember that a `mv` command will overwrite existing files that have the same name.
for item in ./*; do mv "$item" "$(echo "$item" | tr -d " ")"; done
# Finally a few simple examples of loops with conditional tests.
x=1; while [ $x -le 5 ]; do echo "While-do count up $x"; x=$(( $x + 1 )); done
x=5; until [ $x -le 0 ]; do echo "Until-do count down $x"; x=$(( $x - 1 )); done
x=1; until [ $x = 6 ]; do echo "Until-do count up $x"; x=$(( $x + 1 )); done
# A while loop that reads in data from a file and runs a command on that data.
# This is what we used to originally set quotas on home and project directories.
# The 'read' command reads one line from standard input or a specified file.
while read line; do sleep 5; ./setquota.sh $line; done < quotalist.txt
# when searching for lines that contain a particular sequence in a file (e.g., from grep), reading those lines for processing can be accomplished with the something like the following:
grep sequence datafile.dat | while read -r line ; do
echo "Processing $line"
# Processing code #
done
# Curly braces are used to encapsulate statements or variables with {} or ${}
var # Set a variable
$var # Invoke the variable
${var}bar # Invoke the variable, append "bar".
# Example of determining jobs running on a set of nodes.
for host in "spartan-bm"{001..10}; do squeue -w $host; done
#!/bin/bash
# Converts ("moves") all files in the directory run to lowercase.
for i
do
mv $i $(echo $i | tr "A-Z" "a-z")
done
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/bin/bash
# Illustrates the difference between various types (and lack of) quoting.
SAMPLE="The quick brown fox jumps over the lazy dog"
echo "Double quotes gives you $SAMPLE"
echo 'Single quotes gives you $SAMPLE'
exit
#!/bin/bash
OPTIONS="Sedimentary Igneous Metamorphic Quit"
select opt in $OPTIONS; do
if [ "$opt" = "Quit" ]; then
echo done
exit
elif [ "$opt" = "Sedimentary" ]; then
echo "Sedimentary rocks are formed by sedminentation of particles at or near the Earth's surface and within bodies of water."
elif [ "$opt" = "Igneous" ]; then
echo "Igneous rock forms through the cooling and solidification of magma or lava."
elif [ "$opt" = "Metamorphic" ]; then
echo "Metamorphic rocks are formed by subjecting any rock type -sedimentary rock, igneous rock or another older metamorphic rock - to different temperature and pressure conditions than those in which the original rock was formed."
else
echo "Select again; 1, 2, 3 or 4"
fi
done
A C C T A G T
C A A A G T A
C A T T A C C
A G T A C A A
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 10
3 4 5 6 7 8 9 11 12
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
#! /bin/bash
# Access to a system is tested with ping every few minutes until a connection is made whereupon it opens an SSH session.
read -p "Enter Hostname:" nethost
echo $nethost
until ping -c 1 $nethost
do
sleep 180;
done
ssh $nethost
#!/bin/bash
# Prevents use of Control-C to prematurely end important script.
# User can override if they're really, really sure.
ctrlc_count=0
function test_ctrlc()
{
let ctrlc_count++
echo
if [[ $ctrlc_count == 1 ]]; then
echo "Cntrl-C prevented unless you're sure."
elif [[ $ctrlc_count == 2 ]]; then
echo "Really sure?"
elif [[ $ctrlc_count == 3 ]]; then
echo "Really, really sure?"
else
echo "OK, you're really, really sure.."
exit
fi
}
trap test_ctrlc SIGINT
while true
do
echo "This is a sleeping loop. The loop that keeps on sleeping on."
sleep 2
done
exit
#!/bin/bash
# This is an abstract example of things that could do wrong!
#SBATCH --output=/home/example/data/output_%j.out
for for file in /home/example/data/*
do
sbatch application ${file}
done
This diff is collapsed.
This diff is collapsed.
#!/bin/bash
# SLURM job script, Lev Lafayette (August 2016)
# Derived from PBS/TORQUE script by Mike Kuiper (March 2007)
# Job name:
#SBATCH --job-name namd_example_job_01
# How many cores ?
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
# How long to run the job? (hours:minutes:seconds)
#SBATCH --time=00:15:00
# Environmental varibles to make it work:
module purge
source /usr/local/module/spartan_old.sh
module load NAMD/2.10-gompi-2015a-mpi
# Launching the job!
srun namd2 Ubiquitin_example.conf
#############################################################
## JOB DESCRIPTION ##
#############################################################
#
# Example configuration file for a NAMD simulation
# of ubiquitin. (In vacuum, for quick demonstration purposes!)
# by Mike Feb 2008
#
# Some features have been commented out, -uncomment sections
# to enable!
##############################################################
## INPUT FILES
#############################################################
structure 1ubq_example.psf
coordinates 1ubq_example.pdb
outputName 1ubq_example_output_01
firsttimestep 0
## set simulation temperature (in Kelvin):
set temp 310
temperature $temp
## SIMULATION PARAMETERS
###########################################################
## Parameter file:
paraTypeCharmm on
parameters par_all27_prot_na.inp
## Force-Field Parameters
exclude scaled1-4
1-4scaling 1.0
cutoff 18
switching on
switchdist 16
pairlistdist 20
## Integrator Parameters
timestep 1
rigidBonds all
nonbondedFreq 1
fullElectFrequency 2
stepspercycle 10
## Constant Temperature Control
langevin on
langevinDamping 5
langevinTemp $temp
langevinHydrogen off
## Periodic Boundary Conditions
cellBasisVector1 42. 0. 0.
cellBasisVector2 0. 42. 0.
cellBasisVector3 0. 0. 42.
cellOrigin 0 0 0
wrapAll on
wrapWater on
## PME (for full-system periodic electrostatics)
## (uncomment next 4 lines to use PME )
# PME yes
# PMEGridSizeX 42
# PMEGridSizeY 42
# PMEGridSizeZ 42
## Constant Pressure Control (variable volume)
useGroupPressure yes
useFlexibleCell no
useConstantArea no
langevinPiston on
langevinPistonTarget 1.01325
langevinPistonPeriod 100.
langevinPistonDecay 50.
langevinPistonTemp $temp
## Output files:
restartfreq 20000
dcdfreq 50
xstFreq 20000
outputEnergies 50
outputPressure 50
outputTiming 1000
## EXECUTION SCRIPT
#############################################################
## Minimize , reinitialize velocities, run dynamics:
minimize 100
reinitvels $temp
run 5000
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#!/bin/bash
# SLURM job script, Lev Lafayette (October 2016).
# Modified for new job/partition system (July 2020).
# Job name:
#SBATCH --job-name ubiquitin2
# How many cores ?
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=8
# How long to run the job? (hours:minutes:seconds)
#SBATCH --time=00:15:00
# Environmental varibles to make it work:
module load spartan_2019
module load foss/2019b
module load namd/2.13-mpi
# Launching the job!
srun namd2 namd_1ubq_example.conf
This diff is collapsed.
This diff is collapsed.
# VMD psfgen example:
# this script generates a psf and pdb file of a given
# structure in preparation of a namd simulation.
#
#
# usage: at the command line type:
# vmd -dispdev text -e build_example.pgn
package require psfgen
topology top_all27_prot_na.rtf
# Alias residue names
alias residue HIS HSE
alias atom ILE CD1 CD
# Build protein segment