ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/testResidueSelectionString.java
Revision: 492
Committed: Wed Jan 2 13:18:57 2008 UTC (16 years, 10 months ago) by duarte
File size: 1138 byte(s)
Log Message:
Copied the aglappe-jung branch into trunk.

Line File contents
1 import java.util.TreeSet;
2
3 import proteinstructure.Interval;
4
5 /**
6 * Program to test parsing of a residue selection string (e.g. 1-3,5,7-8)
7 */
8 public class testResidueSelectionString {
9
10 public static void main(String[] args) {
11
12 String[] tp = {"1","10","10,1","10-9","10-10,5","1,6-7,8-9"};
13 String[] tn = {"", "-",",","1,1,","1,-2","10-9-7",",4","4--5","1.5","1,,2"," "};
14 int fp = 0, fn = 0;
15
16 System.out.println("Positives:");
17 for(String selStr:tp) {
18 System.out.print(selStr + "\t\t");
19 if(Interval.isValidSelectionString(selStr)) {
20 System.out.println("ok");
21 } else {
22 System.out.println("error");
23 fn++;
24 }
25 }
26 System.out.println("Negatives:");
27 for(String selStr:tn) {
28 System.out.print(selStr + "\t\t");
29 if(!Interval.isValidSelectionString(selStr)) {
30 System.out.println("ok");
31 } else {
32 System.out.println("error");
33 fn++;
34 }
35 }
36 assert(fp == 0);
37 assert(fn == 0);
38
39 System.out.println("Parsing:");
40 for(String selStr:tp) {
41 System.out.print(selStr + "\t\t");
42 TreeSet<Integer> nodeSet = Interval.parseSelectionString(selStr);
43 System.out.println(nodeSet);
44 }
45 }
46
47 }