Re: [Seqan-dev] loading SeedSets cargos into maps


Hi,

After not attracting any attention on this one I worked myself through the MemoryManager, which seems to cause all the problems.

First, the part the compiler complains about doesn't make any sense to me at all. So I put the following lines in comments:

memoryManager_int.h:

    //hmmmmmmmmmmm < this was not my comment; its not useful whatsoever
    size_t x = supremumValue<size_t>();
    while (tmpSource != x){
        tmpSource = source[tmpSource];
        target[tmpTarget] = tmpSource;
        tmpTarget = target[tmpTarget];
    }

I also had to change a couple of lines above to prevent a bad memory access. Changed:

    target.lastValue = &target[length(source)-1];

to
    if (length(source) > 0) target.lastValue = &target[length(source)-1];

I also have the other bugfixes that I did submit to the bug-tracker (bug + fix) but unfortunately nobody has actually made the changes in the library so far.

What I figured out:
The SeedSet is instantiated as a local variable and then added to the map. That means everything is copied, at least it should, otherwise its lost when the program leaves the scope of the SeedSet. However, the memoryManager seems to recycle certain memory regions that contain seeds. At least I loose the seed data when I leave the scope.

    TMap map;
    {
        TSeedSet seedset(100, 0);
        TSeed seed(1, 2, 4);
        if (!addSeed(seedset, seed, Single()))
            ::std::cerr << "adding seed went wrong" << ::std::endl;
        insert(map, 0, seedset); // insert the seedset at key=0
        printMap(map,-2,2);
// Seeds still in map
    }
    printMap(map,-2,2);
// Seeds gone from map

Here, the second printMap() throws a memory access exception. The data for the seed are lost:

first printMap(map,-2,2):
-2 missed
-1 missed
0 found
1 1-4     2-5
1 missed

second
printMap(map,-2,2):
-2 missed
-1 missed
0 found
Current language:  auto; currently c++
Program received signal:  “EXC_BAD_ACCESS”.


Any idea on how to fix this is very much appreciated since this bug proves himself a stopper.

Thanks a lot!

Cheers,
Fabian

Fabian Buske wrote:
Hi,

I tried to use a map (skiplist) loaded with an __int64 key and a seedSet cargo but get a compiler error.
Is there a size limit as to what load of a cargo or what type of cargo can be used?

Sample code:

typedef SeedSet< int, SimpleSeed,  DefaultNoScore , void > TSeedSet;
typedef Pair< int, TSeedSet> TSkipValue;
typedef Map< TSkipValue , Skiplist< > > TDiagMap;
SeedSet< int, SimpleSeed,  DefaultNoScore , void > seedset(100, 0);
TDiagMap diagMap;
insert(diagMap, 1, seedset);

throws:

seqan/seeds/memoryManager_int.h:185: error: cannot convert 'const seqan::Seed<int, const seqan::Tag<seqan::_Seed_simple> >' to 'size_t' in assignment
seqan/seeds/memoryManager_int.h:185: error: cannot convert 'const seqan::Seed<int, const seqan::Tag<seqan::_Seed_simple> >' to 'size_t' in assignment
seqan/seeds/memoryManager_int.h:185: error: cannot convert 'const seqan::Seed<int, const seqan::Tag<seqan::_Seed_simple> >' to 'size_t' in assignment

I did put in a ticket for this as well.

On a minor note seed_base and the seedSet_base are missing the "= operator" implementation.

Seed & operator = (Seed const &orig)


Cheers,
Fabian



-- 
Fabian Buske
Institute for Molecular Bioscience
The University of Queensland 
Brisbane, Qld. 4072 Australia
Phone: (61)-(7)-334-62608