Changeset 78
- Timestamp:
- 11/28/06 00:42:17 (2 years ago)
- Files:
-
- trunk/paircomp/lib/NwayComparison.cc (modified) (1 diff)
- trunk/paircomp/lib/paircomp.hh (modified) (1 diff)
- trunk/paircomp/python/c++-ext/_paircomp_parser.cc (modified) (2 diffs)
- trunk/paircomp/tests/nway.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/paircomp/lib/NwayComparison.cc
r77 r78 97 97 std::vector<NwayPath> NwayComparison::filter() 98 98 { 99 do_comparisons(); 100 99 101 std::string seq0 = _sequences[0]; 100 102 std::vector<NwayPath> ret_paths; trunk/paircomp/lib/paircomp.hh
r11 r78 11 11 #include "MutableComparison.hh" 12 12 #include "ImmutableComparison.hh" 13 #include "NwayComparison.hh" 13 14 14 15 #include "algorithms.hh" trunk/paircomp/python/c++-ext/_paircomp_parser.cc
r50 r78 550 550 551 551 return ret; 552 } 553 554 static PyObject * create_nway(PyObject * self, PyObject * args) 555 { 556 unsigned int windowsize; 557 float threshold; 558 559 if (!PyArg_ParseTuple(args, "If", &windowsize, &threshold)) { 560 return NULL; 561 } 562 563 NwayComparison * nway = new NwayComparison(windowsize, threshold); 564 565 return PyCObject_FromVoidPtr(nway, NULL); // @CTB 566 } 567 568 static PyObject * add_sequence_to_nway(PyObject * self, PyObject * args) 569 { 570 char * seq; 571 PyObject * p; 572 573 if (!PyArg_ParseTuple(args, "Os", &p, &seq)) { 574 return NULL; 575 } 576 577 NwayComparison * nway = (NwayComparison *) PyCObject_AsVoidPtr(p); 578 nway->add_sequence(seq); 579 580 Py_INCREF(Py_None); 581 return Py_None; 582 } 583 584 std::string print_poso_v(NwayPath v) 585 { 586 char buf[50]; 587 std::string ret; 588 for (unsigned int i = 0; i < v.size(); i++) { 589 PosAndO p = v[i]; 590 sprintf(buf, "%d(%c) ", p.pos, p.orient > 0 ? '+' : '-'); 591 ret += buf; 592 } 593 ret += "\n"; 594 595 return ret; 596 } 597 598 static PyObject * get_nway_filtered_paths(PyObject * self, PyObject * args) 599 { 600 PyObject * p; 601 602 if (!PyArg_ParseTuple(args, "O", &p)) { 603 return NULL; 604 } 605 606 NwayComparison * nway = (NwayComparison *) PyCObject_AsVoidPtr(p); 607 608 std::string ret; 609 std::vector<NwayPath> paths = nway->filter(); 610 for (unsigned int i = 0; i < paths.size(); i++) { 611 NwayPath path = paths[i]; 612 ret += print_poso_v(path); 613 } 614 615 return PyString_FromString(ret.c_str()); 552 616 } 553 617 … … 577 641 { "is_empty", is_empty, METH_VARARGS }, 578 642 { "subtract", subtract, METH_VARARGS }, 643 { "create_nway", create_nway, METH_VARARGS }, 644 { "add_sequence_to_nway", add_sequence_to_nway, METH_VARARGS }, 645 { "get_nway_filtered_paths", get_nway_filtered_paths, METH_VARARGS }, 579 646 { NULL, NULL } 580 647 }; trunk/paircomp/tests/nway.py
r77 r78 322 322 if __name__ == '__main__': 323 323 test() 324 325 from paircomp import _paircomp_parser 326 o = _paircomp_parser.create_nway(10, 0.7) 327 _paircomp_parser.add_sequence_to_nway(o, 'AAAAAAAAAA') 328 _paircomp_parser.add_sequence_to_nway(o, 'AAAAAAAAAA') 329 _paircomp_parser.add_sequence_to_nway(o, 'AAAAAAAAAA') 330 _paircomp_parser.add_sequence_to_nway(o, 'TTTTTTTTTT') 331 print _paircomp_parser.get_nway_filtered_paths(o)
