| 1 | #!/bin/bash |
| 2 | |
| 3 | usage(){ |
| 4 | echo " |
| 5 | Written by Brian Bushnell |
| 6 | Last modified May 6, 2024 |
| 7 | |
| 8 | Description: Converts BGI/Complete Genomics reads to Illumina header format, |
| 9 | and optionally appends barcodes/indexes. For example, |
| 10 | @E200008112L1C001R00100063962/1 |
| 11 | would become |
| 12 | @E200008112:0:FC:1:6396:1:1 1:N:0: |
| 13 | |
| 14 | Usage: bgi2illumina.sh in=<input file> out=<output file> barcode=<string> |
| 15 | |
| 16 | Input may be fasta or fastq, compressed or uncompressed. |
| 17 | |
| 18 | Standard parameters: |
| 19 | in=<file> Primary input, or read 1 input. |
| 20 | in2=<file> Read 2 input if reads are in two files. |
| 21 | out=<file> Primary output, or read 1 output. |
| 22 | out2=<file> Read 2 output if reads are in two files. |
| 23 | overwrite=f (ow) Set to false to force the program to abort rather than |
| 24 | overwrite an existing file. |
| 25 | ziplevel=2 (zl) Set to 1 (lowest) through 9 (max) to change compression |
| 26 | level; lower compression is faster. |
| 27 | |
| 28 | Processing parameters: |
| 29 | barcode= (index) Optionally append a barcode to the header. |
| 30 | parseextra=f Set this to true if the reads headers have comments |
| 31 | delimited by a whitespace. |
| 32 | |
| 33 | Please contact Brian Bushnell at [email protected] if you encounter any problems. |
| 34 | " |
| 35 | } |
| 36 | |
| 37 | #This block allows symlinked shellscripts to correctly set classpath. |
| 38 | pushd . > /dev/null |
| 39 | DIR="${BASH_SOURCE[0]}" |
| 40 | while [ -h "$DIR" ]; do |
| 41 | cd "$(dirname "$DIR")" |
| 42 | DIR="$(readlink "$(basename "$DIR")")" |
| 43 | done |
| 44 | cd "$(dirname "$DIR")" |
| 45 | DIR="$(pwd)/" |
| 46 | popd > /dev/null |
| 47 | |
| 48 | #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/" |
| 49 | CP="$DIR""current/" |
| 50 | |
| 51 | z="-Xmx300m" |
| 52 | z2="-Xms300m" |
| 53 | set=0 |
| 54 | |
| 55 | if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then |
| 56 | usage |
| 57 | exit |
| 58 | fi |
| 59 | |
| 60 | calcXmx () { |
| 61 | source "$DIR""/calcmem.sh" |
| 62 | setEnvironment |
| 63 | parseXmx "$@" |
| 64 | } |
| 65 | calcXmx "$@" |
| 66 | |
| 67 | function bgi2ill() { |
| 68 | local CMD="java $EA $EOOM $z $z2 -cp $CP hiseq.BGI2Illumina $@" |
| 69 | echo $CMD >&2 |
| 70 | eval $CMD |
| 71 | } |
| 72 | |
| 73 | bgi2ill "$@" |