### Install and Provision Fuseki Server Source: https://github.com/vgteam/vg/wiki/RDF/Example:-Serving-out-an-RDF-version-of-a-VG-graph-with-Apache-Fuseki This section details the installation of the Fuseki SPARQL server using Homebrew on macOS and its subsequent provisioning to load a Turtle file. It starts the server in update mode and uses s-put to load the data. Dependencies: Homebrew, fuseki-server, s-put. ```bash brew install fuseki fuseki-server --update --mem /b3106 s-put -v http://localhost:3030/b3106/data default b3106.ttl ``` -------------------------------- ### Testing a Single Documentation File (Bash) Source: https://github.com/vgteam/vg/wiki/Testable-Documentation This command demonstrates how to test a specific Markdown file containing testable documentation examples. It uses the `txm` tool, specifying a single job and providing the path to the Markdown file relative to the `test` directory. ```bash txm --jobs 1 ../doc/wiki/Testable-Documentation.md ``` -------------------------------- ### Virtuoso Configuration File Example Source: https://github.com/vgteam/vg/wiki/RDF/RDF:-for-VG This is an example `virtuoso.ini` configuration file for setting up Virtuoso. It specifies database file paths, logging, server parameters like port, threads, and checkpoint intervals. Key settings include `DatabaseFile`, `ErrorLogFile`, `ServerPort`, `ServerThreads`, and `CheckpointInterval`. ```ini ; ; virtuoso.ini ; ; Database setup ; [Database] DatabaseFile = /scratch/uuw_sparql/jerven_rdf_vg_experiment_delete_in_2016/triples/virtuoso.db ErrorLogFile = /scratch/uuw_sparql/jerven_rdf_vg_experiment_delete_in_2016/triples/virtuoso.log LockFile = /scratch/uuw_sparql/jerven_rdf_vg_experiment_delete_in_2016/triples/virtuoso.lck TransactionFile = /scratch/uuw_sparql/jerven_rdf_vg_experiment_delete_in_2016/triples/virtuoso.trx xa_persistent_file = /scratch/uuw_sparql/jerven_rdf_vg_experiment_delete_in_2016/triples/virtuoso.pxa ErrorLogLevel = 7 FileExtend = 20000 MaxCheckpointRemap = 20000 Striping = 0 TempStorage = TempDatabase [TempDatabase] DatabaseFile = /scratch/uuw_sparql/jerven_rdf_vg_experiment_delete_in_2016/triples/virtuoso-temp.db TransactionFile = /scratch/uuw_sparql/jerven_rdf_vg_experiment_delete_in_2016/triples/virtuoso-temp.trx MaxCheckpointRemap = 2000 Striping = 0 ; ; Server parameters ; [Parameters] ServerPort = 1113 LiteMode = 1 DisableUnixSocket = 0 DisableTcpSocket = 0 ServerThreads = 64 AsyncQueueMaxThreads = 10 MaxClientConnections = 64 CheckpointInterval = 600 O_DIRECT = 0 UseAIO = 1 CaseMode = 2 MaxStaticCursorRows = 5000 CheckpointAuditTrail = 0 AllowOSCalls = 0 SchedulerInterval = 10 DirsAllowed = /scratch/uuw_sparql/jerven_rdf_vg_experiment_delete_in_2016/ ThreadCleanupInterval = 0 ThreadThreshold = 10 ResourcesCleanupInterval = 0 FreeTextBatchSize = 100000 SingleCPU = 0 VADInstallDir = /dev/null PrefixResultNames = 0 dfFreeTextRulesSize = 100 IndexTreeMaps = 256 MaxMemPoolSize = 134217728 TransactionAfterImageLimit = 1000000000 ``` -------------------------------- ### Start Virtuoso Server Source: https://github.com/vgteam/vg/wiki/RDF/RDF:-for-VG This command starts the Virtuoso server using a specified configuration file. `nohup` ensures the process continues after logout, and output is redirected to a log file. The `-f` flag indicates the configuration file path. ```bash nohup ./virtuoso-t -f +wait +configfile ./virtuoso-config-for-test.ini >> vg_rdf_exp_load.log ``` -------------------------------- ### Testing Documentation Script (Bash) Source: https://github.com/vgteam/vg/wiki/Testable-Documentation This command executes a script located at `doc/test-docs.sh` within the VG repository. This script is responsible for running all the testable documentation examples embedded in the project's Markdown files. ```bash ./doc/test-docs.sh ``` -------------------------------- ### Example Test Case: Trivial Command Execution (Markdown) Source: https://github.com/vgteam/vg/wiki/Testable-Documentation An example demonstrating how to define a testable code snippet within a Markdown file. The `` comment annotates the `echo` and `rev` command, indicating that `txm` should execute this command and ensure it completes successfully. ```markdown ``` echo "racecar" | rev ``` ``` -------------------------------- ### Install Python Openstack Client Source: https://github.com/vgteam/vg/wiki/Openstack-Gitlab-Runner-Setup Installs the python-openstackclient package using pip. This is a prerequisite for interacting with Openstack resources via the command line. ```bash pip install --user python-openstackclient ``` -------------------------------- ### Install Cactus and hal2vg Source: https://github.com/vgteam/vg/wiki/Importing-Cactus-Alignments-into-vg Steps to download and build Cactus and hal2vg. Requires cloning repositories, running make commands, and sourcing the environment. Ensure VGDIR is correctly set in include.mk for hal2vg. ```bash git clone https://github.com/glennhickey/progressiveCactus.git --recursive cd progressiveCactus make . environment ``` ```bash cd .. git clone https://github.com/ComparativeGenomicsToolkit/hal2vg.git --recursive cd hal2vg # EDIT INCLUDE.MK SO THAT VGDIR POINTS TO THE PATH OF VG ON YOUR COMPUTER make ``` -------------------------------- ### Install and Register Gitlab Runner with Docker and S3 Cache Source: https://github.com/vgteam/vg/wiki/Openstack-Gitlab-Runner-Setup Installs Gitlab runner and Docker on the VM, then registers the runner with the Gitlab instance. It configures the runner to use Docker as an executor, with specified memory, CPU limits, and a Docker-in-Docker image. It also sets up caching using Ceph's S3-compatible storage, providing access keys and endpoint details. Finally, it adjusts the runner's concurrency settings in the configuration file. ```bash S3API_ACCESS_KEY=!!!FILL!IN!!! S3API_SECRET_KEY=!!!FILL!IN!!! TASK_MEMORY=25G TASKS_PER_NODE=1 CPUS_PER_TASK=8 bash -c "export DEBIAN_FRONTEND=noninteractive; curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | bash" DEBIAN_FRONTEND=noninteractive apt update && sudo DEBIAN_FRONTEND=noninteractive apt upgrade -y DEBIAN_FRONTEND=noninteractive apt install -y docker.io gitlab-runner gitlab-runner register --non-interactive \ --url https://ucsc-ci.com --token "${RUNNER_TOKEN}" --limit "${TASKS_PER_NODE}" \ --executor docker --docker-privileged --docker-memory "${TASK_MEMORY}" --docker-cpus "${CPUS_PER_TASK}" --docker-image docker:dind \ --cache-type S3 --cache-s3-bucket-name gitlab-cache --cache-path "cache" --cache-shared true \ --cache-s3-server-address "gi-cprv-md.prism:7480" --cache-s3-insecure true \ --cache-s3-access-key "${S3API_ACCESS_KEY}" --cache-s3-secret-key "${S3API_SECRET_KEY}" sed -i "s/concurrent = 1/concurrent = ${TASKS_PER_NODE}/g" /etc/gitlab-runner/config.toml echo " output_limit = 40960" >>/etc/gitlab-runner/config.toml gitlab-runner restart ``` -------------------------------- ### Show vg command usage Source: https://github.com/vgteam/vg/wiki/Quickstart Displays the general usage instructions for the vg toolkit. This is a good starting point to understand the available commands. ```bash ./bin/vg ``` -------------------------------- ### Install rpvg for Linux x86_64 Source: https://github.com/vgteam/vg/wiki/Long‐read-RNA‐seq-with-pre‐existing-pangenome Installs the 'rpvg' tool for Linux x86_64 systems if it's not already found. It downloads, extracts, and moves the rpvg executable to the vg directory. If the system is not Linux x86_64, it suggests following the standard installation instructions. ```bash if ! which rpvg ; then if [[ "$(uname -sm)" == "Linux x86_64" ]] ; then wget https://github.com/jonassibbesen/rpvg/releases/download/v1.0/rpvg-v1.0_linux.tar.gz tar -xvf rpvg-v1.0_linux.tar.gz rpvg-v1.0_linux/bin/rpvg mv rpvg-v1.0_linux/bin/rpvg "$(dirname \"$(which vg)\")" rmdir rpvg-v1.0_linux/bin rmdir rpvg-v1.0_linux rm rpvg-v1.0_linux.tar.gz fi # Otherwise follow the actual instructions fi ``` -------------------------------- ### Install vg Binary Source: https://github.com/vgteam/vg/wiki/Long-read-giraffe-demo Instructions to download and make the vg binary executable for version 1.68.0. This allows running vg commands directly from the current directory. ```bash chmod +x vg ./vg ``` -------------------------------- ### Mark Code Block for Testing (Markdown) Source: https://github.com/vgteam/vg/wiki/Testable-Documentation This comment precedes a code block in a Markdown file, instructing the `txm` tool to treat the following code as a test case. The `check` keyword signifies that `txm` should verify the command's successful execution (exit code 0). This is useful for ensuring documentation examples are runnable and correct. ```markdown ``` -------------------------------- ### Start Interactive Docker Registry Proxy Source: https://github.com/vgteam/vg/wiki/Openstack-Gitlab-Runner-Setup Starts a Docker registry proxy container in interactive mode. This is useful for debugging as the container will stop when the terminal session ends. It forwards requests to the official Docker Hub registry and listens on port 5000. The `--rm` flag ensures the container is removed upon exit. ```bash docker run --rm -ti -e REGISTRY_PROXY_REMOTEURL=https://registry-1.docker.io -p 5000:5000 -p 80:5000 --name registry registry:2 ``` -------------------------------- ### Linux: Install VG Dependencies Source: https://github.com/vgteam/vg/blob/master/README.md Installs VG's dependencies on Ubuntu 22.04 using apt. Requires build-essential, git, cmake, and various development libraries including protobuf, jansson, and testing tools like jq, bc, and npm. Ensure package index is up-to-date with 'sudo apt update'. ```bash sudo apt update apt install sudo sudo apt update sudo apt-get install build-essential git cmake pkg-config libncurses-dev libbz2-dev \ protobuf-compiler libprotoc-dev libprotobuf-dev libjansson-dev \ automake gettext autopoint libtool jq bsdmainutils bc rs parallel \ npm curl unzip redland-utils librdf-dev bison flex gawk lzma-dev \ liblzma-dev liblz4-dev libffi-dev libcairo-dev libboost-all-dev \ libzstd-dev pybind11-dev python3-pybind11 libssl-dev ``` -------------------------------- ### Build Haplotype Information File with vg haplotypes Source: https://github.com/vgteam/vg/blob/master/test/haplotype-sampling/README.md Builds the haplotype information file required for haplotype sampling. It uses the vg haplotypes command with options for progress verbosity and subchain length. ```bash vg haplotypes -v 2 --subchain-length 300 -H micb-kir3dl1.hapl micb-kir3dl1.gbz ``` -------------------------------- ### Running Callgrind Profiler with vg Source: https://github.com/vgteam/vg/wiki/Troubleshooting This command executes the vg tool with the Callgrind profiler enabled. The `--tool=callgrind` flag activates the profiler, and `vg ...` specifies the vg command to run. If selective instrumentation is used, `--instr-atstart=no` should be added to avoid profiling the initial setup. ```bash valgrind --tool=callgrind vg [your vg arguments] ``` ```bash valgrind --tool=callgrind --instr-atstart=no vg [your vg arguments] ``` -------------------------------- ### Create GBZ File using vg Source: https://github.com/vgteam/vg/wiki/Programming-with-the-vg-API This snippet demonstrates how to create a GBZ file from a GFA input using the `vg gbwt` command. It requires the `vg` binary to be installed and accessible in the project's PATH. ```bash cd myproject vg gbwt -G cactus-BRCA2.gfa --gbz-format -g cactus-BRCA2.gbz ``` -------------------------------- ### RDF Graph Representation in Turtle Syntax Source: https://github.com/vgteam/vg/wiki/RDF/RDF:-for-VG Shows how multiple triples can form a Directed Acyclic Graph (DAG) in RDF. This example extends the previous one to include a relationship from the blank node to another resource. ```turtle linkedin:jervenbolleman dictionary:love _:1 . _:1 dictionary:love . ``` -------------------------------- ### Instrumenting Code for Callgrind Profiling (C++) Source: https://github.com/vgteam/vg/wiki/Troubleshooting This snippet demonstrates how to selectively profile parts of your C++ code using Callgrind. It requires including the `valgrind/callgrind.h` header and using the `CALLGRIND_START_INSTRUMENTATION` macro. This is useful for focusing analysis on specific operations, excluding setup or loading times. ```cpp #include // ... your code ... CALLGRIND_START_INSTRUMENTATION; // Code you want to profile goes here // ... more code ... ``` -------------------------------- ### Build Giraffe Indexes for vg autoindex Source: https://github.com/vgteam/vg/blob/master/test/haplotype-sampling/README.md Builds the necessary indexes for Giraffe using the vg autoindex command. This converts the graph to GBZ format and creates distance and minimizer indexes. ```bash vg autoindex --workflow giraffe --prefix micb-kir3dl1 -g micb-kir3dl1.gfa ``` -------------------------------- ### Call Variants from Augmented Graph using vg Source: https://github.com/vgteam/vg/blob/master/README.md This example shows how to call variants when using an augmented graph. It involves indexing the augmented graph, computing read support from the augmented GAM, and then generating a VCF file with `vg call`. ```bash # Index our augmented graph vg index aug.vg -x aug.xg # Compute the read support from the augmented GAM (ignoring qualitiy < 5, and 1st and last 5bp of each read) vg pack -x aug.xg -g aug.gam -Q 5 -s 5 -o aln_aug.pack # Generate a VCF from the support vg call aug.xg -k aln_aug.pack > calls.vcf ``` -------------------------------- ### Visualize Graph with vg and Graphviz Source: https://github.com/vgteam/vg/wiki/Introduction-to-visualization This example demonstrates how to generate a Graphviz-formatted SVG output from a vg graph and display it in a web browser. It requires vg, Graphviz tools, and a web browser. The input is a vg graph, and the output is an SVG file displayed in the browser. ```shell vg construct -v tiny/tiny.vcf.gz -r tiny/tiny.fa \ | vg view -d - \ | dot -Tsvg -o x.svg chromium-browser x.svg ``` -------------------------------- ### Convert GFA graph to HashGraph format Source: https://github.com/vgteam/vg/wiki/Programming-with-the-vg-API This command converts a graph from GFA format to the HashGraph format used by libbdsg. It requires the `vg` tool to be installed and uses `curl` to download an example GFA file before performing the conversion. ```bash cd myproject curl -O https://raw.githubusercontent.com/vgteam/vg/ffd491375f7e6d97c63598e35fefc653c9aea286/test/graphs/cactus-BRCA2.gfa vg convert --hash-out cactus-BRCA2.gfa >cactus-BRCA2.vg ``` -------------------------------- ### GBWT Construction from Phased VCF Files with Parallel Jobs Source: https://github.com/vgteam/vg/wiki/VG-GBWT-Subcommand This example demonstrates building a GBWT index from phased VCF files using multiple parallel construction jobs. It first combines input graphs and then constructs the GBWT, specifying the number of parallel jobs and VCF input. This process requires significant memory and time, depending on the data size. ```bash # Combine multiple input graphs built with `vg construct -a`. vg index -x graph-with-alts.xg -L $(for i in $(seq 1 22; echo X; echo Y); do echo chr${i}.vg; done) # Build the GBWT using 14 parallel jobs. This requires ~200 GiB memory. Construction # time is bounded by the time required for indexing chr2. vg gbwt -x graph-with-alts.xg -o 1000gp.gbwt --preset 1000gp --num-jobs 14 -v \ $(for i in $(seq 1 22; echo X; echo Y); do echo chr${i}.vcf.gz; done) ``` -------------------------------- ### Get Gene Positions on E.coli Sakai Chromosome (SPARQL) Source: https://github.com/vgteam/vg/wiki/VG-RDF,-the-Ensembl-bacteria-E.-coli-genome-hack-attack Retrieves the start and end positions of protein-coding genes on the E. coli Sakai chromosome that are also represented as paths in the VG graph. It links Ensembl gene locations to specific chromosomes using `owl:sameAs`. ```sparql PREFIX owl: PREFIX faldo: SELECT ?s ?bp ?ep WHERE { ?s a ; faldo:location ?l . ?l faldo:end ?e ; faldo:begin ?b . ?e faldo:position ?ep ; faldo:reference ?chromo . ?b faldo:position ?bp ; faldo:reference ?chromo . owl:sameAs ?chromo } ``` -------------------------------- ### SPARQL Query: Nodes Within Distance of a Given Node Source: https://github.com/vgteam/vg/wiki/RDF/Example:-Serving-out-an-RDF-version-of-a-VG-graph-with-Apache-Fuseki This SPARQL query attempts to find nodes within a certain hop count (less than 10) from a specified starting node. It uses vg:linksForwardToForward for path traversal and groups results by hop count. Note: The query returns nodes with at most 10 hops between them, not necessarily direct neighbors. ```sparql PREFIX vg: PREFIX rdf: PREFIX vgnode: SELECT ?nearbynode ?hopcount WHERE { SELECT ?nearbynode (count(?hop) as ?hopcount) WHERE { vgnode:261 vg:linksForwardToForward* ?hop. ?hop vg:linksForwardToForward+ ?nearbynode . } GROUP BY ?nearbynode HAVING (?hopcount < 10) ORDER BY ?hopcount } ``` -------------------------------- ### macOS: Install VG Dependencies with MacPorts Source: https://github.com/vgteam/vg/blob/master/README.md Installs VG dependencies on macOS using MacPorts. This command installs essential libraries such as libtool, protobuf3-cpp, jansson, jq, cmake, and others required for building and running VG. ```bash sudo port install libtool protobuf3-cpp jansson jq cmake pkgconfig autoconf automake libtool coreutils samtools redland bison gperftools md5sha1sum rasqal gmake autogen cairo libomp boost zstd pybind11 openssl ``` -------------------------------- ### macOS: Install VG Dependencies with Homebrew Source: https://github.com/vgteam/vg/blob/master/README.md Installs VG dependencies on macOS using Homebrew's Brewfile. The 'brew bundle' command reads the Brewfile in the VG repository root and installs all listed dependencies, making them available for VG. ```bash brew bundle ``` -------------------------------- ### Set up directories and variables for vg graph construction Source: https://github.com/vgteam/vg/wiki/Construction-Examples This bash script sets up the necessary directories for storing graphs, indexes, and logs. It also defines variables for file paths and a temporary directory for large disk operations. The log file is cleared at the beginning of the process. ```bash CONSTRUCTION=./wiki-data/mock-hs37d5 GRAPHS=${CONSTRUCTION}/graphs INDEXES=${CONSTRUCTION}/indexes MAPPING=${GRAPHS}/node_mapping LOGS=${CONSTRUCTION}/logs # Create necessary directories mkdir -p ${GRAPHS} mkdir -p ${INDEXES} mkdir -p ${LOGS} LARGE_DISK_TMP="$(dirname "$(mktemp -u)")" # Make sure logfile is open LOGFILE=${LOGS}/vg_all.log rm -f $LOGFILE ``` -------------------------------- ### Map Reads with vg map using On-Disk Index Source: https://github.com/vgteam/vg/blob/master/README.md This example demonstrates mapping reads using `vg map` with an on-disk index created by `vg index`. It covers constructing a graph, building an index (xg/gcsa), mapping a single read, simulating multiple reads, mapping them, and finally surjecting the alignments back to reference space producing a BAM file. Dependencies include `vg construct`, `vg index`, `vg map`, `vg sim`, and `vg surject`. ```sh # construct the graph (paths below assume running from `vg/test` directory) vg construct -r small/x.fa -v small/x.vcf.gz > x.vg # store the graph in the xg/gcsa index pair vg index -x x.xg -g x.gcsa -k 16 x.vg # align a read to the indexed version of the graph # note that the graph file is not opened, but x.vg.index is assumed vg map -s CTACTGACAGCAGAAGTTTGCTGTGAAGATTAAATTAGGTGATGCTTG -x x.xg -g x.gcsa > read.gam # simulate a bunch of 150bp reads from the graph, one per line vg sim -n 1000 -l 150 -x x.xg > x.sim.txt # now map these reads against the graph to get a GAM vg map -T x.sim.txt -x x.xg -g x.gcsa > aln.gam # surject the alignments back into the reference space of sequence "x", yielding a BAM file vg surject -x x.xg -b aln.gam > aln.bam ``` -------------------------------- ### Build and Push VG Docker Image Source: https://github.com/vgteam/vg/wiki/Releases This script builds a Docker image for the VG release and pushes it to a container registry. It clones the repository, checks out the specified version, updates submodules, and then uses Docker to build and tag the image. It logs into and out of the registry before pushing. ```shell VG_VERSION="vX.Y.Z" git clone --recursive https://github.com/vgteam/vg.git cd vg git checkout ${VG_VERSION} git submodule sync git submodule update --init --recursive make version docker pull mirror.gcr.io/library/ubuntu:20.04 docker build --target run -t quay.io/vgteam/vg:${VG_VERSION} -f Dockerfile . docker build --target test -f Dockerfile . docker logout quay.io docker login quay.io docker push quay.io/vgteam/vg:${VG_VERSION} docker logout quay.io ``` -------------------------------- ### Set up C++ project with libbdsg submodule Source: https://github.com/vgteam/vg/wiki/Programming-with-the-vg-API This snippet demonstrates how to initialize a new C++ project, add libbdsg as a Git submodule, checkout a specific commit, and configure the project's CMakeLists.txt to include libbdsg. It sets the C++ standard and disables Python bindings and Doxygen documentation for libbdsg. ```bash mkdir myproject cd myproject git init mkdir deps cd deps git submodule add https://github.com/vgteam/libbdsg.git cd libbdsg git checkout 46917e3dd7a4b5f0995d01b798688eea13f708fc git submodule update --init --recursive cd ../.. cat >CMakeLists.txt <<'EOF' cmake_minimum_required(VERSION 3.10) project(myproject VERSION 0.0.1) set(CMAKE_CXX_STANDARD 14) # We will not need libbdsg's Python bindings set(BUILD_PYTHON_BINDINGS OFF CACHE INTERNAL "" FORCE) # We also will not need its Doxygen docs set(RUN_DOXYGEN OFF CACHE INTERNAL "" FORCE) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/deps/libbdsg") EOF ``` -------------------------------- ### Augment Graph with Variation using vg Source: https://github.com/vgteam/vg/blob/master/README.md This section shows how to augment a graph with variations from alignments. The first example augments the graph with variations from a GAM, saving the result to a new GAM and VG file. The second example includes soft clips and saves each mapping as a path. ```bash # augment the graph with all variation from the GAM except that implied by soft clips, saving to aug.vg. aug.gam contains the same reads as aln.gam but mapped to aug.vg vg augment x.vg aln.gam -A aug.gam > aug.vg # augment the graph with all variation from the GAM, saving each mapping as a path in the graph. # softclips of alignment paths are preserved (`-S`). # Note, this can be much less efficient than the above example if there are many alignments in the GAM vg augment x.vg aln.gam -i -S > aug_with_paths.vg ``` -------------------------------- ### Construct Graph with Paths from VCF and Build GBWT Index Source: https://github.com/vgteam/vg/wiki/Index-Construction This sequence of commands first constructs a vg graph that includes paths corresponding to variants from a VCF file, using the '-a' option. Subsequently, it builds the XG and GCSA indexes for the graph, and then constructs the GBWT (Gapped Buried Wavelet Tree) index from the VCF file. ```bash vg construct -r reference.fa -v variants.vcf.gz -a > graph.vg vg index -x graph.xg -g graph.gcsa graph.vg vg gbwt -x graph.vg -o graph.gbwt -v variants.vcf.gz ``` -------------------------------- ### Build Example Pantranscriptome Target Graph and Copy Files Source: https://github.com/vgteam/vg/wiki/Long‐read-RNA‐seq-with-pre‐existing-pangenome Generates an example pantranscriptome target graph using 'vg gbwt' and copies necessary annotation and read files for demonstration purposes. This allows users to follow along without needing to create large graph files. ```bash vg gbwt --gbz-format -g graph.gbz -G longread/graph.gfa cp longread/annotations.gff3 ./annotations.ref.gff3 cp longread/annotations.gff3 ./annotations.sample1.gff3 cp longread/annotations.gff3 ./annotations.sample2.gff3 cp longread/kinnex.fq ./reads.fastq ``` -------------------------------- ### Construct GBWT Index with VG Source: https://github.com/vgteam/vg/wiki/Construction-Examples This script constructs a GBWT () index from a set of VG graph files and VCF files. It first builds a temporary XG index with alt paths and then uses this to construct the GBWT. Ensure VG version 1.30.0 or later is installed. ```bash #!/bin/bash LOGS=${CONSTRUCTION}/logs DATA=${CONSTRUCTION}/data GRAPHS=${CONSTRUCTION}/graphs INDEXES=${CONSTRUCTION}/indexes JOBS=14 export TMPDIR=${LARGE_DISK_TMP} OUTPUT=all GBWT=${INDEXES}/${OUTPUT}.gbwt LOGFILE=${LOGS}/gbwt_${OUTPUT}.log rm -f $LOGFILE START=$(date +%s) echo "Start time: $START" >> $LOGFILE echo "Jobs: $JOBS" >> $LOGFILE echo >> $LOGFILE XG_ALTS=${TMPDIR}/graph-with-alts.xg # Build a temporary XG index with alt paths. vg index -x $XG_ALTS -L -p \ $(for i in $(seq 1 22; echo X; echo Y); do echo ${GRAPHS}/chr${i}.vg; done) 2>> $LOGFILE MID=$(date +%s) echo >> $LOGFILE echo "Checkpoint: $MID" >> $LOGFILE echo "Temporary XG construction: $(($MID-$START)) seconds" >> $LOGFILE echo >> $LOGFILE # Build the GBWT. vg gbwt -x $XG_ALTS -o $GBWT --preset 1000gp --num-jobs $JOBS -p -v \ $(for i in $(seq 1 22; echo X; echo Y); do echo ${DATA}/chr${i}.vcf.gz; done) 2>> $LOGFILE rm -f $XG_ALTS STOP=$(date +%s) echo "Finish time: $STOP" >> $LOGFILE echo "GBWT construction: $(($STOP-$MID)) seconds" >> $LOGFILE echo "Total time: $(($STOP-$START)) seconds" >> $LOGFILE ``` -------------------------------- ### Construct Minimizer Index and Zipcodes File with VG Source: https://github.com/vgteam/vg/wiki/Index-Construction Constructs a minimizer index and an associated zipcodes file from a GBZ graph and a distance index. Requires the GBZ graph and distance index as input, and outputs the minimizer index and zipcodes file. The command supports multi-threading for faster processing. ```bash vg minimizer -t 16 -d graph.dist -o graph.withzip.min -z graph.zipcodes graph.gbz ``` -------------------------------- ### Start Persistent Docker Registry Proxy Source: https://github.com/vgteam/vg/wiki/Openstack-Gitlab-Runner-Setup Starts a Docker registry proxy container in detached mode. This container forwards requests to the official Docker Hub registry and listens on port 5000. The `--restart always` flag ensures the container restarts automatically if the Docker daemon restarts or the server reboots. This acts as a local mirror for Docker images. ```bash docker run -d -e REGISTRY_PROXY_REMOTEURL=https://registry-1.docker.io -p 5000:5000 -p 80:5000 --restart always --name registry registry:2 ``` -------------------------------- ### Deconstruct Nested Site with -n Option (GFA to VCF) - SNP in Insertion Example Source: https://github.com/vgteam/vg/wiki/VCF-export-with-vg-deconstruct This command demonstrates the 'vg deconstruct' tool with the '-n' option on a GFA file containing a nested SNP within an insertion. The output is in VCF format, illustrating how the tool represents nested structures and associated alleles using new INFO tags. This example specifically targets a scenario with a SNP inside an insertion. ```bash vg deconstruct test/nesting/nested_snp_in_ins2.gfa -p x -n ``` -------------------------------- ### Build XG index from VG graphs using vg index Source: https://github.com/vgteam/vg/wiki/Construction-Examples This bash script builds a compact XG index from multiple VG graph files using the `vg index -x` command. The XG format is optimized for quick access by other vg algorithms. The script logs the start and end times, and the total duration of the indexing process. ```bash OUTPUT=all XG=${INDEXES}/${OUTPUT}.xg # Set up log file LOGFILE=${LOGS}/xg_${OUTPUT}.log rm -f $LOGFILE START=$(date +%s) echo "Start time: $START" >> $LOGFILE echo >> $LOGFILE # Perform XG indexing vg index -x $XG $(for i in $(seq 1 22; echo X; echo Y); do echo ${GRAPHS}/chr${i}.vg; done) STOP=$(date +%s) echo "Finish time: $STOP" >> $LOGFILE echo "Total time: $(($STOP-$START)) seconds" >> $LOGFILE ``` -------------------------------- ### Load RDF Data into Virtuoso using isql Source: https://github.com/vgteam/vg/wiki/VG-RDF,-the-Ensembl-bacteria-E.-coli-genome-hack-attack Loads compressed RDF data files into a Virtuoso triple store using the `isql` command-line client. Requires Virtuoso to be running and accessible, with specified port, user, and password. Data must be in an absolute path. The `rdf_loader_run` command initiates the loading process. ```bash isql $port $user $pass \ exec="ld_dir('${HOME}/ecoli','k12_and_o157.ttl.xz', 'http://example.org/vg_ecoli')" isql $port $user $pass \ exec="ld_dir('${HOME}/ecoli','escherichia_coli_o157_h7_str_sakai.ttl.gz','http://example.org/ensembl_ecoli')" isql $port $user $pass \ exec="ld_dir('${HOME}/ecoli','escherichia_coli_str_k_12_substr_dh10b.ttl.gz','http://example.org/ensembl_ecoli')" isql $port $user $pass \ exec="rdf_loader_run(log_enable=>2);" ``` -------------------------------- ### Run Virtuoso RDF Loader in Parallel Source: https://github.com/vgteam/vg/wiki/RDF/RDF:-for-VG This script optimizes the RDF loading process by temporarily disabling checkpoints and then launching multiple `rdf_loader_run()` jobs in parallel. The number of parallel jobs is determined by half the available CPU cores. Checkpoints are re-enabled and a final checkpoint is performed after loading. ```bash #turn off text indexing as that is use less for this data $isql $port $user $password exec="DB.DBA.RDF_OBJ_FT_RULE_DEL (null, null, 'All');" then we want to load all the data, this is faster if auto checkpoints are turned of so we do. We auto detect the number of CPUs and we launch a job for half of them. If you have less files than halve the number of CPUs, that will be the limiting factor in loading your data, other wise it is the largest file being the limiting factor. $isql $port $user $password exec="checkpoint_interval (0)"; for i in $(seq 1 2 $(cat /proc/cpuinfo | grep processor | tail -n 1 | grep -oP "\d+")); do #echo $i; $isql $port $user $password exec="rdf_loader_run();" & done wait; date $isql $port $user $password exec="checkpoint" $isql $port $user $password exec="checkpoint_interval (60)"; ``` -------------------------------- ### Get statistics for the MHC graph Source: https://github.com/vgteam/vg/wiki/Metagenomics-and-Assembly-with-VG/Long-read-assemblies-using-vg-msga Calculates and displays statistics for the generated MHC graph, including the number of nodes, edges, and total sequence length. ```bash vg stats -lz MHC.vg ``` -------------------------------- ### Clone VG Repository (Bash) Source: https://github.com/vgteam/vg/blob/master/README.md This command clones the vg repository and its submodules, which is the first step in building vg from source on Linux. Ensure you have git installed. ```bash git clone --recursive https://github.com/vgteam/vg.git cd vg ``` -------------------------------- ### View and visualize a variation graph Source: https://github.com/vgteam/vg/wiki/Quickstart Visualizes the structure of a vg graph file by converting it to a PDF format using 'dot' from the graphtools package. Requires graphtools to be installed. ```bash ./bin/vg view -d graph.vg | dot -Tpdf -o graph.pdf ``` -------------------------------- ### Compute stable graph name for GBZ graph Source: https://github.com/vgteam/vg/wiki/VG-GBWT-Subcommand Computes and sets the stable graph name (pggname) for an existing GBZ graph. This is relevant for graph compatibility checks starting from vg version 1.71.0. ```bash # Compute the stable graph name for an existing GBZ graph. vg gbwt -g graph.gbz --set-pggname -Z graph.gbz ``` -------------------------------- ### Generate Primer3 Configuration Source: https://github.com/vgteam/vg/wiki/Primer-Filter Example configuration for primer3 to identify potential primers. Requires SEQUENCE_ID formatted for vg primers and SEQUENCE_TEMPLATE for the nucleotide sequence. ```text SEQUENCE_ID=CHM13#0#chr17|BRCA1P1|exon_1|44026826 SEQUENCE_TEMPLATE=CATGT... PRIMER_NUM_RETURN=10 PRIMER_TASK=generic PRIMER_PICK_LEFT_PRIMER=1 PRIMER_PICK_INTERNAL_OLIGO=0 PRIMER_PICK_RIGHT_PRIMER=1 PRIMER_OPT_SIZE=20 PRIMER_MIN_SIZE=18 PRIMER_MAX_SIZE=22 PRIMER_PRODUCT_SIZE_RANGE=75-150 PRIMER_EXPLAIN_FLAG=1 = ```