本帖最后由 wtfitis 于 2021-9-24 22:10 编辑
这是calcmem.sh#!/bin/bash
#usage(){
# echo "CalcMem v1.15"
# echo "Written by Brian Bushnell, Doug Jacobsen, Alex Copeland, Bryce Foster"
# echo "Calculates available memory in megabytes"
# echo "Last modified December 17, 2019"
#}
#Also parses other Java flags
function parseXmx () {
local setxmx=0
local setxms=0
for arg in "$@"
do
if [[ "$arg" == "Xmx="* ]] || [[ "$arg" == "xmx="* ]]; then
z="-Xmx"${arg:4}
setxmx=1
elif [[ "$arg" == "-Xmx="* ]] || [[ "$arg" == "-xmx="* ]]; then
z="-Xmx"${arg:5}
setxmx=1
elif [[ "$arg" == -Xmx* ]] || [[ "$arg" == -xmx* ]]; then
#z="$arg"
z="-X"${arg:2}
setxmx=1
elif [[ "$arg" == Xmx* ]] || [[ "$arg" == xmx* ]]; then
#z="-$arg"
z="-X"${arg:1}
setxmx=1
elif [[ "$arg" == -Xms* ]]; then
z2="$arg"
setxms=1
elif [[ "$arg" == Xms* ]]; then
z2="-$arg"
setxms=1
elif [[ "$arg" == -da ]] || [[ "$arg" == -ea ]]; then
EA="$arg"
elif [[ "$arg" == da ]] || [[ "$arg" == ea ]]; then
EA="-$arg"
elif [[ "$arg" == ExitOnOutOfMemoryError ]] || [[ "$arg" == exitonoutofmemoryerror ]] || [[ "$arg" == eoom ]]; then
EOOM="-XX:+ExitOnOutOfMemoryError"
elif [[ "$arg" == -ExitOnOutOfMemoryError ]] || [[ "$arg" == -exitonoutofmemoryerror ]] || [[ "$arg" == -eoom ]]; then
EOOM="-XX:+ExitOnOutOfMemoryError"
elif [[ "$arg" == json ]] || [[ "$arg" == "json=t" ]] || [[ "$arg" == "json=true" ]] || [[ "$arg" == "format=json" ]]; then
json=1
elif [[ "$arg" == silent ]] || [[ "$arg" == "silent=t" ]] || [[ "$arg" == "silent=true" ]]; then
silent=1
fi
done
if [[ $setxmx == 1 ]] && [[ $setxms == 0 ]]; then
local substring=`echo $z| cut -d'x' -f 2`
z2="-Xms$substring"
setxms=1
elif [[ $setxmx == 0 ]] && [[ $setxms == 1 ]]; then
local substring=`echo $z2| cut -d's' -f 2`
z="-Xmx$substring"
setxmx=1
fi
set=$setxmx
}
function setEnvironment(){
EA="-ea"
EOOM=""
if [[ $SHIFTER_RUNTIME == 1 ]]; then
#Ignore NERSC_HOST
shifter=1
elif [ -v "$EC2_HOME" ]; then
#Let's assume this is the AWS taxonomy server...
PATH=/test1/binaries/bgzip:$PATH
PATH=/test1/binaries/lbzip2/bin:$PATH
PATH=/test1/binaries/sambamba:$PATH
#PATH=/test1/binaries/java/jdk-11.0.2/bin:$PATH
PATH=/test1/binaries/pigz2/pigz-2.4:$PATH
elif [ -z "$NERSC_HOST" ]; then
#Not NERSC; do nothing
:
else
PATH=/global/projectb/sandbox/gaag/bbtools/bgzip:$PATH
PATH=/global/projectb/sandbox/gaag/bbtools/lbzip2/bin:$PATH
PATH=/global/projectb/sandbox/gaag/bbtools/sambamba:$PATH
PATH=/global/projectb/sandbox/gaag/bbtools/java/jdk-11.0.2/bin:$PATH
PATH=/global/projectb/sandbox/gaag/bbtools/pigz2/pigz-2.4:$PATH
if [[ $NERSC_HOST == cori ]]; then
#module unload PrgEnv-intel
#module load PrgEnv-gnu/7.1
PATH=/global/projectb/sandbox/gaag/bbtools/samtools_cori/bin:$PATH
:
fi
fi
}
function freeRam(){
RAM=0;
#Memory is in kilobytes.
local defaultMem=3200000
if [ $# -gt 0 ]; then
defaultMem=$1;
case $defaultMem in
*g)
defaultMem=`echo $defaultMem| cut -d'g' -f 1`
defaultMem=$(( $defaultMem * $(( 1024 * 1024 )) ))
;;
*m)
defaultMem=`echo $defaultMem| cut -d'm' -f 1`
defaultMem=$(( $defaultMem * 1024 ))
;;
*k)
defaultMem=`echo $defaultMem| cut -d'k' -f 1`
;;
esac
fi
local mult=84
if [ $# -gt 1 ]; then
mult=$2;
fi
#echo "mult = $mult" # percent of memory to allocate
#echo "default = $defaultMem"
local ulimit=$(ulimit -v)
ulimit="${ulimit:-0}"
if [ "$ulimit" = "unlimited" ]; then ulimit=0; fi
local x=$ulimit
#echo "x = ${x}" # normally ulimit -v
#local HOSTNAME=`hostname`
local sge_x=0
local slurm_x=$(( SLURM_MEM_PER_NODE * 1024 ))
if [[ $RQCMEM -gt 0 ]]; then
#echo "branch for manual memory"
x=$(( RQCMEM * 1024 ));
elif [ -e /proc/meminfo ]; then
local vfree=$(cat /proc/meminfo | awk -F: 'BEGIN{total=-1;used=-1} /^CommitLimit:/ { total=$2 }; /^Committed_AS:/ { used=$2 } END{ print (total-used) }')
local pfree=$(cat /proc/meminfo | awk -F: 'BEGIN{free=-1;cached=-1;buffers=-1} /^MemFree:/ { free=$2 }; /^Cached:/ { cached=$2}; /^Buffers:/ { buffers=$2} END{ print (free+cached+buffers) }')
#echo "vfree = $vfree"
#echo "pfree = $pfree"
#echo "ulimit = $ulimit"
local x2=0;
if [ $vfree -gt 0 ] && [ $pfree -gt 0 ]; then
if [ $vfree -gt $pfree ]; then x2=$pfree;
else x2=$vfree; fi
elif [ $vfree -gt 0 ]; then x2=$vfree;
elif [ $pfree -gt 0 ]; then x2=$pfree;
fi
#echo $sge_x
#echo $slurm_x
#echo $x
#echo $x2
# set to SGE_HGR_RAMC or SLURM_MEM_PER_NODE value
if [ $sge_x -gt 0 ]; then
if [ $x2 -gt $sge_x ] || [ $x2 -eq 0 ]; then
x=$sge_x;
x2=$x;
fi
elif [ $slurm_x -gt 0 ]; then
if [ $x2 -gt $slurm_x ] || [ $x2 -eq 0 ]; then
x=$slurm_x;
x2=$x;
fi
fi
#echo "x = ${x}"
#echo "x2 = ${x2}"
#echo $vfree
#echo $pfree
if [ "$x" = "unlimited" ] || (("$x" > $x2)); then x=$x2; fi
if [ $x -lt 1 ]; then x=$x2; fi
fi
if [ $x -lt 1 ] || [[ $HOSTNAME == genepool* ]]; then
#echo "branch for unknown memory"
#echo $x
#echo "ram is unlimited"
RAM=$((defaultMem/1024))
echo "Max memory cannot be determined. Attempting to use $RAM MB." 1>&2
echo "If this fails, please add the -Xmx flag (e.g. -Xmx24g) to your command, " 1>&2
echo "or run this program qsubbed or from a qlogin session on Genepool, or set ulimit to an appropriate value." 1>&2
else
#echo "branch for known memory"
#echo "x = ${x}"
#echo "m = ${mult}"
# available (ram - 500k) * 85% / 1024kb = megs of ram to use
# not sure where this formula came from
RAM=$(( ((x-500000)*mult/100)/1024 ))
#echo $RAM
fi
#local z="-Xmx${RAM}m"
#echo $RAM
return 0
}
#freeRam "$@"
这是bbrename.sh#!/bin/bash
usage(){
echo "
Written by Brian Bushnell
Last modified April 1, 2020
Description: Renames reads to <prefix>_<number> where you specify the prefix
and the numbers are ordered. There are other renaming modes too.
If reads are paired, pairs should be processed together; if reads are
interleaved, the interleaved flag should be set. This ensures that if a
read number (such as 1: or 2:) is added, it will be added correctly.
Usage: rename.sh in=<file> in2=<file2> out=<outfile> out2=<outfile2> prefix=<>
in2 and out2 are for paired reads and are optional.
If input is paired and there is only one output file, it will be written interleaved.
Parameters:
prefix= The string to prepend to existing read names.
ow=f (overwrite) Overwrites files that already exist.
zl=4 (ziplevel) Set compression level, 1 (low) to 9 (max).
int=f (interleaved) Determines whether INPUT file is considered interleaved.
fastawrap=70 Length of lines in fasta output.
minscaf=1 Ignore fasta reads shorter than this.
qin=auto ASCII offset for input quality. May be 33 (Sanger), 64 (Illumina), or auto.
qout=auto ASCII offset for output quality. May be 33 (Sanger), 64 (Illumina), or auto (same as input).
ignorebadquality=f (ibq) Fix out-of-range quality values instead of crashing with a warning.
Renaming modes (if not default):
renamebyinsert=f Rename the read to indicate its correct insert size.
renamebymapping=f Rename the read to indicate its correct mapping coordinates.
renamebytrim=f Rename the read to indicate its correct post-trimming length.
addprefix=f Rename the read by prepending the prefix to the existing name.
prefixonly=f Only use the prefix; don't add _<number>
addunderscore=t Add an underscore after the prefix (if there is a prefix).
addpairnum=t Add a pairnum (e.g. ' 1:') to paired reads in some modes.
fixsra=f Fixes headers of SRA reads renamed from Illumina.
Specifically, it converts something like this:
SRR17611.11 HWI-ST79:17:D091UACXX:4:1101:210:824 length=75
...into this:
HWI-ST79:17:D091UACXX:4:1101:210:824 1:
Sampling parameters:
reads=-1 Set to a positive number to only process this many INPUT reads (or pairs), then quit.
Java Parameters:
-Xmx This will set Java's memory usage, overriding autodetection.
-Xmx20g will specify 20 gigs of RAM, and -Xmx200m will specify 200 megs.
The max is typically 85% of physical memory.
-eoom This flag will cause the process to exit if an
out-of-memory exception occurs. Requires Java 8u92+.
-da Disable assertions.
Please contact Brian Bushnell at bbushnell@lbl.gov if you encounter any problems.
"
}
#This block allows symlinked shellscripts to correctly set classpath.
pushd . > /dev/null
DIR="${BASH_SOURCE[0]}"
while [ -h "$DIR" ]; do
cd "$(dirname "$DIR")"
DIR="$(readlink "$(basename "$DIR")")"
done
cd "$(dirname "$DIR")"
DIR="$(pwd)/"
popd > /dev/null
#DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/"
CP="$DIR""current/"
z="-Xmx1g"
set=0
if [ -z "$1" ] || [[ $1 == -h ]] || [[ $1 == --help ]]; then
usage
exit
fi
calcXmx () {
source "$DIR""/calcmem.sh"
setEnvironment
parseXmx "$@"
}
calcXmx "$@"
function rename() {
local CMD="java $EA $EOOM $z $CP -cp jgi.RenameReads $@"
echo $CMD >&2
eval $CMD
}
rename "$@"
我程序运行bbrename.sh就出错了。。Error: Could not find or load main class jgi.RenameReads
这个class在那个文件夹下面是有的,但是为什么就是无法载入。。不太懂java
这是在centos下运行的。。
这个是运行命令java -ea -Xmx1g -classpath /02.antisense/BBMap-master/sh/current/ jgi.RenameReads
02.antisense/BBMap-master/current/jgi/RenameReads.java
这个文件的确存在 没办法载入
|