<NME> ordered_region_overlap_matcher.h
<BEF> ADDFILE
<MSG> renamed files

<DFF> @@ -0,0 +1,75 @@
+/* The MIT License
+
+   Copyright (c) 2014 Adrian Tan <atks@umich.edu>
+
+   Permission is hereby granted, free of charge, to any person obtaining a copy
+   of this software and associated documentation files (the "Software"), to deal
+   in the Software without restriction, including without limitation the rights
+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   copies of the Software, and to permit persons to whom the Software is
+   furnished to do so, subject to the following conditions:
+
+   The above copyright notice and this permission notice shall be included in
+   all copies or substantial portions of the Software.
+
+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   THE SOFTWARE.
+*/
+
+#ifndef OVERLAP_REGION_MATCHER_H
+#define OVERLAP_REGION_MATCHER_H
+
+#include "htslib/vcf.h"
+#include "htslib/kseq.h"
+#include "program.h"
+#include "hts_utils.h"
+#include "tbx_ordered_reader.h"
+#include "interval_tree.h"
+#include <list>
+#include "bed.h"
+
+class OrderedRegionOverlapMatcher
+{
+    public:
+
+    ///////////
+    //options//
+    ///////////
+    std::string input_file;   
+    
+    ///////
+    //i/o//
+    ///////
+    TBXOrderedReader *todr;
+    
+    
+    kstring_t s;
+    
+    GenomeInterval current_interval;
+    std::list<BEDRecord> buffer;
+    bool end_of_file;
+    
+    OrderedRegionOverlapMatcher(std::string& file);
+
+    ~OrderedRegionOverlapMatcher();
+    /**
+     *
+     */
+    bool overlaps_with(std::string& chrom, int32_t start1, int32_t end1);
+    
+    /**
+     * Clear buffer.
+     */
+    void clear_buffer();
+     
+    
+
+    private:
+};
+    
+#endif

{'commit': 'diff --git a/ordered_region_overlap_matcher.cpp b/ordered_region_overlap_matcher.cpp\nnew file mode 100644\nindex 0000000..b52f42b\n--- /dev/null\n+++ b/ordered_region_overlap_matcher.cpp\n@@ -0,0 +1,136 @@\n+/* The MIT License\n+\n+   Copyright (c) 2014 Adrian Tan <atks@umich.edu>\n+\n+   Permission is hereby granted, free of charge, to any person obtaining a copy\n+   of this software and associated documentation files (the "Software"), to deal\n+   in the Software without restriction, including without limitation the rights\n+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+   copies of the Software, and to permit persons to whom the Software is\n+   furnished to do so, subject to the following conditions:\n+\n+   The above copyright notice and this permission notice shall be included in\n+   all copies or substantial portions of the Software.\n+\n+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+   THE SOFTWARE.\n+*/\n+\n+#include "ordered_region_overlap_matcher.h"\n+\n+OrderedRegionOverlapMatcher::OrderedRegionOverlapMatcher(std::string& file)\n+{\n+    todr = new TBXOrderedReader(file);\n+    s = {0,0,0};\n+    current_interval.seq = "";\n+};\n+\n+\n+ \n+OrderedRegionOverlapMatcher::~OrderedRegionOverlapMatcher() {};\n+\n+/**\n+ *\n+ */\n+bool OrderedRegionOverlapMatcher::overlaps_with(std::string& chrom, int32_t start1, int32_t end1)\n+{\n+    \n+    std::cerr << "DEBUG\\t\\"" << current_interval.seq << "\\"   "  <<  chrom  <<  "\\n";\n+    \n+    bool overlaps = false;\n+    \n+    if (current_interval.seq!=chrom)\n+    {\n+        //std::cerr << "jump to: "  << chrom  <<  "\\n";\n+            \n+        \n+        buffer.clear();\n+        current_interval.set(chrom);\n+        std::cerr << "CRUNNRE " << chrom << "\\n";\n+        todr->jump_to_interval(current_interval);\n+        std::cerr << "completed jump\\n";\n+        exit(1);\n+//            while (todr->read(&s))\n+//            {\n+//                std::cerr << "read in: " << s.s << "\\n";\n+//                BEDRecord br(&s);\n+//                \n+//                if (br.end1<start1)\n+//                {\n+//                    continue;\n+//                }\n+//                \n+//                overlaps = br.start1<=end1;\n+//                \n+//                buffer.push_back(br);\n+//                \n+//                if (br.start1>end1)\n+//                {\n+//                    break;\n+//                }\n+//            }\n+    }\n+    else\n+    {\n+        //process intervals in buffer\n+        std::list<BEDRecord>::iterator i = buffer.begin();\n+        while (i!=buffer.end())\n+        {\n+            //preceding region\n+            if ((*i).end1<start1)\n+            {\n+                i = buffer.erase(i);\n+                continue;\n+            }\n+            \n+            //overlaps\n+            if ((*i).start1<=end1)\n+            {\n+                overlaps = true;\n+                break;\n+            }\n+            else\n+            {\n+                overlaps = false;\n+                break;\n+            }\n+        }\n+        \n+        if (buffer.size()==0 && !overlaps)\n+        {\n+            //add records\n+            while (todr->read(&s))\n+            {\n+                BEDRecord br(&s);\n+                \n+                if (br.end1<start1)\n+                {\n+                    continue;\n+                }\n+                \n+                overlaps = br.start1<=end1;\n+                \n+                buffer.push_back(br);\n+                \n+                if (br.start1>end1)\n+                {\n+                    break;\n+                }\n+            }\n+        }\n+    }\n+    \n+    return overlaps;\n+};\n+\n+/**\n+ * Clear buffer.\n+ */\n+void OrderedRegionOverlapMatcher::clear_buffer()\n+{\n+}\ndiff --git a/ordered_region_overlap_matcher.h b/ordered_region_overlap_matcher.h\nnew file mode 100644\nindex 0000000..ff41c08\n--- /dev/null\n+++ b/ordered_region_overlap_matcher.h\n@@ -0,0 +1,75 @@\n+/* The MIT License\n+\n+   Copyright (c) 2014 Adrian Tan <atks@umich.edu>\n+\n+   Permission is hereby granted, free of charge, to any person obtaining a copy\n+   of this software and associated documentation files (the "Software"), to deal\n+   in the Software without restriction, including without limitation the rights\n+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+   copies of the Software, and to permit persons to whom the Software is\n+   furnished to do so, subject to the following conditions:\n+\n+   The above copyright notice and this permission notice shall be included in\n+   all copies or substantial portions of the Software.\n+\n+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+   THE SOFTWARE.\n+*/\n+\n+#ifndef OVERLAP_REGION_MATCHER_H\n+#define OVERLAP_REGION_MATCHER_H\n+\n+#include "htslib/vcf.h"\n+#include "htslib/kseq.h"\n+#include "program.h"\n+#include "hts_utils.h"\n+#include "tbx_ordered_reader.h"\n+#include "interval_tree.h"\n+#include <list>\n+#include "bed.h"\n+\n+class OrderedRegionOverlapMatcher\n+{\n+    public:\n+\n+    ///////////\n+    //options//\n+    ///////////\n+    std::string input_file;   \n+    \n+    ///////\n+    //i/o//\n+    ///////\n+    TBXOrderedReader *todr;\n+    \n+    \n+    kstring_t s;\n+    \n+    GenomeInterval current_interval;\n+    std::list<BEDRecord> buffer;\n+    bool end_of_file;\n+    \n+    OrderedRegionOverlapMatcher(std::string& file);\n+\n+    ~OrderedRegionOverlapMatcher();\n+    /**\n+     *\n+     */\n+    bool overlaps_with(std::string& chrom, int32_t start1, int32_t end1);\n+    \n+    /**\n+     * Clear buffer.\n+     */\n+    void clear_buffer();\n+     \n+    \n+\n+    private:\n+};\n+    \n+#endif\n', 'commit_subject': 'renamed files', 'repo_name': 'atks/vt', 'committer': {'name': 'Adrian Tan', 'email': 'c020c9680ad37eddd8d67b394f8ae32a2548a468@umich.edu', 'time_sec': '1399387785', 'tz_offset': '-240', 'date': {'seconds': '1399387785'}}, 'commit_tree': '5d1607940a8eba64a06e149ca6befda64eb5c69c', 'commit_message': 'renamed files\n', 'language_name': 'Shell', 'license': 'mit', 'hunks': '@@ -0,0 +1,75 @@\n+/* The MIT License\n+\n+   Copyright (c) 2014 Adrian Tan <atks@umich.edu>\n+\n+   Permission is hereby granted, free of charge, to any person obtaining a copy\n+   of this software and associated documentation files (the "Software"), to deal\n+   in the Software without restriction, including without limitation the rights\n+   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+   copies of the Software, and to permit persons to whom the Software is\n+   furnished to do so, subject to the following conditions:\n+\n+   The above copyright notice and this permission notice shall be included in\n+   all copies or substantial portions of the Software.\n+\n+   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+   THE SOFTWARE.\n+*/\n+\n+#ifndef OVERLAP_REGION_MATCHER_H\n+#define OVERLAP_REGION_MATCHER_H\n+\n+#include "htslib/vcf.h"\n+#include "htslib/kseq.h"\n+#include "program.h"\n+#include "hts_utils.h"\n+#include "tbx_ordered_reader.h"\n+#include "interval_tree.h"\n+#include <list>\n+#include "bed.h"\n+\n+class OrderedRegionOverlapMatcher\n+{\n+    public:\n+\n+    ///////////\n+    //options//\n+    ///////////\n+    std::string input_file;   \n+    \n+    ///////\n+    //i/o//\n+    ///////\n+    TBXOrderedReader *todr;\n+    \n+    \n+    kstring_t s;\n+    \n+    GenomeInterval current_interval;\n+    std::list<BEDRecord> buffer;\n+    bool end_of_file;\n+    \n+    OrderedRegionOverlapMatcher(std::string& file);\n+\n+    ~OrderedRegionOverlapMatcher();\n+    /**\n+     *\n+     */\n+    bool overlaps_with(std::string& chrom, int32_t start1, int32_t end1);\n+    \n+    /**\n+     * Clear buffer.\n+     */\n+    void clear_buffer();\n+     \n+    \n+\n+    private:\n+};\n+    \n+#endif\n', 'addition_count': 75, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/ordered_region_overlap_matcher.h', 'file_extension': '.h', 'before_file': 'ADDFILE', 'message': 'renamed files\n', 'author_name': 'Adrian Tan', 'lang': 'h'}