~ubuntu-branches/ubuntu/natty/python-cogent/natty

« back to all changes in this revision

Viewing changes to cogent/align/_compare.c

  • Committer: Bazaar Package Importer
  • Author(s): Steffen Moeller
  • Date: 2010-12-04 22:30:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101204223035-j11kinhcrrdgg2p2
Tags: 1.5-1
* Bumped standard to 3.9.1, no changes required.
* New upstream version.
  - major additions to Cookbook
  - added AlleleFreqs attribute to ensembl Variation objects.
  - added getGeneByStableId method to genome objects.
  - added Introns attribute to Transcript objects and an Intron class.
  - added Mann-Whitney test and a Monte-Carlo version
  - exploratory and confirmatory period estimation techniques (suitable for
    symbolic and continuous data)
  - Information theoretic measures (AIC and BIC) added
  - drawing of trees with collapsed nodes
  - progress display indicator support for terminal and GUI apps
  - added parser for illumina HiSeq2000 and GAiix sequence files as 
    cogent.parse.illumina_sequence.MinimalIlluminaSequenceParser.
  - added parser to FASTQ files, one of the output options for illumina's
    workflow, also added cookbook demo.
  - added functionality for parsing of SFF files without the Roche tools in
    cogent.parse.binary_sff
  - thousand fold performance improvement to nmds
  - >10-fold performance improvements to some Table operations

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Generated by Cython 0.12 on Wed Apr  7 21:31:07 2010 */
 
1
/* Generated by Cython 0.12 on Mon Nov  8 09:06:42 2010 */
2
2
 
3
3
#define PY_SSIZE_T_CLEAN
4
4
#include "Python.h"
320
320
 
321
321
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
322
322
 
323
 
static INLINE long __Pyx_mod_long(long, long); /* proto */
324
 
 
325
323
static INLINE int __Pyx_mod_int(int, int); /* proto */
326
324
 
327
325
static INLINE PyObject* __Pyx_PyObject_Pop(PyObject* L) {
364
362
    }
365
363
}
366
364
 
367
 
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
368
 
 
369
 
static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
370
 
static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
371
 
 
372
 
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
373
 
 
374
 
static int __Pyx_Print(PyObject *, int); /*proto*/
375
 
#if PY_MAJOR_VERSION >= 3
376
 
static PyObject* __pyx_print = 0;
377
 
static PyObject* __pyx_print_kwargs = 0;
378
 
#endif
379
 
 
380
365
static INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
381
366
 
382
367
static INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
418
403
int __pyx_module_is_main_cogent__align___compare = 0;
419
404
 
420
405
/* Implementation of cogent.align._compare */
421
 
static PyObject *__pyx_builtin_max;
422
 
static PyObject *__pyx_builtin_range;
423
 
static PyObject *__pyx_builtin_min;
424
406
static char __pyx_k_1[] = "50x speedup for dotplots, but sequences must be strings and scoring is based on identity only\n";
425
 
static char __pyx_k_2[] = "('1', '4', '1')";
426
 
static char __pyx_k_3[] = "dotplot (line 23)";
427
 
static char __pyx_k__max[] = "max";
428
 
static char __pyx_k__min[] = "min";
429
 
static char __pyx_k__band[] = "band";
 
407
static char __pyx_k_2[] = "('1', '5', '0')";
 
408
static char __pyx_k_3[] = "segments_from_diagonal (line 19)";
 
409
static char __pyx_k_4[] = "segments_from_diagonal";
430
410
static char __pyx_k__seq1[] = "seq1";
431
411
static char __pyx_k__seq2[] = "seq2";
432
 
static char __pyx_k__range[] = "range";
433
412
static char __pyx_k__window[] = "window";
434
 
static char __pyx_k__dotplot[] = "dotplot";
435
413
static char __pyx_k____main__[] = "__main__";
436
414
static char __pyx_k____test__[] = "__test__";
437
 
static char __pyx_k__progress[] = "progress";
 
415
static char __pyx_k__diagonal[] = "diagonal";
438
416
static char __pyx_k__threshold[] = "threshold";
439
417
static char __pyx_k____version__[] = "__version__";
 
418
static char __pyx_k__version_info[] = "version_info";
440
419
static char __pyx_k__min_gap_length[] = "min_gap_length";
441
420
static PyObject *__pyx_kp_s_2;
442
421
static PyObject *__pyx_kp_u_3;
 
422
static PyObject *__pyx_n_s_4;
443
423
static PyObject *__pyx_n_s____main__;
444
424
static PyObject *__pyx_n_s____test__;
445
425
static PyObject *__pyx_n_s____version__;
446
 
static PyObject *__pyx_n_s__band;
447
 
static PyObject *__pyx_n_s__dotplot;
448
 
static PyObject *__pyx_n_s__max;
449
 
static PyObject *__pyx_n_s__min;
 
426
static PyObject *__pyx_n_s__diagonal;
450
427
static PyObject *__pyx_n_s__min_gap_length;
451
 
static PyObject *__pyx_n_s__progress;
452
 
static PyObject *__pyx_n_s__range;
453
428
static PyObject *__pyx_n_s__seq1;
454
429
static PyObject *__pyx_n_s__seq2;
455
430
static PyObject *__pyx_n_s__threshold;
 
431
static PyObject *__pyx_n_s__version_info;
456
432
static PyObject *__pyx_n_s__window;
457
433
static PyObject *__pyx_int_1;
458
 
static PyObject *__pyx_int_neg_1;
 
434
static PyObject *__pyx_int_3;
459
435
 
460
 
/* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":11
461
 
 *     int PyErr_CheckSignals()
 
436
/* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":7
 
437
 * __version__ = "('1', '5', '0')"
462
438
 * 
463
439
 * cdef int cmax(int a, int b):             # <<<<<<<<<<<<<<
464
440
 *     if a > b:
470
446
  int __pyx_t_1;
471
447
  __Pyx_RefNannySetupContext("cmax");
472
448
 
473
 
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":12
 
449
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":8
474
450
 * 
475
451
 * cdef int cmax(int a, int b):
476
452
 *     if a > b:             # <<<<<<<<<<<<<<
480
456
  __pyx_t_1 = (__pyx_v_a > __pyx_v_b);
481
457
  if (__pyx_t_1) {
482
458
 
483
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":13
 
459
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":9
484
460
 * cdef int cmax(int a, int b):
485
461
 *     if a > b:
486
462
 *         return a             # <<<<<<<<<<<<<<
493
469
  }
494
470
  /*else*/ {
495
471
 
496
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":15
 
472
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":11
497
473
 *         return a
498
474
 *     else:
499
475
 *         return b             # <<<<<<<<<<<<<<
511
487
  return __pyx_r;
512
488
}
513
489
 
514
 
/* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":17
 
490
/* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":13
515
491
 *         return b
516
492
 * 
517
493
 * cdef int cmin(int a, int b):             # <<<<<<<<<<<<<<
524
500
  int __pyx_t_1;
525
501
  __Pyx_RefNannySetupContext("cmin");
526
502
 
527
 
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":18
 
503
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":14
528
504
 * 
529
505
 * cdef int cmin(int a, int b):
530
506
 *     if a < b:             # <<<<<<<<<<<<<<
534
510
  __pyx_t_1 = (__pyx_v_a < __pyx_v_b);
535
511
  if (__pyx_t_1) {
536
512
 
537
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":19
 
513
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":15
538
514
 * cdef int cmin(int a, int b):
539
515
 *     if a < b:
540
516
 *         return a             # <<<<<<<<<<<<<<
547
523
  }
548
524
  /*else*/ {
549
525
 
550
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":21
 
526
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":17
551
527
 *         return a
552
528
 *     else:
553
529
 *         return b             # <<<<<<<<<<<<<<
554
530
 * 
555
 
 * def dotplot(
 
531
 * def segments_from_diagonal(
556
532
 */
557
533
    __pyx_r = __pyx_v_b;
558
534
    goto __pyx_L0;
565
541
  return __pyx_r;
566
542
}
567
543
 
568
 
/* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":23
 
544
/* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":19
569
545
 *         return b
570
546
 * 
571
 
 * def dotplot(             # <<<<<<<<<<<<<<
 
547
 * def segments_from_diagonal(             # <<<<<<<<<<<<<<
572
548
 *         char seq1[],
573
549
 *         char seq2[],
574
550
 */
575
551
 
576
 
static PyObject *__pyx_pf_6cogent_5align_8_compare_dotplot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
577
 
static char __pyx_doc_6cogent_5align_8_compare_dotplot[] = "List of ((x1,y1), (x2,y2)) for diagonal line segments scoring >= threshold/window";
578
 
static PyObject *__pyx_pf_6cogent_5align_8_compare_dotplot(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
 
552
static PyObject *__pyx_pf_6cogent_5align_8_compare_segments_from_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 
553
static char __pyx_doc_6cogent_5align_8_compare_segments_from_diagonal[] = "List of ((x1,y1), (x2,y2)) for diagonal line segments scoring >= threshold/window";
 
554
static PyObject *__pyx_pf_6cogent_5align_8_compare_segments_from_diagonal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
579
555
  char *__pyx_v_seq1;
580
556
  char *__pyx_v_seq2;
581
557
  int __pyx_v_window;
582
558
  int __pyx_v_threshold;
583
 
  PyObject *__pyx_v_min_gap_length = 0;
584
 
  PyObject *__pyx_v_band = 0;
585
 
  int __pyx_v_progress;
 
559
  int __pyx_v_min_gap_length;
 
560
  int __pyx_v_diagonal;
586
561
  int __pyx_v_was_high;
587
562
  int __pyx_v_score;
588
563
  int __pyx_v_i;
589
564
  int __pyx_v_i_lo;
590
565
  int __pyx_v_i_hi;
591
 
  int __pyx_v_diagonal;
592
566
  int __pyx_v_j;
593
567
  int __pyx_v_k;
594
568
  int __pyx_v_start;
 
569
  int __pyx_v_prior_end;
595
570
  int __pyx_v_len1;
596
571
  int __pyx_v_len2;
597
 
  int __pyx_v_end;
598
572
  int __pyx_v_scores[100];
599
573
  PyObject *__pyx_v_result;
600
 
  PyObject *__pyx_v_forget1;
601
574
  PyObject *__pyx_v_jumped_end;
602
 
  PyObject *__pyx_v_forget2;
603
575
  PyObject *__pyx_r = NULL;
604
576
  PyObject *__pyx_t_1 = NULL;
605
577
  Py_ssize_t __pyx_t_2;
606
578
  int __pyx_t_3;
607
 
  PyObject *__pyx_t_4 = NULL;
 
579
  int __pyx_t_4;
608
580
  PyObject *__pyx_t_5 = NULL;
609
 
  long __pyx_t_6;
610
 
  long __pyx_t_7;
611
 
  int __pyx_t_8;
612
 
  int __pyx_t_9;
613
 
  PyObject *__pyx_t_10 = NULL;
614
 
  PyObject *__pyx_t_11 = NULL;
615
 
  int __pyx_t_12;
616
 
  PyObject *__pyx_t_13 = NULL;
617
 
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__seq1,&__pyx_n_s__seq2,&__pyx_n_s__window,&__pyx_n_s__threshold,&__pyx_n_s__min_gap_length,&__pyx_n_s__band,&__pyx_n_s__progress,0};
618
 
  __Pyx_RefNannySetupContext("dotplot");
 
581
  PyObject *__pyx_t_6 = NULL;
 
582
  int __pyx_t_7;
 
583
  PyObject *__pyx_t_8 = NULL;
 
584
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__seq1,&__pyx_n_s__seq2,&__pyx_n_s__window,&__pyx_n_s__threshold,&__pyx_n_s__min_gap_length,&__pyx_n_s__diagonal,0};
 
585
  __Pyx_RefNannySetupContext("segments_from_diagonal");
619
586
  __pyx_self = __pyx_self;
620
587
  if (unlikely(__pyx_kwds)) {
621
588
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
622
 
    PyObject* values[7] = {0,0,0,0,0,0,0};
 
589
    PyObject* values[6] = {0,0,0,0,0,0};
623
590
    switch (PyTuple_GET_SIZE(__pyx_args)) {
624
 
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
625
591
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
626
592
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
627
593
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
640
606
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seq2);
641
607
      if (likely(values[1])) kw_args--;
642
608
      else {
643
 
        __Pyx_RaiseArgtupleInvalid("dotplot", 1, 7, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
609
        __Pyx_RaiseArgtupleInvalid("segments_from_diagonal", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
644
610
      }
645
611
      case  2:
646
612
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__window);
647
613
      if (likely(values[2])) kw_args--;
648
614
      else {
649
 
        __Pyx_RaiseArgtupleInvalid("dotplot", 1, 7, 7, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
615
        __Pyx_RaiseArgtupleInvalid("segments_from_diagonal", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
650
616
      }
651
617
      case  3:
652
618
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__threshold);
653
619
      if (likely(values[3])) kw_args--;
654
620
      else {
655
 
        __Pyx_RaiseArgtupleInvalid("dotplot", 1, 7, 7, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
621
        __Pyx_RaiseArgtupleInvalid("segments_from_diagonal", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
656
622
      }
657
623
      case  4:
658
624
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_gap_length);
659
625
      if (likely(values[4])) kw_args--;
660
626
      else {
661
 
        __Pyx_RaiseArgtupleInvalid("dotplot", 1, 7, 7, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
627
        __Pyx_RaiseArgtupleInvalid("segments_from_diagonal", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
662
628
      }
663
629
      case  5:
664
 
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__band);
 
630
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__diagonal);
665
631
      if (likely(values[5])) kw_args--;
666
632
      else {
667
 
        __Pyx_RaiseArgtupleInvalid("dotplot", 1, 7, 7, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
668
 
      }
669
 
      case  6:
670
 
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__progress);
671
 
      if (likely(values[6])) kw_args--;
672
 
      else {
673
 
        __Pyx_RaiseArgtupleInvalid("dotplot", 1, 7, 7, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
633
        __Pyx_RaiseArgtupleInvalid("segments_from_diagonal", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
674
634
      }
675
635
    }
676
636
    if (unlikely(kw_args > 0)) {
677
 
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "dotplot") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
637
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "segments_from_diagonal") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
678
638
    }
679
 
    __pyx_v_seq1 = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_seq1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
680
 
    __pyx_v_seq2 = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_seq2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
681
 
    __pyx_v_window = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_window == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
682
 
    __pyx_v_threshold = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_threshold == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
683
 
    __pyx_v_min_gap_length = values[4];
684
 
    __pyx_v_band = values[5];
685
 
    __pyx_v_progress = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_progress == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
686
 
  } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
 
639
    __pyx_v_seq1 = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_seq1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
640
    __pyx_v_seq2 = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_seq2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
641
    __pyx_v_window = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_window == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
642
    __pyx_v_threshold = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_threshold == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
643
    __pyx_v_min_gap_length = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_min_gap_length == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
644
    __pyx_v_diagonal = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_diagonal == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
645
  } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
687
646
    goto __pyx_L5_argtuple_error;
688
647
  } else {
689
 
    __pyx_v_seq1 = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_seq1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
690
 
    __pyx_v_seq2 = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_seq2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
691
 
    __pyx_v_window = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_window == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
692
 
    __pyx_v_threshold = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_threshold == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
693
 
    __pyx_v_min_gap_length = PyTuple_GET_ITEM(__pyx_args, 4);
694
 
    __pyx_v_band = PyTuple_GET_ITEM(__pyx_args, 5);
695
 
    __pyx_v_progress = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 6)); if (unlikely((__pyx_v_progress == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
648
    __pyx_v_seq1 = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_seq1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
649
    __pyx_v_seq2 = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_seq2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
650
    __pyx_v_window = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_window == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
651
    __pyx_v_threshold = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_threshold == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
652
    __pyx_v_min_gap_length = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_min_gap_length == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
653
    __pyx_v_diagonal = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_diagonal == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
696
654
  }
697
655
  goto __pyx_L4_argument_unpacking_done;
698
656
  __pyx_L5_argtuple_error:;
699
 
  __Pyx_RaiseArgtupleInvalid("dotplot", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
 
657
  __Pyx_RaiseArgtupleInvalid("segments_from_diagonal", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
700
658
  __pyx_L3_error:;
701
 
  __Pyx_AddTraceback("cogent.align._compare.dotplot");
 
659
  __Pyx_AddTraceback("cogent.align._compare.segments_from_diagonal");
702
660
  return NULL;
703
661
  __pyx_L4_argument_unpacking_done:;
704
 
  __Pyx_INCREF(__pyx_v_min_gap_length);
705
 
  __Pyx_INCREF(__pyx_v_band);
706
662
  __pyx_v_result = Py_None; __Pyx_INCREF(Py_None);
707
 
  __pyx_v_forget1 = Py_None; __Pyx_INCREF(Py_None);
708
663
  __pyx_v_jumped_end = Py_None; __Pyx_INCREF(Py_None);
709
 
  __pyx_v_forget2 = Py_None; __Pyx_INCREF(Py_None);
710
664
 
711
 
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":35
712
 
 *     cdef int was_high, score, i, i_lo, i_hi, diagonal, j, k, start, len1, len2, end
 
665
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":31
 
666
 *     cdef int len1, len2
713
667
 *     cdef int scores[100]   # yuk - use malloc?
714
668
 *     assert window < 100             # <<<<<<<<<<<<<<
715
669
 *     len1 = len(seq1)
718
672
  #ifndef PYREX_WITHOUT_ASSERTIONS
719
673
  if (unlikely(!(__pyx_v_window < 100))) {
720
674
    PyErr_SetNone(PyExc_AssertionError);
721
 
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
675
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
722
676
  }
723
677
  #endif
724
678
 
725
 
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":36
 
679
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":32
726
680
 *     cdef int scores[100]   # yuk - use malloc?
727
681
 *     assert window < 100
728
682
 *     len1 = len(seq1)             # <<<<<<<<<<<<<<
729
683
 *     len2 = len(seq2)
730
684
 *     result = []
731
685
 */
732
 
  __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_seq1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
686
  __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_seq1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
733
687
  __Pyx_GOTREF(__pyx_t_1);
734
 
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
688
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
735
689
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
736
690
  __pyx_v_len1 = __pyx_t_2;
737
691
 
738
 
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":37
 
692
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":33
739
693
 *     assert window < 100
740
694
 *     len1 = len(seq1)
741
695
 *     len2 = len(seq2)             # <<<<<<<<<<<<<<
742
696
 *     result = []
743
 
 *     if band is None:
 
697
 *     was_high = 0
744
698
 */
745
 
  __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_seq2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
699
  __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_seq2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
746
700
  __Pyx_GOTREF(__pyx_t_1);
747
 
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
701
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
748
702
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
749
703
  __pyx_v_len2 = __pyx_t_2;
750
704
 
751
 
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":38
 
705
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":34
752
706
 *     len1 = len(seq1)
753
707
 *     len2 = len(seq2)
754
708
 *     result = []             # <<<<<<<<<<<<<<
755
 
 *     if band is None:
756
 
 *         band = max(len1, len2)
 
709
 *     was_high = 0
 
710
 *     for i from 0 <= i < window:
757
711
 */
758
 
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
712
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
759
713
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
760
714
  __Pyx_DECREF(__pyx_v_result);
761
715
  __pyx_v_result = ((PyObject *)__pyx_t_1);
762
716
  __pyx_t_1 = 0;
763
717
 
 
718
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":35
 
719
 *     len2 = len(seq2)
 
720
 *     result = []
 
721
 *     was_high = 0             # <<<<<<<<<<<<<<
 
722
 *     for i from 0 <= i < window:
 
723
 *         scores[i] = 0
 
724
 */
 
725
  __pyx_v_was_high = 0;
 
726
 
 
727
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":36
 
728
 *     result = []
 
729
 *     was_high = 0
 
730
 *     for i from 0 <= i < window:             # <<<<<<<<<<<<<<
 
731
 *         scores[i] = 0
 
732
 *     score = 0
 
733
 */
 
734
  __pyx_t_3 = __pyx_v_window;
 
735
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {
 
736
 
 
737
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":37
 
738
 *     was_high = 0
 
739
 *     for i from 0 <= i < window:
 
740
 *         scores[i] = 0             # <<<<<<<<<<<<<<
 
741
 *     score = 0
 
742
 *     i_lo = cmax(0, 0-diagonal)
 
743
 */
 
744
    (__pyx_v_scores[__pyx_v_i]) = 0;
 
745
  }
 
746
 
 
747
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":38
 
748
 *     for i from 0 <= i < window:
 
749
 *         scores[i] = 0
 
750
 *     score = 0             # <<<<<<<<<<<<<<
 
751
 *     i_lo = cmax(0, 0-diagonal)
 
752
 *     i_hi = cmin(len1, len2-diagonal)
 
753
 */
 
754
  __pyx_v_score = 0;
 
755
 
764
756
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":39
765
 
 *     len2 = len(seq2)
766
 
 *     result = []
767
 
 *     if band is None:             # <<<<<<<<<<<<<<
768
 
 *         band = max(len1, len2)
769
 
 *     for diagonal in range(-1*min(len1, band), min(len2, band)+1):
 
757
 *         scores[i] = 0
 
758
 *     score = 0
 
759
 *     i_lo = cmax(0, 0-diagonal)             # <<<<<<<<<<<<<<
 
760
 *     i_hi = cmin(len1, len2-diagonal)
 
761
 *     prior_end = 0
770
762
 */
771
 
  __pyx_t_3 = (__pyx_v_band == Py_None);
772
 
  if (__pyx_t_3) {
 
763
  __pyx_v_i_lo = __pyx_f_6cogent_5align_8_compare_cmax(0, (0 - __pyx_v_diagonal));
773
764
 
774
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":40
775
 
 *     result = []
776
 
 *     if band is None:
777
 
 *         band = max(len1, len2)             # <<<<<<<<<<<<<<
778
 
 *     for diagonal in range(-1*min(len1, band), min(len2, band)+1):
779
 
 *         if PyErr_CheckSignals():
 
765
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":40
 
766
 *     score = 0
 
767
 *     i_lo = cmax(0, 0-diagonal)
 
768
 *     i_hi = cmin(len1, len2-diagonal)             # <<<<<<<<<<<<<<
 
769
 *     prior_end = 0
 
770
 *     for i from i_lo <=  i < i_hi:
780
771
 */
781
 
    __pyx_t_1 = PyInt_FromLong(__pyx_v_len1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
782
 
    __Pyx_GOTREF(__pyx_t_1);
783
 
    __pyx_t_4 = PyInt_FromLong(__pyx_v_len2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
784
 
    __Pyx_GOTREF(__pyx_t_4);
785
 
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
786
 
    __Pyx_GOTREF(__pyx_t_5);
787
 
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
788
 
    __Pyx_GIVEREF(__pyx_t_1);
789
 
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
790
 
    __Pyx_GIVEREF(__pyx_t_4);
791
 
    __pyx_t_1 = 0;
792
 
    __pyx_t_4 = 0;
793
 
    __pyx_t_4 = PyObject_Call(__pyx_builtin_max, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
794
 
    __Pyx_GOTREF(__pyx_t_4);
795
 
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
796
 
    __Pyx_DECREF(__pyx_v_band);
797
 
    __pyx_v_band = __pyx_t_4;
798
 
    __pyx_t_4 = 0;
799
 
    goto __pyx_L6;
800
 
  }
801
 
  __pyx_L6:;
 
772
  __pyx_v_i_hi = __pyx_f_6cogent_5align_8_compare_cmin(__pyx_v_len1, (__pyx_v_len2 - __pyx_v_diagonal));
802
773
 
803
774
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":41
804
 
 *     if band is None:
805
 
 *         band = max(len1, len2)
806
 
 *     for diagonal in range(-1*min(len1, band), min(len2, band)+1):             # <<<<<<<<<<<<<<
807
 
 *         if PyErr_CheckSignals():
808
 
 *             raise PyErr_Occurred()
809
 
 */
810
 
  __pyx_t_4 = PyInt_FromLong(__pyx_v_len2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
811
 
  __Pyx_GOTREF(__pyx_t_4);
812
 
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
813
 
  __Pyx_GOTREF(__pyx_t_5);
814
 
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
815
 
  __Pyx_GIVEREF(__pyx_t_4);
816
 
  __Pyx_INCREF(__pyx_v_band);
817
 
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_band);
818
 
  __Pyx_GIVEREF(__pyx_v_band);
819
 
  __pyx_t_4 = 0;
820
 
  __pyx_t_4 = PyObject_Call(__pyx_builtin_min, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
821
 
  __Pyx_GOTREF(__pyx_t_4);
822
 
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
823
 
  __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
824
 
  __Pyx_GOTREF(__pyx_t_5);
825
 
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
826
 
  __pyx_t_6 = __Pyx_PyInt_AsLong(__pyx_t_5); if (unlikely((__pyx_t_6 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
827
 
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
828
 
  __pyx_t_5 = PyInt_FromLong(__pyx_v_len1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
829
 
  __Pyx_GOTREF(__pyx_t_5);
830
 
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
831
 
  __Pyx_GOTREF(__pyx_t_4);
832
 
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
833
 
  __Pyx_GIVEREF(__pyx_t_5);
834
 
  __Pyx_INCREF(__pyx_v_band);
835
 
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_band);
836
 
  __Pyx_GIVEREF(__pyx_v_band);
837
 
  __pyx_t_5 = 0;
838
 
  __pyx_t_5 = PyObject_Call(__pyx_builtin_min, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
839
 
  __Pyx_GOTREF(__pyx_t_5);
840
 
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
841
 
  __pyx_t_4 = PyNumber_Multiply(__pyx_int_neg_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
842
 
  __Pyx_GOTREF(__pyx_t_4);
843
 
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
844
 
  __pyx_t_7 = __Pyx_PyInt_AsLong(__pyx_t_4); if (unlikely((__pyx_t_7 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
845
 
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
846
 
  for (__pyx_t_8 = __pyx_t_7; __pyx_t_8 < __pyx_t_6; __pyx_t_8+=1) {
847
 
    __pyx_v_diagonal = __pyx_t_8;
848
 
 
849
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":42
850
 
 *         band = max(len1, len2)
851
 
 *     for diagonal in range(-1*min(len1, band), min(len2, band)+1):
852
 
 *         if PyErr_CheckSignals():             # <<<<<<<<<<<<<<
853
 
 *             raise PyErr_Occurred()
854
 
 *         was_high = 0
855
 
 */
856
 
    __pyx_t_9 = PyErr_CheckSignals();
857
 
    if (__pyx_t_9) {
858
 
 
859
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":43
860
 
 *     for diagonal in range(-1*min(len1, band), min(len2, band)+1):
861
 
 *         if PyErr_CheckSignals():
862
 
 *             raise PyErr_Occurred()             # <<<<<<<<<<<<<<
863
 
 *         was_high = 0
864
 
 *         end = -1 * (min_gap_length+1)
865
 
 */
866
 
      __pyx_t_4 = PyErr_Occurred(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
867
 
      __Pyx_GOTREF(__pyx_t_4);
868
 
      __Pyx_Raise(__pyx_t_4, 0, 0);
869
 
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
870
 
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
871
 
      goto __pyx_L9;
872
 
    }
873
 
    __pyx_L9:;
 
775
 *     i_lo = cmax(0, 0-diagonal)
 
776
 *     i_hi = cmin(len1, len2-diagonal)
 
777
 *     prior_end = 0             # <<<<<<<<<<<<<<
 
778
 *     for i from i_lo <=  i < i_hi:
 
779
 *         j = i + diagonal
 
780
 */
 
781
  __pyx_v_prior_end = 0;
 
782
 
 
783
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":42
 
784
 *     i_hi = cmin(len1, len2-diagonal)
 
785
 *     prior_end = 0
 
786
 *     for i from i_lo <=  i < i_hi:             # <<<<<<<<<<<<<<
 
787
 *         j = i + diagonal
 
788
 *         k = i % window
 
789
 */
 
790
  __pyx_t_3 = __pyx_v_i_hi;
 
791
  for (__pyx_v_i = __pyx_v_i_lo; __pyx_v_i < __pyx_t_3; __pyx_v_i++) {
 
792
 
 
793
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":43
 
794
 *     prior_end = 0
 
795
 *     for i from i_lo <=  i < i_hi:
 
796
 *         j = i + diagonal             # <<<<<<<<<<<<<<
 
797
 *         k = i % window
 
798
 *         score -= scores[k]
 
799
 */
 
800
    __pyx_v_j = (__pyx_v_i + __pyx_v_diagonal);
874
801
 
875
802
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":44
876
 
 *         if PyErr_CheckSignals():
877
 
 *             raise PyErr_Occurred()
878
 
 *         was_high = 0             # <<<<<<<<<<<<<<
879
 
 *         end = -1 * (min_gap_length+1)
880
 
 *         for i from 0 <= i < window:
 
803
 *     for i from i_lo <=  i < i_hi:
 
804
 *         j = i + diagonal
 
805
 *         k = i % window             # <<<<<<<<<<<<<<
 
806
 *         score -= scores[k]
 
807
 *         scores[k] = (seq1[i] == seq2[j])
881
808
 */
882
 
    __pyx_v_was_high = 0;
 
809
    if (unlikely(__pyx_v_window == 0)) {
 
810
      PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
 
811
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
812
    }
 
813
    __pyx_v_k = __Pyx_mod_int(__pyx_v_i, __pyx_v_window);
883
814
 
884
815
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":45
885
 
 *             raise PyErr_Occurred()
886
 
 *         was_high = 0
887
 
 *         end = -1 * (min_gap_length+1)             # <<<<<<<<<<<<<<
888
 
 *         for i from 0 <= i < window:
889
 
 *             scores[i] = 0
 
816
 *         j = i + diagonal
 
817
 *         k = i % window
 
818
 *         score -= scores[k]             # <<<<<<<<<<<<<<
 
819
 *         scores[k] = (seq1[i] == seq2[j])
 
820
 *         score += scores[k]
890
821
 */
891
 
    __pyx_t_4 = PyNumber_Add(__pyx_v_min_gap_length, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
892
 
    __Pyx_GOTREF(__pyx_t_4);
893
 
    __pyx_t_5 = PyNumber_Multiply(__pyx_int_neg_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
894
 
    __Pyx_GOTREF(__pyx_t_5);
895
 
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
896
 
    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
897
 
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
898
 
    __pyx_v_end = __pyx_t_9;
 
822
    __pyx_v_score -= (__pyx_v_scores[__pyx_v_k]);
899
823
 
900
824
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":46
901
 
 *         was_high = 0
902
 
 *         end = -1 * (min_gap_length+1)
903
 
 *         for i from 0 <= i < window:             # <<<<<<<<<<<<<<
904
 
 *             scores[i] = 0
905
 
 *         score = 0
 
825
 *         k = i % window
 
826
 *         score -= scores[k]
 
827
 *         scores[k] = (seq1[i] == seq2[j])             # <<<<<<<<<<<<<<
 
828
 *         score += scores[k]
 
829
 *         if score >= threshold:
906
830
 */
907
 
    __pyx_t_9 = __pyx_v_window;
908
 
    for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {
 
831
    (__pyx_v_scores[__pyx_v_k]) = ((__pyx_v_seq1[__pyx_v_i]) == (__pyx_v_seq2[__pyx_v_j]));
909
832
 
910
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":47
911
 
 *         end = -1 * (min_gap_length+1)
912
 
 *         for i from 0 <= i < window:
913
 
 *             scores[i] = 0             # <<<<<<<<<<<<<<
914
 
 *         score = 0
915
 
 *         i_lo = cmax(0, 0-diagonal)
 
833
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":47
 
834
 *         score -= scores[k]
 
835
 *         scores[k] = (seq1[i] == seq2[j])
 
836
 *         score += scores[k]             # <<<<<<<<<<<<<<
 
837
 *         if score >= threshold:
 
838
 *             if not was_high:
916
839
 */
917
 
      (__pyx_v_scores[__pyx_v_i]) = 0;
918
 
    }
 
840
    __pyx_v_score += (__pyx_v_scores[__pyx_v_k]);
919
841
 
920
842
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":48
921
 
 *         for i from 0 <= i < window:
922
 
 *             scores[i] = 0
923
 
 *         score = 0             # <<<<<<<<<<<<<<
924
 
 *         i_lo = cmax(0, 0-diagonal)
925
 
 *         i_hi = cmin(len1, len2-diagonal)
926
 
 */
927
 
    __pyx_v_score = 0;
928
 
 
929
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":49
930
 
 *             scores[i] = 0
931
 
 *         score = 0
932
 
 *         i_lo = cmax(0, 0-diagonal)             # <<<<<<<<<<<<<<
933
 
 *         i_hi = cmin(len1, len2-diagonal)
934
 
 *         if progress:
935
 
 */
936
 
    __pyx_v_i_lo = __pyx_f_6cogent_5align_8_compare_cmax(0, (0 - __pyx_v_diagonal));
937
 
 
938
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":50
939
 
 *         score = 0
940
 
 *         i_lo = cmax(0, 0-diagonal)
941
 
 *         i_hi = cmin(len1, len2-diagonal)             # <<<<<<<<<<<<<<
942
 
 *         if progress:
943
 
 *             if diagonal %100 == 0:
944
 
 */
945
 
    __pyx_v_i_hi = __pyx_f_6cogent_5align_8_compare_cmin(__pyx_v_len1, (__pyx_v_len2 - __pyx_v_diagonal));
946
 
 
947
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":51
948
 
 *         i_lo = cmax(0, 0-diagonal)
949
 
 *         i_hi = cmin(len1, len2-diagonal)
950
 
 *         if progress:             # <<<<<<<<<<<<<<
951
 
 *             if diagonal %100 == 0:
952
 
 *                 print diagonal, (i_lo, i_lo+diagonal), (i_hi, i_hi+diagonal), len(result)
953
 
 */
954
 
    __pyx_t_9 = __pyx_v_progress;
955
 
    if (__pyx_t_9) {
956
 
 
957
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":52
958
 
 *         i_hi = cmin(len1, len2-diagonal)
959
 
 *         if progress:
960
 
 *             if diagonal %100 == 0:             # <<<<<<<<<<<<<<
961
 
 *                 print diagonal, (i_lo, i_lo+diagonal), (i_hi, i_hi+diagonal), len(result)
962
 
 *         for i from i_lo <=  i < i_hi:
963
 
 */
964
 
      __pyx_t_3 = (__Pyx_mod_long(__pyx_v_diagonal, 100) == 0);
965
 
      if (__pyx_t_3) {
966
 
 
967
 
        /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":53
968
 
 *         if progress:
969
 
 *             if diagonal %100 == 0:
970
 
 *                 print diagonal, (i_lo, i_lo+diagonal), (i_hi, i_hi+diagonal), len(result)             # <<<<<<<<<<<<<<
971
 
 *         for i from i_lo <=  i < i_hi:
972
 
 *             j = i + diagonal
973
 
 */
974
 
        __pyx_t_5 = PyInt_FromLong(__pyx_v_diagonal); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
843
 *         scores[k] = (seq1[i] == seq2[j])
 
844
 *         score += scores[k]
 
845
 *         if score >= threshold:             # <<<<<<<<<<<<<<
 
846
 *             if not was_high:
 
847
 *                 start = cmax(i_lo, i - window)
 
848
 */
 
849
    __pyx_t_4 = (__pyx_v_score >= __pyx_v_threshold);
 
850
    if (__pyx_t_4) {
 
851
 
 
852
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":49
 
853
 *         score += scores[k]
 
854
 *         if score >= threshold:
 
855
 *             if not was_high:             # <<<<<<<<<<<<<<
 
856
 *                 start = cmax(i_lo, i - window)
 
857
 *                 if min_gap_length and prior_end:
 
858
 */
 
859
      __pyx_t_4 = (!__pyx_v_was_high);
 
860
      if (__pyx_t_4) {
 
861
 
 
862
        /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":50
 
863
 *         if score >= threshold:
 
864
 *             if not was_high:
 
865
 *                 start = cmax(i_lo, i - window)             # <<<<<<<<<<<<<<
 
866
 *                 if min_gap_length and prior_end:
 
867
 *                     if start < prior_end + min_gap_length:
 
868
 */
 
869
        __pyx_v_start = __pyx_f_6cogent_5align_8_compare_cmax(__pyx_v_i_lo, (__pyx_v_i - __pyx_v_window));
 
870
 
 
871
        /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":51
 
872
 *             if not was_high:
 
873
 *                 start = cmax(i_lo, i - window)
 
874
 *                 if min_gap_length and prior_end:             # <<<<<<<<<<<<<<
 
875
 *                     if start < prior_end + min_gap_length:
 
876
 *                         (start, jumped_end) = result.pop()
 
877
 */
 
878
        if (__pyx_v_min_gap_length) {
 
879
          __pyx_t_4 = __pyx_v_prior_end;
 
880
        } else {
 
881
          __pyx_t_4 = __pyx_v_min_gap_length;
 
882
        }
 
883
        if (__pyx_t_4) {
 
884
 
 
885
          /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":52
 
886
 *                 start = cmax(i_lo, i - window)
 
887
 *                 if min_gap_length and prior_end:
 
888
 *                     if start < prior_end + min_gap_length:             # <<<<<<<<<<<<<<
 
889
 *                         (start, jumped_end) = result.pop()
 
890
 *                 was_high = 1
 
891
 */
 
892
          __pyx_t_4 = (__pyx_v_start < (__pyx_v_prior_end + __pyx_v_min_gap_length));
 
893
          if (__pyx_t_4) {
 
894
 
 
895
            /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":53
 
896
 *                 if min_gap_length and prior_end:
 
897
 *                     if start < prior_end + min_gap_length:
 
898
 *                         (start, jumped_end) = result.pop()             # <<<<<<<<<<<<<<
 
899
 *                 was_high = 1
 
900
 *         else:
 
901
 */
 
902
            __pyx_t_1 = __Pyx_PyObject_Pop(__pyx_v_result); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
903
            __Pyx_GOTREF(__pyx_t_1);
 
904
            if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
 
905
              PyObject* tuple = __pyx_t_1;
 
906
              __pyx_t_5 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_5);
 
907
              __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
908
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
909
              __pyx_t_6 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_6);
 
910
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
911
              __pyx_v_start = __pyx_t_7;
 
912
              __Pyx_DECREF(__pyx_v_jumped_end);
 
913
              __pyx_v_jumped_end = __pyx_t_6;
 
914
              __pyx_t_6 = 0;
 
915
            } else {
 
916
              __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
917
              __Pyx_GOTREF(__pyx_t_8);
 
918
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
919
              __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_8, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
920
              __Pyx_GOTREF(__pyx_t_5);
 
921
              __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
922
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
923
              __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_8, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
924
              __Pyx_GOTREF(__pyx_t_6);
 
925
              if (__Pyx_EndUnpack(__pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
926
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
927
              __pyx_v_start = __pyx_t_7;
 
928
              __Pyx_DECREF(__pyx_v_jumped_end);
 
929
              __pyx_v_jumped_end = __pyx_t_6;
 
930
              __pyx_t_6 = 0;
 
931
            }
 
932
            goto __pyx_L13;
 
933
          }
 
934
          __pyx_L13:;
 
935
          goto __pyx_L12;
 
936
        }
 
937
        __pyx_L12:;
 
938
 
 
939
        /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":54
 
940
 *                     if start < prior_end + min_gap_length:
 
941
 *                         (start, jumped_end) = result.pop()
 
942
 *                 was_high = 1             # <<<<<<<<<<<<<<
 
943
 *         else:
 
944
 *             if was_high:
 
945
 */
 
946
        __pyx_v_was_high = 1;
 
947
        goto __pyx_L11;
 
948
      }
 
949
      __pyx_L11:;
 
950
      goto __pyx_L10;
 
951
    }
 
952
    /*else*/ {
 
953
 
 
954
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":56
 
955
 *                 was_high = 1
 
956
 *         else:
 
957
 *             if was_high:             # <<<<<<<<<<<<<<
 
958
 *                 result.append((start, i))
 
959
 *                 prior_end = i
 
960
 */
 
961
      __pyx_t_7 = __pyx_v_was_high;
 
962
      if (__pyx_t_7) {
 
963
 
 
964
        /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":57
 
965
 *         else:
 
966
 *             if was_high:
 
967
 *                 result.append((start, i))             # <<<<<<<<<<<<<<
 
968
 *                 prior_end = i
 
969
 *                 was_high = 0
 
970
 */
 
971
        __pyx_t_1 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
972
        __Pyx_GOTREF(__pyx_t_1);
 
973
        __pyx_t_6 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
974
        __Pyx_GOTREF(__pyx_t_6);
 
975
        __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
975
976
        __Pyx_GOTREF(__pyx_t_5);
976
 
        __pyx_t_4 = PyInt_FromLong(__pyx_v_i_lo); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
977
 
        __Pyx_GOTREF(__pyx_t_4);
978
 
        __pyx_t_1 = PyInt_FromLong((__pyx_v_i_lo + __pyx_v_diagonal)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
979
 
        __Pyx_GOTREF(__pyx_t_1);
980
 
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
981
 
        __Pyx_GOTREF(__pyx_t_10);
982
 
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4);
983
 
        __Pyx_GIVEREF(__pyx_t_4);
984
 
        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1);
985
 
        __Pyx_GIVEREF(__pyx_t_1);
986
 
        __pyx_t_4 = 0;
987
 
        __pyx_t_1 = 0;
988
 
        __pyx_t_1 = PyInt_FromLong(__pyx_v_i_hi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
989
 
        __Pyx_GOTREF(__pyx_t_1);
990
 
        __pyx_t_4 = PyInt_FromLong((__pyx_v_i_hi + __pyx_v_diagonal)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
991
 
        __Pyx_GOTREF(__pyx_t_4);
992
 
        __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
993
 
        __Pyx_GOTREF(__pyx_t_11);
994
 
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1);
995
 
        __Pyx_GIVEREF(__pyx_t_1);
996
 
        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
997
 
        __Pyx_GIVEREF(__pyx_t_4);
998
 
        __pyx_t_1 = 0;
999
 
        __pyx_t_4 = 0;
1000
 
        __pyx_t_2 = PyObject_Length(__pyx_v_result); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1001
 
        __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1002
 
        __Pyx_GOTREF(__pyx_t_4);
1003
 
        __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1004
 
        __Pyx_GOTREF(__pyx_t_1);
1005
 
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
1006
 
        __Pyx_GIVEREF(__pyx_t_5);
1007
 
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_10);
1008
 
        __Pyx_GIVEREF(__pyx_t_10);
1009
 
        PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_11);
1010
 
        __Pyx_GIVEREF(__pyx_t_11);
1011
 
        PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4);
1012
 
        __Pyx_GIVEREF(__pyx_t_4);
1013
 
        __pyx_t_5 = 0;
1014
 
        __pyx_t_10 = 0;
1015
 
        __pyx_t_11 = 0;
1016
 
        __pyx_t_4 = 0;
1017
 
        if (__Pyx_Print(__pyx_t_1, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1018
 
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1019
 
        goto __pyx_L13;
1020
 
      }
1021
 
      __pyx_L13:;
1022
 
      goto __pyx_L12;
1023
 
    }
1024
 
    __pyx_L12:;
1025
 
 
1026
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":54
1027
 
 *             if diagonal %100 == 0:
1028
 
 *                 print diagonal, (i_lo, i_lo+diagonal), (i_hi, i_hi+diagonal), len(result)
1029
 
 *         for i from i_lo <=  i < i_hi:             # <<<<<<<<<<<<<<
1030
 
 *             j = i + diagonal
1031
 
 *             k = i % window
1032
 
 */
1033
 
    __pyx_t_9 = __pyx_v_i_hi;
1034
 
    for (__pyx_v_i = __pyx_v_i_lo; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {
1035
 
 
1036
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":55
1037
 
 *                 print diagonal, (i_lo, i_lo+diagonal), (i_hi, i_hi+diagonal), len(result)
1038
 
 *         for i from i_lo <=  i < i_hi:
1039
 
 *             j = i + diagonal             # <<<<<<<<<<<<<<
1040
 
 *             k = i % window
1041
 
 *             score -= scores[k]
1042
 
 */
1043
 
      __pyx_v_j = (__pyx_v_i + __pyx_v_diagonal);
1044
 
 
1045
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":56
1046
 
 *         for i from i_lo <=  i < i_hi:
1047
 
 *             j = i + diagonal
1048
 
 *             k = i % window             # <<<<<<<<<<<<<<
1049
 
 *             score -= scores[k]
1050
 
 *             scores[k] = (seq1[i] == seq2[j])
1051
 
 */
1052
 
      if (unlikely(__pyx_v_window == 0)) {
1053
 
        PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
1054
 
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1055
 
      }
1056
 
      __pyx_v_k = __Pyx_mod_int(__pyx_v_i, __pyx_v_window);
1057
 
 
1058
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":57
1059
 
 *             j = i + diagonal
1060
 
 *             k = i % window
1061
 
 *             score -= scores[k]             # <<<<<<<<<<<<<<
1062
 
 *             scores[k] = (seq1[i] == seq2[j])
1063
 
 *             score += scores[k]
1064
 
 */
1065
 
      __pyx_v_score -= (__pyx_v_scores[__pyx_v_k]);
1066
 
 
1067
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":58
1068
 
 *             k = i % window
1069
 
 *             score -= scores[k]
1070
 
 *             scores[k] = (seq1[i] == seq2[j])             # <<<<<<<<<<<<<<
1071
 
 *             score += scores[k]
1072
 
 *             if score >= threshold:
1073
 
 */
1074
 
      (__pyx_v_scores[__pyx_v_k]) = ((__pyx_v_seq1[__pyx_v_i]) == (__pyx_v_seq2[__pyx_v_j]));
1075
 
 
1076
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":59
1077
 
 *             score -= scores[k]
1078
 
 *             scores[k] = (seq1[i] == seq2[j])
1079
 
 *             score += scores[k]             # <<<<<<<<<<<<<<
1080
 
 *             if score >= threshold:
1081
 
 *                 if not was_high:
1082
 
 */
1083
 
      __pyx_v_score += (__pyx_v_scores[__pyx_v_k]);
1084
 
 
1085
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":60
1086
 
 *             scores[k] = (seq1[i] == seq2[j])
1087
 
 *             score += scores[k]
1088
 
 *             if score >= threshold:             # <<<<<<<<<<<<<<
1089
 
 *                 if not was_high:
1090
 
 *                     start = cmax(i_lo, i - window)
1091
 
 */
1092
 
      __pyx_t_3 = (__pyx_v_score >= __pyx_v_threshold);
1093
 
      if (__pyx_t_3) {
1094
 
 
1095
 
        /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":61
1096
 
 *             score += scores[k]
1097
 
 *             if score >= threshold:
1098
 
 *                 if not was_high:             # <<<<<<<<<<<<<<
1099
 
 *                     start = cmax(i_lo, i - window)
1100
 
 *                     was_high = 1
1101
 
 */
1102
 
        __pyx_t_3 = (!__pyx_v_was_high);
1103
 
        if (__pyx_t_3) {
1104
 
 
1105
 
          /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":62
1106
 
 *             if score >= threshold:
1107
 
 *                 if not was_high:
1108
 
 *                     start = cmax(i_lo, i - window)             # <<<<<<<<<<<<<<
1109
 
 *                     was_high = 1
1110
 
 *             else:
1111
 
 */
1112
 
          __pyx_v_start = __pyx_f_6cogent_5align_8_compare_cmax(__pyx_v_i_lo, (__pyx_v_i - __pyx_v_window));
1113
 
 
1114
 
          /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":63
1115
 
 *                 if not was_high:
1116
 
 *                     start = cmax(i_lo, i - window)
1117
 
 *                     was_high = 1             # <<<<<<<<<<<<<<
1118
 
 *             else:
1119
 
 *                 if was_high:
1120
 
 */
1121
 
          __pyx_v_was_high = 1;
1122
 
          goto __pyx_L17;
1123
 
        }
1124
 
        __pyx_L17:;
1125
 
        goto __pyx_L16;
1126
 
      }
1127
 
      /*else*/ {
1128
 
 
1129
 
        /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":65
1130
 
 *                     was_high = 1
1131
 
 *             else:
1132
 
 *                 if was_high:             # <<<<<<<<<<<<<<
1133
 
 *                     if start - end  < min_gap_length:
1134
 
 *                         ((start, forget1), (jumped_end, forget2)) = result.pop()
1135
 
 */
1136
 
        __pyx_t_12 = __pyx_v_was_high;
1137
 
        if (__pyx_t_12) {
1138
 
 
1139
 
          /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":66
1140
 
 *             else:
1141
 
 *                 if was_high:
1142
 
 *                     if start - end  < min_gap_length:             # <<<<<<<<<<<<<<
1143
 
 *                         ((start, forget1), (jumped_end, forget2)) = result.pop()
1144
 
 *                     end = i - 1
1145
 
 */
1146
 
          __pyx_t_1 = PyInt_FromLong((__pyx_v_start - __pyx_v_end)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1147
 
          __Pyx_GOTREF(__pyx_t_1);
1148
 
          __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_v_min_gap_length, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1149
 
          __Pyx_GOTREF(__pyx_t_4);
1150
 
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1151
 
          __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1152
 
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1153
 
          if (__pyx_t_3) {
1154
 
 
1155
 
            /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":67
1156
 
 *                 if was_high:
1157
 
 *                     if start - end  < min_gap_length:
1158
 
 *                         ((start, forget1), (jumped_end, forget2)) = result.pop()             # <<<<<<<<<<<<<<
1159
 
 *                     end = i - 1
1160
 
 *                     result.append(((start, start+diagonal), (end, end+diagonal)))
1161
 
 */
1162
 
            __pyx_t_4 = __Pyx_PyObject_Pop(__pyx_v_result); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1163
 
            __Pyx_GOTREF(__pyx_t_4);
1164
 
            if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
1165
 
              PyObject* tuple = __pyx_t_4;
1166
 
              __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
1167
 
              __pyx_t_11 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_11);
1168
 
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1169
 
              if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
1170
 
                PyObject* tuple = __pyx_t_1;
1171
 
                __pyx_t_10 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_10);
1172
 
                __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_10); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1173
 
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1174
 
                __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
1175
 
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1176
 
                __pyx_v_start = __pyx_t_12;
1177
 
                __Pyx_DECREF(__pyx_v_forget1);
1178
 
                __pyx_v_forget1 = __pyx_t_5;
1179
 
                __pyx_t_5 = 0;
1180
 
              } else {
1181
 
                __pyx_t_13 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1182
 
                __Pyx_GOTREF(__pyx_t_13);
1183
 
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1184
 
                __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_13, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1185
 
                __Pyx_GOTREF(__pyx_t_10);
1186
 
                __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_10); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1187
 
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1188
 
                __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_13, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1189
 
                __Pyx_GOTREF(__pyx_t_5);
1190
 
                if (__Pyx_EndUnpack(__pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1191
 
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
1192
 
                __pyx_v_start = __pyx_t_12;
1193
 
                __Pyx_DECREF(__pyx_v_forget1);
1194
 
                __pyx_v_forget1 = __pyx_t_5;
1195
 
                __pyx_t_5 = 0;
1196
 
              }
1197
 
              if (PyTuple_CheckExact(__pyx_t_11) && likely(PyTuple_GET_SIZE(__pyx_t_11) == 2)) {
1198
 
                PyObject* tuple = __pyx_t_11;
1199
 
                __pyx_t_5 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_5);
1200
 
                __pyx_t_10 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_10);
1201
 
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1202
 
                __Pyx_DECREF(__pyx_v_jumped_end);
1203
 
                __pyx_v_jumped_end = __pyx_t_5;
1204
 
                __pyx_t_5 = 0;
1205
 
                __Pyx_DECREF(__pyx_v_forget2);
1206
 
                __pyx_v_forget2 = __pyx_t_10;
1207
 
                __pyx_t_10 = 0;
1208
 
              } else {
1209
 
                __pyx_t_13 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1210
 
                __Pyx_GOTREF(__pyx_t_13);
1211
 
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1212
 
                __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_13, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1213
 
                __Pyx_GOTREF(__pyx_t_5);
1214
 
                __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_13, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1215
 
                __Pyx_GOTREF(__pyx_t_10);
1216
 
                if (__Pyx_EndUnpack(__pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1217
 
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
1218
 
                __Pyx_DECREF(__pyx_v_jumped_end);
1219
 
                __pyx_v_jumped_end = __pyx_t_5;
1220
 
                __pyx_t_5 = 0;
1221
 
                __Pyx_DECREF(__pyx_v_forget2);
1222
 
                __pyx_v_forget2 = __pyx_t_10;
1223
 
                __pyx_t_10 = 0;
1224
 
              }
1225
 
            } else {
1226
 
              __pyx_t_10 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1227
 
              __Pyx_GOTREF(__pyx_t_10);
1228
 
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1229
 
              __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_10, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1230
 
              __Pyx_GOTREF(__pyx_t_1);
1231
 
              __pyx_t_11 = __Pyx_UnpackItem(__pyx_t_10, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1232
 
              __Pyx_GOTREF(__pyx_t_11);
1233
 
              if (__Pyx_EndUnpack(__pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1234
 
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1235
 
              if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
1236
 
                PyObject* tuple = __pyx_t_1;
1237
 
                __pyx_t_10 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_10);
1238
 
                __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_10); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1239
 
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1240
 
                __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
1241
 
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1242
 
                __pyx_v_start = __pyx_t_12;
1243
 
                __Pyx_DECREF(__pyx_v_forget1);
1244
 
                __pyx_v_forget1 = __pyx_t_5;
1245
 
                __pyx_t_5 = 0;
1246
 
              } else {
1247
 
                __pyx_t_13 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1248
 
                __Pyx_GOTREF(__pyx_t_13);
1249
 
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1250
 
                __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_13, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1251
 
                __Pyx_GOTREF(__pyx_t_10);
1252
 
                __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_10); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1253
 
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1254
 
                __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_13, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1255
 
                __Pyx_GOTREF(__pyx_t_5);
1256
 
                if (__Pyx_EndUnpack(__pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1257
 
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
1258
 
                __pyx_v_start = __pyx_t_12;
1259
 
                __Pyx_DECREF(__pyx_v_forget1);
1260
 
                __pyx_v_forget1 = __pyx_t_5;
1261
 
                __pyx_t_5 = 0;
1262
 
              }
1263
 
              if (PyTuple_CheckExact(__pyx_t_11) && likely(PyTuple_GET_SIZE(__pyx_t_11) == 2)) {
1264
 
                PyObject* tuple = __pyx_t_11;
1265
 
                __pyx_t_5 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_5);
1266
 
                __pyx_t_10 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_10);
1267
 
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1268
 
                __Pyx_DECREF(__pyx_v_jumped_end);
1269
 
                __pyx_v_jumped_end = __pyx_t_5;
1270
 
                __pyx_t_5 = 0;
1271
 
                __Pyx_DECREF(__pyx_v_forget2);
1272
 
                __pyx_v_forget2 = __pyx_t_10;
1273
 
                __pyx_t_10 = 0;
1274
 
              } else {
1275
 
                __pyx_t_13 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1276
 
                __Pyx_GOTREF(__pyx_t_13);
1277
 
                __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1278
 
                __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_13, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1279
 
                __Pyx_GOTREF(__pyx_t_5);
1280
 
                __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_13, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1281
 
                __Pyx_GOTREF(__pyx_t_10);
1282
 
                if (__Pyx_EndUnpack(__pyx_t_13) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1283
 
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
1284
 
                __Pyx_DECREF(__pyx_v_jumped_end);
1285
 
                __pyx_v_jumped_end = __pyx_t_5;
1286
 
                __pyx_t_5 = 0;
1287
 
                __Pyx_DECREF(__pyx_v_forget2);
1288
 
                __pyx_v_forget2 = __pyx_t_10;
1289
 
                __pyx_t_10 = 0;
1290
 
              }
1291
 
            }
1292
 
            goto __pyx_L19;
1293
 
          }
1294
 
          __pyx_L19:;
1295
 
 
1296
 
          /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":68
1297
 
 *                     if start - end  < min_gap_length:
1298
 
 *                         ((start, forget1), (jumped_end, forget2)) = result.pop()
1299
 
 *                     end = i - 1             # <<<<<<<<<<<<<<
1300
 
 *                     result.append(((start, start+diagonal), (end, end+diagonal)))
1301
 
 *                     was_high = 0
1302
 
 */
1303
 
          __pyx_v_end = (__pyx_v_i - 1);
1304
 
 
1305
 
          /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":69
1306
 
 *                         ((start, forget1), (jumped_end, forget2)) = result.pop()
1307
 
 *                     end = i - 1
1308
 
 *                     result.append(((start, start+diagonal), (end, end+diagonal)))             # <<<<<<<<<<<<<<
1309
 
 *                     was_high = 0
1310
 
 *         if was_high:
1311
 
 */
1312
 
          __pyx_t_4 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1313
 
          __Pyx_GOTREF(__pyx_t_4);
1314
 
          __pyx_t_11 = PyInt_FromLong((__pyx_v_start + __pyx_v_diagonal)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1315
 
          __Pyx_GOTREF(__pyx_t_11);
1316
 
          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1317
 
          __Pyx_GOTREF(__pyx_t_1);
1318
 
          PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
1319
 
          __Pyx_GIVEREF(__pyx_t_4);
1320
 
          PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11);
1321
 
          __Pyx_GIVEREF(__pyx_t_11);
1322
 
          __pyx_t_4 = 0;
1323
 
          __pyx_t_11 = 0;
1324
 
          __pyx_t_11 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1325
 
          __Pyx_GOTREF(__pyx_t_11);
1326
 
          __pyx_t_4 = PyInt_FromLong((__pyx_v_end + __pyx_v_diagonal)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1327
 
          __Pyx_GOTREF(__pyx_t_4);
1328
 
          __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1329
 
          __Pyx_GOTREF(__pyx_t_10);
1330
 
          PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11);
1331
 
          __Pyx_GIVEREF(__pyx_t_11);
1332
 
          PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4);
1333
 
          __Pyx_GIVEREF(__pyx_t_4);
1334
 
          __pyx_t_11 = 0;
1335
 
          __pyx_t_4 = 0;
1336
 
          __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1337
 
          __Pyx_GOTREF(__pyx_t_4);
1338
 
          PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
1339
 
          __Pyx_GIVEREF(__pyx_t_1);
1340
 
          PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_10);
1341
 
          __Pyx_GIVEREF(__pyx_t_10);
1342
 
          __pyx_t_1 = 0;
1343
 
          __pyx_t_10 = 0;
1344
 
          __pyx_t_10 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_t_4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1345
 
          __Pyx_GOTREF(__pyx_t_10);
1346
 
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1347
 
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1348
 
 
1349
 
          /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":70
1350
 
 *                     end = i - 1
1351
 
 *                     result.append(((start, start+diagonal), (end, end+diagonal)))
1352
 
 *                     was_high = 0             # <<<<<<<<<<<<<<
1353
 
 *         if was_high:
1354
 
 *             end = i - 1
1355
 
 */
1356
 
          __pyx_v_was_high = 0;
1357
 
          goto __pyx_L18;
1358
 
        }
1359
 
        __pyx_L18:;
1360
 
      }
1361
 
      __pyx_L16:;
1362
 
    }
1363
 
 
1364
 
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":71
1365
 
 *                     result.append(((start, start+diagonal), (end, end+diagonal)))
1366
 
 *                     was_high = 0
1367
 
 *         if was_high:             # <<<<<<<<<<<<<<
1368
 
 *             end = i - 1
1369
 
 *             result.append(((start, start+diagonal), (end, end+diagonal)))
1370
 
 */
1371
 
    __pyx_t_9 = __pyx_v_was_high;
1372
 
    if (__pyx_t_9) {
1373
 
 
1374
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":72
1375
 
 *                     was_high = 0
1376
 
 *         if was_high:
1377
 
 *             end = i - 1             # <<<<<<<<<<<<<<
1378
 
 *             result.append(((start, start+diagonal), (end, end+diagonal)))
1379
 
 *     return result
1380
 
 */
1381
 
      __pyx_v_end = (__pyx_v_i - 1);
1382
 
 
1383
 
      /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":73
1384
 
 *         if was_high:
1385
 
 *             end = i - 1
1386
 
 *             result.append(((start, start+diagonal), (end, end+diagonal)))             # <<<<<<<<<<<<<<
1387
 
 *     return result
1388
 
 */
1389
 
      __pyx_t_10 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1390
 
      __Pyx_GOTREF(__pyx_t_10);
1391
 
      __pyx_t_4 = PyInt_FromLong((__pyx_v_start + __pyx_v_diagonal)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1392
 
      __Pyx_GOTREF(__pyx_t_4);
1393
 
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1394
 
      __Pyx_GOTREF(__pyx_t_1);
1395
 
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10);
1396
 
      __Pyx_GIVEREF(__pyx_t_10);
1397
 
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
1398
 
      __Pyx_GIVEREF(__pyx_t_4);
1399
 
      __pyx_t_10 = 0;
1400
 
      __pyx_t_4 = 0;
1401
 
      __pyx_t_4 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1402
 
      __Pyx_GOTREF(__pyx_t_4);
1403
 
      __pyx_t_10 = PyInt_FromLong((__pyx_v_end + __pyx_v_diagonal)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1404
 
      __Pyx_GOTREF(__pyx_t_10);
1405
 
      __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1406
 
      __Pyx_GOTREF(__pyx_t_11);
1407
 
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4);
1408
 
      __Pyx_GIVEREF(__pyx_t_4);
1409
 
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10);
1410
 
      __Pyx_GIVEREF(__pyx_t_10);
1411
 
      __pyx_t_4 = 0;
1412
 
      __pyx_t_10 = 0;
1413
 
      __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1414
 
      __Pyx_GOTREF(__pyx_t_10);
1415
 
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1);
1416
 
      __Pyx_GIVEREF(__pyx_t_1);
1417
 
      PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_11);
1418
 
      __Pyx_GIVEREF(__pyx_t_11);
1419
 
      __pyx_t_1 = 0;
1420
 
      __pyx_t_11 = 0;
1421
 
      __pyx_t_11 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1422
 
      __Pyx_GOTREF(__pyx_t_11);
1423
 
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
1424
 
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
1425
 
      goto __pyx_L20;
1426
 
    }
1427
 
    __pyx_L20:;
1428
 
  }
1429
 
 
1430
 
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":74
1431
 
 *             end = i - 1
1432
 
 *             result.append(((start, start+diagonal), (end, end+diagonal)))
 
977
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
 
978
        __Pyx_GIVEREF(__pyx_t_1);
 
979
        PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
 
980
        __Pyx_GIVEREF(__pyx_t_6);
 
981
        __pyx_t_1 = 0;
 
982
        __pyx_t_6 = 0;
 
983
        __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
984
        __Pyx_GOTREF(__pyx_t_6);
 
985
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
986
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
987
 
 
988
        /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":58
 
989
 *             if was_high:
 
990
 *                 result.append((start, i))
 
991
 *                 prior_end = i             # <<<<<<<<<<<<<<
 
992
 *                 was_high = 0
 
993
 *     if was_high:
 
994
 */
 
995
        __pyx_v_prior_end = __pyx_v_i;
 
996
 
 
997
        /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":59
 
998
 *                 result.append((start, i))
 
999
 *                 prior_end = i
 
1000
 *                 was_high = 0             # <<<<<<<<<<<<<<
 
1001
 *     if was_high:
 
1002
 *         result.append((start, i_hi))
 
1003
 */
 
1004
        __pyx_v_was_high = 0;
 
1005
        goto __pyx_L14;
 
1006
      }
 
1007
      __pyx_L14:;
 
1008
    }
 
1009
    __pyx_L10:;
 
1010
  }
 
1011
 
 
1012
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":60
 
1013
 *                 prior_end = i
 
1014
 *                 was_high = 0
 
1015
 *     if was_high:             # <<<<<<<<<<<<<<
 
1016
 *         result.append((start, i_hi))
 
1017
 *     return result
 
1018
 */
 
1019
  __pyx_t_3 = __pyx_v_was_high;
 
1020
  if (__pyx_t_3) {
 
1021
 
 
1022
    /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":61
 
1023
 *                 was_high = 0
 
1024
 *     if was_high:
 
1025
 *         result.append((start, i_hi))             # <<<<<<<<<<<<<<
 
1026
 *     return result
 
1027
 */
 
1028
    __pyx_t_6 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1029
    __Pyx_GOTREF(__pyx_t_6);
 
1030
    __pyx_t_5 = PyInt_FromLong(__pyx_v_i_hi); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1031
    __Pyx_GOTREF(__pyx_t_5);
 
1032
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1033
    __Pyx_GOTREF(__pyx_t_1);
 
1034
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
 
1035
    __Pyx_GIVEREF(__pyx_t_6);
 
1036
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
 
1037
    __Pyx_GIVEREF(__pyx_t_5);
 
1038
    __pyx_t_6 = 0;
 
1039
    __pyx_t_5 = 0;
 
1040
    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_result, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1041
    __Pyx_GOTREF(__pyx_t_5);
 
1042
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
1043
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
1044
    goto __pyx_L15;
 
1045
  }
 
1046
  __pyx_L15:;
 
1047
 
 
1048
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":62
 
1049
 *     if was_high:
 
1050
 *         result.append((start, i_hi))
1433
1051
 *     return result             # <<<<<<<<<<<<<<
1434
1052
 */
1435
1053
  __Pyx_XDECREF(__pyx_r);
1441
1059
  goto __pyx_L0;
1442
1060
  __pyx_L1_error:;
1443
1061
  __Pyx_XDECREF(__pyx_t_1);
1444
 
  __Pyx_XDECREF(__pyx_t_4);
1445
1062
  __Pyx_XDECREF(__pyx_t_5);
1446
 
  __Pyx_XDECREF(__pyx_t_10);
1447
 
  __Pyx_XDECREF(__pyx_t_11);
1448
 
  __Pyx_XDECREF(__pyx_t_13);
1449
 
  __Pyx_AddTraceback("cogent.align._compare.dotplot");
 
1063
  __Pyx_XDECREF(__pyx_t_6);
 
1064
  __Pyx_XDECREF(__pyx_t_8);
 
1065
  __Pyx_AddTraceback("cogent.align._compare.segments_from_diagonal");
1450
1066
  __pyx_r = NULL;
1451
1067
  __pyx_L0:;
1452
1068
  __Pyx_DECREF(__pyx_v_result);
1453
 
  __Pyx_DECREF(__pyx_v_forget1);
1454
1069
  __Pyx_DECREF(__pyx_v_jumped_end);
1455
 
  __Pyx_DECREF(__pyx_v_forget2);
1456
 
  __Pyx_DECREF(__pyx_v_min_gap_length);
1457
 
  __Pyx_DECREF(__pyx_v_band);
1458
1070
  __Pyx_XGIVEREF(__pyx_r);
1459
1071
  __Pyx_RefNannyFinishContext();
1460
1072
  return __pyx_r;
1461
1073
}
1462
1074
 
1463
1075
static struct PyMethodDef __pyx_methods[] = {
1464
 
  {__Pyx_NAMESTR("dotplot"), (PyCFunction)__pyx_pf_6cogent_5align_8_compare_dotplot, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6cogent_5align_8_compare_dotplot)},
 
1076
  {__Pyx_NAMESTR("segments_from_diagonal"), (PyCFunction)__pyx_pf_6cogent_5align_8_compare_segments_from_diagonal, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6cogent_5align_8_compare_segments_from_diagonal)},
1465
1077
  {0, 0, 0, 0}
1466
1078
};
1467
1079
 
1484
1096
static __Pyx_StringTabEntry __pyx_string_tab[] = {
1485
1097
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
1486
1098
  {&__pyx_kp_u_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 1, 0, 0},
 
1099
  {&__pyx_n_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 1},
1487
1100
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
1488
1101
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
1489
1102
  {&__pyx_n_s____version__, __pyx_k____version__, sizeof(__pyx_k____version__), 0, 0, 1, 1},
1490
 
  {&__pyx_n_s__band, __pyx_k__band, sizeof(__pyx_k__band), 0, 0, 1, 1},
1491
 
  {&__pyx_n_s__dotplot, __pyx_k__dotplot, sizeof(__pyx_k__dotplot), 0, 0, 1, 1},
1492
 
  {&__pyx_n_s__max, __pyx_k__max, sizeof(__pyx_k__max), 0, 0, 1, 1},
1493
 
  {&__pyx_n_s__min, __pyx_k__min, sizeof(__pyx_k__min), 0, 0, 1, 1},
 
1103
  {&__pyx_n_s__diagonal, __pyx_k__diagonal, sizeof(__pyx_k__diagonal), 0, 0, 1, 1},
1494
1104
  {&__pyx_n_s__min_gap_length, __pyx_k__min_gap_length, sizeof(__pyx_k__min_gap_length), 0, 0, 1, 1},
1495
 
  {&__pyx_n_s__progress, __pyx_k__progress, sizeof(__pyx_k__progress), 0, 0, 1, 1},
1496
 
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
1497
1105
  {&__pyx_n_s__seq1, __pyx_k__seq1, sizeof(__pyx_k__seq1), 0, 0, 1, 1},
1498
1106
  {&__pyx_n_s__seq2, __pyx_k__seq2, sizeof(__pyx_k__seq2), 0, 0, 1, 1},
1499
1107
  {&__pyx_n_s__threshold, __pyx_k__threshold, sizeof(__pyx_k__threshold), 0, 0, 1, 1},
 
1108
  {&__pyx_n_s__version_info, __pyx_k__version_info, sizeof(__pyx_k__version_info), 0, 0, 1, 1},
1500
1109
  {&__pyx_n_s__window, __pyx_k__window, sizeof(__pyx_k__window), 0, 0, 1, 1},
1501
1110
  {0, 0, 0, 0, 0, 0, 0}
1502
1111
};
1503
1112
static int __Pyx_InitCachedBuiltins(void) {
1504
 
  __pyx_builtin_max = __Pyx_GetName(__pyx_b, __pyx_n_s__max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1505
 
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1506
 
  __pyx_builtin_min = __Pyx_GetName(__pyx_b, __pyx_n_s__min); if (!__pyx_builtin_min) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1507
1113
  return 0;
1508
 
  __pyx_L1_error:;
1509
1114
  return -1;
1510
1115
}
1511
1116
 
1512
1117
static int __Pyx_InitGlobals(void) {
1513
1118
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
1514
1119
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
1515
 
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
 
1120
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
1516
1121
  return 0;
1517
1122
  __pyx_L1_error:;
1518
1123
  return -1;
1584
1189
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":4
1585
1190
 * """
1586
1191
 * 
1587
 
 * __version__ = "('1', '4', '1')"             # <<<<<<<<<<<<<<
1588
 
 * 
1589
 
 * # Because this can be long-running check for interupts in the outer loop
1590
 
 */
1591
 
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____version__, ((PyObject *)__pyx_kp_s_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1192
 * version_info = (1, 3)             # <<<<<<<<<<<<<<
 
1193
 * __version__ = "('1', '5', '0')"
 
1194
 * 
 
1195
 */
 
1196
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1197
  __Pyx_GOTREF(__pyx_t_1);
 
1198
  __Pyx_INCREF(__pyx_int_1);
 
1199
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_1);
 
1200
  __Pyx_GIVEREF(__pyx_int_1);
 
1201
  __Pyx_INCREF(__pyx_int_3);
 
1202
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_3);
 
1203
  __Pyx_GIVEREF(__pyx_int_3);
 
1204
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__version_info, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1205
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
1206
 
 
1207
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":5
 
1208
 * 
 
1209
 * version_info = (1, 3)
 
1210
 * __version__ = "('1', '5', '0')"             # <<<<<<<<<<<<<<
 
1211
 * 
 
1212
 * cdef int cmax(int a, int b):
 
1213
 */
 
1214
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____version__, ((PyObject *)__pyx_kp_s_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1592
1215
 
1593
1216
  /* "/Users/mcdonald/ResearchWork/pycogent/trunk/cogent/align/_compare.pyx":1
1594
1217
 * """50x speedup for dotplots, but sequences must be strings and scoring is based on identity only             # <<<<<<<<<<<<<<
1597
1220
 */
1598
1221
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1599
1222
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
1600
 
  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__dotplot); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
1223
  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1601
1224
  __Pyx_GOTREF(__pyx_t_2);
1602
1225
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__");
1603
1226
  __Pyx_GOTREF(__pyx_t_3);
1758
1381
    return -1;
1759
1382
}
1760
1383
 
1761
 
static INLINE long __Pyx_mod_long(long a, long b) {
1762
 
    long r = a % b;
1763
 
    r += ((r != 0) & ((r ^ b) < 0)) * b;
1764
 
    return r;
1765
 
}
1766
 
 
1767
1384
static INLINE int __Pyx_mod_int(int a, int b) {
1768
1385
    int r = a % b;
1769
1386
    r += ((r != 0) & ((r ^ b) < 0)) * b;
1807
1424
        return -1;
1808
1425
}
1809
1426
 
1810
 
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
1811
 
    PyObject *result;
1812
 
    result = PyObject_GetAttr(dict, name);
1813
 
    if (!result)
1814
 
        PyErr_SetObject(PyExc_NameError, name);
1815
 
    return result;
1816
 
}
1817
 
 
1818
 
static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
1819
 
    PyObject *tmp_type, *tmp_value, *tmp_tb;
1820
 
    PyThreadState *tstate = PyThreadState_GET();
1821
 
 
1822
 
    tmp_type = tstate->curexc_type;
1823
 
    tmp_value = tstate->curexc_value;
1824
 
    tmp_tb = tstate->curexc_traceback;
1825
 
    tstate->curexc_type = type;
1826
 
    tstate->curexc_value = value;
1827
 
    tstate->curexc_traceback = tb;
1828
 
    Py_XDECREF(tmp_type);
1829
 
    Py_XDECREF(tmp_value);
1830
 
    Py_XDECREF(tmp_tb);
1831
 
}
1832
 
 
1833
 
static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
1834
 
    PyThreadState *tstate = PyThreadState_GET();
1835
 
    *type = tstate->curexc_type;
1836
 
    *value = tstate->curexc_value;
1837
 
    *tb = tstate->curexc_traceback;
1838
 
 
1839
 
    tstate->curexc_type = 0;
1840
 
    tstate->curexc_value = 0;
1841
 
    tstate->curexc_traceback = 0;
1842
 
}
1843
 
 
1844
 
 
1845
 
#if PY_MAJOR_VERSION < 3
1846
 
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
1847
 
    Py_XINCREF(type);
1848
 
    Py_XINCREF(value);
1849
 
    Py_XINCREF(tb);
1850
 
    /* First, check the traceback argument, replacing None with NULL. */
1851
 
    if (tb == Py_None) {
1852
 
        Py_DECREF(tb);
1853
 
        tb = 0;
1854
 
    }
1855
 
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
1856
 
        PyErr_SetString(PyExc_TypeError,
1857
 
            "raise: arg 3 must be a traceback or None");
1858
 
        goto raise_error;
1859
 
    }
1860
 
    /* Next, replace a missing value with None */
1861
 
    if (value == NULL) {
1862
 
        value = Py_None;
1863
 
        Py_INCREF(value);
1864
 
    }
1865
 
    #if PY_VERSION_HEX < 0x02050000
1866
 
    if (!PyClass_Check(type))
1867
 
    #else
1868
 
    if (!PyType_Check(type))
1869
 
    #endif
1870
 
    {
1871
 
        /* Raising an instance.  The value should be a dummy. */
1872
 
        if (value != Py_None) {
1873
 
            PyErr_SetString(PyExc_TypeError,
1874
 
                "instance exception may not have a separate value");
1875
 
            goto raise_error;
1876
 
        }
1877
 
        /* Normalize to raise <class>, <instance> */
1878
 
        Py_DECREF(value);
1879
 
        value = type;
1880
 
        #if PY_VERSION_HEX < 0x02050000
1881
 
            if (PyInstance_Check(type)) {
1882
 
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
1883
 
                Py_INCREF(type);
1884
 
            }
1885
 
            else {
1886
 
                type = 0;
1887
 
                PyErr_SetString(PyExc_TypeError,
1888
 
                    "raise: exception must be an old-style class or instance");
1889
 
                goto raise_error;
1890
 
            }
1891
 
        #else
1892
 
            type = (PyObject*) Py_TYPE(type);
1893
 
            Py_INCREF(type);
1894
 
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
1895
 
                PyErr_SetString(PyExc_TypeError,
1896
 
                    "raise: exception class must be a subclass of BaseException");
1897
 
                goto raise_error;
1898
 
            }
1899
 
        #endif
1900
 
    }
1901
 
 
1902
 
    __Pyx_ErrRestore(type, value, tb);
1903
 
    return;
1904
 
raise_error:
1905
 
    Py_XDECREF(value);
1906
 
    Py_XDECREF(type);
1907
 
    Py_XDECREF(tb);
1908
 
    return;
1909
 
}
1910
 
 
1911
 
#else /* Python 3+ */
1912
 
 
1913
 
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
1914
 
    if (tb == Py_None) {
1915
 
        tb = 0;
1916
 
    } else if (tb && !PyTraceBack_Check(tb)) {
1917
 
        PyErr_SetString(PyExc_TypeError,
1918
 
            "raise: arg 3 must be a traceback or None");
1919
 
        goto bad;
1920
 
    }
1921
 
    if (value == Py_None)
1922
 
        value = 0;
1923
 
 
1924
 
    if (PyExceptionInstance_Check(type)) {
1925
 
        if (value) {
1926
 
            PyErr_SetString(PyExc_TypeError,
1927
 
                "instance exception may not have a separate value");
1928
 
            goto bad;
1929
 
        }
1930
 
        value = type;
1931
 
        type = (PyObject*) Py_TYPE(value);
1932
 
    } else if (!PyExceptionClass_Check(type)) {
1933
 
        PyErr_SetString(PyExc_TypeError,
1934
 
            "raise: exception class must be a subclass of BaseException");
1935
 
        goto bad;
1936
 
    }
1937
 
 
1938
 
    PyErr_SetObject(type, value);
1939
 
 
1940
 
    if (tb) {
1941
 
        PyThreadState *tstate = PyThreadState_GET();
1942
 
        PyObject* tmp_tb = tstate->curexc_traceback;
1943
 
        if (tb != tmp_tb) {
1944
 
            Py_INCREF(tb);
1945
 
            tstate->curexc_traceback = tb;
1946
 
            Py_XDECREF(tmp_tb);
1947
 
        }
1948
 
    }
1949
 
 
1950
 
bad:
1951
 
    return;
1952
 
}
1953
 
#endif
1954
 
 
1955
 
#if PY_MAJOR_VERSION < 3
1956
 
static PyObject *__Pyx_GetStdout(void) {
1957
 
    PyObject *f = PySys_GetObject((char *)"stdout");
1958
 
    if (!f) {
1959
 
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
1960
 
    }
1961
 
    return f;
1962
 
}
1963
 
 
1964
 
static int __Pyx_Print(PyObject *arg_tuple, int newline) {
1965
 
    PyObject *f;
1966
 
    PyObject* v;
1967
 
    int i;
1968
 
 
1969
 
    if (!(f = __Pyx_GetStdout()))
1970
 
        return -1;
1971
 
    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
1972
 
        if (PyFile_SoftSpace(f, 1)) {
1973
 
            if (PyFile_WriteString(" ", f) < 0)
1974
 
                return -1;
1975
 
        }
1976
 
        v = PyTuple_GET_ITEM(arg_tuple, i);
1977
 
        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
1978
 
            return -1;
1979
 
        if (PyString_Check(v)) {
1980
 
            char *s = PyString_AsString(v);
1981
 
            Py_ssize_t len = PyString_Size(v);
1982
 
            if (len > 0 &&
1983
 
                isspace(Py_CHARMASK(s[len-1])) &&
1984
 
                s[len-1] != ' ')
1985
 
                    PyFile_SoftSpace(f, 0);
1986
 
        }
1987
 
    }
1988
 
    if (newline) {
1989
 
        if (PyFile_WriteString("\n", f) < 0)
1990
 
            return -1;
1991
 
        PyFile_SoftSpace(f, 0);
1992
 
    }
1993
 
    return 0;
1994
 
}
1995
 
 
1996
 
#else /* Python 3 has a print function */
1997
 
 
1998
 
static int __Pyx_Print(PyObject *arg_tuple, int newline) {
1999
 
    PyObject* kwargs = 0;
2000
 
    PyObject* result = 0;
2001
 
    PyObject* end_string;
2002
 
    if (!__pyx_print) {
2003
 
        __pyx_print = __Pyx_GetAttrString(__pyx_b, "print");
2004
 
        if (!__pyx_print)
2005
 
            return -1;
2006
 
    }
2007
 
    if (!newline) {
2008
 
        if (!__pyx_print_kwargs) {
2009
 
            __pyx_print_kwargs = PyDict_New();
2010
 
            if (!__pyx_print_kwargs)
2011
 
                return -1;
2012
 
            end_string = PyUnicode_FromStringAndSize(" ", 1);
2013
 
            if (!end_string)
2014
 
                return -1;
2015
 
            if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) {
2016
 
                Py_DECREF(end_string);
2017
 
                return -1;
2018
 
            }
2019
 
            Py_DECREF(end_string);
2020
 
        }
2021
 
        kwargs = __pyx_print_kwargs;
2022
 
    }
2023
 
    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
2024
 
    if (!result)
2025
 
        return -1;
2026
 
    Py_DECREF(result);
2027
 
    return 0;
2028
 
}
2029
 
 
2030
 
#endif
2031
 
 
2032
1427
static INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
2033
1428
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
2034
1429
    const int is_unsigned = neg_one > const_zero;