annotate 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
rev   line source
victor@2 1 '''
victor@2 2 @organization: Lancaster University & University of Leeds
victor@2 3 @version: 1.0
victor@2 4 Created on 11/12/2014
victor@2 5
victor@2 6 @author: Victor Padilla
victor@2 7 @contact: v.padilla@lancaster.ac.uk
victor@2 8
victor@2 9 test file for checking
victor@2 10 '''
victor@2 11
victor@2 12 from MultipleOMR.Alignment import FastAlignmentArrays
victor@2 13 from MultipleOMR.Alignment import NWunsch
victor@2 14
victor@2 15 a=["foo00","abc","123"]
victor@2 16 b=["foo000","abc","1234"]
victor@2 17
victor@2 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', '!']
victor@2 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', '!']
victor@2 20
victor@2 21
victor@2 22 faa=FastAlignmentArrays()
victor@2 23 alignment,finalValue,finalScore=faa.needleman_wunsch(a, b,isFast=False)
victor@2 24 print finalScore
victor@2 25 alignment,finalValue,finalScore=faa.needleman_wunsch(a, b,isFast=True)
victor@2 26 print finalScore
victor@2 27 score=NWunsch.NWunsch_getSimilarity(a,b)
victor@2 28 print score
victor@2 29