File: solexapairend.py

package info (click to toggle)
obitools 3.0.1~b26%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,756 kB
  • sloc: ansic: 24,299; python: 657; sh: 27; makefile: 21
file content (54 lines) | stat: -rwxr-xr-x 1,369 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#cython: language_level=3

'''
Created on 17 mai 2010

@author: coissac
'''

from obitools3.libalign import columnIterator


def iterOnAligment(ali):
    pos0=0
    pos1=0
    begin0=False
    end0=False
    begin1=False
    end1=False
    
    for nuc0,nuc1 in columnIterator(ali):
        if nuc0==b"-":
            if begin0:
                if not end0:
                    score0 = ( ali[0].wrapped.quality_array[pos0-1]
                              +ali[0].wrapped.quality_array[pos0]
                             )/2
                else:
                    score0 = 1.
            else:
                score0 = 0.
        else:
            begin0=True
            score0 = ali[0].wrapped.quality_array[pos0]
            pos0+=1
            end0= pos0==len(ali[0].wrapped)
            
        if nuc1==b"-":
            if begin1:
                if not end1:
                    score1 = ( ali[1].wrapped.quality_array[pos1-1]
                              +ali[1].wrapped.quality_array[pos1]
                             )/2
                else:
                    score1 = 0.
            else:
                score1 = 1.
        else:
            begin1=True
            score1 = ali[1].wrapped.quality_array[pos1]
            pos1+=1
            end1= pos1==len(ali[1].wrapped)
        
        result = (nuc0,score0,nuc1,score1)
        yield result