- 更新日時:
- 2014/09/26 10:11:02 (10 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
r154 r174 9 9 * @author atsuko 10 10 */ 11 import java.util. ArrayList;12 import java.util.LinkedList;13 import java.util.List;14 import java.util.ListIterator;11 import java.util.*; 12 //import java.util.LinkedList; 13 //import java.util.List; 14 //import java.util.ListIterator; 15 15 16 16 public class OWLClassGraph extends LabeledMultiDigraph{ … … 20 20 int limit; 21 21 int th; 22 double concut; 23 double divcut; 22 int prunecut; 24 23 25 24 public class LinkAndPath{ … … 27 26 ClassLink classLink; 28 27 List<ClassLink> path; 29 boolean converge;28 //boolean converge; 30 29 31 30 public LinkAndPath(ClassLink classLink, List<ClassLink> path){ 32 31 this.classLink = classLink; 33 32 this.path = path; 34 this.converge = false;35 } 36 37 public LinkAndPath(ClassLink classLink, List<ClassLink> path, String originalClassURI , boolean converge){33 //this.converge = false; 34 } 35 36 public LinkAndPath(ClassLink classLink, List<ClassLink> path, String originalClassURI){ 38 37 this.classLink = classLink; 39 38 this.path = path; 40 39 this.originalClassURI = originalClassURI; 41 this.converge = converge;40 //this.converge = converge; 42 41 } 43 42 } … … 51 50 nsteps = 3; 52 51 limit = 1000; 53 //th = 0; 54 //concut = 2.0; 55 //divcut = - 2.0; 52 prunecut = 100; 56 53 } 57 54 58 55 public Path[] getPaths(RDFSchemaAnalyzer rdfsa, boolean countLink){ 59 56 List<List<ClassLink>> paths = null; 60 paths = searchPaths(rdfsa, countLink); 61 Path[] patharray = new Path[paths.size()];57 paths = searchPaths(rdfsa, countLink); 58 NavigableSet<Path> sortedpath = new TreeSet<Path>(); 62 59 ListIterator<List<ClassLink>> pit = paths.listIterator(); 63 int i = 0;64 60 while ( pit.hasNext() ){ 65 patharray[i]= new Path();66 path array[i].setStartClass(startClass);67 List<ClassLink> path = pit.next();68 path array[i].setClassLinks(path);69 ListIterator<ClassLink> cit = path.listIterator();61 Path path = new Path(); 62 path.setStartClass(startClass); 63 List<ClassLink> crrpath = pit.next(); 64 path.setClassLinks(crrpath); 65 ListIterator<ClassLink> cit = crrpath.listIterator(); 70 66 int min = Integer.MAX_VALUE; 71 67 while ( cit.hasNext() ){ … … 75 71 } 76 72 } 77 patharray[i].setWidth(min); 73 path.setWidth(min); 74 sortedpath.add(path); 75 } 76 Path[] patharray = new Path[paths.size()]; 77 Iterator<Path> pait = sortedpath.descendingIterator(); 78 int i = 0; 79 while ( pait.hasNext() ){ 80 patharray[i] = pait.next(); 78 81 i++; 79 82 } … … 84 87 List<List<ClassLink>> paths = new ArrayList<>(); 85 88 List<LinkAndPath> lp = new LinkedList<>(); 86 lp.add(new LinkAndPath(new ClassLink("",startClass,null,Direction.both,0,0,0,0,0,false,false), new LinkedList<ClassLink>(), "" , false));89 lp.add(new LinkAndPath(new ClassLink("",startClass,null,Direction.both,0,0,0,0,0,false,false), new LinkedList<ClassLink>(), "")); 87 90 try{ 88 91 for ( int i = 0; i < nsteps; i++ ){ … … 91 94 while ( lit.hasNext() ){ 92 95 LinkAndPath crrlp = lit.next(); 96 /*if ( crrlp.classLink.getLinkedClassURI().equals("http://www.biopax.org/release/biopax-level3.owl#Pathway") ){ 97 System.out.println("here!"); 98 }*/ 93 99 ClassLink[] classLinks = rdfsa.getNextClass(null, crrlp.classLink.getLinkedClassURI(), limit, countLinks); 94 100 for ( int j = 0 ; j < classLinks.length; j++ ){ 101 /*if ( classLinks[j].getLinkedClassURI().endsWith("http://www.biopax.org/release/biopax-level3.owl#BiochemicalReaction") ){ 102 ClassLink cltmp = classLinks[j]; 103 }*/ 95 104 List<ClassLink> crrpath = new LinkedList<>(crrlp.path); 96 105 crrpath.add(classLinks[j]); … … 107 116 crrlp.classLink.getDirection() != classLinks[j].getDirection() && 108 117 crrlp.originalClassURI.equals( classLinks[j].getLinkedClassURI()) ){ 118 System.out.println("P1"); 109 119 continue; 110 120 } 111 } 112 113 nextlp.add(new LinkAndPath(classLinks[j], crrpath, crrlp.classLink.getLinkedClassURI(), false)); 121 if ( checkPruning(crrlp.classLink, classLinks[j]) ){ 122 System.out.println("P2"); 123 continue; 124 } 125 } 126 /* 127 if ( classLinks[j].getDirection() != Direction.reverse ){ 128 System.out.println("here b"); 129 }*/ 130 131 nextlp.add(new LinkAndPath(classLinks[j], crrpath, crrlp.classLink.getLinkedClassURI())); 114 132 } 115 133 } … … 178 196 */ 179 197 180 /* 181 private boolean decideConvergence(ClassLink classLink){ 198 private boolean checkPruning(ClassLink classLink1, ClassLink classLink2){ 199 // true -> prune link2, false -> add link2 200 int noi1 = classLink1.getNumOfOriginInstances(); 201 int nli1 = classLink1.getNumOfLinkedInstances(); 202 int noi2 = classLink2.getNumOfOriginInstances(); 203 int nli2 = classLink2.getNumOfLinkedInstances(); 204 if ( noi1 == 0 || nli1 == 0 || noi2 == 0 || nli2 == 0 ){ 205 return true; 206 } 207 return ( noi1 / nli1 > prunecut && nli2 / noi2 > prunecut ); 208 } 209 210 /* private boolean decideConvergence(ClassLink classLink){ 182 211 double con = getValueForConvergence(classLink.getNumOfOriginInstances(), 183 212 classLink.getNumOfLinkedInstances(), … … 209 238 } 210 239 */ 240 211 241 }