|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# This is the complete workflow for chromflock |
| 5 | +# |
| 6 | +# Along the run, the overall progress can be read from status.txt |
| 7 | +# The progress from gnu parallel can be found in parallel.log |
| 8 | +# |
| 9 | +# Tips: |
| 10 | +# If this script does not finish, see how far it went by starting it with |
| 11 | +# $ bash -x chromflock_gen |
| 12 | + |
| 13 | + |
| 14 | +### SETTINGS |
| 15 | + |
| 16 | +## Input Files |
| 17 | +# The file with input probabilities, given as 64 bit doubles |
| 18 | +aFile="./A.double" |
| 19 | +# File specifying chromosome Labels use 1 for chr1, ... |
| 20 | +lFile="./L.uint8" |
| 21 | +# The file with radial values, given as 64 bit doubles. Use `nan` or `inf` for missing values. |
| 22 | +# NOTE: not used unless kRad is set in the lua script. |
| 23 | +# rFile="G.double" |
| 24 | +rFile="" |
| 25 | +# OPTIONAL: specify the proportion of structures that should be assigned each radial constraint |
| 26 | +# i.e., the probability in the same sense as the A matrix. If this is set each structure will |
| 27 | +# have an own R-file -- generated and updated by aflock in the same way as the W matrices. |
| 28 | +# prFile="../prFile.double" |
| 29 | +# NOT supported for diploid experiments! |
| 30 | +prFile="" |
| 31 | + |
| 32 | +## Input Parameters |
| 33 | +# Number of parallel jobs |
| 34 | +nCores=4 |
| 35 | +# Number of structures to generate |
| 36 | +nStruct=128 |
| 37 | + |
| 38 | +## GEOMETRY |
| 39 | +# Volume quotient, i.e. volume of all beads/volume of nuclei |
| 40 | +# Note that the bead radius can be set with -R |
| 41 | +# Alber uses vq=0.2 |
| 42 | +vq=0.2 |
| 43 | + |
| 44 | +# For ellipsoid, set the axes lengths below, if not set a spherical |
| 45 | +# geometry is used with ea=eb=ec=1 |
| 46 | +# Note that 1=ea>=eb>=ec>0 |
| 47 | +ea= |
| 48 | +eb= |
| 49 | +ec= |
| 50 | + |
| 51 | +# Set to 1 if diploid leave empty otherwise |
| 52 | +diploid= |
| 53 | + |
| 54 | +## CONTACTS |
| 55 | +# Theta boundaries, from high to low |
| 56 | +thetas=(1 .2 .1 .05 .02 .01 0.001) |
| 57 | + |
| 58 | +# Molecular Dynamics configuration |
| 59 | +dconfFile="mflock.lua" |
| 60 | + |
| 61 | +## OPTIMIZATION |
| 62 | +nReassign=3 |
| 63 | + |
| 64 | +outScript=chromflock_run |
| 65 | +touch $outScript |
| 66 | +chmod +x $outScript |
| 67 | +echo "" > $outScript |
| 68 | + |
| 69 | +## |
| 70 | +## RUN -- no need to edit below this line |
| 71 | +## |
| 72 | + |
| 73 | +# geostring goes into both aflock and mflock |
| 74 | +if [[ ! -z "$ea" ]] |
| 75 | +then |
| 76 | + geostring="--ea $ea --eb $eb --ec $ec" |
| 77 | +else |
| 78 | + geostring= |
| 79 | +fi |
| 80 | + |
| 81 | +# adiplo |
| 82 | +if [[ ! -z "$diploid" ]] |
| 83 | +then |
| 84 | + adiplo="--diploid" |
| 85 | +else |
| 86 | + adiplo= |
| 87 | +fi |
| 88 | + |
| 89 | +# For mflock |
| 90 | +moptstring="--cmmz $geostring --dconf $dconfFile" |
| 91 | + |
| 92 | +prArg="" |
| 93 | +if [[ ! -z "$rFile" ]]; then |
| 94 | + if [ -z "$prFile" ] |
| 95 | + then |
| 96 | + echo "rFile is set but not prFile. Same radial constraints for all structures." |
| 97 | + echo "Required action: Set kRad in mflock.lua" |
| 98 | + mflock_arguments="-r $rFile $moptstring -L $lFile" |
| 99 | + else |
| 100 | + # -r is set by aflock and put into mflock_jobs |
| 101 | + echo "rFile and prFile is set. Individual radial constraints for each structure" |
| 102 | + mflock_arguments="$moptstring -L $lFile" |
| 103 | + prArg="--rpos $rFile --prpos $prFile" |
| 104 | + fi |
| 105 | +else |
| 106 | + mflock_arguments="$moptstring -L $lFile" |
| 107 | +fi |
| 108 | + |
| 109 | +## Finialize the output script |
| 110 | +# One folder per structure will be created |
| 111 | +# and initialize with W from contacts |
| 112 | +# from A where theta == 1 |
| 113 | +# A list of jobs to run will be written to `mflock_jobs` |
| 114 | +echo "set -e" >> $outScript |
| 115 | +echo echo ""Initialization started" > status.txt" >> $outScript |
| 116 | +echo "hostname >> status.txt" >> $outScript |
| 117 | +echo "aflock --version >> status.txt" >> $outScript |
| 118 | +echo "date >> status.txt" >> $outScript |
| 119 | + |
| 120 | +echo "aflock $adiplo $geostring -A $aFile -n $nStruct -I -Q $vq $prArg -P \""${mflock_arguments}\""" >> $outScript |
| 121 | + |
| 122 | +echo "date >> status.txt" >> $outScript |
| 123 | +echo "echo "Initialization done" >> status.txt" >> $outScript |
| 124 | +echo "echo "Running for theta==1"" >> $outScript |
| 125 | +# Run first batch of jobs in parallel |
| 126 | +echo "parallel --halt-on-error 2 --jobs $nCores --joblog parallel.log < mflock_jobs" >> $outScript |
| 127 | + |
| 128 | +nsteps=${#thetas[*]} |
| 129 | + |
| 130 | +if (( $nsteps > 1 )); then |
| 131 | + |
| 132 | +let "nsteps = $nsteps-1" |
| 133 | + |
| 134 | +# Then, for each theta value, run again (write as a loop) |
| 135 | + |
| 136 | +for idx in `seq 1 $nsteps` |
| 137 | +do |
| 138 | + thHigh=${thetas[$idx-1]} |
| 139 | + thLow=${thetas[$idx]} |
| 140 | + |
| 141 | + for iter in `seq 1 $nReassign` |
| 142 | + do |
| 143 | + |
| 144 | + echo "date >> status.txt" >> $outScript |
| 145 | + echo "echo "Assigning contacts where theta in [$thLow ,$thHigh ["" >> $outScript |
| 146 | + echo "aflock $adiplo $geostring -A $aFile $prArg -n $nStruct -Q $vq -h $thHigh -l $thLow -U" >> $outScript |
| 147 | + |
| 148 | + echo "date >> status.txt" >> $outScript |
| 149 | + echo "echo "Running for theta in [$thLow, $thHigh [" >> status.txt" >> $outScript |
| 150 | + echo "parallel --halt-on-error 2 --jobs $nCores --joblog parallel.log < mflock_jobs" >> $outScript |
| 151 | + |
| 152 | + echo "echo "ok" >> status.txt" >> $outScript |
| 153 | + done |
| 154 | +done |
| 155 | +fi |
| 156 | + |
| 157 | +echo "date >> status.txt" >> $outScript |
| 158 | +echo "echo "Finalizing ..." >> status.txt" >> $outScript |
| 159 | +echo "aflock $adiplo $geostring -F -A $aFile $prArg -n $nStruct -Q $vq" >> $outScript |
| 160 | +echo "date >> status.txt" >> $outScript |
| 161 | +echo "echo "Done!" >> status.txt" >> $outScript |
| 162 | +echo "Now run $outScript" |
0 commit comments