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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ LOC_INCLUDE=include
LOC_SRC=src
OBJDIR=obj

CXXFLAGS += -Wall $(DEBUG) $(PROFILE) $(OPT) $(ARCH) -m64 -I. -I$(LOC_INCLUDE) \
CXXFLAGS += -Wall $(DEBUG) $(PROFILE) $(OPT) $(ARCH) -m64 -I. -I$(LOC_INCLUDE) -I$(MYINCL) \
-Wno-unused-result -Wno-strict-aliasing -Wno-unused-function -Wno-sign-compare

CFLAGS += -Wall $(DEBUG) $(PROFILE) $(OPT) $(ARCH) -m64 -I. -I$(LOC_INCLUDE)\
Expand Down Expand Up @@ -59,6 +59,7 @@ $(OBJDIR)/hashutil.o: $(LOC_INCLUDE)/hashutil.h
# dependencies between .o files and .cc (or .c) files

$(OBJDIR)/gqf.o: $(LOC_SRC)/cqf/gqf.c $(LOC_INCLUDE)/cqf/gqf.h
$(OBJDIR)/query.o: $(LOC_SRC)/sockets.h

#
# generic build rules
Expand Down
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,59 @@ OPTIONS
<query> Prefix of input files.
```

The command takes the following options :
The command takes the following options:
- `--input-prefix,-p`: the directory where the output of coloreddbg command is present.
- `--output,-o`: the file where the query results should be written (default : `samples.output`).

additionally the command takes the following mandatory _positional_ argument :
- query transcripts: input transcripts to be queried.

Finally, rather than writing the results in the "simple" output format, they can be written in JSON if you
provide the `--json,-j` flag to the `query` comamnd.
provide the `--json,-j` flag to the `query` command.

The output file in contains the list of experiments (i.e., hits) corresponding to each queried transcript.

Server
-------

`mantis server` lets you run mantis as a server which loads a mantis index and waits for queries.

```bash
$ make mantis
$ ./mantis server -p raw/
```

The options and arguments are as follows:

```bash
SYNOPSIS
mantis server [-j] -p <query_prefix>

OPTIONS
-j, --json Write the output in JSON format

<query_prefix>
Prefix of input files.
```

The command takes the following options:
- `--input-prefix,-p`: the directory where the output of coloreddbg command is present.

Rather than writing the results in the "simple" output format, they can be written in JSON if you
provide the `--json,-j` flag to the `query` command.

The server loads mantis index to memory and starts to accept queries (port 23901 is used by default) in the following format:

```
<query_filepath> <output_filepath>
```

The query has the following arguments:
- query filepath: input transcripts to be queried.
- output filepath: the file where the query results should be written. The output file in contains the list of experiments (i.e., hits) corresponding to each queried transcript.

There is a client example written in python `src/client.py` which demonstrates how one can communicate with the server.

Contributing
------------
Contributions via GitHub pull requests are welcome.
Expand Down
14 changes: 14 additions & 0 deletions scripts/install_mantis_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
. load_deps_spack.sh # load mantis dependencies with spack and save environment variables

TOOLS=~/tools
mkdir -p $TOOLS/src
git clone https://github.com/simongog/sdsl-lite.git $TOOLS/src/sdsl-lite
$TOOLS/src/sdsl-lite/install.sh $TOOLS

git clone https://github.com/effect/mantis.git $TOOLS/mantis

LIBRARY_PATH=$TOOLS/lib:$LIBRARY_PATH
./patch_makefile.sh $TOOLS/mantis/Makefile
cd $TOOLS/mantis
MYINCL=$TOOLS/include make NH=1
6 changes: 6 additions & 0 deletions scripts/libpaths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
IFS=":"
for line in $LIBRARY_PATH; do
echo -L$line '\\'
done

7 changes: 7 additions & 0 deletions scripts/load_deps_spack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
spack load gcc
spack load cmake
spack load boost
spack load zlib
spack load bzip2
spack load binutils
6 changes: 6 additions & 0 deletions scripts/patch_makefile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
MAKEFILE=$1
LIBPATHS="$(./libpaths.sh)"
LIBPATHS="$(echo "$LIBPATHS" | sed '$ ! s/$/\\/')" # escape new lines
sed -i "/TARGETS=/aMYLIBS=$LIBPATHS" $MAKEFILE # add MYLIBS var with all libraries path
sed -i "s/LDFLAGS += /LDFLAGS += \$\(MYLIBS\) /g" $MAKEFILE # add MYLIBS to LDFLAGS
17 changes: 17 additions & 0 deletions src/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import socket
import sys

HOST, PORT = "localhost", 23901

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.connect((HOST, PORT))

query_filepath = "/home/paf2023/run_mantis/queries/query{0}.fa"
output_filepath = "/home/paf2023/run_mantis/out/out{0}.res"

for x in range(0, 5):
print("Send request {0}".format(query_filepath.format(x)))
s.send(query_filepath.format(x) + " " + output_filepath.format(x))
result = str(s.recv(4096))
print("Got result {0}".format(result))
16 changes: 13 additions & 3 deletions src/mantis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void explore_options_verbose(T& res) {
}

int query_main (QueryOpts& opt);
int server_main (QueryOpts& opt);
int build_main (BuildOpts& opt);
int validate_main (ValidateOpts& opt);

Expand All @@ -57,16 +58,18 @@ int validate_main (ValidateOpts& opt);
*/
int main ( int argc, char *argv[] ) {
using namespace clipp;
enum class mode {build, query, validate, help};
enum class mode {build, query, server, validate, help};
mode selected = mode::help;

auto console = spdlog::stdout_color_mt("mantis_console");

BuildOpts bopt;
QueryOpts qopt;
QueryOpts qopt, sopt;
ValidateOpts vopt;

bopt.console = console;
qopt.console = console;
sopt.console = console;
vopt.console = console;

start_time = time(NULL);
Expand Down Expand Up @@ -145,6 +148,11 @@ int main ( int argc, char *argv[] ) {
option("-o", "--output") & value("output_file", qopt.output) % "Where to write query output.",
value(ensure_file_exists, "query", qopt.query_file) % "Prefix of input files."
);
auto server_mode = (
command("server").set(selected, mode::server),
option("-j", "--json").set(sopt.use_json) % "Write the output in JSON format",
required("-p", "--input-prefix") & value(ensure_dir_exists, "query_prefix", sopt.prefix) % "Prefix of input files." // ,
);

auto validate_mode = (
command("validate").set(selected, mode::validate),
Expand All @@ -155,11 +163,12 @@ int main ( int argc, char *argv[] ) {
);

auto cli = (
(build_mode | query_mode | validate_mode | command("help").set(selected,mode::help) ),
(build_mode | query_mode | server_mode | validate_mode | command("help").set(selected,mode::help) ),
option("-v", "--version").call([]{std::cout << "version 1.0\n\n";}).doc("show version") );

assert(build_mode.flags_are_prefix_free());
assert(query_mode.flags_are_prefix_free());
assert(server_mode.flags_are_prefix_free());
assert(validate_mode.flags_are_prefix_free());

decltype(parse(argc, argv, cli)) res;
Expand All @@ -178,6 +187,7 @@ int main ( int argc, char *argv[] ) {
switch(selected) {
case mode::build: build_main(bopt); break;
case mode::query: query_main(qopt); break;
case mode::server: server_main(sopt); break;
case mode::validate: validate_main(vopt); break;
case mode::help: std::cout << make_man_page(cli, "mantis"); break;
}
Expand Down
Loading