| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified February 27, 2025 |
| 7 | Description: Shreds sequences into shorter, possibly overlapping sequences. |
| 8 | |
| 9 | Usage: shred.sh in=<file> out=<file> length=<int> |
| 10 | |
| 11 | in=<file> Input sequences. |
| 12 | out=<file> Destination of output shreds. |
| 13 | length=500 Desired length of shreds if a uniform length is desired. |
| 14 | minlen=-1 Shortest allowed shred. The last shred of each input sequence |
| 15 | may be shorter than desired length if this is not set. |
| 16 | maxlen=-1 Longest shred length. If minlength and maxlength are both |
| 17 | set, shreds will use a random flat length distribution. |
| 18 | median=-1 Alternatively, setting median and variance will override |
| 19 | minlen and maxlen. |
| 20 | variance=-1 |
| 21 | linear When maxlen is greater than minlen, the distribution can |
| 22 | be linear, exp, or log (pick one as a flag). |
| 23 | overlap=0 Amount of overlap between successive shreds. |
| 24 | reads=-1 If nonnegative, stop after this many input sequences. |
| 25 | equal=f Shred each sequence into subsequences of equal size of at most |
| 26 | 'length', instead of a fixed size. |
| 27 | qfake=30 Quality score, if using fastq output. |
| 28 | filetid=f Name shreds with a tid parsed from the filename (e.g. tid_5). |
| 29 | headertid=f Name shreds with a tid parsed from sequence headers. |
| 30 | |
| 31 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 32 | " |
| 33 | } |
| 34 | |
| 35 | #This block allows symlinked shellscripts to correctly set classpath. |
| 36 | pushd . > /dev/null |
| 37 | DIR="${BASH_SOURCE[0]}" |
| 38 | while [ -h "$DIR" ]; do |
| 39 | cd "$(dirname "$DIR")" |
| 40 | DIR="$(readlink "$(basename "$DIR")")" |
| 41 | done |
| 42 | cd "$(dirname "$DIR")" |
| 43 | DIR="$(pwd)/" |
| 44 | popd > /dev/null |
| 45 | |
| 46 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 47 | CP="$DIR""current/" |
| 48 | |
| 49 | z="-Xmx4000m" |
| 50 | set=0 |
| 51 | |
| 52 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 53 | usage |
| 54 | exit |
| 55 | fi |
| 56 | |
| 57 | calcXmx () { |
| 58 | source "$DIR""/calcmem.sh" |
| 59 | setEnvironment |
| 60 | parseXmx "$@" |
| 61 | } |
| 62 | calcXmx "$@" |
| 63 | |
| 64 | stats() { |
| 65 | local CMD="java $EA $EOOM $z -cp $CP jgi.Shred $@" |
| 66 | # echo $CMD >&2 |
| 67 | eval $CMD |
| 68 | } |
| 69 | |
| 70 | stats "$@" |