| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified April 24, 2019 |
| 7 | |
| 8 | Description: Reformats a fungal assembly for release. |
| 9 | Also creates contig and agp files. |
| 10 | |
| 11 | Usage: fungalrelease.sh in=<input file> out=<output file> |
| 12 | |
| 13 | I/O parameters: |
| 14 | in=<file> Input scaffolds. |
| 15 | out=<file> Output scaffolds. |
| 16 | outc=<file> Output contigs. |
| 17 | qfin=<file> Optional quality scores input. |
| 18 | qfout=<file> Optional quality scores output. |
| 19 | qfoutc=<file> Optional contig quality scores output. |
| 20 | agp=<file> Output AGP file. |
| 21 | legend=<file> Output name legend file. |
| 22 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 23 | overwrite an existing file. |
| 24 | |
| 25 | Processing parameters: |
| 26 | fastawrap=60 Wrap length for fasta lines. |
| 27 | tuc=t Convert sequence to upper case. |
| 28 | baniupac=t Crash on encountering a non-ACGTN base call. |
| 29 | mingap=10 Expand all gaps (Ns) to be at least this long. |
| 30 | mingapin=1 Only expand gaps that are at least this long. |
| 31 | sortcscaffolds=t Sort scaffolds descending by length. |
| 32 | sortcontigs=f Sort contigs descending by length. |
| 33 | renamescaffolds=t Rename scaffolds to 'scaffold_#'. |
| 34 | scafnum=1 Number of first scaffold. |
| 35 | renamecontigs=f Rename contigs to 'contig_#' instead of 'scafname_c#'. |
| 36 | contignum=1 Number of first contig; only used if renamecontigs=t. |
| 37 | minscaf=1 Only retain scaffolds at least this long. |
| 38 | mincontig=1 Only retain contigs at least this long. |
| 39 | |
| 40 | Java Parameters: |
| 41 | -Xmx This will set Java's memory usage, overriding autodetection. |
| 42 | -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs. |
| 43 | The max is typically 85% of physical memory. |
| 44 | -eoom This flag will cause the process to exit if an |
| 45 | out-of-memory exception occurs. Requires Java 8u92+. |
| 46 | -da Disable assertions. |
| 47 | |
| 48 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 49 | " |
| 50 | } |
| 51 | |
| 52 | #This block allows symlinked shellscripts to correctly set classpath. |
| 53 | pushd . > /dev/null |
| 54 | DIR="${BASH_SOURCE[0]}" |
| 55 | while [ -h "$DIR" ]; do |
| 56 | cd "$(dirname "$DIR")" |
| 57 | DIR="$(readlink "$(basename "$DIR")")" |
| 58 | done |
| 59 | cd "$(dirname "$DIR")" |
| 60 | DIR="$(pwd)/" |
| 61 | popd > /dev/null |
| 62 | |
| 63 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 64 | CP="$DIR""current/" |
| 65 | |
| 66 | z="-Xmx4g" |
| 67 | z2="-Xms4g" |
| 68 | set=0 |
| 69 | |
| 70 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 71 | usage |
| 72 | exit |
| 73 | fi |
| 74 | |
| 75 | calcXmx () { |
| 76 | source "$DIR""/calcmem.sh" |
| 77 | setEnvironment |
| 78 | parseXmx "$@" |
| 79 | if [[ $set == 1 ]]; then |
| 80 | return |
| 81 | fi |
| 82 | } |
| 83 | calcXmx "$@" |
| 84 | |
| 85 | fungalrelease() { |
| 86 | local CMD="java $EOOM $EA $EOOM $z $z2 -cp $CP jgi.FungalRelease $@" |
| 87 | echo $CMD >&2 |
| 88 | eval $CMD |
| 89 | } |
| 90 | |
| 91 | fungalrelease "$@" |