예제 #1
0
  /*
   * This method is called to wind down the simulation.
   */
  public void finish() {
    super.finish();

    System.out.println("Terminating the simulation");

    /*
     * write CSV and XML output from simulation
     */
    File csvDataFile =
        new File(resultFilePath + "/" + description + "/" + runFilePath + "/simOutputData.csv");
    System.out.println("Output written to " + csvDataFile);

    // File xmlDataFile = new File(resultFilePath + "/" + description + "/Results/" + runFilePath +
    // "/simOutputData.xml");

    PrintWriter dataOutput;

    try {
      dataOutput = new PrintWriter(csvDataFile);
      dataOutput.print(dataStore.compileTableToString());
      dataOutput.close();

      //	dataStore.compileXMLOutput(xmlDataFile);
    } catch (Exception e) {
      e.printStackTrace();
    }

    System.out.println("Run took " + (System.currentTimeMillis() - startTime) + " milliseconds");
  }
예제 #2
0
  /**
   * This method is called to start the simulation. the run parameters are copied to the results
   * output directory. The run output file is created ready for writing.
   */
  public void start() {
    super.start(); // call supertype's start method.

    // System.out.println("In main on CBSimulation class");

    // need to read the parameter file
    readParameters(true);

    // And I want to write the random number seed used for this run - for record keeping

    PrintWriter dataOutput;

    new File(resultFilePath + "/" + description + "/" + runFilePath).mkdirs();
    File runSeedFile =
        new File(resultFilePath + "/" + description + "/" + runFilePath + "/simRunSeed");
    System.out.println("Creating output file " + runSeedFile.getName());

    String paramCopyFile =
        resultFilePath + "/" + description + "/" + runFilePath + "/" + paramCopyName;
    copyFile(xmlFileLocation, paramCopyFile);

    try {
      dataOutput = new PrintWriter(runSeedFile);
      dataOutput.print(seed);
      dataOutput.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    // I'll need to instantiate the data store here
    // I'll schedule it from the constructor...
    dataStore = new DataStore(this);
    // System.out.println("Created DataStore object " + dataStore);

  }
예제 #3
0
  public void readParameters(boolean ic) {

    try {
      // open the xmlFileLocation to read input
      DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
      Document doc = docBuilder.parse(new File(xmlFileLocation));

      Element setupComponent = (Element) doc.getElementsByTagName("simulation_setup").item(0);
      processSetupParams(setupComponent);

      // locate the <cistromes> tag
      Element cistromesComponent = (Element) doc.getElementsByTagName("cistromes").item(0);

      // process this into details of individual cistromes
      processCistromesComponent(cistromesComponent);

      // we'll pass the Cistrome components on to the Cell Object to make sense of...
      // if(instantiateCell)
      // {
      // We'll set up a Cell object to hold our Cistrome(s)
      // System.out.println("Cistrome data sources are " + sources);
      cell = new Cell(sources, this);
      // System.out.println("Created cell object " + cell);
      // }

      // System.out.println("Fetching cistrome data from " + cell);
      ArrayList<Cistrome> cistromeList = cell.getCistromeList();

      for (int c = 0; c < cistromeList.size(); c++) {
        Cistrome thisCistrome = ((Cistrome) cistromeList.get(c));

        // System.out.println("Cistrome " + c);
        thisCistrome.setName(names.get(c));
        // System.out.println("Name: " + names.get(c));
        thisCistrome.setBranchingRate(branchingRates.get(c));
        // System.out.println("Branching rate: " + branchingRates.get(c));
        thisCistrome.setInitialReds(numsInitialReds.get(c));
        // System.out.println("Initial reds: " + numsInitialReds.get(c));
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }