Debian Codegraph @

seqtovec.sh

raw symbols SCIP
1 #!/bin/bash
2
3 usage(){
4 echo "
5 Written by Brian Bushnell
6 Last modified January 29, 2024
7
8 Description: Generates vectors from sequence.
9 These can be one-hot 4-bit vectors, or kmer frequency spectra.
10
11 Usage: sectovec.sh in=<sequence data> out=<text vectors>
12
13 Input may be fasta or fastq, compressed or uncompressed.
14
15 Standard parameters:
16 in=<file> Sequence data.
17 out=<file> Vectors in tsv form, with the last column as the result.
18 overwrite=f (ow) Set to false to force the program to abort rather than
19 overwrite an existing file.
20
21 Processing parameters:
22 parse=f Set to true to parse the result from individual sequence
23 headers, from a tab-delimited 'result=X' term.
24 result=-1 Set the desired result for all vectors.
25
26 Raw mode parameters:
27 width=55 Maximum vector width, in bases; the actual vector size will be
28 4+4*width+1 (where the +1 is the desired output). For
29 longer sequences, only the first 'width' bases will be used;
30 shorter sequences will be zero-padded.
31 rcomp=f If true, also output vectors for the reverse-complement.
32
33 Spectrum mode parameters:
34 k=0 If k is positive, generate vectors of kmer frequencies instead
35 of raw sequence. Range is 1-8; recommended range is 4-6.
36 dimensions=0 If positive, restrict the vector size in spectrum mode to
37 dimensions+5. The first 4 and last 1 columns are reserved.
38
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
43 specify 200 megs. The max is typically 85% of physical memory.
44 -eoom This flag will cause the process to exit if an out-of-memory
45 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="-Xmx1g"
67 z2="-Xms1g"
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 }
80 calcXmx "$@"
81
82 seqtovec() {
83 local CMD="java $EA $EOOM $z -cp $CP ml.SequenceToVector $@"
84 echo $CMD >&2
85 eval $CMD
86 }
87
88 seqtovec "$@"