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