jpayne@69
|
1 #!/bin/bash
|
jpayne@69
|
2
|
jpayne@69
|
3 usage(){
|
jpayne@69
|
4 echo "
|
jpayne@69
|
5 Written by Brian Bushnell
|
jpayne@69
|
6 Last modified April 1, 2020
|
jpayne@69
|
7
|
jpayne@69
|
8 Description: Renames reads to <prefix>_<number> where you specify the prefix
|
jpayne@69
|
9 and the numbers are ordered. There are other renaming modes too.
|
jpayne@69
|
10 If reads are paired, pairs should be processed together; if reads are
|
jpayne@69
|
11 interleaved, the interleaved flag should be set. This ensures that if a
|
jpayne@69
|
12 read number (such as 1: or 2:) is added, it will be added correctly.
|
jpayne@69
|
13
|
jpayne@69
|
14 Usage: rename.sh in=<file> in2=<file2> out=<outfile> out2=<outfile2> prefix=<>
|
jpayne@69
|
15
|
jpayne@69
|
16 in2 and out2 are for paired reads and are optional.
|
jpayne@69
|
17 If input is paired and there is only one output file, it will be written interleaved.
|
jpayne@69
|
18
|
jpayne@69
|
19 Parameters:
|
jpayne@69
|
20 prefix= The string to prepend to existing read names.
|
jpayne@69
|
21 ow=f (overwrite) Overwrites files that already exist.
|
jpayne@69
|
22 zl=4 (ziplevel) Set compression level, 1 (low) to 9 (max).
|
jpayne@69
|
23 int=f (interleaved) Determines whether INPUT file is considered interleaved.
|
jpayne@69
|
24 fastawrap=70 Length of lines in fasta output.
|
jpayne@69
|
25 minscaf=1 Ignore fasta reads shorter than this.
|
jpayne@69
|
26 qin=auto ASCII offset for input quality. May be 33 (Sanger), 64 (Illumina), or auto.
|
jpayne@69
|
27 qout=auto ASCII offset for output quality. May be 33 (Sanger), 64 (Illumina), or auto (same as input).
|
jpayne@69
|
28 ignorebadquality=f (ibq) Fix out-of-range quality values instead of crashing with a warning.
|
jpayne@69
|
29
|
jpayne@69
|
30 Renaming modes (if not default):
|
jpayne@69
|
31 renamebyinsert=f Rename the read to indicate its correct insert size.
|
jpayne@69
|
32 renamebymapping=f Rename the read to indicate its correct mapping coordinates.
|
jpayne@69
|
33 renamebytrim=f Rename the read to indicate its correct post-trimming length.
|
jpayne@69
|
34 addprefix=f Rename the read by prepending the prefix to the existing name.
|
jpayne@69
|
35 prefixonly=f Only use the prefix; don't add _<number>
|
jpayne@69
|
36 addunderscore=t Add an underscore after the prefix (if there is a prefix).
|
jpayne@69
|
37 addpairnum=t Add a pairnum (e.g. ' 1:') to paired reads in some modes.
|
jpayne@69
|
38 fixsra=f Fixes headers of SRA reads renamed from Illumina.
|
jpayne@69
|
39 Specifically, it converts something like this:
|
jpayne@69
|
40 SRR17611.11 HWI-ST79:17:D091UACXX:4:1101:210:824 length=75
|
jpayne@69
|
41 ...into this:
|
jpayne@69
|
42 HWI-ST79:17:D091UACXX:4:1101:210:824 1:
|
jpayne@69
|
43
|
jpayne@69
|
44 Sampling parameters:
|
jpayne@69
|
45 reads=-1 Set to a positive number to only process this many INPUT reads (or pairs), then quit.
|
jpayne@69
|
46
|
jpayne@69
|
47 Java Parameters:
|
jpayne@69
|
48 -Xmx This will set Java's memory usage, overriding autodetection.
|
jpayne@69
|
49 -Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs.
|
jpayne@69
|
50 The max is typically 85% of physical memory.
|
jpayne@69
|
51 -eoom This flag will cause the process to exit if an
|
jpayne@69
|
52 out-of-memory exception occurs. Requires Java 8u92+.
|
jpayne@69
|
53 -da Disable assertions.
|
jpayne@69
|
54
|
jpayne@69
|
55 Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems.
|
jpayne@69
|
56 "
|
jpayne@69
|
57 }
|
jpayne@69
|
58
|
jpayne@69
|
59 #This block allows symlinked shellscripts to correctly set classpath.
|
jpayne@69
|
60 pushd . > /dev/null
|
jpayne@69
|
61 DIR="${BASH_SOURCE[0]}"
|
jpayne@69
|
62 while [ -h "$DIR" ]; do
|
jpayne@69
|
63 cd "$(dirname "$DIR")"
|
jpayne@69
|
64 DIR="$(readlink "$(basename "$DIR")")"
|
jpayne@69
|
65 done
|
jpayne@69
|
66 cd "$(dirname "$DIR")"
|
jpayne@69
|
67 DIR="$(pwd)/"
|
jpayne@69
|
68 popd > /dev/null
|
jpayne@69
|
69
|
jpayne@69
|
70 #DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
|
jpayne@69
|
71 CP="$DIR""current/"
|
jpayne@69
|
72
|
jpayne@69
|
73 z="-Xmx1g"
|
jpayne@69
|
74 set=0
|
jpayne@69
|
75
|
jpayne@69
|
76 if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
|
jpayne@69
|
77 usage
|
jpayne@69
|
78 exit
|
jpayne@69
|
79 fi
|
jpayne@69
|
80
|
jpayne@69
|
81 calcXmx () {
|
jpayne@69
|
82 source "$DIR""/calcmem.sh"
|
jpayne@69
|
83 setEnvironment
|
jpayne@69
|
84 parseXmx "$@"
|
jpayne@69
|
85 }
|
jpayne@69
|
86 calcXmx "$@"
|
jpayne@69
|
87
|
jpayne@69
|
88 function rename() {
|
jpayne@69
|
89 local CMD="java $EA $EOOM $z -cp $CP jgi.RenameReads $@"
|
jpayne@69
|
90 echo $CMD >&2
|
jpayne@69
|
91 eval $CMD
|
jpayne@69
|
92 }
|
jpayne@69
|
93
|
jpayne@69
|
94 rename "$@"
|