Package uk.ac.cam.ch.wwmm.ptclib.io

Examples of uk.ac.cam.ch.wwmm.ptclib.io.ResourceGetter


  }
 
  private MultiFragmentStructureDiagramGenerator() {
    th = new TemplateHandler(DefaultChemObjectBuilder.getInstance());
    try {
      ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/ptclib/cdk/resources/");
      for(String s : rg.getStrings("extraTemplates.txt")) {
        if(s != null && s.length() > 0) th.addMolecule(StructureConverter.cmlToMolecule(rg.getStream(s)));
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here


  /**
   * @param args
   */
  public static void main(String[] args) throws Exception {
    ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/ptc/experimental/resources/");
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer(new StreamSource(rg.getStream("scrapbookToText.xsl")));

    List<File> fl = new ArrayList<File>();
    fl.addAll(FileTools.getFilesFromDirectoryByName(new File("/home/ptc24/cleanOscar/oscar3-chem/scrapbookfold1_pruned/"), "scrapbook.xml"));
    fl.addAll(FileTools.getFilesFromDirectoryByName(new File("/home/ptc24/cleanOscar/oscar3-chem/scrapbookfold2_pruned/"), "scrapbook.xml"));
    fl.addAll(FileTools.getFilesFromDirectoryByName(new File("/home/ptc24/cleanOscar/oscar3-chem/scrapbookfold3_pruned/"), "scrapbook.xml"));
View Full Code Here

        nodeNames.add(e.getLocalName());
      }
    }
    System.out.println(nodeNames);
   
    ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/ptc/experimental/resources/");
   
    XSLTransform xslt = new XSLTransform(rg.getXMLDocument("patents2.xsl"));
   
    Nodes paperNodes = doc.query("/PAPERS/PAPER");
   
    File outFolder = new File("/home/ptc24/newows/corpora/NewSciXMLPatents2");
    if(!outFolder.exists()) outFolder.mkdir();
View Full Code Here

  Document doc;
  Element root;
  Set<String> fns;
 
  void recursePlace(String place) throws Exception {
    ResourceGetter rg = new ResourceGetter(place);
    //System.out.println("IM IN UR " + place);
    for(String s : rg.getStrings("")) {
      //System.out.println(s);
      if(s.matches("[a-z0-9]+")) {
        if(place.length() > 0) {
          recursePlace(place + s + "/");
        } else {
View Full Code Here

      fos.close();
    }     
  }
 
  private static Map<String, SciXMLDocument> getSciXML(Document pubmedResults) throws Exception {
    XSLTransform xslt = new XSLTransform(new ResourceGetter("uk/ac/cam/ch/wwmm/ptclib/scixml/resources/").getXMLDocument("pubmed2scixml.xsl"));
    Map<String, SciXMLDocument> docs = new LinkedHashMap<String, SciXMLDocument>();
    Nodes n = pubmedResults.query("/PubmedArticleSet/PubmedArticle");
    for(int i=0;i<n.size();i++) {
      try {
        if(n.get(i).query(".//ArticleTitle").size() == 0) continue;
View Full Code Here

public class PatternRecogniserTest {

  @Test
  public void test_findNamedEntities() throws Exception
  {
    ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/oscar3/test/testcard/resources/");
    String s = rg.getString("testcard.txt");
    assertTrue("Have testcard string", s != null && s.length() > 0);
    Document doc = TextToSciXML.textToSciXML(s);

    ProcessingDocument procDoc = ProcessingDocumentFactory.getInstance().makeTokenisedDocument(doc, false, false, false);
    assertTrue(procDoc != null);
View Full Code Here

public class MEMMRecogniserTest {

  @Test
  public void test_findNamedEntities() throws Exception
  {
    ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/oscar3/test/testcard/resources/");
    String s = rg.getString("testcard.txt");
    assertTrue("Have testcard string", s != null && s.length() > 0);
    Document doc = TextToSciXML.textToSciXML(s);
   
    ProcessingDocument procDoc = ProcessingDocumentFactory.getInstance().makeTokenisedDocument(doc, false, false, false);
    assertTrue(procDoc != null);
View Full Code Here

    for(int i=0;i<blockMarkupArray.length;i++) blockMarkup.add(blockMarkupArray[i]);
    for(int i=0;i<specPropMarkupArray.length;i++) specPropMarkup.add(specPropMarkupArray[i]);
  }
 
  private void loadStrings(String schemaName) {
    ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/ptclib/scixml/resources/");
    try {
      Document doc = rg.getXMLDocument(schemaName + ".xml");
      Elements ee = doc.getRootElement().getChildElements();
      Map<String,String> varMap = new HashMap<String,String>();
      for(int i=0;i<ee.size();i++) {
        Element e = ee.get(i);
        if(e.getLocalName().equals("xpc")) {
View Full Code Here

   * appropriately.
   *
   * @throws Exception
   */
  public static void deployInChI() throws Exception {
    ResourceGetter rg = new ResourceGetter("uk/ac/cam/ch/wwmm/oscar3/deployment/resources/");
    File inchiFile = null;
    if(System.getProperty("os.name").equals("Linux")) {
      inchiFile = new File("cInChI-1");
      rg.writeToFile("cInChI-1.bin", inchiFile);
      Runtime.getRuntime().exec("chmod a+x " + inchiFile.getAbsolutePath());
    } else if(System.getProperty("os.name").startsWith("Windows")) {
      inchiFile = new File("cInChI-1.exe");
      rg.writeToFile("cInChI-1.exe", inchiFile);
    }
    if(inchiFile != null) {
      Oscar3Props.setProperty("InChI", inchiFile.getAbsolutePath());
    } else {
      Oscar3Props.setProperty("InChI", "none");
View Full Code Here

      response.setContentType("text/plain");
      response.getWriter().println("Error: can't PUT a directory");
      return;
    }
   
    ResourceGetter rg = new ResourceGetter(pathTo);

    try {
      OutputStream out = rg.getOutputStream(name);
      InputStream in = request.getInputStream();
      for(int i=in.read();i!=-1;i=in.read()) out.write(i);
      out.close();
    } catch (Exception e) {
      response.setContentType("text/plain");
View Full Code Here

TOP

Related Classes of uk.ac.cam.ch.wwmm.ptclib.io.ResourceGetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.