GitHub PullRequestReviewCommentEvent at 2014-03-18 02:24:14
Repository: pywrap-ssw
Actor: ebolyen
Payload: {"comment":{"url":"https://api.github.com/repos/biocore/pywrap-ssw/pulls/comments/10688288","id":10688288,"diff_hunk":"@@ -0,0 +1,327 @@\n+#!/usr/bin/env python\n+\n+#-----------------------------------------------------------------------------\n+# Copyright (c) 2014--, biocore team.\n+#\n+# Distributed under the terms of the Modified BSD License.\n+#\n+# The full license is in the file COPYING.txt, distributed with this software.\n+#-----------------------------------------------------------------------------\n+\n+from cpython cimport bool\n+import numpy as np\n+cimport numpy as np\n+\n+cdef extern from \"ssw_native.h\":\n+\n+    ctypedef struct s_align:\n+        np.uint16_t score1\n+        np.uint16_t score2\n+        np.int32_t ref_begin1\n+        np.int32_t ref_end1\n+        np.int32_t read_begin1\n+        np.int32_t read_end1\n+        np.int32_t ref_end2\n+        np.uint32_t* cigar\n+        np.int32_t cigarLen\n+\n+    ctypedef struct s_profile:\n+        pass\n+\n+    cdef s_profile* ssw_init(const np.int8_t* read, \n+                             const np.int32_t readLen, \n+                             const np.int8_t* mat,\n+                             const np.int32_t n, \n+                             const np.int8_t score_size)\n+\n+    cdef void init_destroy(s_profile* p)\n+\n+    cdef s_align* ssw_align(const s_profile* prof, \n+                            const np.int8_t* ref, \n+                            np.int32_t refLen, \n+                            const np.uint8_t weight_gapO, \n+                            const np.uint8_t weight_gapE, \n+                            const np.uint8_t flag, \n+                            const np.uint16_t filters,\n+                            const np.int32_t filterd,\n+                            const np.int32_t maskLen)\n+\n+    cdef void align_destroy(s_align* a)\n+\n+np_aa_table = np.array([\n+        23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n+        23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n+        23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n+        23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n+        23,  0, 20,  4,  3,  6, 13,  7,  8,  9, 23, 11, 10, 12,  2, 23,\n+        14,  5,  1, 15, 16, 23, 19, 17, 22, 18, 21, 23, 23, 23, 23, 23,\n+        23,  0, 20,  4,  3,  6, 13,  7,  8,  9, 23, 11, 10, 12,  2, 23,\n+        14,  5,  1, 15, 16, 23, 19, 17, 22, 18, 21, 23, 23, 23, 23, 23])\n+\n+np_nt_table = np.array([\n+         4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,\n+         4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,\n+         4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,\n+         4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,\n+         4,  0,  4,  1,  4,  4,  4,  2,  4,  4,  4,  4,  4,  4,  4,  4,\n+         4,  4,  4,  4,  3,  0,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,\n+         4,  0,  4,  1,  4,  4,  4,  2,  4,  4,  4,  4,  4,  4,  4,  4,\n+         4,  4,  4,  4,  3,  0,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4])\n+\n+mid_table = np.array(['M','I','D'])\n+\n+cdef class AlignmentStructure:\n+    cdef s_align *p\n+    cdef str read_sequence\n+    cdef str reference_sequence\n+    cdef int index_starts_at\n+\n+    def __cinit__(self, read_sequence, reference_sequence, index_starts_at):\n+        self.read_sequence = read_sequence\n+        self.reference_sequence = reference_sequence\n+        self.index_starts_at = index_starts_at\n+\n+    cdef __constructor__(self, s_align* pointer):\n+        self.p = pointer\n+    \n+    def __dealloc__(self):\n+        if self.p is not NULL:\n+            align_destroy(self.p)\n+\n+    cdef _get_cigar(self):\n+        cigar_string = \"\"\n+        for i in range(self.p.cigarLen):\n+            cigar_string += str(self.p.cigar[i]>>4)\n+            cigar_string += mid_table[self.p.cigar[i]&0xf]\n+        return cigar_string\n+\n+    def __str__(self):\n+        return \"{\\n    '%s': %d,\\n\"\\\n+                  \"    '%s': %d,\\n\"\\\n+                  \"    '%s': %d,\\n\"\\\n+                  \"    '%s': %d,\\n\"\\\n+                  \"    '%s': %d,\\n\"\\\n+                  \"    '%s': %d,\\n\"\\\n+                  \"    '%s': %d,\\n\"\\\n+                  \"    '%s': '%s',\\n\"\\\n+                  \"    '%s': '%s',\\n\"\\\n+                  \"    '%s': '%s'\\n}\" % \\\n+                   (\n+                    'optimal_alignment_score',self.optimal_alignment_score,\n+                    'suboptimal_alignment_score',self.suboptimal_alignment_score,\n+                    'target_begin',self.target_begin1,\n+                    'target_end_optimal',self.target_end_optimal,\n+                    'target_end_suboptimal',self.target_end_suboptimal,\n+                    'query_begin',self.query_begin1,\n+                    'query_end',self.query_end1,\n+                    'cigar',self.cigar,\n+                    'query_sequence', self.query_sequence,\n+                    'target_sequence', self.target_sequence\n+                    )\n+\n+    def __getattr__(self, name):\n+        index_starts_at =  self.index_starts_at\n+\n+        if name == 'optimal_alignment_score':","path":"ssw.pyx","position":125,"original_position":125,"commit_id":"b7f314be6c073794243289e0c77e985101d4dd05","original_commit_id":"b7f314be6c073794243289e0c77e985101d4dd05","user":{"login":"ebolyen","id":3976804,"avatar_url":"https://avatars.githubusercontent.com/u/3976804?","gravatar_id":"33e6f018b7faea6c4822f0a5f1e1a2f8","url":"https://api.github.com/users/ebolyen","html_url":"https://github.com/ebolyen","followers_url":"https://api.github.com/users/ebolyen/followers","following_url":"https://api.github.com/users/ebolyen/following{/other_user}","gists_url":"https://api.github.com/users/ebolyen/gists{/gist_id}","starred_url":"https://api.github.com/users/ebolyen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebolyen/subscriptions","organizations_url":"https://api.github.com/users/ebolyen/orgs","repos_url":"https://api.github.com/users/ebolyen/repos","events_url":"https://api.github.com/users/ebolyen/events{/privacy}","received_events_url":"https://api.github.com/users/ebolyen/received_events","type":"User","site_admin":false},"body":"Unfortunately this doesn't work in cython. I have tried. Regardless it is changing to property decorators ","created_at":"2014-03-18T02:24:14Z","updated_at":"2014-03-18T02:24:14Z","html_url":"https://github.com/biocore/pywrap-ssw/pull/1#discussion_r10688288","pull_request_url":"https://api.github.com/repos/biocore/pywrap-ssw/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/biocore/pywrap-ssw/pulls/comments/10688288"},"html":{"href":"https://github.com/biocore/pywrap-ssw/pull/1#discussion_r10688288"},"pull_request":{"href":"https://api.github.com/repos/biocore/pywrap-ssw/pulls/1"}}}}