edawson / gfakluge

A C++ library and utilities for manipulating the Graphical Fragment Assembly format.
http://edawson.github.io/gfakluge/
MIT License
51 stars 20 forks source link

Links still not showing #19

Closed LukasW94 closed 6 years ago

LukasW94 commented 6 years ago

With the following code I try to replicate the GFA-1 example from https://github.com/GFA-spec/GFA-spec/blob/master/GFA1.md

void gfakluge_test() {
    gfak::GFAKluge og;

    og.set_version(1);

    gfak::sequence_elem s;
    s.sequence = "ACCTT";
    s.name = "11";

    gfak::sequence_elem t;
    t.sequence = "TCAAGG";
    t.name = "12";

    gfak::sequence_elem u;
    u.sequence = "CTTGATT";
    u.name = "13";

    gfak::link_elem l;
    l.source_name = s.name;
    l.sink_name = t.name;
    l.source_orientation_forward = true;
    l.sink_orientation_forward = false;
    l.cigar = "4M";

    gfak::link_elem m;
    m.source_name = t.name;
    m.sink_name = u.name;
    m.source_orientation_forward = false;
    m.sink_orientation_forward = true;
    m.cigar = "5M";

    gfak::link_elem n;
    n.source_name = s.name;
    n.sink_name = u.name;
    n.source_orientation_forward = true;
    n.sink_orientation_forward = true;
    n.cigar = "3M";

    gfak::path_elem p;
    p.name = "14";
    p.segment_names = {s.name, t.name, u.name};
    p.orientations = {true, false, true};
    p.overlaps = {"4M", "5M"};

    og.add_sequence(s);
    og.add_sequence(t);
    og.add_sequence(u);
    og.add_link(s, l);
    og.add_link(t, m);
    og.add_link(s, n);
    og.add_path(p.name, p);

    cout << og << endl;
}

The resulting output, when using the latest version, gives:

H   VN:Z:1.0
P   14  11+,12-,13+
S   11  ACCTT
S   12  TCAAGG
S   13  CTTGATT

When using https://github.com/edawson/gfakluge/commit/99bf3413e68e3e8d9767806f3f2a4d5efe427d9e the output is as followed:

H   VN:Z:1.0
P   14  11+,12-,13+ 4M,5M
S   11  ACCTT
L   11  +   12  -   4M
L   11  +   13  +   3M
S   12  TCAAGG
L   12  -   13  +   5M
S   13  CTTGATT

Which is the wanted result if I'm not mistaken.

edawson commented 6 years ago

This should now be fixed - I had a bug in the way the GFA1 <-> GFA2 normalization happened, where I never actually moved the links and containments to edges. This wasn't affected if parsing from a file, because that bit of the API is already forced to use edges.

edawson commented 6 years ago

@LukasW94 does this seem to do the expected thing now?

LukasW94 commented 6 years ago

I believe it does :+1: