bio-velvet_underground 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitmodules +3 -0
- data/.travis.yml +13 -0
- data/Gemfile +19 -0
- data/LICENSE.txt +20 -0
- data/README.md +53 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/ext/bioruby.patch +60 -0
- data/ext/mkrf_conf.rb +50 -0
- data/ext/src/Makefile +125 -0
- data/ext/src/src/allocArray.c +305 -0
- data/ext/src/src/allocArray.h +86 -0
- data/ext/src/src/autoOpen.c +107 -0
- data/ext/src/src/autoOpen.h +18 -0
- data/ext/src/src/binarySequences.c +813 -0
- data/ext/src/src/binarySequences.h +125 -0
- data/ext/src/src/concatenatedGraph.c +233 -0
- data/ext/src/src/concatenatedGraph.h +30 -0
- data/ext/src/src/concatenatedPreGraph.c +262 -0
- data/ext/src/src/concatenatedPreGraph.h +29 -0
- data/ext/src/src/correctedGraph.c +2642 -0
- data/ext/src/src/correctedGraph.h +32 -0
- data/ext/src/src/dfib.c +509 -0
- data/ext/src/src/dfib.h +69 -0
- data/ext/src/src/dfibHeap.c +89 -0
- data/ext/src/src/dfibHeap.h +39 -0
- data/ext/src/src/dfibpriv.h +105 -0
- data/ext/src/src/fib.c +628 -0
- data/ext/src/src/fib.h +78 -0
- data/ext/src/src/fibHeap.c +79 -0
- data/ext/src/src/fibHeap.h +41 -0
- data/ext/src/src/fibpriv.h +110 -0
- data/ext/src/src/globals.h +153 -0
- data/ext/src/src/graph.c +3983 -0
- data/ext/src/src/graph.h +233 -0
- data/ext/src/src/graphReConstruction.c +1472 -0
- data/ext/src/src/graphReConstruction.h +30 -0
- data/ext/src/src/graphStats.c +2167 -0
- data/ext/src/src/graphStats.h +72 -0
- data/ext/src/src/kmer.c +652 -0
- data/ext/src/src/kmer.h +73 -0
- data/ext/src/src/kmerOccurenceTable.c +236 -0
- data/ext/src/src/kmerOccurenceTable.h +44 -0
- data/ext/src/src/kseq.h +223 -0
- data/ext/src/src/locallyCorrectedGraph.c +557 -0
- data/ext/src/src/locallyCorrectedGraph.h +40 -0
- data/ext/src/src/passageMarker.c +677 -0
- data/ext/src/src/passageMarker.h +137 -0
- data/ext/src/src/preGraph.c +1717 -0
- data/ext/src/src/preGraph.h +106 -0
- data/ext/src/src/preGraphConstruction.c +990 -0
- data/ext/src/src/preGraphConstruction.h +26 -0
- data/ext/src/src/readCoherentGraph.c +557 -0
- data/ext/src/src/readCoherentGraph.h +30 -0
- data/ext/src/src/readSet.c +1734 -0
- data/ext/src/src/readSet.h +67 -0
- data/ext/src/src/recycleBin.c +199 -0
- data/ext/src/src/recycleBin.h +58 -0
- data/ext/src/src/roadMap.c +342 -0
- data/ext/src/src/roadMap.h +65 -0
- data/ext/src/src/run.c +318 -0
- data/ext/src/src/run.h +52 -0
- data/ext/src/src/run2.c +712 -0
- data/ext/src/src/scaffold.c +1876 -0
- data/ext/src/src/scaffold.h +64 -0
- data/ext/src/src/shortReadPairs.c +1243 -0
- data/ext/src/src/shortReadPairs.h +32 -0
- data/ext/src/src/splay.c +259 -0
- data/ext/src/src/splay.h +43 -0
- data/ext/src/src/splayTable.c +1315 -0
- data/ext/src/src/splayTable.h +31 -0
- data/ext/src/src/tightString.c +362 -0
- data/ext/src/src/tightString.h +82 -0
- data/ext/src/src/utility.c +199 -0
- data/ext/src/src/utility.h +98 -0
- data/ext/src/third-party/zlib-1.2.3/ChangeLog +855 -0
- data/ext/src/third-party/zlib-1.2.3/FAQ +339 -0
- data/ext/src/third-party/zlib-1.2.3/INDEX +51 -0
- data/ext/src/third-party/zlib-1.2.3/Makefile +154 -0
- data/ext/src/third-party/zlib-1.2.3/Makefile.in +154 -0
- data/ext/src/third-party/zlib-1.2.3/README +125 -0
- data/ext/src/third-party/zlib-1.2.3/adler32.c +149 -0
- data/ext/src/third-party/zlib-1.2.3/algorithm.txt +209 -0
- data/ext/src/third-party/zlib-1.2.3/amiga/Makefile.pup +66 -0
- data/ext/src/third-party/zlib-1.2.3/amiga/Makefile.sas +65 -0
- data/ext/src/third-party/zlib-1.2.3/as400/bndsrc +132 -0
- data/ext/src/third-party/zlib-1.2.3/as400/compile.clp +123 -0
- data/ext/src/third-party/zlib-1.2.3/as400/readme.txt +111 -0
- data/ext/src/third-party/zlib-1.2.3/as400/zlib.inc +331 -0
- data/ext/src/third-party/zlib-1.2.3/compress.c +79 -0
- data/ext/src/third-party/zlib-1.2.3/configure +459 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/README.contrib +71 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/buffer_demo.adb +106 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/mtest.adb +156 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/read.adb +156 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/readme.txt +65 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/test.adb +463 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-streams.adb +225 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-streams.ads +114 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-thin.adb +141 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib-thin.ads +450 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib.adb +701 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib.ads +328 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/ada/zlib.gpr +20 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/asm586/README.586 +43 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/asm586/match.S +364 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/asm686/README.686 +34 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/asm686/match.S +329 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/Makefile +8 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/README +4 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/blast.c +444 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/blast.h +71 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/test.pk +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/blast/test.txt +1 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/delphi/ZLib.pas +557 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/delphi/ZLibConst.pas +11 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/delphi/readme.txt +76 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/delphi/zlibd32.mak +93 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib.build +33 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib.chm +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib.sln +21 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/dotzlib/readme.txt +58 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/README +1 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/infback9.c +608 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/infback9.h +37 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inffix9.h +107 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inflate9.h +47 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inftree9.c +323 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/infback9/inftree9.h +55 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/inflate86/inffas86.c +1157 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/inflate86/inffast.S +1368 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream/test.cpp +24 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream/zfstream.cpp +329 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream/zfstream.h +128 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream2/zstream.h +307 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream2/zstream_test.cpp +25 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/README +35 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/TODO +17 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/test.cc +50 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/zfstream.cc +479 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/iostream3/zfstream.h +466 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masm686/match.asm +413 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/bld_ml64.bat +2 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/gvmat64.asm +513 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/gvmat64.obj +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/inffas8664.c +186 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/inffasx64.asm +392 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/inffasx64.obj +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx64/readme.txt +28 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/bld_ml32.bat +2 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/gvmat32.asm +972 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/gvmat32.obj +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/gvmat32c.c +62 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/inffas32.asm +1083 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/inffas32.obj +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/mkasm.bat +3 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/masmx86/readme.txt +21 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/ChangeLogUnzip +67 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/Makefile +25 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/crypt.h +132 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/ioapi.c +177 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/ioapi.h +75 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/iowin32.c +270 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/iowin32.h +21 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/miniunz.c +585 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/minizip.c +420 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/mztools.c +281 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/mztools.h +31 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/unzip.c +1598 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/unzip.h +354 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/zip.c +1219 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/minizip/zip.h +235 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/pascal/example.pas +599 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/pascal/readme.txt +76 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/pascal/zlibd32.mak +93 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/pascal/zlibpas.pas +236 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/Makefile +8 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/README +63 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/puff.c +837 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/puff.h +31 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/puff/zeros.raw +0 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/testzlib/testzlib.c +275 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/testzlib/testzlib.txt +10 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/untgz/Makefile +14 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/untgz/Makefile.msc +17 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/untgz/untgz.c +674 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/readme.txt +73 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/miniunz.vcproj +126 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/minizip.vcproj +126 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/testzlib.vcproj +126 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlib.rc +32 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibstat.vcproj +246 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibvc.def +92 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibvc.sln +78 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc7/zlibvc.vcproj +445 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/miniunz.vcproj +566 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/minizip.vcproj +563 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/testzlib.vcproj +948 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/testzlibdll.vcproj +567 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlib.rc +32 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibstat.vcproj +870 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.def +92 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.sln +144 -0
- data/ext/src/third-party/zlib-1.2.3/contrib/vstudio/vc8/zlibvc.vcproj +1219 -0
- data/ext/src/third-party/zlib-1.2.3/crc32.c +423 -0
- data/ext/src/third-party/zlib-1.2.3/crc32.h +441 -0
- data/ext/src/third-party/zlib-1.2.3/deflate.c +1736 -0
- data/ext/src/third-party/zlib-1.2.3/deflate.h +331 -0
- data/ext/src/third-party/zlib-1.2.3/example.c +565 -0
- data/ext/src/third-party/zlib-1.2.3/examples/README.examples +42 -0
- data/ext/src/third-party/zlib-1.2.3/examples/fitblk.c +233 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gun.c +693 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gzappend.c +500 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gzjoin.c +448 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gzlog.c +413 -0
- data/ext/src/third-party/zlib-1.2.3/examples/gzlog.h +58 -0
- data/ext/src/third-party/zlib-1.2.3/examples/zlib_how.html +523 -0
- data/ext/src/third-party/zlib-1.2.3/examples/zpipe.c +191 -0
- data/ext/src/third-party/zlib-1.2.3/examples/zran.c +404 -0
- data/ext/src/third-party/zlib-1.2.3/gzio.c +1026 -0
- data/ext/src/third-party/zlib-1.2.3/infback.c +623 -0
- data/ext/src/third-party/zlib-1.2.3/inffast.c +318 -0
- data/ext/src/third-party/zlib-1.2.3/inffast.h +11 -0
- data/ext/src/third-party/zlib-1.2.3/inffixed.h +94 -0
- data/ext/src/third-party/zlib-1.2.3/inflate.c +1368 -0
- data/ext/src/third-party/zlib-1.2.3/inflate.h +115 -0
- data/ext/src/third-party/zlib-1.2.3/inftrees.c +329 -0
- data/ext/src/third-party/zlib-1.2.3/inftrees.h +55 -0
- data/ext/src/third-party/zlib-1.2.3/make_vms.com +461 -0
- data/ext/src/third-party/zlib-1.2.3/minigzip.c +322 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.bor +109 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.dj2 +104 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.emx +69 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.msc +106 -0
- data/ext/src/third-party/zlib-1.2.3/msdos/Makefile.tc +94 -0
- data/ext/src/third-party/zlib-1.2.3/old/Makefile.riscos +151 -0
- data/ext/src/third-party/zlib-1.2.3/old/README +3 -0
- data/ext/src/third-party/zlib-1.2.3/old/descrip.mms +48 -0
- data/ext/src/third-party/zlib-1.2.3/old/os2/Makefile.os2 +136 -0
- data/ext/src/third-party/zlib-1.2.3/old/os2/zlib.def +51 -0
- data/ext/src/third-party/zlib-1.2.3/old/visual-basic.txt +160 -0
- data/ext/src/third-party/zlib-1.2.3/old/zlib.html +971 -0
- data/ext/src/third-party/zlib-1.2.3/projects/README.projects +41 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/README.txt +73 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/example.dsp +278 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/minigzip.dsp +278 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/zlib.dsp +609 -0
- data/ext/src/third-party/zlib-1.2.3/projects/visualc6/zlib.dsw +59 -0
- data/ext/src/third-party/zlib-1.2.3/qnx/package.qpg +141 -0
- data/ext/src/third-party/zlib-1.2.3/trees.c +1219 -0
- data/ext/src/third-party/zlib-1.2.3/trees.h +128 -0
- data/ext/src/third-party/zlib-1.2.3/uncompr.c +61 -0
- data/ext/src/third-party/zlib-1.2.3/win32/DLL_FAQ.txt +397 -0
- data/ext/src/third-party/zlib-1.2.3/win32/Makefile.bor +107 -0
- data/ext/src/third-party/zlib-1.2.3/win32/Makefile.emx +69 -0
- data/ext/src/third-party/zlib-1.2.3/win32/Makefile.gcc +141 -0
- data/ext/src/third-party/zlib-1.2.3/win32/Makefile.msc +126 -0
- data/ext/src/third-party/zlib-1.2.3/win32/VisualC.txt +3 -0
- data/ext/src/third-party/zlib-1.2.3/win32/zlib.def +60 -0
- data/ext/src/third-party/zlib-1.2.3/win32/zlib1.rc +39 -0
- data/ext/src/third-party/zlib-1.2.3/zconf.h +332 -0
- data/ext/src/third-party/zlib-1.2.3/zconf.in.h +332 -0
- data/ext/src/third-party/zlib-1.2.3/zlib.3 +159 -0
- data/ext/src/third-party/zlib-1.2.3/zlib.h +1357 -0
- data/ext/src/third-party/zlib-1.2.3/zutil.c +318 -0
- data/ext/src/third-party/zlib-1.2.3/zutil.h +269 -0
- data/lib/bio-velvet_underground.rb +12 -0
- data/lib/bio-velvet_underground/external/VERSION +1 -0
- data/lib/bio-velvet_underground/velvet_underground.rb +72 -0
- data/spec/binary_sequence_store_spec.rb +27 -0
- data/spec/data/1/CnyUnifiedSeq +0 -0
- data/spec/spec_helper.rb +31 -0
- metadata +456 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
/*
|
2
|
+
Copyright 2007, 2008 Daniel Zerbino (zerbino@ebi.ac.uk)
|
3
|
+
|
4
|
+
This file is part of Velvet.
|
5
|
+
|
6
|
+
Velvet is free software; you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU General Public License as published by
|
8
|
+
the Free Software Foundation; either version 2 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
Velvet is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with Velvet; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
|
20
|
+
*/
|
21
|
+
#ifndef _CONCATENATEDPREGRAPH_H_
|
22
|
+
#define _CONCATENATEDPREGRAPH_H_
|
23
|
+
|
24
|
+
// Concatenates all pairs of nodes which form a linear structure
|
25
|
+
void concatenatePreGraph_pg(PreGraph * preGraph);
|
26
|
+
|
27
|
+
void clipTips_pg(PreGraph * preGraph);
|
28
|
+
|
29
|
+
#endif
|
@@ -0,0 +1,2642 @@
|
|
1
|
+
/*
|
2
|
+
Copyright 2007, 2008 Daniel Zerbino (zerbino@ebi.ac.uk)
|
3
|
+
|
4
|
+
This file is part of Velvet.
|
5
|
+
|
6
|
+
Velvet is free software; you can redistribute it and/or modify
|
7
|
+
it under the terms of the GNU General Public License as published by
|
8
|
+
the Free Software Foundation; either version 2 of the License, or
|
9
|
+
(at your option) any later version.
|
10
|
+
|
11
|
+
Velvet is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with Velvet; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
|
20
|
+
*/
|
21
|
+
#include <stdlib.h>
|
22
|
+
#include <stdio.h>
|
23
|
+
#include <time.h>
|
24
|
+
|
25
|
+
#include "globals.h"
|
26
|
+
#include "graph.h"
|
27
|
+
#include "tightString.h"
|
28
|
+
#include "dfibHeap.h"
|
29
|
+
#include "fibHeap.h"
|
30
|
+
#include "recycleBin.h"
|
31
|
+
#include "passageMarker.h"
|
32
|
+
#include "concatenatedGraph.h"
|
33
|
+
#include "graphStats.h"
|
34
|
+
#include "utility.h"
|
35
|
+
|
36
|
+
#define TICKET_BLOCK_SIZE 10000
|
37
|
+
|
38
|
+
static const Time INDEL = 0;
|
39
|
+
static const Time SIM[4][4] = {
|
40
|
+
{1, 0, 0, 0},
|
41
|
+
{0, 1, 0, 0},
|
42
|
+
{0, 0, 1, 0},
|
43
|
+
{0, 0, 0, 1}
|
44
|
+
};
|
45
|
+
|
46
|
+
typedef struct tkt_st Ticket;
|
47
|
+
|
48
|
+
struct tkt_st {
|
49
|
+
Ticket *next;
|
50
|
+
IDnum id_a;
|
51
|
+
} ATTRIBUTE_PACKED;
|
52
|
+
|
53
|
+
//Global variables used throughout this procedure(internal use only !)
|
54
|
+
static int MAXREADLENGTH = 100;
|
55
|
+
static int MAXNODELENGTH = 200;
|
56
|
+
static double MAXDIVERGENCE = 0.2;
|
57
|
+
static int MAXGAPS = 3;
|
58
|
+
|
59
|
+
static Time *times;
|
60
|
+
static Node **previous;
|
61
|
+
|
62
|
+
static DFibHeapNode **dheapNodes;
|
63
|
+
static DFibHeap *dheap;
|
64
|
+
|
65
|
+
static TightString *fastSequence;
|
66
|
+
static TightString *slowSequence;
|
67
|
+
|
68
|
+
static Node *activeNode;
|
69
|
+
static Node *startingNode;
|
70
|
+
static int WORDLENGTH;
|
71
|
+
static Graph *graph;
|
72
|
+
static IDnum dbgCounter;
|
73
|
+
|
74
|
+
static PassageMarkerI fastPath;
|
75
|
+
static PassageMarkerI slowPath;
|
76
|
+
|
77
|
+
static IDnum *eligibleStartingPoints;
|
78
|
+
|
79
|
+
static double **Fmatrix;
|
80
|
+
static Coordinate *slowToFastMapping;
|
81
|
+
static Coordinate *fastToSlowMapping;
|
82
|
+
|
83
|
+
static RecycleBin *ticketMemory;
|
84
|
+
|
85
|
+
static Ticket **todoLists;
|
86
|
+
static Ticket **todo;
|
87
|
+
static Ticket *done;
|
88
|
+
static boolean *progressStatus;
|
89
|
+
|
90
|
+
static ShortLength *sequenceLengths;
|
91
|
+
static Category *sequenceCategories;
|
92
|
+
|
93
|
+
//End of global variables;
|
94
|
+
|
95
|
+
static void setNodeTime(Node * node, Time time)
|
96
|
+
{
|
97
|
+
times[getNodeID(node) + nodeCount(graph)] = time;
|
98
|
+
}
|
99
|
+
|
100
|
+
static Time getNodeTime(Node * node)
|
101
|
+
{
|
102
|
+
return times[getNodeID(node) + nodeCount(graph)];
|
103
|
+
}
|
104
|
+
|
105
|
+
static void setNodePrevious(Node * previousNode, Node * node)
|
106
|
+
{
|
107
|
+
previous[getNodeID(node) + nodeCount(graph)] = previousNode;
|
108
|
+
}
|
109
|
+
|
110
|
+
static Node *getNodePrevious(Node * node)
|
111
|
+
{
|
112
|
+
return previous[getNodeID(node) + nodeCount(graph)];
|
113
|
+
}
|
114
|
+
|
115
|
+
static void setNodeDHeapNode(Node * node, DFibHeapNode * dheapNode)
|
116
|
+
{
|
117
|
+
dheapNodes[getNodeID(node) + nodeCount(graph)] = dheapNode;
|
118
|
+
}
|
119
|
+
|
120
|
+
static DFibHeapNode *getNodeDHeapNode(Node * node)
|
121
|
+
{
|
122
|
+
return dheapNodes[getNodeID(node) + nodeCount(graph)];
|
123
|
+
}
|
124
|
+
|
125
|
+
static Ticket *newTicket()
|
126
|
+
{
|
127
|
+
if (ticketMemory == NULL)
|
128
|
+
ticketMemory =
|
129
|
+
newRecycleBin(sizeof(Ticket), TICKET_BLOCK_SIZE);
|
130
|
+
|
131
|
+
return allocatePointer(ticketMemory);
|
132
|
+
}
|
133
|
+
|
134
|
+
static boolean isPreviousToNode(Node * previous, Node * target)
|
135
|
+
{
|
136
|
+
Node *currentNode = target;
|
137
|
+
Node *previousNode = NULL;
|
138
|
+
Time targetTime = getNodeTime(target);
|
139
|
+
|
140
|
+
//velvetLog("Testing if %ld is previous to %ld\n", getNodeID(previous), getNodeID(target));
|
141
|
+
|
142
|
+
while (true) {
|
143
|
+
if (currentNode == previous)
|
144
|
+
return true;
|
145
|
+
|
146
|
+
if (currentNode == previousNode)
|
147
|
+
return false;
|
148
|
+
|
149
|
+
if (getNodeTime(currentNode) != targetTime)
|
150
|
+
return false;
|
151
|
+
|
152
|
+
previousNode = currentNode;
|
153
|
+
currentNode = getNodePrevious(currentNode);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
static void concatenateCommonTodoLists(Node * nodeA, Node * nodeB)
|
158
|
+
{
|
159
|
+
Ticket **listA = &todoLists[getNodeID(nodeA) + nodeCount(graph)];
|
160
|
+
Ticket **listB = &todoLists[getNodeID(nodeB) + nodeCount(graph)];
|
161
|
+
Ticket *head = NULL;
|
162
|
+
Ticket *tail = NULL;
|
163
|
+
Ticket *tmp;
|
164
|
+
IDnum idA, idB;
|
165
|
+
IDnum targetID = getNodeID(nodeA);
|
166
|
+
IDnum indexA, indexB;
|
167
|
+
IDnum nodes = nodeCount(graph);
|
168
|
+
|
169
|
+
//velvetLog("Merging todo list %ld into %ld\n", getNodeID(nodeB),
|
170
|
+
// getNodeID(nodeA));
|
171
|
+
|
172
|
+
if (*listB == NULL)
|
173
|
+
return;
|
174
|
+
|
175
|
+
if (*listA == NULL) {
|
176
|
+
*listA = *listB;
|
177
|
+
*listB = NULL;
|
178
|
+
return;
|
179
|
+
}
|
180
|
+
|
181
|
+
while (*listA != NULL && *listB != NULL) {
|
182
|
+
idA = (*listA)->id_a;
|
183
|
+
idB = (*listB)->id_a;
|
184
|
+
indexA = idA + nodes;
|
185
|
+
indexB = idB + nodes;
|
186
|
+
|
187
|
+
if (previous[indexA] == nodeA) {
|
188
|
+
tmp = *listA;
|
189
|
+
*listA = (*listA)->next;
|
190
|
+
deallocatePointer(ticketMemory, tmp);
|
191
|
+
continue;
|
192
|
+
}
|
193
|
+
|
194
|
+
if (idB == targetID || previous[indexB] == nodeA) {
|
195
|
+
tmp = *listB;
|
196
|
+
*listB = (*listB)->next;
|
197
|
+
deallocatePointer(ticketMemory, tmp);
|
198
|
+
continue;
|
199
|
+
}
|
200
|
+
|
201
|
+
if (idA > idB) {
|
202
|
+
tmp = *listB;
|
203
|
+
*listB = (*listB)->next;
|
204
|
+
} else if (idA < idB) {
|
205
|
+
tmp = *listA;
|
206
|
+
*listA = (*listA)->next;
|
207
|
+
} else {
|
208
|
+
tmp = *listB;
|
209
|
+
*listB = (*listB)->next;
|
210
|
+
deallocatePointer(ticketMemory, tmp);
|
211
|
+
|
212
|
+
tmp = *listA;
|
213
|
+
*listA = (*listA)->next;
|
214
|
+
}
|
215
|
+
|
216
|
+
if (tail == NULL) {
|
217
|
+
tail = tmp;
|
218
|
+
head = tail;
|
219
|
+
} else {
|
220
|
+
tail->next = tmp;
|
221
|
+
tail = tail->next;
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
while (*listA != NULL) {
|
226
|
+
idA = (*listA)->id_a;
|
227
|
+
indexA = idA + nodes;
|
228
|
+
|
229
|
+
if (previous[indexA] == nodeA) {
|
230
|
+
tmp = *listA;
|
231
|
+
*listA = (*listA)->next;
|
232
|
+
deallocatePointer(ticketMemory, tmp);
|
233
|
+
} else if (tail != NULL) {
|
234
|
+
tail->next = *listA;
|
235
|
+
*listA = (*listA)->next;
|
236
|
+
tail = tail->next;
|
237
|
+
} else {
|
238
|
+
head = *listA;
|
239
|
+
*listA = (*listA)->next;
|
240
|
+
tail = head;
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
while (*listB != NULL) {
|
245
|
+
idB = (*listB)->id_a;
|
246
|
+
indexB = idB + nodes;
|
247
|
+
|
248
|
+
if (idB == targetID || previous[indexB] == nodeA) {
|
249
|
+
tmp = *listB;
|
250
|
+
*listB = (*listB)->next;
|
251
|
+
deallocatePointer(ticketMemory, tmp);
|
252
|
+
} else if (tail != NULL) {
|
253
|
+
tail->next = *listB;
|
254
|
+
*listB = (*listB)->next;
|
255
|
+
tail = tail->next;
|
256
|
+
} else {
|
257
|
+
head = *listB;
|
258
|
+
*listB = (*listB)->next;
|
259
|
+
tail = head;
|
260
|
+
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
if (tail != NULL)
|
265
|
+
tail->next = NULL;
|
266
|
+
|
267
|
+
*listA = head;
|
268
|
+
*listB = NULL;
|
269
|
+
}
|
270
|
+
|
271
|
+
static void concatenateTodoListIntoActive(Node * nodeB)
|
272
|
+
{
|
273
|
+
Ticket **listB = &todoLists[getNodeID(nodeB) + nodeCount(graph)];
|
274
|
+
Ticket *head = NULL;
|
275
|
+
Ticket *tail = NULL;
|
276
|
+
Ticket *tmp;
|
277
|
+
IDnum nodes = nodeCount(graph);
|
278
|
+
IDnum idA, idB;
|
279
|
+
IDnum activeID = getNodeID(activeNode);
|
280
|
+
IDnum indexB, indexA;
|
281
|
+
|
282
|
+
//velvetLog("Merging todo list %ld into active node %ld\n",
|
283
|
+
// getNodeID(nodeB), getNodeID(activeNode));
|
284
|
+
|
285
|
+
if (*listB == NULL)
|
286
|
+
return;
|
287
|
+
|
288
|
+
if (*todo == NULL) {
|
289
|
+
*todo = *listB;
|
290
|
+
*listB = NULL;
|
291
|
+
return;
|
292
|
+
}
|
293
|
+
|
294
|
+
while (*todo != NULL && *listB != NULL) {
|
295
|
+
idA = (*todo)->id_a;
|
296
|
+
idB = (*listB)->id_a;
|
297
|
+
indexA = idA + nodes;
|
298
|
+
indexB = idB + nodes;
|
299
|
+
|
300
|
+
if (previous[indexA] == activeNode
|
301
|
+
|| progressStatus[indexA]) {
|
302
|
+
tmp = *todo;
|
303
|
+
*todo = (*todo)->next;
|
304
|
+
deallocatePointer(ticketMemory, tmp);
|
305
|
+
continue;
|
306
|
+
}
|
307
|
+
|
308
|
+
if (idB == activeID || previous[indexB] == activeNode
|
309
|
+
|| progressStatus[indexB]) {
|
310
|
+
tmp = *listB;
|
311
|
+
*listB = (*listB)->next;
|
312
|
+
deallocatePointer(ticketMemory, tmp);
|
313
|
+
continue;
|
314
|
+
}
|
315
|
+
|
316
|
+
if (idA > idB) {
|
317
|
+
tmp = *listB;
|
318
|
+
*listB = (*listB)->next;
|
319
|
+
} else if (idA < idB) {
|
320
|
+
tmp = *todo;
|
321
|
+
*todo = (*todo)->next;
|
322
|
+
} else {
|
323
|
+
tmp = *listB;
|
324
|
+
*listB = (*listB)->next;
|
325
|
+
deallocatePointer(ticketMemory, tmp);
|
326
|
+
|
327
|
+
tmp = *todo;
|
328
|
+
*todo = (*todo)->next;
|
329
|
+
}
|
330
|
+
|
331
|
+
if (tail == NULL) {
|
332
|
+
tail = tmp;
|
333
|
+
head = tail;
|
334
|
+
} else {
|
335
|
+
tail->next = tmp;
|
336
|
+
tail = tmp;
|
337
|
+
}
|
338
|
+
}
|
339
|
+
|
340
|
+
while (*todo != NULL) {
|
341
|
+
idA = (*todo)->id_a;
|
342
|
+
indexA = idA + nodes;
|
343
|
+
|
344
|
+
if (previous[indexA] == activeNode
|
345
|
+
|| progressStatus[indexA]) {
|
346
|
+
tmp = *todo;
|
347
|
+
*todo = (*todo)->next;
|
348
|
+
deallocatePointer(ticketMemory, tmp);
|
349
|
+
} else if (tail != NULL) {
|
350
|
+
tail->next = *todo;
|
351
|
+
*todo = (*todo)->next;
|
352
|
+
tail = tail->next;
|
353
|
+
} else {
|
354
|
+
head = *todo;
|
355
|
+
*todo = (*todo)->next;
|
356
|
+
tail = head;
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
while (*listB != NULL) {
|
361
|
+
idB = (*listB)->id_a;
|
362
|
+
indexB = idB + nodes;
|
363
|
+
|
364
|
+
if (idB == activeID || previous[indexB] == activeNode
|
365
|
+
|| progressStatus[indexB]) {
|
366
|
+
tmp = *listB;
|
367
|
+
*listB = (*listB)->next;
|
368
|
+
deallocatePointer(ticketMemory, tmp);
|
369
|
+
} else if (tail != NULL) {
|
370
|
+
tail->next = *listB;
|
371
|
+
*listB = (*listB)->next;
|
372
|
+
tail = tail->next;
|
373
|
+
} else {
|
374
|
+
head = *listB;
|
375
|
+
*listB = (*listB)->next;
|
376
|
+
tail = head;
|
377
|
+
|
378
|
+
}
|
379
|
+
}
|
380
|
+
|
381
|
+
if (tail != NULL)
|
382
|
+
tail->next = NULL;
|
383
|
+
*todo = head;
|
384
|
+
*listB = NULL;
|
385
|
+
}
|
386
|
+
|
387
|
+
static void concatenateTodoLists(Node * nodeA, Node * nodeB)
|
388
|
+
{
|
389
|
+
if (nodeA == activeNode)
|
390
|
+
concatenateTodoListIntoActive(nodeB);
|
391
|
+
else
|
392
|
+
concatenateCommonTodoLists(nodeA, nodeB);
|
393
|
+
}
|
394
|
+
|
395
|
+
static IDnum nextTodoTicket()
|
396
|
+
{
|
397
|
+
Ticket *tkt;
|
398
|
+
IDnum index;
|
399
|
+
|
400
|
+
while (*todo != NULL) {
|
401
|
+
tkt = *todo;
|
402
|
+
*todo = tkt->next;
|
403
|
+
|
404
|
+
index = tkt->id_a + nodeCount(graph);
|
405
|
+
|
406
|
+
if (previous[index] == activeNode) {
|
407
|
+
deallocatePointer(ticketMemory, tkt);
|
408
|
+
continue;
|
409
|
+
}
|
410
|
+
|
411
|
+
progressStatus[index] = true;
|
412
|
+
|
413
|
+
tkt->next = done;
|
414
|
+
done = tkt;
|
415
|
+
|
416
|
+
return tkt->id_a;
|
417
|
+
}
|
418
|
+
|
419
|
+
return 0;
|
420
|
+
}
|
421
|
+
|
422
|
+
static void freeDoneTickets()
|
423
|
+
{
|
424
|
+
Ticket *tkt;
|
425
|
+
IDnum nodes = nodeCount(graph);
|
426
|
+
|
427
|
+
while (done != NULL) {
|
428
|
+
tkt = done;
|
429
|
+
done = tkt->next;
|
430
|
+
progressStatus[tkt->id_a + nodes] = false;
|
431
|
+
deallocatePointer(ticketMemory, tkt);
|
432
|
+
}
|
433
|
+
}
|
434
|
+
|
435
|
+
static void updateNodeStatus(Node * node)
|
436
|
+
{
|
437
|
+
FibHeap *heap = newFibHeap();
|
438
|
+
Arc *arc;
|
439
|
+
Node *currentNode = node;
|
440
|
+
Node *destination;
|
441
|
+
|
442
|
+
setNodeStatus(currentNode, true);
|
443
|
+
|
444
|
+
while (currentNode != NULL) {
|
445
|
+
for (arc = getArc(currentNode); arc != NULL;
|
446
|
+
arc = getNextArc(arc)) {
|
447
|
+
destination = getDestination(arc);
|
448
|
+
if (getNodeStatus(destination) > 1) {
|
449
|
+
setNodeStatus(destination, true);
|
450
|
+
insertNodeIntoHeap(heap,
|
451
|
+
getNodeID(destination),
|
452
|
+
destination);
|
453
|
+
}
|
454
|
+
}
|
455
|
+
|
456
|
+
currentNode = removeNextNodeFromHeap(heap);
|
457
|
+
}
|
458
|
+
|
459
|
+
destroyHeap(heap);
|
460
|
+
}
|
461
|
+
|
462
|
+
static void determineEligibleStartingPoints()
|
463
|
+
{
|
464
|
+
IDnum nodeIndex;
|
465
|
+
IDnum maxmult;
|
466
|
+
Node *node;
|
467
|
+
Arc *arc;
|
468
|
+
IDnum counter = 0;
|
469
|
+
FibHeap *heap = newFibHeap();
|
470
|
+
|
471
|
+
velvetLog("Determining eligible starting points\n");
|
472
|
+
|
473
|
+
for (nodeIndex = 1; nodeIndex <= nodeCount(graph); nodeIndex++) {
|
474
|
+
node = getNodeInGraph(graph, nodeIndex);
|
475
|
+
if (node == NULL)
|
476
|
+
continue;
|
477
|
+
|
478
|
+
maxmult = 0;
|
479
|
+
for (arc = getArc(node); arc != NULL;
|
480
|
+
arc = getNextArc(arc))
|
481
|
+
if (getMultiplicity(arc) > maxmult)
|
482
|
+
maxmult = getMultiplicity(arc);
|
483
|
+
|
484
|
+
insertNodeIntoHeap(heap, -maxmult, node);
|
485
|
+
|
486
|
+
// Same for twin node
|
487
|
+
node = getNodeInGraph(graph, -nodeIndex);
|
488
|
+
maxmult = 0;
|
489
|
+
for (arc = getArc(node); arc != NULL;
|
490
|
+
arc = getNextArc(arc))
|
491
|
+
if (getMultiplicity(arc) > maxmult)
|
492
|
+
maxmult = getMultiplicity(arc);
|
493
|
+
|
494
|
+
insertNodeIntoHeap(heap, -maxmult, node);
|
495
|
+
}
|
496
|
+
|
497
|
+
while ((node = removeNextNodeFromHeap(heap)) != NULL)
|
498
|
+
eligibleStartingPoints[counter++] = getNodeID(node);
|
499
|
+
|
500
|
+
destroyHeap(heap);
|
501
|
+
velvetLog("Done listing starting nodes\n");
|
502
|
+
}
|
503
|
+
|
504
|
+
static Node *nextStartingPoint()
|
505
|
+
{
|
506
|
+
static IDnum counter = 0;
|
507
|
+
Node *result = NULL;
|
508
|
+
|
509
|
+
while (result == NULL || getNodeStatus(result) > 0) {
|
510
|
+
if (counter >= nodeCount(graph) * 2)
|
511
|
+
return NULL;
|
512
|
+
|
513
|
+
result =
|
514
|
+
getNodeInGraph(graph,
|
515
|
+
eligibleStartingPoints[counter++]);
|
516
|
+
}
|
517
|
+
|
518
|
+
return result;
|
519
|
+
}
|
520
|
+
|
521
|
+
static boolean
|
522
|
+
extractSequence(PassageMarkerI path, TightString * sequence)
|
523
|
+
{
|
524
|
+
PassageMarkerI marker;
|
525
|
+
Coordinate seqLength = 0;
|
526
|
+
Coordinate writeIndex = 0;
|
527
|
+
|
528
|
+
//velvetLog("Extracting sequence %ld ... ", pathLength);
|
529
|
+
|
530
|
+
//Measure length
|
531
|
+
for (marker = getNextInSequence(path); !isTerminal(marker);
|
532
|
+
marker = getNextInSequence(marker))
|
533
|
+
seqLength += getNodeLength(getNode(marker));
|
534
|
+
|
535
|
+
if (seqLength > MAXREADLENGTH)
|
536
|
+
return false;
|
537
|
+
else
|
538
|
+
setTightStringLength(sequence, seqLength);
|
539
|
+
|
540
|
+
//Copy sequences
|
541
|
+
for (marker = getNextInSequence(path); !isTerminal(marker);
|
542
|
+
marker = getNextInSequence(marker)) {
|
543
|
+
appendNodeSequence(getNode(marker), sequence, writeIndex);
|
544
|
+
writeIndex += getNodeLength(getNode(marker));
|
545
|
+
}
|
546
|
+
|
547
|
+
return true;
|
548
|
+
}
|
549
|
+
|
550
|
+
static Time max(Time A, Time B, Time C)
|
551
|
+
{
|
552
|
+
if (A >= B && A >= C)
|
553
|
+
return A;
|
554
|
+
else if (B >= C)
|
555
|
+
return B;
|
556
|
+
else
|
557
|
+
return C;
|
558
|
+
}
|
559
|
+
|
560
|
+
static boolean
|
561
|
+
compareSequences(TightString * sequence1, TightString * sequence2)
|
562
|
+
{
|
563
|
+
Coordinate i, j;
|
564
|
+
Coordinate length1 = getLength(sequence1);
|
565
|
+
Coordinate length2 = getLength(sequence2);
|
566
|
+
Coordinate maxLength;
|
567
|
+
Time Choice1, Choice2, Choice3;
|
568
|
+
Time maxScore;
|
569
|
+
|
570
|
+
if (length1 == 0 || length2 == 0)
|
571
|
+
return false;
|
572
|
+
|
573
|
+
maxLength = (length1 > length2 ? length1 : length2);
|
574
|
+
|
575
|
+
if (length1 < WORDLENGTH || length2 < WORDLENGTH) {
|
576
|
+
if (maxLength - length1 > MAXGAPS
|
577
|
+
|| maxLength - length2 > MAXGAPS)
|
578
|
+
return false;
|
579
|
+
if (WORDLENGTH - length1 > MAXGAPS
|
580
|
+
|| WORDLENGTH - length2 > MAXGAPS)
|
581
|
+
return false;
|
582
|
+
}
|
583
|
+
|
584
|
+
for (i = 0; i <= length1; i++)
|
585
|
+
Fmatrix[i][0] = 0;
|
586
|
+
for (j = 0; j <= length2; j++)
|
587
|
+
Fmatrix[0][j] = 0;
|
588
|
+
|
589
|
+
for (i = 1; i <= length1; i++) {
|
590
|
+
for (j = 1; j <= length2; j++) {
|
591
|
+
Choice1 =
|
592
|
+
Fmatrix[i - 1][j - 1] +
|
593
|
+
SIM[(int) getNucleotide(i - 1, sequence1)]
|
594
|
+
[(int) getNucleotide(j - 1, sequence2)];
|
595
|
+
Choice2 = Fmatrix[i - 1][j] + INDEL;
|
596
|
+
Choice3 = Fmatrix[i][j - 1] + INDEL;
|
597
|
+
Fmatrix[i][j] = max(Choice1, Choice2, Choice3);
|
598
|
+
}
|
599
|
+
}
|
600
|
+
|
601
|
+
maxScore = Fmatrix[length1][length2];
|
602
|
+
|
603
|
+
if (maxScore < maxLength - MAXGAPS)
|
604
|
+
return false;
|
605
|
+
|
606
|
+
if ((1 - maxScore / maxLength) > MAXDIVERGENCE)
|
607
|
+
return false;
|
608
|
+
|
609
|
+
return true;
|
610
|
+
}
|
611
|
+
|
612
|
+
static void mapSlowOntoFast()
|
613
|
+
{
|
614
|
+
Coordinate slowIndex = getLength(slowSequence);
|
615
|
+
Coordinate fastIndex = getLength(fastSequence);
|
616
|
+
int fastn, slown;
|
617
|
+
|
618
|
+
if (slowIndex == 0) {
|
619
|
+
slowToFastMapping[0] = fastIndex;
|
620
|
+
|
621
|
+
while (fastIndex >= 0)
|
622
|
+
fastToSlowMapping[fastIndex--] = 0;
|
623
|
+
|
624
|
+
return;
|
625
|
+
}
|
626
|
+
|
627
|
+
if (fastIndex == 0) {
|
628
|
+
while (slowIndex >= 0)
|
629
|
+
slowToFastMapping[slowIndex--] = 0;
|
630
|
+
|
631
|
+
fastToSlowMapping[0] = slowIndex;
|
632
|
+
|
633
|
+
return;
|
634
|
+
}
|
635
|
+
|
636
|
+
while (slowIndex > 0 && fastIndex > 0) {
|
637
|
+
fastn = (int) getNucleotide(fastIndex - 1, fastSequence);
|
638
|
+
slown = (int) getNucleotide(slowIndex - 1, slowSequence);
|
639
|
+
|
640
|
+
if (Fmatrix[fastIndex][slowIndex] ==
|
641
|
+
Fmatrix[fastIndex - 1][slowIndex - 1] +
|
642
|
+
SIM[fastn][slown]) {
|
643
|
+
fastToSlowMapping[--fastIndex] = --slowIndex;
|
644
|
+
slowToFastMapping[slowIndex] = fastIndex;
|
645
|
+
} else if (Fmatrix[fastIndex][slowIndex] ==
|
646
|
+
Fmatrix[fastIndex - 1][slowIndex] + INDEL)
|
647
|
+
fastToSlowMapping[--fastIndex] = slowIndex - 1;
|
648
|
+
|
649
|
+
else if (Fmatrix[fastIndex][slowIndex] ==
|
650
|
+
Fmatrix[fastIndex][slowIndex - 1] + INDEL)
|
651
|
+
slowToFastMapping[--slowIndex] = fastIndex - 1;
|
652
|
+
|
653
|
+
else {
|
654
|
+
velvetLog("Error\n");
|
655
|
+
fflush(stdout);
|
656
|
+
abort();
|
657
|
+
}
|
658
|
+
}
|
659
|
+
|
660
|
+
while (slowIndex > 0)
|
661
|
+
slowToFastMapping[--slowIndex] = -1;
|
662
|
+
while (fastIndex > 0)
|
663
|
+
fastToSlowMapping[--fastIndex] = -1;
|
664
|
+
|
665
|
+
slowToFastMapping[getLength(slowSequence)] =
|
666
|
+
getLength(fastSequence);
|
667
|
+
fastToSlowMapping[getLength(fastSequence)] =
|
668
|
+
getLength(slowSequence);
|
669
|
+
}
|
670
|
+
|
671
|
+
static void remapNodeArcsOntoTarget(Node * source, Node * target)
|
672
|
+
{
|
673
|
+
Arc *arc;
|
674
|
+
|
675
|
+
if (source == activeNode) {
|
676
|
+
activeNode = target;
|
677
|
+
todo =
|
678
|
+
&todoLists[getNodeID(activeNode) + nodeCount(graph)];
|
679
|
+
}
|
680
|
+
concatenateTodoLists(target, source);
|
681
|
+
|
682
|
+
arc = getArc(source);
|
683
|
+
while (arc != NULL) {
|
684
|
+
createAnalogousArc(target, getDestination(arc), arc, graph);
|
685
|
+
destroyArc(arc, graph);
|
686
|
+
arc = getArc(source);
|
687
|
+
}
|
688
|
+
}
|
689
|
+
|
690
|
+
static void remapNodeArcsOntoNeighbour(Node * source, Node * target)
|
691
|
+
{
|
692
|
+
remapNodeArcsOntoTarget(source, target);
|
693
|
+
remapNodeArcsOntoTarget(getTwinNode(source), getTwinNode(target));
|
694
|
+
}
|
695
|
+
|
696
|
+
static void remapNodeMarkersOntoNeighbour(Node * source,
|
697
|
+
PassageMarkerI sourceMarker,
|
698
|
+
Node * target,
|
699
|
+
PassageMarkerI targetMarker)
|
700
|
+
{
|
701
|
+
PassageMarkerI marker;
|
702
|
+
Coordinate offset;
|
703
|
+
IDnum sourceLength, index;
|
704
|
+
ShortReadMarker *sourceArray, *shortMarker;
|
705
|
+
Coordinate position;
|
706
|
+
|
707
|
+
Coordinate targetStart = getPassageMarkerStart(targetMarker);
|
708
|
+
Coordinate targetFinish = getPassageMarkerFinish(targetMarker);
|
709
|
+
Coordinate sourceStart = getPassageMarkerStart(sourceMarker);
|
710
|
+
Coordinate sourceFinish = getPassageMarkerFinish(sourceMarker);
|
711
|
+
|
712
|
+
Coordinate alignedTargetLength = targetFinish - targetStart;
|
713
|
+
Coordinate alignedSourceLength = sourceFinish - sourceStart;
|
714
|
+
|
715
|
+
Coordinate realTargetLength = getNodeLength(target);
|
716
|
+
Coordinate realSourceLength = getNodeLength(source);
|
717
|
+
|
718
|
+
while (getMarker(source) != NULL_IDX) {
|
719
|
+
marker = getMarker(source);
|
720
|
+
extractPassageMarker(marker);
|
721
|
+
transposePassageMarker(marker, target);
|
722
|
+
|
723
|
+
if (realSourceLength != 0 && alignedTargetLength != 0) {
|
724
|
+
if (isInitial(marker)) {
|
725
|
+
offset = getStartOffset(marker);
|
726
|
+
offset *= alignedSourceLength;
|
727
|
+
offset /= realSourceLength;
|
728
|
+
offset += sourceStart;
|
729
|
+
offset = slowToFastMapping[offset];
|
730
|
+
offset -= targetStart;
|
731
|
+
offset *= realTargetLength;
|
732
|
+
offset /= alignedTargetLength;
|
733
|
+
|
734
|
+
if (offset < 0)
|
735
|
+
offset = 0;
|
736
|
+
if (offset > realTargetLength)
|
737
|
+
offset = realTargetLength;
|
738
|
+
} else
|
739
|
+
offset = 0;
|
740
|
+
|
741
|
+
setStartOffset(marker, offset);
|
742
|
+
|
743
|
+
if (isTerminal(marker)) {
|
744
|
+
offset = getFinishOffset(marker);
|
745
|
+
offset *= alignedSourceLength;
|
746
|
+
offset /= realSourceLength;
|
747
|
+
offset = sourceFinish - offset;
|
748
|
+
offset = slowToFastMapping[offset];
|
749
|
+
offset = targetFinish - offset;
|
750
|
+
offset *= realTargetLength;
|
751
|
+
offset /= alignedTargetLength;
|
752
|
+
|
753
|
+
if (offset < 0)
|
754
|
+
offset = 0;
|
755
|
+
if (offset > realTargetLength)
|
756
|
+
offset = realTargetLength;
|
757
|
+
} else
|
758
|
+
offset = 0;
|
759
|
+
|
760
|
+
setFinishOffset(marker, offset);
|
761
|
+
} else {
|
762
|
+
setStartOffset(marker, 0);
|
763
|
+
setFinishOffset(marker, 0);
|
764
|
+
}
|
765
|
+
}
|
766
|
+
|
767
|
+
// Short read markers
|
768
|
+
if (readStartsAreActivated(graph)) {
|
769
|
+
// Update Coordinates
|
770
|
+
sourceArray = getNodeReads(source, graph);
|
771
|
+
sourceLength = getNodeReadCount(source, graph);
|
772
|
+
|
773
|
+
for (index = 0; index < sourceLength; index++) {
|
774
|
+
shortMarker =
|
775
|
+
getShortReadMarkerAtIndex(sourceArray, index);
|
776
|
+
position = getShortReadMarkerPosition(shortMarker);
|
777
|
+
|
778
|
+
if (position > -1) {
|
779
|
+
if (realSourceLength > 0
|
780
|
+
&& alignedTargetLength > 0) {
|
781
|
+
position *= alignedSourceLength;
|
782
|
+
position /= realSourceLength;
|
783
|
+
position += sourceStart;
|
784
|
+
position =
|
785
|
+
slowToFastMapping[position];
|
786
|
+
position -= targetStart;
|
787
|
+
position *= realTargetLength;
|
788
|
+
position /= alignedTargetLength;
|
789
|
+
|
790
|
+
if (position < 0)
|
791
|
+
position = 0;
|
792
|
+
if (position > realTargetLength)
|
793
|
+
position =
|
794
|
+
realTargetLength;
|
795
|
+
} else
|
796
|
+
position = 0;
|
797
|
+
}
|
798
|
+
|
799
|
+
setShortReadMarkerPosition(shortMarker, position);
|
800
|
+
}
|
801
|
+
mergeNodeReads(target, source, graph);
|
802
|
+
|
803
|
+
// Same but for symmetrical reads
|
804
|
+
sourceArray = getNodeReads(getTwinNode(source), graph);
|
805
|
+
sourceLength =
|
806
|
+
getNodeReadCount(getTwinNode(source), graph);
|
807
|
+
|
808
|
+
for (index = 0; index < sourceLength; index++) {
|
809
|
+
shortMarker =
|
810
|
+
getShortReadMarkerAtIndex(sourceArray, index);
|
811
|
+
position = getShortReadMarkerPosition(shortMarker);
|
812
|
+
|
813
|
+
if (position > -1) {
|
814
|
+
if (realSourceLength > 0
|
815
|
+
&& alignedTargetLength > 0) {
|
816
|
+
position =
|
817
|
+
realSourceLength - position;
|
818
|
+
position *= alignedSourceLength;
|
819
|
+
position /= realSourceLength;
|
820
|
+
position += sourceStart;
|
821
|
+
position =
|
822
|
+
slowToFastMapping[position];
|
823
|
+
position -= targetStart;
|
824
|
+
position *= realTargetLength;
|
825
|
+
position /= alignedTargetLength;
|
826
|
+
position =
|
827
|
+
realTargetLength - position;
|
828
|
+
|
829
|
+
if (position < 0)
|
830
|
+
position = 0;
|
831
|
+
if (position > realTargetLength)
|
832
|
+
position =
|
833
|
+
realTargetLength;
|
834
|
+
} else
|
835
|
+
position = 0;
|
836
|
+
}
|
837
|
+
|
838
|
+
setShortReadMarkerPosition(shortMarker, position);
|
839
|
+
}
|
840
|
+
mergeNodeReads(getTwinNode(target), getTwinNode(source),
|
841
|
+
graph);
|
842
|
+
}
|
843
|
+
// Virtual reads
|
844
|
+
#ifndef SINGLE_COV_CAT
|
845
|
+
Category cat;
|
846
|
+
for (cat = 0; cat < CATEGORIES; cat++)
|
847
|
+
incrementVirtualCoverage(target, cat,
|
848
|
+
getVirtualCoverage(source, cat));
|
849
|
+
#else
|
850
|
+
incrementVirtualCoverage(target, getVirtualCoverage(source));
|
851
|
+
#endif
|
852
|
+
}
|
853
|
+
|
854
|
+
static void remapBackOfNodeArcsOntoNeighbour(Node * source, Node * target)
|
855
|
+
{
|
856
|
+
Arc *arc;
|
857
|
+
|
858
|
+
remapNodeArcsOntoTarget(getTwinNode(source), getTwinNode(target));
|
859
|
+
for (arc = getArc(source); arc != NULL; arc = getNextArc(arc))
|
860
|
+
createAnalogousArc(target, source, arc, graph);
|
861
|
+
|
862
|
+
}
|
863
|
+
|
864
|
+
static Coordinate
|
865
|
+
remapBackOfNodeMarkersOntoNeighbour(Node * source,
|
866
|
+
PassageMarkerI sourceMarker,
|
867
|
+
Node * target,
|
868
|
+
PassageMarkerI targetMarker,
|
869
|
+
boolean slowToFast)
|
870
|
+
{
|
871
|
+
PassageMarkerI marker, newMarker, previousMarker, nextMarker;
|
872
|
+
Coordinate halfwayPoint, halfwayPointOffset, breakpoint,
|
873
|
+
newStartOffset, newFinishOffset;
|
874
|
+
Coordinate *targetToSourceMapping, *sourceToTargetMapping;
|
875
|
+
ShortReadMarker *selectedShortReads, *shortRead;
|
876
|
+
IDnum selectedShortReadCount, shortReadIndex;
|
877
|
+
Coordinate position;
|
878
|
+
|
879
|
+
Coordinate targetStart = getPassageMarkerStart(targetMarker);
|
880
|
+
Coordinate targetFinish = getPassageMarkerFinish(targetMarker);
|
881
|
+
Coordinate sourceStart = getPassageMarkerStart(sourceMarker);
|
882
|
+
Coordinate sourceFinish = getPassageMarkerFinish(sourceMarker);
|
883
|
+
|
884
|
+
Coordinate alignedTargetLength = targetFinish - targetStart;
|
885
|
+
Coordinate alignedSourceLength = sourceFinish - sourceStart;
|
886
|
+
|
887
|
+
Coordinate realTargetLength = getNodeLength(target);
|
888
|
+
Coordinate realSourceLength = getNodeLength(source);
|
889
|
+
|
890
|
+
if (slowToFast) {
|
891
|
+
sourceToTargetMapping = slowToFastMapping;
|
892
|
+
targetToSourceMapping = fastToSlowMapping;
|
893
|
+
} else {
|
894
|
+
sourceToTargetMapping = fastToSlowMapping;
|
895
|
+
targetToSourceMapping = slowToFastMapping;
|
896
|
+
}
|
897
|
+
|
898
|
+
// Calculating source node breakpoint:
|
899
|
+
if (alignedSourceLength > 0 && targetFinish > 0) {
|
900
|
+
halfwayPoint =
|
901
|
+
targetToSourceMapping[targetFinish - 1] - sourceStart +
|
902
|
+
1;
|
903
|
+
halfwayPoint *= realSourceLength;
|
904
|
+
halfwayPoint /= alignedSourceLength;
|
905
|
+
} else
|
906
|
+
halfwayPoint = 0;
|
907
|
+
|
908
|
+
if (halfwayPoint < 0)
|
909
|
+
halfwayPoint = 0;
|
910
|
+
if (halfwayPoint > realSourceLength)
|
911
|
+
halfwayPoint = realSourceLength;
|
912
|
+
halfwayPointOffset = realSourceLength - halfwayPoint;
|
913
|
+
|
914
|
+
// Complete markers
|
915
|
+
for (marker = getMarker(source); marker != NULL_IDX;
|
916
|
+
marker = nextMarker) {
|
917
|
+
nextMarker = getNextInNode(marker);
|
918
|
+
|
919
|
+
// To avoid making loops...
|
920
|
+
if (getNode(getPreviousInSequence(marker)) == target)
|
921
|
+
continue;
|
922
|
+
|
923
|
+
// Markers which are downstream of the breakpoint
|
924
|
+
if (getStartOffset(marker) > halfwayPoint) {
|
925
|
+
newStartOffset =
|
926
|
+
getStartOffset(marker) - halfwayPoint;
|
927
|
+
setStartOffset(marker, newStartOffset);
|
928
|
+
continue;
|
929
|
+
}
|
930
|
+
// Markers which are upstream of the breakpoint
|
931
|
+
if (getFinishOffset(marker) > halfwayPointOffset) {
|
932
|
+
if (slowToFast) {
|
933
|
+
if (realSourceLength > 0
|
934
|
+
&& alignedTargetLength > 0) {
|
935
|
+
newFinishOffset =
|
936
|
+
getFinishOffset(marker) -
|
937
|
+
halfwayPointOffset;
|
938
|
+
newFinishOffset *=
|
939
|
+
alignedSourceLength;
|
940
|
+
newFinishOffset /=
|
941
|
+
realSourceLength;
|
942
|
+
newFinishOffset *=
|
943
|
+
realTargetLength;
|
944
|
+
newFinishOffset /=
|
945
|
+
alignedTargetLength;
|
946
|
+
if (newFinishOffset < 0)
|
947
|
+
newFinishOffset = 0;
|
948
|
+
else if (newFinishOffset >
|
949
|
+
realTargetLength)
|
950
|
+
newFinishOffset =
|
951
|
+
realTargetLength;
|
952
|
+
} else
|
953
|
+
newFinishOffset = 0;
|
954
|
+
} else {
|
955
|
+
newFinishOffset =
|
956
|
+
getFinishOffset(marker) -
|
957
|
+
halfwayPointOffset;
|
958
|
+
}
|
959
|
+
setFinishOffset(marker, newFinishOffset);
|
960
|
+
extractPassageMarker(marker);
|
961
|
+
transposePassageMarker(marker, target);
|
962
|
+
continue;
|
963
|
+
}
|
964
|
+
// Markers on both sides of the divide
|
965
|
+
newMarker =
|
966
|
+
addPassageMarker(getPassageMarkerSequenceID(marker),
|
967
|
+
getPassageMarkerStart(marker),
|
968
|
+
target);
|
969
|
+
|
970
|
+
setPassageMarkerStart(newMarker,
|
971
|
+
getPassageMarkerStart(marker));
|
972
|
+
setPassageMarkerStatus(newMarker,
|
973
|
+
getPassageMarkerStatus(marker));
|
974
|
+
|
975
|
+
if (realSourceLength - getStartOffset(marker) -
|
976
|
+
getFinishOffset(marker) > 0) {
|
977
|
+
breakpoint = halfwayPoint - getStartOffset(marker);
|
978
|
+
breakpoint *= getPassageMarkerLength(marker);
|
979
|
+
breakpoint /= realSourceLength -
|
980
|
+
getStartOffset(marker) -
|
981
|
+
getFinishOffset(marker);
|
982
|
+
if (breakpoint > getPassageMarkerLength(marker))
|
983
|
+
breakpoint = getPassageMarkerLength(marker);
|
984
|
+
breakpoint *= passageMarkerDirection(marker);
|
985
|
+
breakpoint += getPassageMarkerStart(marker);
|
986
|
+
} else {
|
987
|
+
breakpoint = getPassageMarkerStart(marker);
|
988
|
+
}
|
989
|
+
|
990
|
+
setPassageMarkerFinish(newMarker, breakpoint);
|
991
|
+
setPassageMarkerStart(marker, breakpoint);
|
992
|
+
|
993
|
+
if (slowToFast) {
|
994
|
+
if (realSourceLength != 0
|
995
|
+
&& alignedTargetLength != 0) {
|
996
|
+
newStartOffset = getStartOffset(marker);
|
997
|
+
newStartOffset *= alignedSourceLength;
|
998
|
+
newStartOffset /= realSourceLength;
|
999
|
+
newStartOffset *= realTargetLength;
|
1000
|
+
newStartOffset /= alignedTargetLength;
|
1001
|
+
if (newStartOffset < 0)
|
1002
|
+
newStartOffset = 0;
|
1003
|
+
else if (newStartOffset > realTargetLength)
|
1004
|
+
newStartOffset = realTargetLength;
|
1005
|
+
} else {
|
1006
|
+
newStartOffset = 0;
|
1007
|
+
}
|
1008
|
+
} else {
|
1009
|
+
newStartOffset = getStartOffset(marker);
|
1010
|
+
}
|
1011
|
+
|
1012
|
+
setStartOffset(newMarker, newStartOffset);
|
1013
|
+
setFinishOffset(newMarker, 0);
|
1014
|
+
setStartOffset(marker, 0);
|
1015
|
+
|
1016
|
+
previousMarker = getPreviousInSequence(marker);
|
1017
|
+
setNextInSequence(previousMarker, newMarker);
|
1018
|
+
setPreviousInSequence(previousMarker, newMarker);
|
1019
|
+
|
1020
|
+
setPreviousInSequence(newMarker, marker);
|
1021
|
+
setNextInSequence(newMarker, marker);
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
// Read starts
|
1025
|
+
if (readStartsAreActivated(graph)) {
|
1026
|
+
selectedShortReads =
|
1027
|
+
extractBackOfNodeReads(source, halfwayPoint, graph,
|
1028
|
+
&selectedShortReadCount,
|
1029
|
+
sourceMarker, sequenceLengths);
|
1030
|
+
if (slowToFast) {
|
1031
|
+
if (realSourceLength > 0
|
1032
|
+
&& alignedTargetLength > 0) {
|
1033
|
+
for (shortReadIndex = 0;
|
1034
|
+
shortReadIndex <
|
1035
|
+
selectedShortReadCount;
|
1036
|
+
shortReadIndex++) {
|
1037
|
+
shortRead =
|
1038
|
+
getShortReadMarkerAtIndex
|
1039
|
+
(selectedShortReads,
|
1040
|
+
shortReadIndex);
|
1041
|
+
position =
|
1042
|
+
getShortReadMarkerPosition
|
1043
|
+
(shortRead);
|
1044
|
+
if (position > -1) {
|
1045
|
+
position *=
|
1046
|
+
alignedSourceLength;
|
1047
|
+
position /=
|
1048
|
+
realSourceLength;
|
1049
|
+
position += sourceStart;
|
1050
|
+
position =
|
1051
|
+
sourceToTargetMapping
|
1052
|
+
[position];
|
1053
|
+
position -= targetStart;
|
1054
|
+
position *=
|
1055
|
+
realTargetLength;
|
1056
|
+
position /=
|
1057
|
+
alignedTargetLength;
|
1058
|
+
if (position < 0)
|
1059
|
+
position = 0;
|
1060
|
+
if (position >
|
1061
|
+
realTargetLength)
|
1062
|
+
position =
|
1063
|
+
realTargetLength;
|
1064
|
+
}
|
1065
|
+
setShortReadMarkerPosition
|
1066
|
+
(shortRead, position);
|
1067
|
+
}
|
1068
|
+
} else {
|
1069
|
+
for (shortReadIndex = 0;
|
1070
|
+
shortReadIndex <
|
1071
|
+
selectedShortReadCount;
|
1072
|
+
shortReadIndex++) {
|
1073
|
+
shortRead =
|
1074
|
+
getShortReadMarkerAtIndex
|
1075
|
+
(selectedShortReads,
|
1076
|
+
shortReadIndex);
|
1077
|
+
position =
|
1078
|
+
getShortReadMarkerPosition
|
1079
|
+
(shortRead);
|
1080
|
+
if (position > -1)
|
1081
|
+
setShortReadMarkerPosition
|
1082
|
+
(shortRead, 0);
|
1083
|
+
}
|
1084
|
+
|
1085
|
+
}
|
1086
|
+
}
|
1087
|
+
injectShortReads(selectedShortReads,
|
1088
|
+
selectedShortReadCount, target, graph);
|
1089
|
+
|
1090
|
+
selectedShortReads =
|
1091
|
+
extractFrontOfNodeReads(getTwinNode(source),
|
1092
|
+
halfwayPoint, graph,
|
1093
|
+
&selectedShortReadCount,
|
1094
|
+
sourceMarker, sequenceLengths);
|
1095
|
+
if (slowToFast) {
|
1096
|
+
if (realSourceLength > 0
|
1097
|
+
&& alignedTargetLength > 0) {
|
1098
|
+
for (shortReadIndex = 0;
|
1099
|
+
shortReadIndex <
|
1100
|
+
selectedShortReadCount;
|
1101
|
+
shortReadIndex++) {
|
1102
|
+
shortRead =
|
1103
|
+
getShortReadMarkerAtIndex
|
1104
|
+
(selectedShortReads,
|
1105
|
+
shortReadIndex);
|
1106
|
+
position =
|
1107
|
+
getShortReadMarkerPosition
|
1108
|
+
(shortRead);
|
1109
|
+
if (position > -1) {
|
1110
|
+
position =
|
1111
|
+
getShortReadMarkerPosition
|
1112
|
+
(shortRead);
|
1113
|
+
position =
|
1114
|
+
realSourceLength -
|
1115
|
+
position;
|
1116
|
+
position *=
|
1117
|
+
alignedSourceLength;
|
1118
|
+
position /=
|
1119
|
+
realSourceLength;
|
1120
|
+
position += sourceStart;
|
1121
|
+
position =
|
1122
|
+
sourceToTargetMapping
|
1123
|
+
[position];
|
1124
|
+
position -= targetStart;
|
1125
|
+
position *=
|
1126
|
+
realTargetLength;
|
1127
|
+
position /=
|
1128
|
+
alignedTargetLength;
|
1129
|
+
position =
|
1130
|
+
realTargetLength -
|
1131
|
+
position;
|
1132
|
+
if (position < 0)
|
1133
|
+
position = 0;
|
1134
|
+
if (position >
|
1135
|
+
realTargetLength)
|
1136
|
+
position =
|
1137
|
+
realTargetLength;
|
1138
|
+
}
|
1139
|
+
setShortReadMarkerPosition
|
1140
|
+
(shortRead, position);
|
1141
|
+
}
|
1142
|
+
} else {
|
1143
|
+
for (shortReadIndex = 0;
|
1144
|
+
shortReadIndex <
|
1145
|
+
selectedShortReadCount;
|
1146
|
+
shortReadIndex++) {
|
1147
|
+
shortRead =
|
1148
|
+
getShortReadMarkerAtIndex
|
1149
|
+
(selectedShortReads,
|
1150
|
+
shortReadIndex);
|
1151
|
+
position =
|
1152
|
+
getShortReadMarkerPosition
|
1153
|
+
(shortRead);
|
1154
|
+
if (position > -1)
|
1155
|
+
setShortReadMarkerPosition
|
1156
|
+
(shortRead, 0);
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
}
|
1160
|
+
}
|
1161
|
+
injectShortReads(selectedShortReads,
|
1162
|
+
selectedShortReadCount,
|
1163
|
+
getTwinNode(target), graph);
|
1164
|
+
}
|
1165
|
+
// Virtual coverage
|
1166
|
+
if (alignedSourceLength != 0) {
|
1167
|
+
Coordinate coverage;
|
1168
|
+
#ifndef SINGLE_COV_CAT
|
1169
|
+
Category cat;
|
1170
|
+
for (cat = 0; cat < CATEGORIES; cat++) {
|
1171
|
+
coverage = getVirtualCoverage(source, cat);
|
1172
|
+
coverage *= halfwayPoint;
|
1173
|
+
coverage /= alignedSourceLength;
|
1174
|
+
incrementVirtualCoverage(target, cat, coverage);
|
1175
|
+
incrementVirtualCoverage(source, cat, -coverage);
|
1176
|
+
|
1177
|
+
coverage = getOriginalVirtualCoverage(source, cat);
|
1178
|
+
coverage *= halfwayPoint;
|
1179
|
+
coverage /= alignedSourceLength;
|
1180
|
+
incrementOriginalVirtualCoverage(source, cat,
|
1181
|
+
-coverage);
|
1182
|
+
}
|
1183
|
+
#else
|
1184
|
+
coverage = getVirtualCoverage(source);
|
1185
|
+
coverage *= halfwayPoint;
|
1186
|
+
coverage /= alignedSourceLength;
|
1187
|
+
incrementVirtualCoverage(target, coverage);
|
1188
|
+
incrementVirtualCoverage(source, -coverage);
|
1189
|
+
#endif
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
return halfwayPointOffset;
|
1193
|
+
}
|
1194
|
+
|
1195
|
+
static void remapNodeInwardReferencesOntoNode(Node * source, Node * target)
|
1196
|
+
{
|
1197
|
+
Arc *arc;
|
1198
|
+
Node *destination;
|
1199
|
+
|
1200
|
+
for (arc = getArc(source); arc != NULL; arc = getNextArc(arc)) {
|
1201
|
+
destination = getDestination(arc);
|
1202
|
+
if (destination == target || destination == source)
|
1203
|
+
continue;
|
1204
|
+
if (getNodePrevious(destination) == source)
|
1205
|
+
setNodePrevious(target, destination);
|
1206
|
+
}
|
1207
|
+
}
|
1208
|
+
|
1209
|
+
static void remapNodeTimesOntoTargetNode(Node * source, Node * target)
|
1210
|
+
{
|
1211
|
+
Time nodeTime = getNodeTime(source);
|
1212
|
+
Node *previous = getNodePrevious(source);
|
1213
|
+
Time targetTime = getNodeTime(target);
|
1214
|
+
|
1215
|
+
if (nodeTime == -1)
|
1216
|
+
return;
|
1217
|
+
|
1218
|
+
if (previous == source) {
|
1219
|
+
setNodeTime(target, nodeTime);
|
1220
|
+
setNodePrevious(target, target);
|
1221
|
+
} else if (targetTime == -1
|
1222
|
+
|| targetTime > nodeTime
|
1223
|
+
|| (targetTime == nodeTime
|
1224
|
+
&& !isPreviousToNode(target, previous))) {
|
1225
|
+
setNodeTime(target, nodeTime);
|
1226
|
+
if (previous != getTwinNode(source))
|
1227
|
+
setNodePrevious(previous, target);
|
1228
|
+
else
|
1229
|
+
setNodePrevious(getTwinNode(target), target);
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
remapNodeInwardReferencesOntoNode(source, target);
|
1233
|
+
|
1234
|
+
setNodePrevious(NULL, source);
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
static void foldSymmetricalNode(Node * node)
|
1238
|
+
{
|
1239
|
+
Node *twinNode = getTwinNode(node);
|
1240
|
+
Node *tmp, *destination;
|
1241
|
+
Arc *arc;
|
1242
|
+
PassageMarkerI oldMarker = getMarker(node);
|
1243
|
+
PassageMarkerI currentMarker, newMarker, previousMarker;
|
1244
|
+
Coordinate halfwayPoint;
|
1245
|
+
IDnum totalMult;
|
1246
|
+
|
1247
|
+
// Reduce time complexity of damn thing
|
1248
|
+
if (simpleArcCount(node) < simpleArcCount(twinNode)) {
|
1249
|
+
tmp = twinNode;
|
1250
|
+
twinNode = node;
|
1251
|
+
node = tmp;
|
1252
|
+
}
|
1253
|
+
// Destroy link to old markers
|
1254
|
+
setMarker(node, NULL_IDX);
|
1255
|
+
|
1256
|
+
// Reinsert markers properly
|
1257
|
+
while (oldMarker != NULL_IDX) {
|
1258
|
+
currentMarker = oldMarker;
|
1259
|
+
oldMarker = getNextInNode(currentMarker);
|
1260
|
+
previousMarker = getPreviousInSequence(currentMarker);
|
1261
|
+
|
1262
|
+
if (getNode(previousMarker) != twinNode) {
|
1263
|
+
newMarker =
|
1264
|
+
addUncertainPassageMarker
|
1265
|
+
(getPassageMarkerSequenceID(currentMarker),
|
1266
|
+
twinNode);
|
1267
|
+
setPassageMarkerStatus(newMarker,
|
1268
|
+
getPassageMarkerStatus
|
1269
|
+
(currentMarker));
|
1270
|
+
|
1271
|
+
setPassageMarkerStart(newMarker,
|
1272
|
+
getPassageMarkerStart
|
1273
|
+
(currentMarker));
|
1274
|
+
|
1275
|
+
// For security issues:
|
1276
|
+
if (currentMarker == slowPath)
|
1277
|
+
slowPath = newMarker;
|
1278
|
+
else if (currentMarker == fastPath)
|
1279
|
+
fastPath = newMarker;
|
1280
|
+
|
1281
|
+
halfwayPoint =
|
1282
|
+
(getPassageMarkerStart(currentMarker) +
|
1283
|
+
getPassageMarkerFinish(currentMarker))
|
1284
|
+
/ 2;
|
1285
|
+
setPassageMarkerFinish(newMarker, halfwayPoint);
|
1286
|
+
|
1287
|
+
setPassageMarkerStart(currentMarker, halfwayPoint);
|
1288
|
+
|
1289
|
+
setStartOffset(newMarker,
|
1290
|
+
getStartOffset(currentMarker));
|
1291
|
+
setFinishOffset(newMarker, 0);
|
1292
|
+
setStartOffset(currentMarker, 0);
|
1293
|
+
|
1294
|
+
setPreviousInSequence(previousMarker, newMarker);
|
1295
|
+
setNextInSequence(previousMarker, newMarker);
|
1296
|
+
|
1297
|
+
setPreviousInSequence(newMarker, currentMarker);
|
1298
|
+
setNextInSequence(newMarker, currentMarker);
|
1299
|
+
}
|
1300
|
+
|
1301
|
+
transposePassageMarker(currentMarker, node);
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
// Read start info
|
1305
|
+
foldSymmetricalNodeReads(node, graph);
|
1306
|
+
|
1307
|
+
// Coverage => already balanced!
|
1308
|
+
|
1309
|
+
// References
|
1310
|
+
if (getNodeTime(node) == -1 && getNodeTime(twinNode) == -1);
|
1311
|
+
else if (getNodeTime(node) == -1) {
|
1312
|
+
setNodeTime(node, getNodeTime(twinNode));
|
1313
|
+
} else if (getNodeTime(twinNode) == -1) {
|
1314
|
+
setNodeTime(twinNode, getNodeTime(node));
|
1315
|
+
setNodePrevious(getNodePrevious(node), twinNode);
|
1316
|
+
} else if (getNodePrevious(node) == node) {
|
1317
|
+
setNodeTime(twinNode, getNodeTime(node));
|
1318
|
+
setNodePrevious(twinNode, twinNode);
|
1319
|
+
} else if (getNodeTime(node) < getNodeTime(twinNode)) {
|
1320
|
+
setNodeTime(twinNode, getNodeTime(node));
|
1321
|
+
setNodePrevious(getNodePrevious(node), twinNode);
|
1322
|
+
} else if (getNodeTime(node) == getNodeTime(twinNode)
|
1323
|
+
&& isPreviousToNode(node, twinNode)) {
|
1324
|
+
setNodePrevious(getNodePrevious(node), twinNode);
|
1325
|
+
} else {
|
1326
|
+
setNodeTime(node, getNodeTime(twinNode));
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
setNodePrevious(twinNode, node);
|
1330
|
+
remapNodeInwardReferencesOntoNode(twinNode, node);
|
1331
|
+
|
1332
|
+
// Active node
|
1333
|
+
if (twinNode == activeNode) {
|
1334
|
+
activeNode = node;
|
1335
|
+
todo =
|
1336
|
+
&todoLists[getNodeID(activeNode) + nodeCount(graph)];
|
1337
|
+
}
|
1338
|
+
concatenateTodoLists(node, twinNode);
|
1339
|
+
|
1340
|
+
// Remap arcs properly
|
1341
|
+
arc = getArc(twinNode);
|
1342
|
+
totalMult = 0;
|
1343
|
+
while (arc != NULL) {
|
1344
|
+
destination = getDestination(arc);
|
1345
|
+
if (destination != node)
|
1346
|
+
createAnalogousArc(node, destination, arc, graph);
|
1347
|
+
totalMult += getMultiplicity(arc);
|
1348
|
+
destroyArc(arc, graph);
|
1349
|
+
arc = getArc(twinNode);
|
1350
|
+
}
|
1351
|
+
|
1352
|
+
arc = createArc(twinNode, node, graph);
|
1353
|
+
setMultiplicity(arc, totalMult);
|
1354
|
+
|
1355
|
+
// Uniqueness
|
1356
|
+
setUniqueness(node, false);
|
1357
|
+
|
1358
|
+
// Starting node
|
1359
|
+
if (startingNode == node)
|
1360
|
+
startingNode = twinNode;
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
static void remapNodeTimesOntoNeighbour(Node * source, Node * target)
|
1364
|
+
{
|
1365
|
+
remapNodeTimesOntoTargetNode(source, target);
|
1366
|
+
remapNodeTimesOntoTargetNode(getTwinNode(source),
|
1367
|
+
getTwinNode(target));
|
1368
|
+
}
|
1369
|
+
|
1370
|
+
static void remapNodeTimesOntoForwardMiddlePath(Node * source,
|
1371
|
+
PassageMarkerI path)
|
1372
|
+
{
|
1373
|
+
PassageMarkerI marker;
|
1374
|
+
Node *target;
|
1375
|
+
Time nodeTime = getNodeTime(source);
|
1376
|
+
Node *previousNode = getNodePrevious(source);
|
1377
|
+
Time targetTime;
|
1378
|
+
|
1379
|
+
//velvetLog("Remapping times from %ld to %ld\n", getNodeID(previousNode), getNodeID(source));
|
1380
|
+
|
1381
|
+
for (marker = path; getNode(marker) != source;
|
1382
|
+
marker = getNextInSequence(marker)) {
|
1383
|
+
target = getNode(marker);
|
1384
|
+
targetTime = getNodeTime(target);
|
1385
|
+
|
1386
|
+
//velvetLog("Through %ld\n", getNodeID(target));
|
1387
|
+
|
1388
|
+
if (targetTime == -1
|
1389
|
+
|| targetTime > nodeTime
|
1390
|
+
|| (targetTime == nodeTime
|
1391
|
+
&& !isPreviousToNode(target, previousNode))) {
|
1392
|
+
setNodeTime(target, nodeTime);
|
1393
|
+
setNodePrevious(previousNode, target);
|
1394
|
+
}
|
1395
|
+
|
1396
|
+
previousNode = target;
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
setNodePrevious(previousNode, source);
|
1400
|
+
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
static void remapNodeTimesOntoTwinMiddlePath(Node * source,
|
1404
|
+
PassageMarkerI path)
|
1405
|
+
{
|
1406
|
+
PassageMarkerI marker;
|
1407
|
+
Node *target;
|
1408
|
+
Node *previousNode = getTwinNode(source);
|
1409
|
+
Time targetTime;
|
1410
|
+
PassageMarkerI limit = getTwinMarker(getPreviousInSequence(path));
|
1411
|
+
Time nodeTime = getNodeTime(getNode(limit));
|
1412
|
+
|
1413
|
+
//velvetLog("Remapping times from twins %ld to %ld\n", getNodeID(previousNode), getNodeID(getNode(limit)));
|
1414
|
+
|
1415
|
+
// Revving up
|
1416
|
+
marker = path;
|
1417
|
+
while (getNode(marker) != source)
|
1418
|
+
marker = getNextInSequence(marker);
|
1419
|
+
marker = getTwinMarker(marker);
|
1420
|
+
|
1421
|
+
// Going down the path
|
1422
|
+
while (marker != limit) {
|
1423
|
+
marker = getNextInSequence(marker);
|
1424
|
+
target = getNode(marker);
|
1425
|
+
targetTime = getNodeTime(target);
|
1426
|
+
|
1427
|
+
//velvetLog("Through %ld\n", getNodeID(target));
|
1428
|
+
|
1429
|
+
if (targetTime == -1
|
1430
|
+
|| targetTime > nodeTime
|
1431
|
+
|| (targetTime == nodeTime
|
1432
|
+
&& !isPreviousToNode(target, previousNode))) {
|
1433
|
+
setNodeTime(target, nodeTime);
|
1434
|
+
getNodeTime(target);
|
1435
|
+
setNodePrevious(previousNode, target);
|
1436
|
+
}
|
1437
|
+
|
1438
|
+
previousNode = target;
|
1439
|
+
}
|
1440
|
+
}
|
1441
|
+
|
1442
|
+
static void
|
1443
|
+
remapNodeFibHeapReferencesOntoNode(Node * source, Node * target)
|
1444
|
+
{
|
1445
|
+
DFibHeapNode *sourceDHeapNode = getNodeDHeapNode(source);
|
1446
|
+
DFibHeapNode *targetDHeapNode = getNodeDHeapNode(target);
|
1447
|
+
|
1448
|
+
if (sourceDHeapNode == NULL)
|
1449
|
+
return;
|
1450
|
+
|
1451
|
+
if (targetDHeapNode == NULL) {
|
1452
|
+
setNodeDHeapNode(target, sourceDHeapNode);
|
1453
|
+
replaceValueInDHeap(sourceDHeapNode, target);
|
1454
|
+
} else if (getKey(targetDHeapNode) > getKey(sourceDHeapNode)) {
|
1455
|
+
setNodeDHeapNode(target, sourceDHeapNode);
|
1456
|
+
replaceValueInDHeap(sourceDHeapNode, target);
|
1457
|
+
destroyNodeInDHeap(targetDHeapNode, dheap);
|
1458
|
+
} else
|
1459
|
+
destroyNodeInDHeap(sourceDHeapNode, dheap);
|
1460
|
+
|
1461
|
+
setNodeDHeapNode(source, NULL);
|
1462
|
+
}
|
1463
|
+
|
1464
|
+
static void remapNodeOntoNeighbour(Node * source,
|
1465
|
+
PassageMarkerI sourceMarker,
|
1466
|
+
Node * target,
|
1467
|
+
PassageMarkerI targetMarker)
|
1468
|
+
{
|
1469
|
+
//velvetLog("Remapping node %ld onto middle path %ld\n", getNodeID(source), getNodeID(target));
|
1470
|
+
remapNodeMarkersOntoNeighbour(source, sourceMarker, target,
|
1471
|
+
targetMarker);
|
1472
|
+
|
1473
|
+
remapNodeTimesOntoNeighbour(source, target);
|
1474
|
+
remapNodeArcsOntoNeighbour(source, target);
|
1475
|
+
|
1476
|
+
remapNodeFibHeapReferencesOntoNode(getTwinNode(source),
|
1477
|
+
getTwinNode(target));
|
1478
|
+
remapNodeFibHeapReferencesOntoNode(source, target);
|
1479
|
+
|
1480
|
+
if (startingNode == source)
|
1481
|
+
startingNode = target;
|
1482
|
+
if (startingNode == getTwinNode(source))
|
1483
|
+
startingNode = getTwinNode(target);
|
1484
|
+
|
1485
|
+
destroyNode(source, graph);
|
1486
|
+
}
|
1487
|
+
|
1488
|
+
static void remapBackOfNodeDescriptorOntoNeighbour(Node * source,
|
1489
|
+
PassageMarkerI sourceMarker,
|
1490
|
+
Node * target,
|
1491
|
+
PassageMarkerI targetMarker,
|
1492
|
+
boolean slowToFast,
|
1493
|
+
Coordinate offset)
|
1494
|
+
{
|
1495
|
+
//velvetLog("Splitting node descriptor %ld // %ld\n", getNodeLength(source), offset);
|
1496
|
+
|
1497
|
+
if (slowToFast)
|
1498
|
+
splitNodeDescriptor(source, NULL, offset);
|
1499
|
+
else
|
1500
|
+
splitNodeDescriptor(source, target, offset);
|
1501
|
+
}
|
1502
|
+
|
1503
|
+
static void remapBackOfNodeTimesOntoNeighbour(Node * source, Node * target)
|
1504
|
+
{
|
1505
|
+
Time targetTime = getNodeTime(target);
|
1506
|
+
Time nodeTime = getNodeTime(source);
|
1507
|
+
Node *twinTarget = getTwinNode(target);
|
1508
|
+
Node *twinSource = getTwinNode(source);
|
1509
|
+
Node *previous;
|
1510
|
+
|
1511
|
+
if (nodeTime != -1) {
|
1512
|
+
previous = getNodePrevious(source);
|
1513
|
+
|
1514
|
+
if (previous == source) {
|
1515
|
+
setNodeTime(target, nodeTime);
|
1516
|
+
setNodePrevious(target, target);
|
1517
|
+
} else if (targetTime == -1
|
1518
|
+
|| targetTime > nodeTime
|
1519
|
+
|| (targetTime == nodeTime
|
1520
|
+
&& !isPreviousToNode(target, previous))) {
|
1521
|
+
setNodeTime(target, nodeTime);
|
1522
|
+
if (previous != getTwinNode(source))
|
1523
|
+
setNodePrevious(previous, target);
|
1524
|
+
else
|
1525
|
+
setNodePrevious(getTwinNode(target),
|
1526
|
+
target);
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
setNodePrevious(target, source);
|
1530
|
+
}
|
1531
|
+
|
1532
|
+
targetTime = getNodeTime(twinTarget);
|
1533
|
+
nodeTime = getNodeTime(twinSource);
|
1534
|
+
|
1535
|
+
if (nodeTime != -1) {
|
1536
|
+
if (targetTime == -1
|
1537
|
+
|| targetTime > nodeTime
|
1538
|
+
|| (targetTime == nodeTime
|
1539
|
+
&& !isPreviousToNode(twinTarget, twinSource))) {
|
1540
|
+
setNodeTime(twinTarget, nodeTime);
|
1541
|
+
setNodePrevious(twinSource, twinTarget);
|
1542
|
+
}
|
1543
|
+
}
|
1544
|
+
|
1545
|
+
remapNodeInwardReferencesOntoNode(twinSource, twinTarget);
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
static void
|
1549
|
+
remapBackOfNodeOntoNeighbour(Node * source, PassageMarkerI sourceMarker,
|
1550
|
+
Node * target, PassageMarkerI targetMarker,
|
1551
|
+
boolean slowToFast)
|
1552
|
+
{
|
1553
|
+
Coordinate offset;
|
1554
|
+
//velvetLog("Remapping node %ld onto middle path\n", getNodeID(node));
|
1555
|
+
|
1556
|
+
offset =
|
1557
|
+
remapBackOfNodeMarkersOntoNeighbour(source, sourceMarker,
|
1558
|
+
target, targetMarker,
|
1559
|
+
slowToFast);
|
1560
|
+
remapBackOfNodeDescriptorOntoNeighbour(source, sourceMarker,
|
1561
|
+
target, targetMarker,
|
1562
|
+
slowToFast, offset);
|
1563
|
+
remapBackOfNodeTimesOntoNeighbour(source, target);
|
1564
|
+
remapBackOfNodeArcsOntoNeighbour(source, target);
|
1565
|
+
|
1566
|
+
remapNodeFibHeapReferencesOntoNode(getTwinNode(source),
|
1567
|
+
getTwinNode(target));
|
1568
|
+
|
1569
|
+
if (getTwinNode(source) == startingNode)
|
1570
|
+
startingNode = getTwinNode(target);
|
1571
|
+
}
|
1572
|
+
|
1573
|
+
static void remapEmptyPathArcsOntoMiddlePathSimple(PassageMarkerI emptyPath,
|
1574
|
+
PassageMarkerI targetPath)
|
1575
|
+
{
|
1576
|
+
PassageMarkerI pathMarker;
|
1577
|
+
Node *start = getNode(getPreviousInSequence(emptyPath));
|
1578
|
+
Node *finish = getNode(emptyPath);
|
1579
|
+
Node *previousNode = start;
|
1580
|
+
Node *currentNode;
|
1581
|
+
Arc *originalArc = getArcBetweenNodes(start, finish, graph);
|
1582
|
+
|
1583
|
+
for (pathMarker = targetPath; getNode(pathMarker) != finish;
|
1584
|
+
pathMarker = getNextInSequence(pathMarker)) {
|
1585
|
+
currentNode = getNode(pathMarker);
|
1586
|
+
createAnalogousArc(previousNode, currentNode, originalArc, graph);
|
1587
|
+
previousNode = currentNode;
|
1588
|
+
}
|
1589
|
+
|
1590
|
+
createAnalogousArc(previousNode, finish, originalArc, graph);
|
1591
|
+
|
1592
|
+
destroyArc(originalArc, graph);
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
static void remapEmptyPathMarkersOntoMiddlePathSimple(PassageMarkerI emptyPath,
|
1596
|
+
PassageMarkerI targetPath)
|
1597
|
+
{
|
1598
|
+
PassageMarkerI marker, newMarker, previousMarker, pathMarker;
|
1599
|
+
Node *start = getNode(getPreviousInSequence(emptyPath));
|
1600
|
+
Node *finish = getNode(emptyPath);
|
1601
|
+
PassageMarkerI oldMarker = getMarker(finish);
|
1602
|
+
Coordinate markerStart;
|
1603
|
+
IDnum intersectionLength, twinIntersectionLength;
|
1604
|
+
ShortReadMarker *intersectionReads =
|
1605
|
+
commonNodeReads(start, finish, graph, &intersectionLength);
|
1606
|
+
ShortReadMarker *twinIntersectionReads =
|
1607
|
+
commonNodeReads(getTwinNode(start), getTwinNode(finish), graph,
|
1608
|
+
&twinIntersectionLength);
|
1609
|
+
|
1610
|
+
//velvetLog("SIMPLE %ld\t%ld\t%i\t%i\n", markerCount(finish),
|
1611
|
+
// getNodeID(finish), arcCount(finish),
|
1612
|
+
// arcCount(getTwinNode(finish)));
|
1613
|
+
|
1614
|
+
// Destroy link to old nodes
|
1615
|
+
setMarker(finish, NULL_IDX);
|
1616
|
+
|
1617
|
+
while (oldMarker != NULL_IDX) {
|
1618
|
+
marker = oldMarker;
|
1619
|
+
oldMarker = getNextInNode(marker);
|
1620
|
+
newMarker = getPreviousInSequence(marker);
|
1621
|
+
|
1622
|
+
if (getNode(newMarker) != start) {
|
1623
|
+
transposePassageMarker(marker, finish);
|
1624
|
+
continue;
|
1625
|
+
}
|
1626
|
+
|
1627
|
+
markerStart = getPassageMarkerStart(marker);
|
1628
|
+
for (pathMarker = targetPath;
|
1629
|
+
getNode(pathMarker) != finish;
|
1630
|
+
pathMarker = getNextInSequence(pathMarker)) {
|
1631
|
+
previousMarker = newMarker;
|
1632
|
+
|
1633
|
+
newMarker =
|
1634
|
+
addUncertainPassageMarker
|
1635
|
+
(getPassageMarkerSequenceID(marker),
|
1636
|
+
getNode(pathMarker));
|
1637
|
+
setPassageMarkerStatus(newMarker,
|
1638
|
+
getPassageMarkerStatus
|
1639
|
+
(marker));
|
1640
|
+
setPassageMarkerStart(newMarker, markerStart);
|
1641
|
+
setPassageMarkerFinish(newMarker, markerStart);
|
1642
|
+
setNextInSequence(previousMarker, newMarker);
|
1643
|
+
setPreviousInSequence(previousMarker, newMarker);
|
1644
|
+
|
1645
|
+
setStartOffset(newMarker, 0);
|
1646
|
+
setFinishOffset(newMarker, 0);
|
1647
|
+
|
1648
|
+
}
|
1649
|
+
|
1650
|
+
setNextInSequence(newMarker, marker);
|
1651
|
+
setPreviousInSequence(newMarker, marker);
|
1652
|
+
transposePassageMarker(marker, finish);
|
1653
|
+
}
|
1654
|
+
|
1655
|
+
if (readStartsAreActivated(graph)) {
|
1656
|
+
for (pathMarker = targetPath;
|
1657
|
+
getNode(pathMarker) != finish;
|
1658
|
+
pathMarker = getNextInSequence(pathMarker)) {
|
1659
|
+
// Read starts
|
1660
|
+
spreadReadIDs(intersectionReads,
|
1661
|
+
intersectionLength,
|
1662
|
+
getNode(pathMarker), graph);
|
1663
|
+
spreadReadIDs(twinIntersectionReads,
|
1664
|
+
twinIntersectionLength,
|
1665
|
+
getTwinNode(getNode(pathMarker)),
|
1666
|
+
graph);
|
1667
|
+
}
|
1668
|
+
}
|
1669
|
+
|
1670
|
+
free(intersectionReads);
|
1671
|
+
free(twinIntersectionReads);
|
1672
|
+
}
|
1673
|
+
|
1674
|
+
static boolean markerFollowsPath(PassageMarkerI marker,
|
1675
|
+
PassageMarkerI start,
|
1676
|
+
PassageMarkerI finish, Node * stopNode)
|
1677
|
+
{
|
1678
|
+
PassageMarkerI current, path;
|
1679
|
+
|
1680
|
+
path = start;
|
1681
|
+
current = marker;
|
1682
|
+
|
1683
|
+
while (true) {
|
1684
|
+
if (current == NULL_IDX || path == finish || path == NULL_IDX)
|
1685
|
+
return true;
|
1686
|
+
|
1687
|
+
if (getNode(current) != getNode(path))
|
1688
|
+
return false;
|
1689
|
+
|
1690
|
+
current = getNextInSequence(current);
|
1691
|
+
path = getNextInSequence(path);
|
1692
|
+
}
|
1693
|
+
}
|
1694
|
+
|
1695
|
+
static PassageMarkerList *getAnchors(PassageMarkerI marker, Node * nodeA,
|
1696
|
+
Node * nodeB)
|
1697
|
+
{
|
1698
|
+
PassageMarkerI current, next;
|
1699
|
+
Node *twinA = getTwinNode(nodeA);
|
1700
|
+
Node *twinB = getTwinNode(nodeB);
|
1701
|
+
PassageMarkerList *result = NULL;
|
1702
|
+
|
1703
|
+
current = marker;
|
1704
|
+
while (current != NULL_IDX) {
|
1705
|
+
next = getNextInSequence(current);
|
1706
|
+
if (getNode(current) == nodeA && getNode(next) == nodeB) {
|
1707
|
+
result = newPassageMarkerList(next, result);
|
1708
|
+
}
|
1709
|
+
if (getNode(current) == twinB && getNode(next) == twinA) {
|
1710
|
+
result =
|
1711
|
+
newPassageMarkerList(getTwinMarker(current),
|
1712
|
+
result);
|
1713
|
+
}
|
1714
|
+
current = next;
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
return result;
|
1718
|
+
}
|
1719
|
+
|
1720
|
+
static void destroyPassageMarkerList(PassageMarkerList ** list)
|
1721
|
+
{
|
1722
|
+
PassageMarkerList *ptr;
|
1723
|
+
|
1724
|
+
while (*list != NULL) {
|
1725
|
+
ptr = *list;
|
1726
|
+
*list = ptr->next;
|
1727
|
+
deallocatePassageMarkerList(ptr);
|
1728
|
+
}
|
1729
|
+
}
|
1730
|
+
|
1731
|
+
static void remapEmptyPathMarkersOntoMiddlePathDevious(PassageMarkerI emptyPath,
|
1732
|
+
PassageMarkerI targetPath)
|
1733
|
+
{
|
1734
|
+
PassageMarkerI marker, newMarker, previousMarker, pathMarker;
|
1735
|
+
Node *start = getNode(getPreviousInSequence(emptyPath));
|
1736
|
+
Node *finish = getNode(emptyPath);
|
1737
|
+
PassageMarkerList *anchors = getAnchors(targetPath, start, finish);
|
1738
|
+
PassageMarkerList *currentAnchor;
|
1739
|
+
boolean untouchable = false;
|
1740
|
+
Coordinate markerStart;
|
1741
|
+
|
1742
|
+
velvetLog("DEVIOUS %li\t%li\t%li\t%li\n", (long) markerCount(finish),
|
1743
|
+
(long) getNodeID(finish), (long) arcCount(finish),
|
1744
|
+
(long) arcCount(getTwinNode(finish)));
|
1745
|
+
|
1746
|
+
for (marker = getMarker(finish); marker != NULL_IDX;
|
1747
|
+
marker = getNextInNode(marker)) {
|
1748
|
+
newMarker = getPreviousInSequence(marker);
|
1749
|
+
|
1750
|
+
if (getNode(newMarker) != start)
|
1751
|
+
continue;
|
1752
|
+
|
1753
|
+
|
1754
|
+
for (currentAnchor = anchors; currentAnchor != NULL;
|
1755
|
+
currentAnchor = currentAnchor->next)
|
1756
|
+
if (markerFollowsPath
|
1757
|
+
(marker, currentAnchor->marker, targetPath,
|
1758
|
+
finish)) {
|
1759
|
+
untouchable = true;
|
1760
|
+
break;
|
1761
|
+
}
|
1762
|
+
|
1763
|
+
if (untouchable)
|
1764
|
+
continue;
|
1765
|
+
|
1766
|
+
markerStart = getPassageMarkerStart(marker);
|
1767
|
+
for (pathMarker = targetPath;
|
1768
|
+
getNode(pathMarker) != finish;
|
1769
|
+
pathMarker = getNextInSequence(pathMarker)) {
|
1770
|
+
previousMarker = newMarker;
|
1771
|
+
newMarker =
|
1772
|
+
addUncertainPassageMarker
|
1773
|
+
(getPassageMarkerSequenceID(marker),
|
1774
|
+
getNode(pathMarker));
|
1775
|
+
setPassageMarkerStatus(newMarker,
|
1776
|
+
getPassageMarkerStatus
|
1777
|
+
(marker));
|
1778
|
+
setPassageMarkerStart(newMarker, markerStart);
|
1779
|
+
setPassageMarkerFinish(newMarker, markerStart);
|
1780
|
+
setNextInSequence(previousMarker, newMarker);
|
1781
|
+
setPreviousInSequence(previousMarker, newMarker);
|
1782
|
+
|
1783
|
+
setStartOffset(newMarker, 0);
|
1784
|
+
setFinishOffset(newMarker, 0);
|
1785
|
+
}
|
1786
|
+
|
1787
|
+
setNextInSequence(newMarker, marker);
|
1788
|
+
setPreviousInSequence(newMarker, marker);
|
1789
|
+
}
|
1790
|
+
|
1791
|
+
destroyPassageMarkerList(&anchors);
|
1792
|
+
}
|
1793
|
+
|
1794
|
+
static boolean markerLeadsToArc(PassageMarkerI marker, Node * nodeA,
|
1795
|
+
Node * nodeB)
|
1796
|
+
{
|
1797
|
+
PassageMarkerI current, next;
|
1798
|
+
Node *twinA = getTwinNode(nodeA);
|
1799
|
+
Node *twinB = getTwinNode(nodeB);
|
1800
|
+
|
1801
|
+
current = marker;
|
1802
|
+
while (current != NULL_IDX) {
|
1803
|
+
next = getNextInSequence(current);
|
1804
|
+
if (getNode(current) == nodeA && getNode(next) == nodeB)
|
1805
|
+
return true;
|
1806
|
+
if (getNode(current) == twinB && getNode(next) == twinA)
|
1807
|
+
return true;
|
1808
|
+
current = next;
|
1809
|
+
}
|
1810
|
+
|
1811
|
+
return false;
|
1812
|
+
}
|
1813
|
+
|
1814
|
+
static void
|
1815
|
+
remapEmptyPathOntoMiddlePath(PassageMarkerI emptyPath,
|
1816
|
+
PassageMarkerI targetPath)
|
1817
|
+
{
|
1818
|
+
Node *start = getNode(getPreviousInSequence(emptyPath));
|
1819
|
+
Node *finish = getNode(emptyPath);
|
1820
|
+
|
1821
|
+
// Remapping markers
|
1822
|
+
if (!markerLeadsToArc(targetPath, start, finish)) {
|
1823
|
+
remapEmptyPathArcsOntoMiddlePathSimple(emptyPath,
|
1824
|
+
targetPath);
|
1825
|
+
remapEmptyPathMarkersOntoMiddlePathSimple(emptyPath,
|
1826
|
+
targetPath);
|
1827
|
+
} else {
|
1828
|
+
remapEmptyPathMarkersOntoMiddlePathDevious(emptyPath,
|
1829
|
+
targetPath);
|
1830
|
+
}
|
1831
|
+
|
1832
|
+
//Remap times and previous(if necessary)
|
1833
|
+
if (getNodePrevious(finish) == start)
|
1834
|
+
remapNodeTimesOntoForwardMiddlePath(finish, targetPath);
|
1835
|
+
|
1836
|
+
if (getNodePrevious(getTwinNode(start)) == getTwinNode(finish))
|
1837
|
+
remapNodeTimesOntoTwinMiddlePath(finish, targetPath);
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
static void reduceSlowNodes(PassageMarkerI slowMarker, Node * finish)
|
1841
|
+
{
|
1842
|
+
PassageMarkerI marker;
|
1843
|
+
|
1844
|
+
for (marker = slowMarker; getNode(marker) != finish;
|
1845
|
+
marker = getNextInSequence(marker)) {
|
1846
|
+
reduceNode(getNode(marker));
|
1847
|
+
}
|
1848
|
+
}
|
1849
|
+
|
1850
|
+
static void destroyPaths()
|
1851
|
+
{
|
1852
|
+
PassageMarkerI marker;
|
1853
|
+
|
1854
|
+
while (slowPath != NULL_IDX) {
|
1855
|
+
marker = slowPath;
|
1856
|
+
slowPath = getNextInSequence(marker);
|
1857
|
+
destroyPassageMarker(marker);
|
1858
|
+
}
|
1859
|
+
|
1860
|
+
while (fastPath != NULL_IDX) {
|
1861
|
+
marker = fastPath;
|
1862
|
+
fastPath = getNextInSequence(marker);
|
1863
|
+
destroyPassageMarker(marker);
|
1864
|
+
}
|
1865
|
+
}
|
1866
|
+
|
1867
|
+
static Coordinate mapDistancesOntoPaths()
|
1868
|
+
{
|
1869
|
+
PassageMarkerI marker;
|
1870
|
+
Coordinate totalDistance = 0;
|
1871
|
+
|
1872
|
+
marker = slowPath;
|
1873
|
+
while (!isTerminal(marker)) {
|
1874
|
+
marker = getNextInSequence(marker);
|
1875
|
+
setPassageMarkerStart(marker, totalDistance);
|
1876
|
+
totalDistance += getNodeLength(getNode(marker));
|
1877
|
+
setPassageMarkerFinish(marker, totalDistance);
|
1878
|
+
}
|
1879
|
+
|
1880
|
+
totalDistance = 0;
|
1881
|
+
marker = fastPath;
|
1882
|
+
while (!isTerminal(marker)) {
|
1883
|
+
marker = getNextInSequence(marker);
|
1884
|
+
setPassageMarkerStart(marker, totalDistance);
|
1885
|
+
totalDistance += getNodeLength(getNode(marker));
|
1886
|
+
setPassageMarkerFinish(marker, totalDistance);
|
1887
|
+
}
|
1888
|
+
|
1889
|
+
return totalDistance;
|
1890
|
+
}
|
1891
|
+
|
1892
|
+
static boolean markerLeadsToNode(PassageMarkerI marker, Node * node)
|
1893
|
+
{
|
1894
|
+
PassageMarkerI currentMarker;
|
1895
|
+
|
1896
|
+
for (currentMarker = marker; currentMarker != NULL_IDX;
|
1897
|
+
currentMarker = getNextInSequence(currentMarker))
|
1898
|
+
if (getNode(currentMarker) == node)
|
1899
|
+
return true;
|
1900
|
+
|
1901
|
+
return false;
|
1902
|
+
}
|
1903
|
+
|
1904
|
+
static void transferNodeData(Node * source, Node * target)
|
1905
|
+
{
|
1906
|
+
Arc *arc;
|
1907
|
+
Node *twinSource = getTwinNode(source);
|
1908
|
+
Node *twinTarget = getTwinNode(target);
|
1909
|
+
Node *destination;
|
1910
|
+
|
1911
|
+
// Time & Outward references
|
1912
|
+
if (getNodePrevious(source) == source) {
|
1913
|
+
setNodeTime(target, getNodeTime(source));
|
1914
|
+
setNodePrevious(target, target);
|
1915
|
+
}
|
1916
|
+
|
1917
|
+
if (getNodeTime(twinSource) == -1);
|
1918
|
+
else if (getNodePrevious(twinSource) == twinSource) {
|
1919
|
+
setNodeTime(twinTarget, getNodeTime(twinSource));
|
1920
|
+
setNodePrevious(twinTarget, twinTarget);
|
1921
|
+
} else if (getNodeTime(twinTarget) == -1
|
1922
|
+
|| getNodeTime(twinSource) < getNodeTime(twinTarget)
|
1923
|
+
|| (getNodeTime(twinSource) == getNodeTime(twinTarget)
|
1924
|
+
&& !isPreviousToNode(twinTarget, twinSource))) {
|
1925
|
+
setNodeTime(twinTarget, getNodeTime(twinSource));
|
1926
|
+
setNodePrevious(getNodePrevious(twinSource), twinTarget);
|
1927
|
+
}
|
1928
|
+
|
1929
|
+
if (getNodePrevious(twinTarget) == source)
|
1930
|
+
setNodePrevious(target, twinTarget);
|
1931
|
+
|
1932
|
+
// Inward references:
|
1933
|
+
for (arc = getArc(source); arc != NULL; arc = getNextArc(arc)) {
|
1934
|
+
destination = getDestination(arc);
|
1935
|
+
if (getNodePrevious(destination) == source)
|
1936
|
+
setNodePrevious(target, destination);
|
1937
|
+
}
|
1938
|
+
|
1939
|
+
// Fib Heap refs
|
1940
|
+
remapNodeFibHeapReferencesOntoNode(source, target);
|
1941
|
+
remapNodeFibHeapReferencesOntoNode(twinSource, twinTarget);
|
1942
|
+
|
1943
|
+
// Starting point
|
1944
|
+
if (startingNode == source)
|
1945
|
+
startingNode = target;
|
1946
|
+
else if (startingNode == twinSource)
|
1947
|
+
startingNode = twinTarget;
|
1948
|
+
|
1949
|
+
if (getNode(slowPath) == twinSource)
|
1950
|
+
slowPath = getNextInSequence(slowPath);
|
1951
|
+
if (getNode(fastPath) == twinSource)
|
1952
|
+
fastPath = getNextInSequence(fastPath);
|
1953
|
+
|
1954
|
+
// Next node
|
1955
|
+
if (source == activeNode) {
|
1956
|
+
activeNode = target;
|
1957
|
+
todo =
|
1958
|
+
&todoLists[getNodeID(activeNode) + nodeCount(graph)];
|
1959
|
+
}
|
1960
|
+
concatenateTodoLists(target, source);
|
1961
|
+
|
1962
|
+
if (twinSource == activeNode) {
|
1963
|
+
activeNode = twinTarget;
|
1964
|
+
todo =
|
1965
|
+
&todoLists[getNodeID(activeNode) + nodeCount(graph)];
|
1966
|
+
}
|
1967
|
+
}
|
1968
|
+
|
1969
|
+
// Replaces two consecutive nodes into a single equivalent node
|
1970
|
+
// The extra memory is freed
|
1971
|
+
static void concatenateNodesAndVaccinate(Node * nodeA, Node * nodeB,
|
1972
|
+
Graph * graph)
|
1973
|
+
{
|
1974
|
+
PassageMarkerI marker, tmpMarker;
|
1975
|
+
Node *twinA = getTwinNode(nodeA);
|
1976
|
+
Node *twinB = getTwinNode(nodeB);
|
1977
|
+
Arc *arc;
|
1978
|
+
|
1979
|
+
//velvetLog("Concatenating nodes %ld and %ld\n", getNodeID(nodeA), getNodeID(nodeB));
|
1980
|
+
// Arc management:
|
1981
|
+
// Freeing useless arcs
|
1982
|
+
while (getArc(nodeA) != NULL)
|
1983
|
+
destroyArc(getArc(nodeA), graph);
|
1984
|
+
|
1985
|
+
// Correct arcs
|
1986
|
+
for (arc = getArc(nodeB); arc != NULL; arc = getNextArc(arc)) {
|
1987
|
+
if (getDestination(arc) != twinB)
|
1988
|
+
createAnalogousArc(nodeA, getDestination(arc), arc, graph);
|
1989
|
+
else
|
1990
|
+
createAnalogousArc(nodeA, twinA, arc, graph);
|
1991
|
+
}
|
1992
|
+
|
1993
|
+
// Passage marker management in node A:
|
1994
|
+
for (marker = getMarker(nodeA); marker != NULL_IDX;
|
1995
|
+
marker = getNextInNode(marker))
|
1996
|
+
if (isTerminal(marker))
|
1997
|
+
incrementFinishOffset(marker,
|
1998
|
+
getNodeLength(nodeB));
|
1999
|
+
|
2000
|
+
// Swapping new born passageMarkers from B to A
|
2001
|
+
for (marker = getMarker(nodeB); marker != NULL_IDX; marker = tmpMarker) {
|
2002
|
+
tmpMarker = getNextInNode(marker);
|
2003
|
+
|
2004
|
+
if (isInitial(marker)) {
|
2005
|
+
extractPassageMarker(marker);
|
2006
|
+
transposePassageMarker(marker, nodeA);
|
2007
|
+
incrementStartOffset(marker, getNodeLength(nodeA));
|
2008
|
+
} else
|
2009
|
+
disconnectNextPassageMarker(getPreviousInSequence
|
2010
|
+
(marker), graph);
|
2011
|
+
}
|
2012
|
+
|
2013
|
+
// Read starts
|
2014
|
+
concatenateReadStarts(nodeA, nodeB, graph);
|
2015
|
+
|
2016
|
+
// Descriptor management
|
2017
|
+
appendDescriptors(nodeA, nodeB);
|
2018
|
+
|
2019
|
+
// Update uniqueness:
|
2020
|
+
setUniqueness(nodeA, getUniqueness(nodeA) || getUniqueness(nodeB));
|
2021
|
+
|
2022
|
+
#ifndef SINGLE_COV_CAT
|
2023
|
+
Category cat;
|
2024
|
+
for (cat = 0; cat < CATEGORIES; cat++) {
|
2025
|
+
// Update virtual coverage
|
2026
|
+
incrementVirtualCoverage(nodeA, cat,
|
2027
|
+
getVirtualCoverage(nodeB, cat));
|
2028
|
+
// Update virtual coverage
|
2029
|
+
incrementOriginalVirtualCoverage(nodeA, cat,
|
2030
|
+
getOriginalVirtualCoverage(nodeB, cat));
|
2031
|
+
}
|
2032
|
+
#else
|
2033
|
+
incrementVirtualCoverage(nodeA, getVirtualCoverage(nodeB));
|
2034
|
+
#endif
|
2035
|
+
|
2036
|
+
// Freeing gobbled node
|
2037
|
+
destroyNode(nodeB, graph);
|
2038
|
+
}
|
2039
|
+
|
2040
|
+
static void simplifyNode(Node * node)
|
2041
|
+
{
|
2042
|
+
Node *twin = getTwinNode(node);
|
2043
|
+
Node *destination, *twinDestination;
|
2044
|
+
|
2045
|
+
if (!hasSingleArc(node))
|
2046
|
+
return;
|
2047
|
+
|
2048
|
+
destination = getDestination(getArc(node));
|
2049
|
+
twinDestination = getTwinNode(destination);
|
2050
|
+
|
2051
|
+
while (hasSingleArc(node)
|
2052
|
+
&& hasSingleArc(twinDestination)
|
2053
|
+
&& destination != twin && destination != node) {
|
2054
|
+
transferNodeData(destination, node);
|
2055
|
+
concatenateNodesAndVaccinate(node, destination, graph);
|
2056
|
+
|
2057
|
+
if (!hasSingleArc(node))
|
2058
|
+
return;
|
2059
|
+
destination = getDestination(getArc(node));
|
2060
|
+
twinDestination = getTwinNode(destination);
|
2061
|
+
}
|
2062
|
+
|
2063
|
+
}
|
2064
|
+
|
2065
|
+
static void concatenatePathNodes(PassageMarkerI pathStart)
|
2066
|
+
{
|
2067
|
+
PassageMarkerI pathMarker;
|
2068
|
+
|
2069
|
+
//velvetLog("Removing null loops\n");
|
2070
|
+
for (pathMarker = pathStart; pathMarker != NULL_IDX;
|
2071
|
+
pathMarker = getNextInSequence(pathMarker)) {
|
2072
|
+
simplifyNode(getNode(pathMarker));
|
2073
|
+
}
|
2074
|
+
}
|
2075
|
+
|
2076
|
+
#define SLOW_TO_FAST true
|
2077
|
+
#define FAST_TO_SLOW false
|
2078
|
+
|
2079
|
+
static void cleanUpRedundancy()
|
2080
|
+
{
|
2081
|
+
PassageMarkerI slowMarker = getNextInSequence(slowPath);
|
2082
|
+
PassageMarkerI fastMarker = getNextInSequence(fastPath);
|
2083
|
+
Coordinate slowLength, fastLength;
|
2084
|
+
Coordinate fastConstraint = 0;
|
2085
|
+
Coordinate slowConstraint = 0;
|
2086
|
+
Coordinate finalLength;
|
2087
|
+
Node *slowNode, *fastNode;
|
2088
|
+
|
2089
|
+
//velvetLog("Correcting new redundancy\n");
|
2090
|
+
mapSlowOntoFast();
|
2091
|
+
finalLength = mapDistancesOntoPaths();
|
2092
|
+
|
2093
|
+
while (slowMarker != NULL_IDX && fastMarker != NULL_IDX) {
|
2094
|
+
if (isTerminal(slowMarker))
|
2095
|
+
slowLength = finalLength;
|
2096
|
+
else {
|
2097
|
+
slowLength =
|
2098
|
+
slowToFastMapping[getPassageMarkerFinish
|
2099
|
+
(slowMarker) - 1];
|
2100
|
+
if (slowLength < slowConstraint)
|
2101
|
+
slowLength = slowConstraint;
|
2102
|
+
}
|
2103
|
+
|
2104
|
+
fastLength = getPassageMarkerFinish(fastMarker) - 1;
|
2105
|
+
if (fastLength < fastConstraint)
|
2106
|
+
fastLength = fastConstraint;
|
2107
|
+
|
2108
|
+
slowNode = getNode(slowMarker);
|
2109
|
+
fastNode = getNode(fastMarker);
|
2110
|
+
|
2111
|
+
if (slowNode == fastNode) {
|
2112
|
+
if (fastLength > slowLength)
|
2113
|
+
slowConstraint = fastLength;
|
2114
|
+
else if (fastLength < slowLength)
|
2115
|
+
fastConstraint = slowLength;
|
2116
|
+
|
2117
|
+
slowMarker = getNextInSequence(slowMarker);
|
2118
|
+
fastMarker = getNextInSequence(fastMarker);
|
2119
|
+
} else if (slowNode == getTwinNode(fastNode)) {
|
2120
|
+
if (fastLength > slowLength)
|
2121
|
+
slowConstraint = fastLength;
|
2122
|
+
else if (fastLength < slowLength)
|
2123
|
+
fastConstraint = slowLength;
|
2124
|
+
|
2125
|
+
slowMarker = getNextInSequence(slowMarker);
|
2126
|
+
fastMarker = getNextInSequence(fastMarker);
|
2127
|
+
foldSymmetricalNode(fastNode);
|
2128
|
+
} else if (markerLeadsToNode(slowMarker, fastNode)) {
|
2129
|
+
reduceSlowNodes(slowMarker, fastNode);
|
2130
|
+
remapEmptyPathOntoMiddlePath(fastMarker,
|
2131
|
+
slowMarker);
|
2132
|
+
while (getNode(slowMarker) != fastNode)
|
2133
|
+
slowMarker = getNextInSequence(slowMarker);
|
2134
|
+
} else if (markerLeadsToNode(fastMarker, slowNode)) {
|
2135
|
+
remapEmptyPathOntoMiddlePath(slowMarker,
|
2136
|
+
fastMarker);
|
2137
|
+
while (getNode(fastMarker) != slowNode)
|
2138
|
+
fastMarker = getNextInSequence(fastMarker);
|
2139
|
+
} else if (slowLength == fastLength) {
|
2140
|
+
remapNodeOntoNeighbour(slowNode, slowMarker,
|
2141
|
+
fastNode, fastMarker);
|
2142
|
+
slowMarker = getNextInSequence(slowMarker);
|
2143
|
+
fastMarker = getNextInSequence(fastMarker);
|
2144
|
+
} else if (slowLength < fastLength) {
|
2145
|
+
remapBackOfNodeOntoNeighbour(fastNode, fastMarker,
|
2146
|
+
slowNode, slowMarker,
|
2147
|
+
FAST_TO_SLOW);
|
2148
|
+
slowMarker = getNextInSequence(slowMarker);
|
2149
|
+
} else {
|
2150
|
+
remapBackOfNodeOntoNeighbour(slowNode, slowMarker,
|
2151
|
+
fastNode, fastMarker,
|
2152
|
+
SLOW_TO_FAST);
|
2153
|
+
fastMarker = getNextInSequence(fastMarker);
|
2154
|
+
}
|
2155
|
+
|
2156
|
+
fflush(stdout);
|
2157
|
+
}
|
2158
|
+
|
2159
|
+
//velvetLog("Done with path\n");
|
2160
|
+
|
2161
|
+
while (!isInitial(slowPath))
|
2162
|
+
slowPath = getPreviousInSequence(slowPath);
|
2163
|
+
while (!isInitial(fastPath))
|
2164
|
+
fastPath = getPreviousInSequence(fastPath);
|
2165
|
+
|
2166
|
+
//velvetLog("Concatenation\n");
|
2167
|
+
|
2168
|
+
// Freeing up memory
|
2169
|
+
if (slowMarker != NULL_IDX)
|
2170
|
+
concatenatePathNodes(slowPath);
|
2171
|
+
else
|
2172
|
+
concatenatePathNodes(fastPath);
|
2173
|
+
|
2174
|
+
//velvetLog("Vaccinatting\n");
|
2175
|
+
|
2176
|
+
destroyPaths();
|
2177
|
+
|
2178
|
+
// Cleaning up silly structures
|
2179
|
+
//vaccinatePath(&returnValue);
|
2180
|
+
|
2181
|
+
//velvetLog("Clean up done\n");
|
2182
|
+
//fflush(stdout);
|
2183
|
+
}
|
2184
|
+
|
2185
|
+
static boolean pathContainsReference(PassageMarkerI path) {
|
2186
|
+
PassageMarkerI marker, marker2;
|
2187
|
+
|
2188
|
+
for (marker = getNextInSequence(path); !isTerminal(marker);
|
2189
|
+
marker = getNextInSequence(marker))
|
2190
|
+
for (marker2 = getMarker(getNode(marker)); marker2 != NULL_IDX; marker2 = getNextInNode(marker2))
|
2191
|
+
if (marker2 != marker && sequenceCategories[getAbsolutePassMarkerSeqID(marker2) - 1] == REFERENCE)
|
2192
|
+
return true;
|
2193
|
+
|
2194
|
+
return false;
|
2195
|
+
|
2196
|
+
}
|
2197
|
+
|
2198
|
+
static void comparePaths(Node * destination, Node * origin)
|
2199
|
+
{
|
2200
|
+
IDnum slowLength, fastLength;
|
2201
|
+
Node *fastNode, *slowNode;
|
2202
|
+
IDnum i;
|
2203
|
+
PassageMarkerI marker;
|
2204
|
+
|
2205
|
+
//Measure lengths
|
2206
|
+
slowLength = fastLength = 0;
|
2207
|
+
fastNode = destination;
|
2208
|
+
slowNode = origin;
|
2209
|
+
|
2210
|
+
while (fastNode != slowNode) {
|
2211
|
+
if (getNodeTime(fastNode) > getNodeTime(slowNode)) {
|
2212
|
+
fastLength++;
|
2213
|
+
fastNode = getNodePrevious(fastNode);
|
2214
|
+
} else if (getNodeTime(fastNode) < getNodeTime(slowNode)) {
|
2215
|
+
slowLength++;
|
2216
|
+
slowNode = getNodePrevious(slowNode);
|
2217
|
+
} else if (isPreviousToNode(slowNode, fastNode)) {
|
2218
|
+
while (fastNode != slowNode) {
|
2219
|
+
fastLength++;
|
2220
|
+
fastNode = getNodePrevious(fastNode);
|
2221
|
+
}
|
2222
|
+
} else if (isPreviousToNode(fastNode, slowNode)) {
|
2223
|
+
while (slowNode != fastNode) {
|
2224
|
+
slowLength++;
|
2225
|
+
slowNode = getNodePrevious(slowNode);
|
2226
|
+
}
|
2227
|
+
} else {
|
2228
|
+
fastLength++;
|
2229
|
+
fastNode = getNodePrevious(fastNode);
|
2230
|
+
slowLength++;
|
2231
|
+
slowNode = getNodePrevious(slowNode);
|
2232
|
+
}
|
2233
|
+
|
2234
|
+
if (slowLength > MAXNODELENGTH
|
2235
|
+
|| fastLength > MAXNODELENGTH)
|
2236
|
+
return;
|
2237
|
+
}
|
2238
|
+
|
2239
|
+
if (fastLength == 0)
|
2240
|
+
return;
|
2241
|
+
|
2242
|
+
//Backtracking to record actual paths
|
2243
|
+
fastPath = addUncertainPassageMarker(1, destination);
|
2244
|
+
setPassageMarkerStatus(fastPath, true);
|
2245
|
+
|
2246
|
+
for (i = 0; i < fastLength; i++) {
|
2247
|
+
marker =
|
2248
|
+
addUncertainPassageMarker(1,
|
2249
|
+
getNodePrevious(getNode
|
2250
|
+
(fastPath)));
|
2251
|
+
setPassageMarkerStatus(marker, true);
|
2252
|
+
connectPassageMarkers(marker, fastPath, graph);
|
2253
|
+
fastPath = marker;
|
2254
|
+
}
|
2255
|
+
|
2256
|
+
slowPath = addUncertainPassageMarker(2, destination);
|
2257
|
+
setPassageMarkerStatus(slowPath, true);
|
2258
|
+
|
2259
|
+
marker = addUncertainPassageMarker(2, origin);
|
2260
|
+
setPassageMarkerStatus(marker, true);
|
2261
|
+
connectPassageMarkers(marker, slowPath, graph);
|
2262
|
+
slowPath = marker;
|
2263
|
+
|
2264
|
+
for (i = 0; i < slowLength; i++) {
|
2265
|
+
marker =
|
2266
|
+
addUncertainPassageMarker(2,
|
2267
|
+
getNodePrevious(getNode
|
2268
|
+
(slowPath)));
|
2269
|
+
setPassageMarkerStatus(marker, true);
|
2270
|
+
connectPassageMarkers(marker, slowPath, graph);
|
2271
|
+
slowPath = marker;
|
2272
|
+
}
|
2273
|
+
|
2274
|
+
// Avoid merging parallel Reference sequences
|
2275
|
+
if (pathContainsReference(fastPath) && pathContainsReference(slowPath)) {
|
2276
|
+
destroyPaths();
|
2277
|
+
return;
|
2278
|
+
}
|
2279
|
+
//Extract sequences
|
2280
|
+
if (!extractSequence(fastPath, fastSequence)
|
2281
|
+
|| !extractSequence(slowPath, slowSequence)) {
|
2282
|
+
destroyPaths();
|
2283
|
+
return;
|
2284
|
+
}
|
2285
|
+
//Compare sequences
|
2286
|
+
if (compareSequences(fastSequence, slowSequence)) {
|
2287
|
+
cleanUpRedundancy();
|
2288
|
+
return;
|
2289
|
+
}
|
2290
|
+
//velvetLog("\tFinished comparing paths, changes made\n");
|
2291
|
+
destroyPaths();
|
2292
|
+
}
|
2293
|
+
|
2294
|
+
static void tourBusArc(Node * origin, Arc * arc, Time originTime)
|
2295
|
+
{
|
2296
|
+
Node *destination = getDestination(arc);
|
2297
|
+
Time arcTime, totalTime, destinationTime;
|
2298
|
+
IDnum nodeIndex = getNodeID(destination) + nodeCount(graph);
|
2299
|
+
Node *oldPrevious = previous[nodeIndex];
|
2300
|
+
|
2301
|
+
if (oldPrevious == origin || getNodeStatus(destination) == 1)
|
2302
|
+
return;
|
2303
|
+
|
2304
|
+
arcTime =
|
2305
|
+
((Time) getNodeLength(origin)) / ((Time) getMultiplicity(arc));
|
2306
|
+
totalTime = originTime + arcTime;
|
2307
|
+
|
2308
|
+
destinationTime = times[nodeIndex];
|
2309
|
+
|
2310
|
+
if (destinationTime == -1) {
|
2311
|
+
setNodeTime(destination, totalTime);
|
2312
|
+
dheapNodes[nodeIndex] =
|
2313
|
+
insertNodeIntoDHeap(dheap, totalTime, destination);
|
2314
|
+
previous[nodeIndex] = origin;
|
2315
|
+
return;
|
2316
|
+
} else if (destinationTime > totalTime) {
|
2317
|
+
if (dheapNodes[nodeIndex] == NULL) {
|
2318
|
+
//velvetLog("Already expanded though\n");
|
2319
|
+
return;
|
2320
|
+
}
|
2321
|
+
|
2322
|
+
setNodeTime(destination, totalTime);
|
2323
|
+
replaceKeyInDHeap(dheap, dheapNodes[nodeIndex], totalTime);
|
2324
|
+
previous[nodeIndex] = origin;
|
2325
|
+
|
2326
|
+
comparePaths(destination, oldPrevious);
|
2327
|
+
return;
|
2328
|
+
} else {
|
2329
|
+
if (destinationTime == getNodeTime(origin)
|
2330
|
+
&& isPreviousToNode(destination, origin)) {
|
2331
|
+
return;
|
2332
|
+
}
|
2333
|
+
|
2334
|
+
comparePaths(destination, origin);
|
2335
|
+
}
|
2336
|
+
}
|
2337
|
+
|
2338
|
+
static void initializeTodoLists()
|
2339
|
+
{
|
2340
|
+
IDnum index;
|
2341
|
+
Node *node;
|
2342
|
+
Arc *arc;
|
2343
|
+
Ticket *tkt;
|
2344
|
+
IDnum nodes = nodeCount(graph);
|
2345
|
+
Ticket **currentList;
|
2346
|
+
Ticket *currentTicket, *tmp;
|
2347
|
+
Node *destination;
|
2348
|
+
|
2349
|
+
velvetLog("Initializing todo lists\n");
|
2350
|
+
|
2351
|
+
for (index = -nodes; index <= nodes; index++) {
|
2352
|
+
node = getNodeInGraph(graph, index);
|
2353
|
+
if (node == NULL)
|
2354
|
+
continue;
|
2355
|
+
|
2356
|
+
currentList = &todoLists[index + nodes];
|
2357
|
+
*currentList = NULL;
|
2358
|
+
|
2359
|
+
for (arc = getArc(node); arc != NULL;
|
2360
|
+
arc = getNextArc(arc)) {
|
2361
|
+
destination = getDestination(arc);
|
2362
|
+
|
2363
|
+
if (destination == node)
|
2364
|
+
continue;
|
2365
|
+
|
2366
|
+
tkt = newTicket();
|
2367
|
+
tkt->id_a = getNodeID(destination);
|
2368
|
+
|
2369
|
+
currentTicket = *currentList;
|
2370
|
+
if (currentTicket == NULL
|
2371
|
+
|| currentTicket->id_a > tkt->id_a) {
|
2372
|
+
tkt->next = currentTicket;
|
2373
|
+
*currentList = tkt;
|
2374
|
+
continue;
|
2375
|
+
}
|
2376
|
+
|
2377
|
+
while (currentTicket->next != NULL
|
2378
|
+
&& currentTicket->next->id_a < tkt->id_a)
|
2379
|
+
currentTicket = currentTicket->next;
|
2380
|
+
|
2381
|
+
tmp = currentTicket->next;
|
2382
|
+
currentTicket->next = tkt;
|
2383
|
+
tkt->next = tmp;
|
2384
|
+
}
|
2385
|
+
}
|
2386
|
+
|
2387
|
+
velvetLog("Done with initilization\n");
|
2388
|
+
}
|
2389
|
+
|
2390
|
+
static void tourBusNode(Node * node)
|
2391
|
+
{
|
2392
|
+
Arc *arc;
|
2393
|
+
Node *destination;
|
2394
|
+
Time nodeTime = getNodeTime(node);
|
2395
|
+
IDnum id;
|
2396
|
+
|
2397
|
+
dbgCounter++;
|
2398
|
+
if (dbgCounter % 10000 == 0) {
|
2399
|
+
velvetLog("%li / %li nodes visited\n", (long) dbgCounter, (long) nodeCount(graph));
|
2400
|
+
fflush(stdout);
|
2401
|
+
}
|
2402
|
+
|
2403
|
+
setSingleNodeStatus(node, 2);
|
2404
|
+
activeNode = node;
|
2405
|
+
todo = &todoLists[getNodeID(activeNode) + nodeCount(graph)];
|
2406
|
+
done = NULL;
|
2407
|
+
|
2408
|
+
while ((id = nextTodoTicket()) != 0) {
|
2409
|
+
destination = getNodeInGraph(graph, id);
|
2410
|
+
|
2411
|
+
// Node doesn't exist anymore
|
2412
|
+
if (destination == NULL)
|
2413
|
+
continue;
|
2414
|
+
|
2415
|
+
arc = getArcBetweenNodes(activeNode, destination, graph);
|
2416
|
+
|
2417
|
+
// Arc does not exist for some reason (?)
|
2418
|
+
if (arc == NULL)
|
2419
|
+
continue;
|
2420
|
+
|
2421
|
+
tourBusArc(activeNode, arc, nodeTime);
|
2422
|
+
}
|
2423
|
+
|
2424
|
+
freeDoneTickets();
|
2425
|
+
}
|
2426
|
+
|
2427
|
+
static Coordinate getTipLength(Node * node)
|
2428
|
+
{
|
2429
|
+
Node *current = getTwinNode(node);
|
2430
|
+
Coordinate length = 0;
|
2431
|
+
|
2432
|
+
if (simpleArcCount(current) > 1)
|
2433
|
+
return getNodeLength(node);
|
2434
|
+
|
2435
|
+
while (current != NULL && simpleArcCount(getTwinNode(current)) < 2
|
2436
|
+
&& simpleArcCount(current) < 2) {
|
2437
|
+
length += getNodeLength(current);
|
2438
|
+
current = getDestination(getArc(current));
|
2439
|
+
}
|
2440
|
+
|
2441
|
+
return length;
|
2442
|
+
}
|
2443
|
+
|
2444
|
+
void clipTipsHard(Graph * graph, boolean conserveLong)
|
2445
|
+
{
|
2446
|
+
IDnum index;
|
2447
|
+
Node *current, *twin;
|
2448
|
+
boolean modified = true;
|
2449
|
+
int Wordlength = getWordLength(graph);
|
2450
|
+
PassageMarkerI marker;
|
2451
|
+
|
2452
|
+
velvetLog("Clipping short tips off graph, drastic\n");
|
2453
|
+
|
2454
|
+
while (modified) {
|
2455
|
+
modified = false;
|
2456
|
+
for (index = 1; index <= nodeCount(graph); index++) {
|
2457
|
+
current = getNodeInGraph(graph, index);
|
2458
|
+
|
2459
|
+
if (current == NULL)
|
2460
|
+
continue;
|
2461
|
+
|
2462
|
+
if (conserveLong && getMarker(current))
|
2463
|
+
continue;
|
2464
|
+
|
2465
|
+
twin = getTwinNode(current);
|
2466
|
+
|
2467
|
+
if (getArc(current) == NULL
|
2468
|
+
&& getTipLength(current) < 2 * Wordlength) {
|
2469
|
+
while ((marker = getMarker(current))) {
|
2470
|
+
if (!isInitial(marker)
|
2471
|
+
&& !isTerminal(marker))
|
2472
|
+
deleteNextPassageMarker
|
2473
|
+
(getPreviousInSequence
|
2474
|
+
(marker), graph);
|
2475
|
+
destroyPassageMarker(marker);
|
2476
|
+
}
|
2477
|
+
destroyNode(current, graph);
|
2478
|
+
modified = true;
|
2479
|
+
} else if (getArc(twin) == NULL
|
2480
|
+
&& getTipLength(twin) <
|
2481
|
+
2 * Wordlength) {
|
2482
|
+
while ((marker = getMarker(current))) {
|
2483
|
+
if (!isInitial(marker)
|
2484
|
+
&& !isTerminal(marker))
|
2485
|
+
deleteNextPassageMarker
|
2486
|
+
(getPreviousInSequence
|
2487
|
+
(marker), graph);
|
2488
|
+
destroyPassageMarker(marker);
|
2489
|
+
}
|
2490
|
+
destroyNode(twin, graph);
|
2491
|
+
modified = true;
|
2492
|
+
}
|
2493
|
+
}
|
2494
|
+
}
|
2495
|
+
|
2496
|
+
concatenateGraph(graph);
|
2497
|
+
velvetLog("%li nodes left\n", (long) nodeCount(graph));
|
2498
|
+
}
|
2499
|
+
|
2500
|
+
static void tourBus(Node * startingPoint)
|
2501
|
+
{
|
2502
|
+
Node *currentNode = startingPoint;
|
2503
|
+
IDnum nodeID = getNodeID(startingPoint) + nodeCount(graph);
|
2504
|
+
|
2505
|
+
//velvetLog("Tour bus from node %ld...\n", (long) getNodeID(startingPoint));
|
2506
|
+
|
2507
|
+
times[nodeID] = 0;
|
2508
|
+
previous[nodeID] = currentNode;
|
2509
|
+
|
2510
|
+
while (currentNode != NULL) {
|
2511
|
+
dheapNodes[getNodeID(currentNode) + nodeCount(graph)] =
|
2512
|
+
NULL;
|
2513
|
+
tourBusNode(currentNode);
|
2514
|
+
currentNode = removeNextNodeFromDHeap(dheap);
|
2515
|
+
}
|
2516
|
+
}
|
2517
|
+
|
2518
|
+
void correctGraph(Graph * argGraph, ShortLength * argSequenceLengths, Category * argSequenceCategories, boolean conserveLong)
|
2519
|
+
{
|
2520
|
+
IDnum nodes;
|
2521
|
+
IDnum index;
|
2522
|
+
double *FmatrixMem;
|
2523
|
+
|
2524
|
+
//Setting global params
|
2525
|
+
graph = argGraph;
|
2526
|
+
WORDLENGTH = getWordLength(graph);
|
2527
|
+
sequenceLengths = argSequenceLengths;
|
2528
|
+
sequenceCategories = argSequenceCategories;
|
2529
|
+
dbgCounter = 0;
|
2530
|
+
// Done with global params
|
2531
|
+
|
2532
|
+
velvetLog("Correcting graph with cutoff %f\n", MAXDIVERGENCE);
|
2533
|
+
|
2534
|
+
nodes = nodeCount(graph);
|
2535
|
+
|
2536
|
+
// Allocating memory
|
2537
|
+
times = mallocOrExit(2 * nodes + 1, Time);
|
2538
|
+
previous = mallocOrExit(2 * nodes + 1, Node *);
|
2539
|
+
dheapNodes = mallocOrExit(2 * nodes + 1, DFibHeapNode *);
|
2540
|
+
|
2541
|
+
for (index = 0; index < (2 * nodeCount(graph) + 1); index++) {
|
2542
|
+
times[index] = -1;
|
2543
|
+
previous[index] = NULL;
|
2544
|
+
dheapNodes[index] = NULL;
|
2545
|
+
}
|
2546
|
+
|
2547
|
+
dheap = newDFibHeap();
|
2548
|
+
|
2549
|
+
fastSequence = newTightString(MAXREADLENGTH);
|
2550
|
+
slowSequence = newTightString(MAXREADLENGTH);
|
2551
|
+
fastToSlowMapping = callocOrExit(MAXREADLENGTH + 1, Coordinate);
|
2552
|
+
slowToFastMapping = callocOrExit(MAXREADLENGTH + 1, Coordinate);
|
2553
|
+
Fmatrix = mallocOrExit(MAXREADLENGTH + 1, double *);
|
2554
|
+
FmatrixMem = callocOrExit((MAXREADLENGTH + 1) * (MAXREADLENGTH + 1), double);
|
2555
|
+
for (index = 0; index < MAXREADLENGTH + 1; index++)
|
2556
|
+
Fmatrix[index] = FmatrixMem + index * (MAXREADLENGTH + 1);
|
2557
|
+
|
2558
|
+
eligibleStartingPoints = mallocOrExit(2 * nodes + 1, IDnum);
|
2559
|
+
progressStatus = callocOrExit(2 * nodes + 1, boolean);
|
2560
|
+
todoLists = callocOrExit(2 * nodes + 1, Ticket *);
|
2561
|
+
//Done with memory
|
2562
|
+
|
2563
|
+
resetNodeStatus(graph);
|
2564
|
+
determineEligibleStartingPoints();
|
2565
|
+
initializeTodoLists();
|
2566
|
+
activateArcLookupTable(graph);
|
2567
|
+
|
2568
|
+
while ((startingNode = nextStartingPoint()) != NULL) {
|
2569
|
+
//velvetLog("Going through the cycle...\n");
|
2570
|
+
tourBus(startingNode);
|
2571
|
+
updateNodeStatus(startingNode);
|
2572
|
+
}
|
2573
|
+
|
2574
|
+
deactivateArcLookupTable(graph);
|
2575
|
+
concatenateGraph(graph);
|
2576
|
+
|
2577
|
+
clipTipsHard(graph, conserveLong);
|
2578
|
+
|
2579
|
+
//Deallocating globals
|
2580
|
+
free(times);
|
2581
|
+
free(previous);
|
2582
|
+
free(dheapNodes);
|
2583
|
+
destroyDHeap(dheap);
|
2584
|
+
|
2585
|
+
destroyTightString(fastSequence);
|
2586
|
+
destroyTightString(slowSequence);
|
2587
|
+
free(fastToSlowMapping);
|
2588
|
+
free(slowToFastMapping);
|
2589
|
+
free(Fmatrix);
|
2590
|
+
free(FmatrixMem);
|
2591
|
+
|
2592
|
+
free(eligibleStartingPoints);
|
2593
|
+
free(progressStatus);
|
2594
|
+
free(todoLists);
|
2595
|
+
|
2596
|
+
if (ticketMemory != NULL)
|
2597
|
+
destroyRecycleBin(ticketMemory);
|
2598
|
+
|
2599
|
+
free(sequenceLengths);
|
2600
|
+
//Done deallocating
|
2601
|
+
}
|
2602
|
+
|
2603
|
+
void setMaxReadLength(int value)
|
2604
|
+
{
|
2605
|
+
if (value < 0) {
|
2606
|
+
velvetLog("Negative branch length %i!\n", value);
|
2607
|
+
velvetLog("Exiting...\n");
|
2608
|
+
#ifdef DEBUG
|
2609
|
+
abort();
|
2610
|
+
#endif
|
2611
|
+
exit(1);
|
2612
|
+
}
|
2613
|
+
MAXREADLENGTH = value;
|
2614
|
+
MAXNODELENGTH = 2 * value;
|
2615
|
+
}
|
2616
|
+
|
2617
|
+
void setMaxGaps(int value)
|
2618
|
+
{
|
2619
|
+
if (value < 0) {
|
2620
|
+
velvetLog("Negative max gap count %i!\n", value);
|
2621
|
+
velvetLog("Exiting...\n");
|
2622
|
+
#ifdef DEBUG
|
2623
|
+
abort();
|
2624
|
+
#endif
|
2625
|
+
exit(1);
|
2626
|
+
}
|
2627
|
+
MAXGAPS = value;
|
2628
|
+
}
|
2629
|
+
|
2630
|
+
void setMaxDivergence(double value)
|
2631
|
+
{
|
2632
|
+
if (value < 0 || value > 1) {
|
2633
|
+
velvetLog("Divergence rate %lf out of bounds [0,1]!\n",
|
2634
|
+
value);
|
2635
|
+
velvetLog("Exiting...\n");
|
2636
|
+
#ifdef DEBUG
|
2637
|
+
abort();
|
2638
|
+
#endif
|
2639
|
+
exit(1);
|
2640
|
+
}
|
2641
|
+
MAXDIVERGENCE = value;
|
2642
|
+
}
|