26 | | // For Test |
27 | | //String sp = "http://data.allie.dbcls.jp/sparql"; |
28 | | //String sc = "http://purl.org/allie/ontology/201108#ShortForm"; |
29 | | //String ec = "http://purl.org/allie/ontology/201108#LongForm"; |
30 | | |
31 | | String sp = "http://www.ebi.ac.uk/rdf/services/chembl/sparql"; |
32 | | String sc = "http://rdf.ebi.ac.uk/terms/chembl#Enzyme"; |
33 | | String ec = "http://rdf.ebi.ac.uk/terms/chembl#Activity"; |
34 | | |
35 | | //String sp = "http://www.ebi.ac.uk/rdf/services/biosamples/sparql"; |
36 | | //String sc = "http://rdf.ebi.ac.uk/terms/biosd/Sample"; |
37 | | //String ec = "http://purl.obolibrary.org/obo/NCBITaxon_7955"; |
38 | | //String sp = "http://www.ebi.ac.uk/rdf/services/biosamples/sparql"; |
39 | | //String sc = "http://rdf.ebi.ac.uk/terms/biosd/Sample"; |
40 | | //String ec = "http://purl.obolibrary.org/obo/NCBITaxon_7955"; |
41 | | //String sp = "http://lsd.dbcls.jp/sparql"; |
42 | | //String sc = "http://purl.jp/bio/10/lsd/ontology/201209#EnglishCode"; |
43 | | //String ec = "http://purl.jp/bio/10/lsd/ontology/201209#JapaneseCode"; |
44 | | //QueryPathGenerator qpg = new QueryPathGenerator(sp, "c:\\cdata"); |
45 | | QueryPathGenerator qpg1 = new QueryPathGenerator(sp, "cdata/"); |
46 | | //qpg1.testOWLClassGraph(); |
47 | | //SClass[] cl = qpg.getClasses(null); |
48 | | }*/ |
| 27 | QueryPathGenerator qpg = new QueryPathGenerator(); |
| 28 | //String[] elist = qpg.getFactory().getEndpointURIList(); |
| 29 | List<String> elist = new LinkedList<String>(); |
| 30 | File file0 = new File("eplist.txt"); |
| 31 | try{ |
| 32 | BufferedReader br = new BufferedReader(new FileReader(file0)); |
| 33 | String buf = null; |
| 34 | while( (buf = br.readLine()) != null){ |
| 35 | elist.add(buf); |
| 36 | } |
| 37 | }catch(IOException e){ |
| 38 | System.err.println(e); |
| 39 | } |
| 40 | |
| 41 | ListIterator<String> eit = elist.listIterator(); |
| 42 | int i = 0; |
| 43 | while(eit.hasNext()){ |
| 44 | String ep = eit.next(); |
| 45 | qpg.setSPARQLendpoint(ep); |
| 46 | qpg.graph = new OWLClassGraph(qpg.analyzer); |
| 47 | SClass[] classes = qpg.getClasses(null); |
| 48 | File file1 = new File("path".concat(Integer.toString(i)).concat(".txt")); |
| 49 | File file2 = new File("ptable".concat(Integer.toString(i)).concat(".txt")); |
| 50 | try{ |
| 51 | BufferedWriter bw1 = new BufferedWriter(new FileWriter(file1)); |
| 52 | BufferedWriter bw2 = new BufferedWriter(new FileWriter(file2)); |
| 53 | String jsonstr = "["; |
| 54 | int m = 0; |
| 55 | for ( int j = 0 ; j < classes.length; j ++ ){ |
| 56 | SClass start = classes[j]; |
| 57 | for ( int k = j + 1 ; k < classes.length; k++ ){ |
| 58 | SClass end = classes[k]; |
| 59 | Path[] paths = qpg.getPaths(start.getClassURI(), end.getClassURI(), false); |
| 60 | for( int l = 0; l < paths.length; l++ ){ |
| 61 | if ( paths[l] == null ){ |
| 62 | continue; |
| 63 | } |
| 64 | if (m > 0 ){ |
| 65 | jsonstr += ","; |
| 66 | } |
| 67 | double cost = paths[l].computeCost(); |
| 68 | bw2.write(Double.toString(cost)); |
| 69 | bw2.write(","); |
| 70 | bw2.write(Boolean.toString(EndpointAccess.checkPath(paths[l], ep))); |
| 71 | bw2.newLine(); |
| 72 | jsonstr += paths[i].toJSONString3(classes); |
| 73 | m++; |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | jsonstr += "]"; |
| 78 | bw1.write(jsonstr); |
| 79 | bw1.newLine(); |
| 80 | |
| 81 | bw1.close(); |
| 82 | bw2.close(); |
| 83 | }catch(IOException e){ |
| 84 | System.err.println(e); |
| 85 | } |
| 86 | i++; |
| 87 | } |
| 88 | } |