Made getters and setters for found nodes public (needed for Jalview)
[jalview.git] / forester / python / clad_sum.py
1 from sys import argv
2 import re
3
4 infile = argv[ 1 ]
5
6 print( 'Infile: ', infile )
7
8 match = 0
9 lessspecific = 0
10 qu = 0
11 na = 0
12 no_match = 0
13
14 with open( infile ) as f:
15     for line in f:
16         line = line.strip()
17         if not line.startswith('#'):
18             elements = line.split('\t')
19             if elements[ 1 ] == 'Matching Clades':
20                 if (elements[ 0 ].endswith(elements[ 2 ])):
21                     match+=1
22                 else:
23                     my_regex = r".+\|" + re.escape(elements[ 2 ]) + r"\."
24                     if  re.search(my_regex, elements[ 0 ]): 
25                         lessspecific+=1
26                     elif elements[ 2 ] == '?':
27                         qu+=1
28                         print('?       :  ', line)    
29                     elif elements[ 0 ].endswith( 'NA' ):
30                         na+=1
31                         print('NA      :  ', line)
32                     else:
33                         no_match+=1
34                         print('no match:  ', line)
35                         
36 print()
37 print( 'Match                            :', match )
38 print( 'Less specific match              :', lessspecific )
39 print( 'No match: result undeceided ("?"):',  qu )
40 print( 'No match: target is "NA"         :',  na )
41 print( 'No match                         :',  no_match )