| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified September 6, 2023 |
| 7 | |
| 8 | Description: Splits a sequence file evenly into multiple files. |
| 9 | |
| 10 | Usage: partition.sh in=<file> in2=<file2> out=<outfile> out2=<outfile2> ways=<number> |
| 11 | |
| 12 | in2 and out2 are for paired reads and are optional. |
| 13 | If input is paired and out2 is not specified, data will be written interleaved. |
| 14 | Output filenames MUST contain a '%' symbol. This will be replaced by a number. |
| 15 | |
| 16 | Parameters and their defaults: |
| 17 | |
| 18 | in=<file> Input file. |
| 19 | out=<file> Output file pattern (containing a % symbol, like 'part%.fa'). |
| 20 | ways=-1 The number of output files to create; must be positive. |
| 21 | pacbio=f Set to true to keep PacBio subreads together. |
| 22 | bp=f Optimize for an even split by base pairs instead of sequences. |
| 23 | Not compatible with PacBio mode. |
| 24 | |
| 25 | ow=f (overwrite) Overwrites files that already exist. |
| 26 | app=f (append) Append to files that already exist. |
| 27 | zl=4 (ziplevel) Set compression level, 1 (low) to 9 (max). |
| 28 | int=f (interleaved) Determines whether INPUT file is considered interleaved. |
| 29 | |
| 30 | Java Parameters: |
| 31 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 32 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 33 | The max is typically 85% of physical memory. |
| 34 | -eoom This flag will cause the process to exit if an out-of-memory |
| 35 | exception occurs. Requires Java 8u92+. |
| 36 | -da Disable assertions. |
| 37 | |
| 38 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 39 | " |
| 40 | } |
| 41 | |
| 42 | #This block allows symlinked shellscripts to correctly set classpath. |
| 43 | pushd . > /dev/null |
| 44 | DIR="${BASH_SOURCE[0]}" |
| 45 | while [ -h "$DIR" ]; do |
| 46 | cd "$(dirname "$DIR")" |
| 47 | DIR="$(readlink "$(basename "$DIR")")" |
| 48 | done |
| 49 | cd "$(dirname "$DIR")" |
| 50 | DIR="$(pwd)/" |
| 51 | popd > /dev/null |
| 52 | |
| 53 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 54 | CP="$DIR""current/" |
| 55 | |
| 56 | z="-Xmx1g" |
| 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 | } |
| 69 | calcXmx "$@" |
| 70 | |
| 71 | function partition() { |
| 72 | local CMD="java $EA $EOOM $z -cp $CP jgi.PartitionReads $@" |
| 73 | echo $CMD >&2 |
| 74 | eval $CMD |
| 75 | } |
| 76 | |
| 77 | partition "$@" |