rvaser / rala

Layout module for raw de novo genome assembly of long uncorrected reads.
MIT License
21 stars 3 forks source link

Changing main.cpp #3

Closed bheimbu closed 3 years ago

bheimbu commented 5 years ago

Dear Robert,

I'd like to include the changes to the main.cpp file, which you suggest here (https://ngschool.eu/index.php/book/export/html/183). However, I'm always getting compiling errors. Could you plaease clarify, how to change the file properly? I'm not really into c++, sorry.

Cheers Bastian

rvaser commented 5 years ago

Dear Bastian, can you paste the compilation errors here so I can assist you accordingly?

Best regards, Robert

bheimbu commented 5 years ago

Dear Robert,

I’m not in office anymore. I’ll send you the errors asap tomorrow.

Many thanks,

Bastian

bheimbu commented 5 years ago

OK,

I used the Mac of my girlfriend. Here we go. Find attached the error message. And here is the code of my main.cpp file:

#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>

#include "sequence.hpp"
#include "graph.hpp"
#include "thread_pool/thread_pool.hpp"

static const char* version = "v1.0.0";

static struct option options[] = {
    {"preconstruct", no_argument, 0, 'p'},
    {"include-unassembled", no_argument, 0, 'u'},
    {"debug", required_argument, 0, 'd'},
    {"sensitive-overlaps", required_argument, 0, 's'},
    {"threads", required_argument, 0, 't'},
    {"version", no_argument, 0, 'v'},
    {"help", no_argument, 0, 'h'},
    {0, 0, 0, 0}
};

void help();

int main(int argc, char** argv) {

    uint32_t num_threads = 1;
    bool drop_unassembled_sequences = true;
    bool preconstruct = false;
    std::string debug_prefix = "";
    std::string sensitive_overlaps_path = "";

    char opt;
    while ((opt = getopt_long(argc, argv, "pud:s:t:h", options, nullptr)) != -1) {
        switch (opt) {
            case 'p':
                preconstruct = true;
                break;
            case 'u':
                drop_unassembled_sequences = false;
                break;
            case 'd':
                debug_prefix = optarg;
                break;
            case 's':
                sensitive_overlaps_path = optarg;
                break;
            case 't':
                num_threads = atoi(optarg);
                break;
            case 'v':
                printf("%s\n", version);
                exit(0);
            case 'h':
                help();
                exit(0);
            default:
                exit(1);
        }
    }

    std::vector<std::string> input_paths;

    for (int32_t i = optind; i < argc; ++i) {
        input_paths.emplace_back(argv[i]);
    }

    if (input_paths.size() < 2) {
        fprintf(stderr, "[rala::] error: missing input file(s)!\n");
        help();
        exit(1);
    }

    auto graph = rala::createGraph(input_paths[0], input_paths[1], num_threads);
    graph->construct(false, false);

    graph->remove_transitive_edges();
        while (true) {
        uint32_t num_changes = 0;
        num_changes += graph->remove_tips();
        num_changes += graph->remove_bubbles();
        if (num_changes == 0) {
        break;
        }
    }

    if (preconstruct) {
        std::vector<std::unique_ptr<rala::Sequence>> nodes;
        graph->extract_nodes(nodes);

        for (const auto& it: nodes) {
            fprintf(stdout, ">%s\n%s\n", it->name().c_str(), it->data().c_str());
        }
        return 0;
    }

    graph->print_gfa("assembly_graph.gfa");
    graph->print_json("assembly_graph.json");

    std::vector<std::unique_ptr<rala::Sequence>> contigs;
    graph->extract_contigs(contigs, drop_unassembled_sequences);

    for (const auto& it: contigs) {
        fprintf(stdout, ">%s\n%s\n", it->name().c_str(), it->data().c_str());
    }

    return 0;
}

void help() {
    printf(
        "usage: rala [options ...] <sequences> <overlaps>\n"
        "\n"
        "    <sequences>\n"
        "        input file in FASTA/FASTQ format (can be compressed with gzip)\n"
        "        containing sequences\n"
        "    <overlaps>\n"
        "        input file in MHAP/PAF format (can be compressed with gzip)\n"
        "        containing pairwise overlaps\n"
        "\n"
        "    options:\n"
        "        -p, --preconstruct\n"
        "            print uncontained sequences for second iteration\n"
        "        -s, --sensitive-overlaps <file>\n"
        "            input file in MHAP/PAF format (can be compress with gzip)\n"
        "            containing more sensitive overlaps\n"
        "        -u, --include-unassembled\n"
        "            output unassembled sequences (singletons and short contigs)\n"
        "        -d, --debug <string>\n"
        "            enable debug output with given prefix\n"
        "        -t, --threads <int>\n"
        "            default: 1\n"
        "            number of threads\n"
        "        --version\n"
        "            prints the version number\n"
        "        -h, --help\n"
        "            prints the usage\n");
}

Many thanks again,

Bastian IMG_1898

bheimbu commented 5 years ago

Sorry for the messy message,

but I'm not using this Mac often.

Cheers Bastian

rvaser commented 5 years ago

Please verify on which branch are you with git status. I suppose you did not switch to branch workshop that has a bit older code for which the tutorial is written. If so, you can do that with git checkout workshop and git submudole update.

bheimbu commented 5 years ago

Actually,

I cloned it from your git repo. So I guess there is no need to change this.

Cheers

rvaser commented 5 years ago

The git repository has several branches. When you clone it you are positioned to the master branch, which in this case differs greatly from branch workshop.

bheimbu commented 5 years ago

Ok,

now I get your point. Sorry. I’ll try tmrrw.

Cheers Bastian

bheimbu commented 5 years ago

Hi,

when I type “git status”, I get following error:

git status fatal: Not a git repository (or any parent up to mount point /home/uni08) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I guess, this is due to the fact that I’m working on a cluster.

How may I proceed?

Cheers

bheimbu commented 5 years ago

Found it. No worries.

I try the steps as you suggested and see how far I can get.

Many thx again and have a nice evening.