| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified August 11, 2023 |
| 7 | |
| 8 | Description: Fuses sequences together, padding gaps with Ns. |
| 9 | |
| 10 | Usage: fuse.sh in=<input file> out=<output file> pad=<number of Ns> |
| 11 | |
| 12 | Parameters: |
| 13 | in=<file> The 'in=' flag is needed if the input file is not the |
| 14 | first parameter. 'in=stdin' will pipe from standard in. |
| 15 | out=<file> The 'out=' flag is needed if the output file is not the |
| 16 | second parameter. 'out=stdout' will pipe to standard out. |
| 17 | pad=300 Pad this many N between sequences. |
| 18 | maxlen=2g If positive, don't make fused sequences longer than this. |
| 19 | quality=30 Fake quality scores, if generating fastq from fasta. |
| 20 | overwrite=t (ow) Set to false to force the program to abort rather |
| 21 | than overwrite an existing file. |
| 22 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change |
| 23 | compression level; lower compression is faster. |
| 24 | fusepairs=f Default mode fuses all sequences into one long sequence. |
| 25 | Setting fusepairs=t will instead fuse each pair together. |
| 26 | name= Set name of output sequence. Default is the name of |
| 27 | the first input sequence. |
| 28 | |
| 29 | Java Parameters: |
| 30 | -Xmx This will set Java's memory usage, overriding |
| 31 | autodetection. -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will |
| 32 | specify 200 megs. The max is typically 85% of physical memory. |
| 33 | -eoom This flag will cause the process to exit if an out-of-memory |
| 34 | exception occurs. Requires Java 8u92+. |
| 35 | -da Disable assertions. |
| 36 | |
| 37 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 38 | " |
| 39 | } |
| 40 | |
| 41 | #This block allows symlinked shellscripts to correctly set classpath. |
| 42 | pushd . > /dev/null |
| 43 | DIR="${BASH_SOURCE[0]}" |
| 44 | while [ -h "$DIR" ]; do |
| 45 | cd "$(dirname "$DIR")" |
| 46 | DIR="$(readlink "$(basename "$DIR")")" |
| 47 | done |
| 48 | cd "$(dirname "$DIR")" |
| 49 | DIR="$(pwd)/" |
| 50 | popd > /dev/null |
| 51 | |
| 52 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 53 | CP="$DIR""current/" |
| 54 | |
| 55 | z="-Xmx2g" |
| 56 | z2="-Xms2g" |
| 57 | set=0 |
| 58 | |
| 59 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 60 | usage |
| 61 | exit |
| 62 | fi |
| 63 | |
| 64 | calcXmx () { |
| 65 | source "$DIR""/calcmem.sh" |
| 66 | setEnvironment |
| 67 | parseXmx "$@" |
| 68 | if [[ $set == 1 ]]; then |
| 69 | return |
| 70 | fi |
| 71 | freeRam 2000m 84 |
| 72 | z="-Xmx${RAM}m" |
| 73 | z2="-Xms${RAM}m" |
| 74 | } |
| 75 | calcXmx "$@" |
| 76 | |
| 77 | fuse() { |
| 78 | local CMD="java $EA $EOOM $z -cp $CP jgi.FuseSequence $@" |
| 79 | echo $CMD >&2 |
| 80 | eval $CMD |
| 81 | } |
| 82 | |
| 83 | fuse "$@" |