Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ Statistics at [Ghent University].
umgap -V
```

4. (optional) Install [FragGeneScanPlusPlus] to use as gene predictor in the
pipeline.
4. (optional) Install [FragGeneScanRs] to use as gene predictor in the
pipeline, for example with `cargo install frag_gene_scan_rs`. The setup
script picks it up from your `PATH`, or you can point at it with `-f`.

5. Run [`scripts/umgap-setup.sh`](scripts/umgap-setup.sh) to interactively
configure the UMGAP and download the data files required for some steps of
Expand Down Expand Up @@ -135,6 +136,6 @@ for more info.
[Rust]: https://www.rust-lang.org/
[metagenomics casestudy]: https://unipept.ugent.be/clidocs/casestudies/metagenomics
[rust-install]: https://www.rust-lang.org/tools/install
[FragGeneScanPlusPlus]: https://github.com/unipept/FragGeneScanPlusPlus
[FragGeneScanRs]: https://github.com/unipept/FragGeneScanRs
[EditorConfig]: https://editorconfig.org/
[RustFMT]: https://github.com/rust-lang/rustfmt
36 changes: 20 additions & 16 deletions scripts/umgap-analyse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fi
debug "parsing the arguments"

count=0
fgspp_used="false"
fgs_used="false"
tryptic_used="false"
ninemer_used="false"
samples=""
Expand All @@ -142,10 +142,10 @@ while getopts c:1:2:t:zo: f; do
case "$type" in
"max-sensitivity") ninemer_used="true" ;;
"high-sensitivity") ninemer_used="true" ;;
"tryptic-sensitivity") fgspp_used="true" ; tryptic_used="true" ;;
"tryptic-precision") fgspp_used="true" ; tryptic_used="true" ;;
"high-precision") fgspp_used="true" ; ninemer_used="true" ;;
"max-precision") fgspp_used="true" ; ninemer_used="true" ;;
"tryptic-sensitivity") fgs_used="true" ; tryptic_used="true" ;;
"tryptic-precision") fgs_used="true" ; tryptic_used="true" ;;
"high-precision") fgs_used="true" ; ninemer_used="true" ;;
"max-precision") fgs_used="true" ; ninemer_used="true" ;;
*) crash "Unrecognized type: '$type'."
esac
log "- Using '$type'."
Expand Down Expand Up @@ -223,10 +223,15 @@ fi
# Environmental checks.
# =========================================================================== #

if [ "$fgspp_used" = "true" ]; then
debug "checking if FGSpp is installed"
if ! [ -h "$(getconfigdir)/FGSpp" ]; then
crash "FragGeneScan++ not found. Please run umgap-setup."
if [ "$fgs_used" = "true" ]; then
debug "checking if FragGeneScanRs is installed"
if ! [ -h "$(getconfigdir)/FragGeneScanRs" ]; then
if [ -h "$(getconfigdir)/FGSpp" ]; then
crash "This configuration still points at FragGeneScan++, which UMGAP no longer
uses. Install FragGeneScanRs (https://github.com/unipept/FragGeneScanRs) and run
umgap-setup again."
fi
crash "FragGeneScanRs not found. Please run umgap-setup."
fi
fi

Expand All @@ -245,9 +250,8 @@ debug "using version '$version'"
# The actual pipeline
# =========================================================================== #

fgspp() {
"$(getconfigdir)/FGSpp/FGSpp" -s stdin -o stdout -w 0 \
-r "$(getconfigdir)/FGSpp/train" -t "illumina_10" -p 4 -c 2
fgs() {
"$(getconfigdir)/FragGeneScanRs" -s stdin -o stdout -w 0 -t "illumina_10" -p 4
}

taxons="$(getconfigdir)/$version/taxons.tsv"
Expand Down Expand Up @@ -287,23 +291,23 @@ while [ -n "${samples}" ]; do
umgap uniq -d / | # join paired ends
umgap taxa2agg -l1 -a hybrid -f 0.25 "$taxons";; # aggregate
"tryptic-sensitivity")
fgspp | # gene prediction
fgs | # gene prediction
umgap prot2tryp2lca -l9 -L45 "$tryptics" | # map to taxa
umgap uniq -d / | # join paired ends
umgap taxa2agg -l1 -m rmq -a mrtl "$taxons" ;; # aggregate
"tryptic-precision")
fgspp | # gene prediction
fgs | # gene prediction
umgap prot2tryp2lca -l9 -L45 "$tryptics" | # map to taxa
umgap uniq -d / | # join paired ends
umgap taxa2agg -l5 -m rmq -a mrtl "$taxons" ;; # aggregate
"high-precision")
fgspp | # gene prediction
fgs | # gene prediction
nc -NU "$socket" | # map to taxa
umgap seedextend -g1 -s3 | # seedextend filter
umgap uniq -d / | # join paired ends
umgap taxa2agg -l2 -a lca\* "$taxons" ;; # aggregate
"max-precision")
fgspp | # gene prediction
fgs | # gene prediction
nc -NU "$socket" | # map to taxa
umgap seedextend -g1 -s4 | # seedextend filter
umgap uniq -d / | # join paired ends
Expand Down
55 changes: 40 additions & 15 deletions scripts/umgap-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Usage: $0 [options]

Options:
-c dir The configuration directory. Defaults to '$config_default'.
-f dir Directory containing the FragGeneScan++ binary (FGSpp) and
training data.
-f path The FragGeneScanRs binary, or a directory containing it. Defaults
to the FragGeneScanRs on your PATH.
-d dir The data directory. The database files will be downloaded here.
Defaults to '$data_default'.
-y Download all files of the latest version without asking.
Expand All @@ -67,7 +67,7 @@ Options:
while getopts c:f:d:y f; do
case "$f" in
c) configdir="$OPTARG" ;;
f) fgsppdir="$OPTARG" ;;
f) fgsrsbin="$OPTARG" ;;
d) datadir="$OPTARG" ;;
y) download_all="true" ;;
\?) crash "$USAGE" ;;
Expand All @@ -93,22 +93,47 @@ if [ ! -d "$configdir" ]; then
fi
fi

# If FGSpp is found and works, link it in the config directory.
if [ -z "$fgsppdir" ]; then
if ! yesno 'FragGeneScan++ (-f) was not provided, only pipelines not using it will be available.'; then
crash 'Pass the location of FragGeneScan++ with -f.'
# Point people coming from the old FragGeneScan++ setup at the change, rather
# than letting them fail the check below with a confusing message.
case "$fgsrsbin" in
*/FGSpp|FGSpp) oldfgs="$fgsrsbin" ;;
esac
if [ -d "$fgsrsbin" ] && [ -x "$fgsrsbin/FGSpp" ] && [ ! -x "$fgsrsbin/FragGeneScanRs" ]; then
oldfgs="$fgsrsbin/FGSpp"
fi
if [ -n "$oldfgs" ]; then
crash "'$oldfgs' is a FragGeneScan++ installation. UMGAP now uses FragGeneScanRs
instead, which is a single binary and carries its own training data. Install it, for
example with 'cargo install frag_gene_scan_rs', then either put it on your PATH or
pass it with -f. See https://github.com/unipept/FragGeneScanRs."
fi

# If FragGeneScanRs is found and works, link it in the config directory.
if [ -d "$fgsrsbin" ]; then
fgsrsbin="$fgsrsbin/FragGeneScanRs"
fi
if [ -z "$fgsrsbin" ]; then
fgsrsbin="$(command -v FragGeneScanRs || true)"
fi
if [ -z "$fgsrsbin" ]; then
if ! yesno 'FragGeneScanRs was not found, only pipelines not using it will be available.'; then
crash 'Install FragGeneScanRs, or pass its location with -f.'
fi
else
cd "$fgsppdir"
if ! printf '>a\nA' | ./FGSpp -s stdin -o stdout -w 0 -t illumina_10 -c 240 > /dev/null; then
crash 'Invoking FGSpp failed, follow installation instructions at https://github.com/unipept/FragGeneScanPlusPlus.'
# A real read, so this checks that a prediction actually comes out, not just
# that the binary starts. FragGeneScanRs also panics on input too short to
# hold a codon, so a placeholder sequence is not usable here.
testread='ATCGCGCACGCGGCCGATGCCCCAGAAGAGATTGACAGCGGTGGGGCGGGCGGCGGCGAGGTGGTCGCAGATCTCGGCGACCTCTGCGTTGAGGGTCGGG'
if ! printf '>a\n%s\n' "$testread" \
| "$fgsrsbin" -s stdin -o stdout -w 0 -t illumina_10 \
| grep -q '^[A-Z]'; then
crash 'Invoking FragGeneScanRs failed, follow installation instructions at https://github.com/unipept/FragGeneScanRs.'
fi
fgsppdir="$(pwd -P)" # make path absolute
cd - > /dev/null
if ln -f -s "$fgsppdir" "$configdir/FGSpp"; then
echo 'Found, tested and remembered the FragGeneScan++ location.'
fgsrsbin="$(cd "$(dirname "$fgsrsbin")" && pwd -P)/$(basename "$fgsrsbin")" # absolute
if ln -f -s "$fgsrsbin" "$configdir/FragGeneScanRs"; then
echo 'Found, tested and remembered the FragGeneScanRs location.'
else
crash 'Could not link the FragGeneScan++ location.'
crash 'Could not link the FragGeneScanRs location.'
fi
fi

Expand Down
Loading