comparison test.py @ 2:46fb79167a61 tip

Main Code
author Victor Padilla <victor.padilla.mc@gmail.com>
date Mon, 04 May 2015 22:56:18 +0200
parents
children
comparison
equal deleted inserted replaced
1:0f7f611deca4 2:46fb79167a61
1 '''
2 @organization: Lancaster University & University of Leeds
3 @version: 1.0
4 Created on 11/12/2014
5
6 @author: Victor Padilla
7 @contact: v.padilla@lancaster.ac.uk
8
9 test file for checking
10 '''
11
12 from MultipleOMR.Alignment import FastAlignmentArrays
13 from MultipleOMR.Alignment import NWunsch
14
15 a=["foo00","abc","123"]
16 b=["foo000","abc","1234"]
17
18 # a=['TS:3/8', 'CL:G', 'KS:0', u'N:C5_0.125', '!', u'N:B4_1.0', u'N:A4_0.5', '!', 'R:1.5', '!', 'R:0.5', u'N:F5_0.25', u'N:D5_0.25', u'N:E5_0.25', u'N:F5_0.25', '!', u'N:D5_0.25', u'N:E5_0.25', u'N:F5_0.5', u'N:G5_0.5', '!', u'N:E5_0.5', '!', 'KS:-3', 'R:0.5', u'N:E-5_0.25', u'N:C5_0.25', u'N:D5_0.25', u'N:E-5_0.25', '!', u'N:C5_0.25', u'N:D5_0.25', u'N:E-5_0.5', u'N:F5_0.5', '!', u'N:D5_0.5', u'N:B-4_0.5', u'N:B-5_0.5', '!', u'N:B-5_0.5', u'N:G5_0.5', u'N:F5_0.25', '!', 'R:1.5', '!', u'N:B-4_1.0', '!', 'R:1.0', 'KS:0', u'N:E3_0.25', u'N:C3_0.25', '!', 'CL:F', u'N:D3_0.5', 'R:0.5', 'R:0.5', '!', u'N:D3_0.5', u'N:D4_0.5', u'N:D4_0.5', '!', 'R:0.25', u'N:B3_0.5', u'N:A3_0.25', u'N:G3_0.25', u'N:F3_0.25', '!', u'N:E3_0.25', '!', 'R:1.5', '!', 'KS:-3', u'N:B-4_1.0', u'N:C5_0.25', u'N:A4_0.25', '!', 'CL:G', u'C:[:A-4_0.5[:A-5_0.5', u'C:[:G4_0.5[:G5_0.5', u'C:[:B-4_0.5[:B-5_0.5', '!', u'N:D5_1.0', u'N:G5_2.0', '!', u'N:E-5_0.25', u'N:C5_0.25', u'C:[:A-4_0.5[:A-5_0.5', u'C:[:G4_0.5[:G5_0.5', '!', u'C:[:B-4_0.5[:B-5_0.5', '!', u'N:D5_1.0', u'N:G5_2.0', '!', u'N:E-5_0.25', u'N:C5_0.25', u'N:B-4_0.25', u'N:D5_0.25', u'N:F5_0.25', u'N:B-5_0.25', '!', u'N:F5_0.25', u'N:D5_0.25', u'N:E-5_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', '!', u'N:D5_0.25', u'N:F4_0.25', u'N:B-4_0.25', u'N:F4_0.25', u'N:D4_0.25', u'N:E-4_0.25', '!', u'N:C4_0.25', u'N:A3_0.25', u'N:B-3_0.5', 'R:0.5', '!', u'C:[:F3_0.5[:B-3_0.5', u'C:[:F3_0.5[:B-3_0.5', 'R:0.5', '!', 'R:0.5', '!', 'R:0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', '!', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:B-5_1.0', '!', u'N:D5_0.5', u'N:E-5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', '!', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:B-5_1.0', '!', u'N:E5_0.5', '!', u'N:F5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', '!', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:B-5_1.0', '!', u'N:F5_0.5', 'R:0.5', u'N:G-5_0.5', '!', u'N:E-5_0.5', 'R:0.5', u'N:E-5_0.5', '!', u'N:A4_0.5', 'R:0.5', u'N:B-4_0.5', '!', u'N:D5_0.5', u'N:F5_0.5', u'N:A5_0.5', '!', u'N:B-5_0.5', '!', u'N:B-4_0.5', u'C:[:D4_0.5[:A-4_0.5', '!', u'C:[:D4_0.5[:A-4_0.5', 'R:0.5', 'R:0.5', '!', 'R:0.5', 'R:0.5', u'N:B-5_0.25', u'N:G5_0.5', u'N:C6_0.25', u'N:B-5_0.25', u'N:F5_0.5', u'N:A-5_0.25', '!', u'N:B-5_0.25', u'N:E-5_0.5', u'N:A-5_0.25', u'N:G5_0.25', u'N:D5_0.5', u'N:A-5_0.25', u'N:G5_0.25', u'N:F5_0.25', '!', u'N:G5_0.25', u'N:C5_0.5', u'N:F5_0.25', u'N:E-5_0.25', u'N:B-4_0.5', u'N:F5_0.25', u'N:E-5_0.25', u'N:D5_0.25', '!', u'N:E-5_0.25', u'N:A-4_0.5', u'N:D5_0.25', u'N:C5_0.25', u'N:G4_0.5', u'N:D5_0.25', u'N:C5_0.25', u'N:B-4_0.5', '!', u'N:B-4_1.5', u'N:F4_0.5', u'N:E-4_0.5', u'N:D4_0.5', '!', u'C:[:D4_0.5[:B-4_0.5', u'C:[:E-4_0.5[:C5_0.5', u'C:[:F4_0.5[:D5_0.5', '!', u'N:E-5_0.25', u'N:G4_1.0', u'N:G5_0.375', u'N:F5_0.25', u'N:E-5_0.25', u'N:D5_0.25', u'N:E-5_0.25', '!', u'N:G4_1.0', u'C:[:A-4_0.5[:C5_0.5', u'N:D5_0.25', u'N:C5_0.25', u'N:B-4_1.0', '!', u'N:A-4_0.25', u'N:F4_0.5', u'N:G4_0.125', u'N:A-4_0.125', u'N:G4_0.5', u'N:D5_0.5', '!', u'N:E-5_0.5', '!', 'R:0.5', u'N:B-5_0.5', u'N:G5_0.5', '!', 'R:0.25', u'N:F5_0.25', u'N:G5_0.25', u'N:A-5_0.25', u'N:B-5_0.25', u'N:C6_0.25', '!', u'N:C6_0.25', u'N:B-5_0.25', u'N:A-5_0.25', u'N:G5_0.25', u'N:F5_0.25', u'N:D5_0.25', '!', u'N:E-5_0.25', u'N:B-4_0.25', u'N:G4_0.25', u'N:B-4_0.25', u'N:G4_0.25', u'N:E-4_0.25', '!', u'N:D4_0.25', u'N:F4_0.25', u'N:A-4_0.25', u'N:G4_0.25', u'N:B-4_0.25', u'N:G4_0.25', '!', u'N:E-5_0.25', u'N:B-4_0.25', u'N:G4_0.25', u'N:A-4_0.25', u'N:F4_0.25', u'N:D4_0.25', '!', u'N:E-4_0.5', 'R:0.5', u'C:[:B-3_0.5[:E-4_0.5', '!', u'C:[:B-3_0.5[:E-4_0.5', 'R:0.5', 'R:0.5', '!', u'N:E-5_0.5', u'N:E-5_0.125', u'N:F5_0.125', u'N:E-5_0.125', u'N:D-5_0.125', u'N:C5_0.5', '!', 'R:0.5', u'N:A-5_0.5', u'N:A-5_0.5', '!', u'N:G5_0.5', u'N:G5_0.125', u'N:A-5_0.125', u'N:B-5_0.125', u'N:A-5_0.125', u'N:G5_0.5', '!', 'R:0.5', u'N:D-6_0.5', u'N:D-6_0.5', '!', u'N:C6_0.5', u'N:C6_0.125', u'N:C6_1.0', u'N:D6_0.125', u'N:E-6_0.125', u'N:D6_0.125', u'N:C6_0.5', '!', 'R:0.5', 'KS:0', '!', u'N:F5_0.5', 'R:1.0', '!', u'N:F5_0.5', u'N:F5_0.25', '!', 'R:1.5', '!', 'R:1.5', '!', u'N:G4_0.5', 'KS:-3', 'R:0.5', u'N:G5_0.5', '!', u'N:F5_0.5', 'KS:0', 'R:0.5', u'N:A5_0.5', '!', 'R:0.5', u'N:C6_0.5', u'N:B-5_0.125', u'N:A5_0.125', u'N:G5_0.125', u'N:F5_0.125', '!', u'N:E5_1.0', u'N:D5_0.5', '!', 'R:4.0', '!', 'R:0.5', 'R:0.5', u'N:B5_0.25', u'N:G5_0.25', u'N:A5_0.25', u'N:B5_0.25', '!', 'R:0.5', u'N:G5_0.25', u'N:A5_0.25', '!', 'KS:-3', u'N:B-5_0.5', u'N:C6_0.5', u'N:A-5_0.5', '!', 'R:0.5', u'N:A-5_0.25', u'N:F5_0.25', u'N:G5_0.25', u'N:A-5_0.25', '!', u'N:F5_0.25', u'N:G5_0.25', u'N:A-5_0.5', u'N:B-5_0.5', '!', u'N:G5_0.5', u'N:E-5_0.5', u'N:E-6_0.5', '!', u'N:E-6_0.5', u'N:C6_0.5', '!', 'R:1.5', '!', u'N:E-5_1.0', u'N:A-5_2.0', '!', u'N:F5_0.25', u'N:D5_0.25', u'N:E-5_0.5', 'R:0.5', '!', 'R:0.5', u'N:B-4_0.5', u'N:G5_0.25', u'N:D5_0.25', '!', u'N:E-5_0.25', u'N:G5_0.25', u'N:D5_0.25', u'N:E-5_0.25', u'N:C5_0.5', '!', u'N:B-4_0.25', u'N:A-4_0.25', u'N:G4_0.25', u'N:F4_0.25', '!', u'N:E-4_1.0', u'N:A-4_2.0', '!', u'N:F4_0.25', u'N:D4_0.25', u'C:[:D-4_0.5[:D-5_0.5', u'C:[:C4_0.5[:C5_0.5', '!', u'C:[:E-4_0.5[:E-5_0.5', u'N:G4_1.0', '!', u'N:C5_2.0', '!', u'N:A-4_0.25', u'N:F4_0.25', u'C:[:D-5_0.5[:D-6_0.5', u'C:[:C5_0.5[:C6_0.5', '!', u'C:[:E-5_0.5[:E-6_0.5', '!', u'N:G5_1.0', u'N:C6_3.0', '!', u'N:A-5_0.25', u'N:F5_0.25', u'N:E-5_0.25', u'N:G5_0.25', u'N:B-5_0.25', u'N:E-6_0.25', '!', u'N:B-5_0.25', u'N:G5_0.25', u'N:A-5_0.25', u'N:F5_0.25', u'N:D5_0.25', u'N:E-5_0.25', '!', u'N:G5_0.25', u'N:B-4_0.25', u'N:E-5_0.25', u'N:B-4_0.25', u'N:G4_0.25', u'N:A-4_0.25', '!', u'N:F4_0.25', u'N:D4_0.25', u'N:E-4_0.5', 'R:0.5', '!', u'C:[:B-3_0.5[:E-4_0.5', u'C:[:B-3_0.5[:E-4_0.5', 'R:0.5', '!', 'R:0.5', '!']
19 # b=['TS:3/8', 'CL:G', 'KS:-3', 'R:0.5', u'N:G5_0.5', u'N:F5_0.125', u'N:E-5_0.125', u'N:D5_0.125', u'N:C5_0.125', '!', u'N:B-4_1.0', u'N:A4_0.5', '!', 'R:1.5', '!', 'R:0.5', u'N:F5_0.25', u'N:D5_0.25', u'N:E-5_0.25', u'N:F5_0.25', u'N:D5_0.25', u'N:E-5_0.25', '!', u'N:F5_0.5', u'N:G5_0.5', u'N:E-5_0.5', '!', 'KS:-3', 'R:0.5', u'N:E-5_0.25', u'N:C5_0.25', u'N:D5_0.25', u'N:E-5_0.25', u'N:C5_0.25', u'N:D5_0.25', '!', u'N:E-5_0.5', u'N:F5_0.5', u'N:D5_0.5', '!', u'N:B-4_0.5', u'N:B-5_0.5', u'N:B-5_0.5', '!', u'N:G5_0.5', u'N:F5_0.25', u'N:E-5_0.25', u'N:D5_0.25', u'N:C5_0.25', '!', 'KS:-3', u'N:B-4_1.0', u'N:C5_0.25', u'N:A4_0.25', '!', u'N:B-4_0.5', 'R:0.5', 'R:0.5', '!', u'N:B-4_0.5', u'N:B-5_0.5', u'N:B-5_0.5', '!', u'N:G5_0.5', u'N:F5_0.25', u'N:E-5_0.25', u'N:D5_0.25', u'N:C5_0.25', '!', 'KS:-3', u'N:B-4_1.0', u'N:C5_0.25', u'N:A4_0.25', '!', u'C:[:A-4_0.5[:A-5_0.5', u'C:[:G4_0.5[:G5_0.5', u'C:[:B-4_0.5[:B-5_0.5', '!', u'N:D5_1.0', u'N:E-5_0.25', u'N:C5_0.25', '!', u'C:[:A-4_0.5[:A-5_0.5', u'C:[:G4_0.5[:G5_0.5', u'C:[:B-4_0.5[:B-5_0.5', '!', 'KS:-3', u'N:D5_1.0', 'R:0.5', '!', u'N:B-4_0.25', u'N:D5_0.25', u'N:F5_0.25', u'N:B-5_0.25', u'N:F5_0.25', u'N:D5_0.25', u'N:E-5_0.25', u'N:C5_0.25', u'N:A4_0.25', '!', u'N:B-4_0.25', u'N:D5_0.25', u'N:F4_0.25', u'N:B-4_0.25', u'N:F4_0.25', u'N:D4_0.25', u'N:E-4_0.25', u'N:C4_0.25', u'N:A3_0.25', '!', u'N:B-3_0.5', 'R:0.5', u'C:[:F3_0.5[:B-3_0.5', '!', u'C:[:F3_0.5[:B-3_0.5', 'R:0.5', 'R:0.5', '!', 'KS:-3', 'R:1.5', '!', 'R:0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', '!', u'N:B-5_1.0', u'N:D5_0.5', '!', u'N:E-5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', '!', u'N:B-5_1.0', u'N:E5_0.5', '!', 'KS:-3', u'N:F5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', u'N:C5_0.25', u'N:A4_0.25', u'N:B-4_0.25', '!', u'N:B-5_1.0', u'N:F5_0.5', '!', 'R:0.5', u'N:G-5_0.5', u'N:E-5_0.5', '!', 'R:0.5', u'N:E-5_0.5', u'N:A4_0.5', '!', 'R:0.5', u'N:B-4_0.5', u'N:D5_0.5', '!', u'N:F5_0.5', u'N:A5_0.5', u'N:B-5_0.5', '!', 'KS:-3', u'N:B-4_0.5', 'R:0.5', u'C:[:D4_0.5[:A-4_0.5', '!', u'C:[:D4_0.5[:A-4_0.5', 'R:0.5', 'R:0.5', '!', 'R:0.5', 'R:0.5', u'N:B-5_0.25', u'N:G5_0.5', u'N:C6_0.25', u'N:B-5_0.25', u'N:A-5_0.25', u'N:F5_0.5', u'N:B-5_0.25', u'N:A-5_0.25', '!', u'N:G5_0.25', u'N:E-5_0.5', u'N:A-5_0.25', u'N:G5_0.25', u'N:F5_0.25', u'N:D5_0.5', u'N:G5_0.25', u'N:F5_0.25', u'N:E-5_0.25', u'N:C5_0.5', u'N:F5_0.25', u'N:E-5_0.25', '!', u'N:D5_0.25', u'N:B-4_0.5', u'N:E-5_0.25', u'N:D5_0.25', u'N:C5_0.25', u'N:A-4_0.5', u'N:D5_0.25', u'N:C5_0.25', u'N:B-4_0.5', u'N:G4_0.5', '!', u'N:B-4_1.5', u'N:F4_0.5', 'KS:-3', u'N:E-4_0.5', u'N:D4_0.5', '!', u'N:E-5_0.25', u'N:G4_1.0', u'N:G5_0.25', u'N:F5_0.25', u'N:E-5_0.25', u'N:D5_0.25', u'N:E-5_0.25', u'N:C5_0.25', u'N:A-4_0.5', u'N:D5_0.25', u'N:C5_0.25', '!', u'N:B-4_1.0', u'N:G4_1.0', u'N:A-4_0.25', u'N:F4_0.5', u'N:G4_0.125', u'N:A-4_0.125', '!', u'N:G4_0.5', u'N:D5_0.5', u'N:E-5_0.5', '!', 'KS:-3', 'R:0.5', u'N:B-5_0.5', u'N:G5_0.5', '!', 'R:0.25', u'N:F5_0.25', u'N:G5_0.25', u'N:A-5_0.25', u'N:B-5_0.25', u'N:C6_0.25', '!', u'N:C6_0.25', u'N:B-5_0.25', u'N:A-5_0.25', u'N:G5_0.25', u'N:F5_0.25', u'N:D5_0.25', '!', u'N:E-5_0.25', u'N:B-4_0.25', u'N:G4_0.25', u'N:B-4_0.25', u'N:G4_0.25', u'N:E-4_0.25', u'N:D4_0.25', u'N:F4_0.25', u'N:A-4_0.25', '!', u'N:G4_0.25', u'N:B-4_0.25', u'N:G4_0.25', u'N:E-5_0.25', u'N:B-4_0.25', u'N:G4_0.25', u'N:A-4_0.25', u'N:F4_0.25', u'N:D4_0.25', '!', u'N:E-4_0.5', 'R:0.5', u'C:[:B-3_0.5[:E-4_0.5', '!', 'KS:-3', u'C:[:B-3_0.5[:E-4_0.5', 'R:0.5', 'R:0.5', '!', u'N:E-5_0.5', u'N:E-5_0.125', u'N:F5_0.125', u'N:E-5_0.125', u'N:D-5_0.125', u'N:C5_0.5', '!', 'R:0.5', u'N:A-5_0.5', u'N:A-5_0.5', '!', u'N:G5_0.5', u'N:G5_0.125', u'N:A-5_0.125', u'N:B-5_0.125', u'N:A-5_0.125', u'N:G5_0.5', '!', 'R:0.5', u'N:D-6_0.5', u'N:D-6_0.5', '!', 'KS:-3', u'N:C6_0.5', u'N:C6_0.125', u'N:D-6_0.125', u'N:E-6_0.125', u'N:D-6_0.125', u'N:C6_0.5', '!', 'R:0.5', u'N:F5_0.5', u'N:F5_0.5', '!', u'N:F5_0.25', u'N:E5_0.25', u'N:G5_0.25', u'N:E5_0.25', u'N:C5_0.25', u'N:B-4_0.25', '!', u'N:A-4_0.5', 'R:0.5', u'N:E-5_0.5', '!', u'N:E-5_0.25', u'N:D5_0.25', u'N:F5_0.25', u'N:D5_0.25', u'N:B-4_0.25', u'N:A-4_0.25', '!', 'KS:-3', u'N:G4_0.5', 'R:0.5', u'N:G5_0.5', '!', u'N:F5_0.5', 'R:0.5', u'N:A-5_0.5', '!', 'R:0.5', u'N:C6_0.5', u'N:B-5_0.125', u'N:A-5_0.125', u'N:G5_0.125', u'N:F5_0.125', '!', u'N:E-5_1.0', u'N:D5_0.5', '!', 'R:1.5', '!', 'R:0.5', u'N:B-5_0.25', u'N:G5_0.25', u'N:A-5_0.25', u'N:B-5_0.25', u'N:G5_0.25', u'N:A-5_0.25', '!', 'KS:-3', u'N:B-5_0.5', u'N:C6_0.5', u'N:A-5_0.5', '!', 'R:0.5', u'N:A-5_0.375', u'N:F5_0.25', u'N:G5_0.25', 'R:0.125', '!', u'N:A-5_0.5', u'N:B-5_0.5', u'N:G5_0.5', '!', u'N:E-5_0.5', u'N:E-6_0.5', u'N:E-6_0.5', '!', u'N:C6_0.5', u'N:B-5_0.25', u'N:A-5_0.25', u'N:G5_0.25', u'N:F5_0.25', '!', 'KS:-3', u'N:E-5_1.0', 'R:0.5', '!', u'N:E-5_0.5', 'R:0.5', 'R:0.5', '!', u'N:B-4_0.5', u'N:G5_0.25', u'N:D5_0.25', u'N:E-5_0.25', u'N:G5_0.25', u'N:D5_0.25', u'N:E-5_0.25', '!', u'N:C5_0.5', u'N:B-4_0.25', u'N:A-4_0.25', u'N:G4_0.25', u'N:F4_0.25', '!', 'KS:-3', u'N:E-4_1.0', u'N:F4_0.25', u'N:D4_0.25', '!', u'C:[:D-4_0.5[:D-5_0.5', u'C:[:C4_0.5[:C5_0.5', u'C:[:E-4_0.5[:E-5_0.5', '!', u'N:G4_1.0', u'N:A-4_0.25', u'N:F4_0.25', '!', u'C:[:D-5_0.5[:D-6_0.5', u'C:[:C5_0.5[:C6_0.5', u'C:[:E-5_0.5[:E-6_0.5', '!', 'KS:-3', u'N:G5_1.0', u'N:A-5_0.25', u'N:F5_0.25', '!', u'N:E-5_0.25', u'N:G5_0.25', u'N:B-5_0.25', u'N:E-6_0.25', u'N:B-5_0.25', u'N:G5_0.25', u'N:A-5_0.25', u'N:F5_0.25', u'N:D5_0.25', '!', u'N:E-5_0.25', u'N:G5_0.25', u'N:B-4_0.25', u'N:E-5_0.25', u'N:B-4_0.25', u'N:G4_0.25', u'N:A-4_0.25', u'N:F4_0.25', u'N:D4_0.25', '!', u'N:E-4_0.5', 'R:0.5', u'C:[:B-3_0.5[:E-4_0.5', '!', u'C:[:B-3_0.5[:E-4_0.5', 'R:0.5', 'R:0.5', '!']
20
21
22 faa=FastAlignmentArrays()
23 alignment,finalValue,finalScore=faa.needleman_wunsch(a, b,isFast=False)
24 print finalScore
25 alignment,finalValue,finalScore=faa.needleman_wunsch(a, b,isFast=True)
26 print finalScore
27 score=NWunsch.NWunsch_getSimilarity(a,b)
28 print score
29