about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2025-05-07 10:23:44 +0300
committerMunyoki Kilyungi2025-05-08 10:20:37 +0300
commit2e7f3ff801c9365b7c83acbed8eca771676d40ef (patch)
tree9ac43f05c46493faa1f6459c9aaf7b2a0e266c09
parent541a6bf83ee23ad98fa5e0d8801d966d7ffaaa6a (diff)
downloadgn-machines-2e7f3ff801c9365b7c83acbed8eca771676d40ef.tar.gz
Add "--init-xapian".
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rwxr-xr-xgenenetwork-local-container.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/genenetwork-local-container.sh b/genenetwork-local-container.sh
index 39be629..f657346 100755
--- a/genenetwork-local-container.sh
+++ b/genenetwork-local-container.sh
@@ -382,3 +382,34 @@ if [ "$1" = "--init-rdf" ]; then
     cd $curr_dir
     exit 0
 fi
+
+if [ "$1" = "--init-xapian" ]; then
+    # Check for required tools
+    log INFO "Please make sure your container is running for this to work"
+    log INFO "This takes some time to run"
+    # Check if directory exists and is accessible
+    if [ -d "$BASE_DIR/var/lib/xapian" ]; then
+        if [ -w "$BASE_DIR/var/lib/xapian" ]; then
+	    log "DEBUG" "Directory exists and is writable: $BASE_DIR/var/lib/xapian"
+        else
+	    log "WARNING" "Directory exists but is not writable: $BASE_DIR/var/lib/xapian.  Making this writable"
+	    sudo chown -R "$USER" "$BASE_DIR/var/lib/xapian"
+        fi
+        continue
+    fi
+    # Check if build directory exists
+    if [ ! -f "$BASE_DIR/var/lib/xapian/build" ]; then
+        rm -rf "$BASE_DIR/var/lib/xapian/build"
+    fi
+
+    env PYTHONPATH="$BASE_DIR/genenetwork3/" guix shell python-wrapper genenetwork3 \
+	--share="$BASE_DIR/var/lib/xapian"  -- \
+	"$BASE_DIR/genenetwork3/scripts/index-genenetwork" create-xapian-index \
+	"$BASE_DIR/var/lib/xapian/build" \
+	"mysql://webqtlout:webqtlout@localhost/db_webqtl_local?unix_socket=/run/mysqld/mysqld.sock&charset=utf8" \
+	"http://localhost:7082/sparql"
+    mv "$BASE_DIR/var/lib/xapian/build/*" "$BASE_DIR/var/lib/xapian/" \
+	&& rmdir "$BASE_DIR/var/lib/xapian/build/"
+    log INFO "Please restart the container to set the correct permissions"
+    exit 0
+fi