| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified May 23, 2016 |
| 7 | |
| 8 | Description: Replaces read names with names from another file. |
| 9 | The other file can either be sequences or simply names, with |
| 10 | one name per line (and no > or @ symbols). If you use one name |
| 11 | per line, please give the file a .header extension. |
| 12 | |
| 13 | Usage: replaceheaders.sh in=<file> hin=<headers file> out=<out file> |
| 14 | |
| 15 | Parameters: |
| 16 | in= Input sequences. Use in2 for a second paired file. |
| 17 | in= Header input sequences. Use hin2 for a second paired file. |
| 18 | out= Output sequences. Use out2 for a second paired file. |
| 19 | ow=f (overwrite) Overwrites files that already exist. |
| 20 | zl=4 (ziplevel) Set compression level, 1 (low) to 9 (max). |
| 21 | int=f (interleaved) Determines whether INPUT file is considered interleaved. |
| 22 | fastawrap=70 Length of lines in fasta output. |
| 23 | qin=auto ASCII offset for input quality. May be 33 (Sanger), 64 (Illumina), or auto. |
| 24 | qout=auto ASCII offset for output quality. May be 33 (Sanger), 64 (Illumina), or auto (same as input). |
| 25 | |
| 26 | Renaming modes (if not default): |
| 27 | addprefix=f Rename the read by prepending the new name to the existing name. |
| 28 | |
| 29 | Sampling parameters: |
| 30 | reads=-1 Set to a positive number to only process this many INPUT reads (or pairs), then quit. |
| 31 | |
| 32 | Java Parameters: |
| 33 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 34 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 35 | The max is typically 85% of physical memory. |
| 36 | -eoom This flag will cause the process to exit if an |
| 37 | out-of-memory exception occurs. Requires Java 8u92+. |
| 38 | -da Disable assertions. |
| 39 | |
| 40 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 41 | " |
| 42 | } |
| 43 | |
| 44 | #This block allows symlinked shellscripts to correctly set classpath. |
| 45 | pushd . > /dev/null |
| 46 | DIR="${BASH_SOURCE[0]}" |
| 47 | while [ -h "$DIR" ]; do |
| 48 | cd "$(dirname "$DIR")" |
| 49 | DIR="$(readlink "$(basename "$DIR")")" |
| 50 | done |
| 51 | cd "$(dirname "$DIR")" |
| 52 | DIR="$(pwd)/" |
| 53 | popd > /dev/null |
| 54 | |
| 55 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 56 | CP="$DIR""current/" |
| 57 | |
| 58 | z="-Xmx1g" |
| 59 | set=0 |
| 60 | |
| 61 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 62 | usage |
| 63 | exit |
| 64 | fi |
| 65 | |
| 66 | calcXmx () { |
| 67 | source "$DIR""/calcmem.sh" |
| 68 | setEnvironment |
| 69 | parseXmx "$@" |
| 70 | } |
| 71 | calcXmx "$@" |
| 72 | |
| 73 | function reheader() { |
| 74 | local CMD="java $EA $EOOM $z -cp $CP jgi.ReplaceHeaders $@" |
| 75 | echo $CMD >&2 |
| 76 | eval $CMD |
| 77 | } |
| 78 | |
| 79 | reheader "$@" |