| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified February 17, 2015 |
| 7 | |
| 8 | Description: Generates fake read pairs from ends of contigs or single reads. |
| 9 | |
| 10 | Usage: bbfakereads.sh in=<file> out=<outfile> out2=<outfile2> |
| 11 | |
| 12 | Out2 is optional; if there is only one output file, it will be written interleaved. |
| 13 | |
| 14 | Standard parameters: |
| 15 | ow=f (overwrite) Overwrites files that already exist. |
| 16 | zl=4 (ziplevel) Set compression level, 1 (low) to 9 (max). |
| 17 | fastawrap=100 Length of lines in fasta output. |
| 18 | tuc=f (touppercase) Change lowercase letters in reads to uppercase. |
| 19 | qin=auto ASCII offset for input quality. May be 33 (Sanger), 64 (Illumina), or auto. |
| 20 | qout=auto ASCII offset for output quality. May be 33 (Sanger), 64 (Illumina), or auto (same as input). |
| 21 | qfin=<.qual file> Read qualities from this qual file, for the reads coming from 'in=<fasta file>' |
| 22 | qfout=<.qual file> Write qualities from this qual file, for the reads going to 'out=<fasta file>' |
| 23 | qfout2=<.qual file> Write qualities from this qual file, for the reads coming from 'out2=<fasta file>' |
| 24 | verifyinterleaved=f (vint) When true, checks a file to see if the names look paired. Prints an error message if not. |
| 25 | tossbrokenreads=f (tbr) Discard reads that have different numbers of bases and qualities. By default this will be detected and cause a crash. |
| 26 | |
| 27 | Faking parameters: |
| 28 | length=250 Generate reads of this length. |
| 29 | minlength=1 Don't generate reads shorter than this. |
| 30 | overlap=0 If you set overlap, then reads will by variable length, overlapping by 'overlap' in the middle. |
| 31 | identifier=null (id) Output read names are prefixed with this. |
| 32 | addspace=t Set to false to omit the space before /1 and /2 of paired reads. |
| 33 | |
| 34 | Java Parameters: |
| 35 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 36 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 37 | The max is typically 85% of physical memory. |
| 38 | -eoom This flag will cause the process to exit if an |
| 39 | out-of-memory exception occurs. Requires Java 8u92+. |
| 40 | -da Disable assertions. |
| 41 | |
| 42 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 43 | " |
| 44 | } |
| 45 | |
| 46 | #This block allows symlinked shellscripts to correctly set classpath. |
| 47 | pushd . > /dev/null |
| 48 | DIR="${BASH_SOURCE[0]}" |
| 49 | while [ -h "$DIR" ]; do |
| 50 | cd "$(dirname "$DIR")" |
| 51 | DIR="$(readlink "$(basename "$DIR")")" |
| 52 | done |
| 53 | cd "$(dirname "$DIR")" |
| 54 | DIR="$(pwd)/" |
| 55 | popd > /dev/null |
| 56 | |
| 57 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 58 | CP="$DIR""current/" |
| 59 | |
| 60 | z="-Xmx600m" |
| 61 | set=0 |
| 62 | |
| 63 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 64 | usage |
| 65 | exit |
| 66 | fi |
| 67 | |
| 68 | |
| 69 | calcXmx () { |
| 70 | source "$DIR""/calcmem.sh" |
| 71 | setEnvironment |
| 72 | parseXmx "$@" |
| 73 | } |
| 74 | calcXmx "$@" |
| 75 | |
| 76 | function fakereads() { |
| 77 | local CMD="java $EA $EOOM $z -cp $CP jgi.FakeReads $@" |
| 78 | echo $CMD >&2 |
| 79 | eval $CMD |
| 80 | } |
| 81 | |
| 82 | fakereads "$@" |