Example #1
0
  /**
   * Test loading a named derived source. Searches under the project directory <code>
   * src/test/sourcetest/project</code>, which in this distribution has a dummy Intermine directory
   * structure.
   *
   * @throws IOException if there is an I/O problem during the test.
   * @see SourceInfoLoader#findDerivedSourceInfo(String, Project, File)
   */
  @Test
  public void testDerivedTypeLoad() throws IOException {

    File projectHome = new File("src/test/sourcetest/project");

    org.intermine.modelviewer.project.ObjectFactory factory =
        new org.intermine.modelviewer.project.ObjectFactory();

    Project project = factory.createProject();
    project.setSources(factory.createProjectSources());

    Property p = factory.createProperty();
    p.setName(SourceInfoLoader.SOURCE_PATH_PROPERTY);
    p.setLocation("../bio/sources");
    project.getProperty().add(p);

    p = factory.createProperty();
    p.setName(SourceInfoLoader.SOURCE_PATH_PROPERTY);
    p.setLocation("../bio/sources/example-sources");
    project.getProperty().add(p);

    // Source s = factory.createSource();
    // s.setName("malaria");
    // s.setType("malaria-gff");
    // project.getSources().getSource().add(s);

    SourceInfo info =
        SourceInfoLoader.getInstance().findDerivedSourceInfo("malaria-gff", project, projectHome);

    assertNotNull("Could not find derived source type for malaria-gff", info);

    assertEquals("Derived type is not gff", "malaria-gff", info.getType());
  }
Example #2
0
  /** Test loading a FASTA data source. */
  @Test
  public void testLoadFastaSource() {

    SourceInfoLoader loader = SourceInfoLoader.getInstance();

    SourceInfo fastaInfo = loader.getSourceInfo("fasta");

    assertNotNull("No source info for 'fasta'", fastaInfo);

    assertEquals("Type wrong", "fasta", fastaInfo.getType());

    SourceDescriptor source = fastaInfo.getSource();
    assertEquals("SourceDescriptor type wrong", "fasta", source.getType());
    assertEquals("Incorrect number of properties in source", 9, source.getProperty().size());

    Map<String, PropertyDescriptor> propMap = new HashMap<String, PropertyDescriptor>();
    for (PropertyDescriptor p : source.getProperty()) {
      propMap.put(p.getName(), p);
    }

    PropertyDescriptor srcDataDir = propMap.get("src.data.dir");
    assertNotNull("No property 'src.data.dir'", srcDataDir);
    assertEquals(
        "'src.data.dir' not required when it should be", Boolean.TRUE, srcDataDir.isRequired());
    assertEquals("'src.data.dir' type wrong", PropertyType.DIRECTORY, srcDataDir.getType());
    assertNull("'src.data.dir' has validation", srcDataDir.getValidation());

    PropertyDescriptor taxonId = propMap.get("fasta.taxonId");
    assertNotNull("No property 'fasta.taxonId'", taxonId);
    assertEquals(
        "'fasta.taxonId' required when it should not be", Boolean.TRUE, taxonId.isRequired());
    assertEquals("'fasta.taxonId' type wrong", PropertyType.STRING, taxonId.getType());
    assertEquals("'fasta.taxonId' validation wrong", "^\\d+(\\s\\d+)*$", taxonId.getValidation());
  }
  /** Registers the given script as a top-level script in the debugger. */
  private void registerTopScript(DebuggableScript topScript, String source) {
    if (!topScript.isTopLevel()) {
      throw new IllegalArgumentException();
    }
    String url = getNormalizedUrl(topScript);
    DebuggableScript[] functions = getAllFunctions(topScript);
    final SourceInfo sourceInfo = new SourceInfo(source, functions, url);

    synchronized (urlToSourceInfo) {
      SourceInfo old = urlToSourceInfo.get(url);
      if (old != null) {
        sourceInfo.copyBreakpointsFrom(old);
      }
      urlToSourceInfo.put(url, sourceInfo);
      for (int i = 0; i != sourceInfo.functionSourcesTop(); ++i) {
        FunctionSource fsource = sourceInfo.functionSource(i);
        String name = fsource.name();
        if (name.length() != 0) {
          functionNames.put(name, fsource);
        }
      }
    }

    synchronized (functionToSource) {
      for (int i = 0; i != functions.length; ++i) {
        FunctionSource fsource = sourceInfo.functionSource(i);
        functionToSource.put(functions[i], fsource);
      }
    }

    callback.updateSourceText(sourceInfo);
  }
Example #4
0
 /**
  * Prints all results stored in this object to the given writer
  *
  * @param wr The writer to which to print the results
  * @throws IOException Thrown when data writing fails
  */
 public void printResults(Writer wr) throws IOException {
   for (SinkInfo sink : this.results.keySet()) {
     wr.write("Found a flow to sink " + sink + ", from the following sources:\n");
     for (SourceInfo source : this.results.get(sink)) {
       wr.write("\t- " + source.getSource() + "\n");
       if (source.getPath() != null && !source.getPath().isEmpty())
         wr.write("\t\ton Path " + source.getPath() + "\n");
     }
   }
 }
Example #5
0
 /** Prints all results stored in this object to the standard output */
 public void printResults() {
   for (SinkInfo sink : this.results.keySet()) {
     logger.info("Found a flow to sink {}, from the following sources:", sink);
     for (SourceInfo source : this.results.get(sink)) {
       logger.info("\t- {}", source.getSource());
       if (source.getPath() != null && !source.getPath().isEmpty())
         logger.info("\t\ton Path {}", source.getPath());
     }
   }
 }
Example #6
0
    /** Initializes the type descriptor */
    void initialize(TypeName t) {
      if (initialization != null) {
        TypeName et;
        if (dimension > 1)
          et = new ArrayTypeName(t, dimension - 1, false, SourceInfo.span(t, this));
        else et = t;

        initialization.setElementType(et);
      }
    }
 /** Clears all breakpoints. */
 public void clearAllBreakpoints() {
   for (SourceInfo si : urlToSourceInfo.values()) {
     si.removeAllBreakpoints();
   }
 }