Package org.moltools.apps.probemaker.project

Examples of org.moltools.apps.probemaker.project.Project


    proj.getSettings().getCandidateModulesStage1().clear();
  }

  public void testCandidateGeneration() throws DuplicateIDException {
   
    Project proj = new Project("Test project"); //$NON-NLS-1$
    proj.getSettings().addDesignerProperties(GreedyTagAllocator.defaultParameters);
    proj.setTagSettings(new DefaultTagSettings(libraries1_10));
    proj.getTagAllocationTable().clearUsed();
    proj.getTargets().addSequence(t1);   
    proj.getSettings().addCandidateModuleStage1(dummy);
    pm.setProject(proj);
   
    dummy.setData(DummyModule.KEY_WARNING_CHANCE, new Integer(100));
    proj.getSettings().addCandidateModuleStage1(dummy);

    ProbeDesignTask task = pm.getProbeDesignTask(false, true, false, new GoodAcceptor(), new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    task.run();

    //Check the number of candidates tested
    long candCount = task.getCandidatesGenerated();  
    assertTrue("Tag selection, 10 candidates expected, " + candCount + " generated.",candCount==10); //$NON-NLS-1$ //$NON-NLS-2$

    proj.getSettings().getCandidateModulesStage1().clear();   
  }
View Full Code Here


    proj.getSettings().getCandidateModulesStage1().clear();   
  }

  public void testSpacer() throws DuplicateIDException {
   
    Project proj = new Project("Test project"); //$NON-NLS-1$
    proj.getSettings().addDesignerProperties(GreedyTagAllocator.defaultParameters);
    proj.setTagSettings(new DefaultTagSettings(libraries1_10));
    proj.getTagAllocationTable().clearUsed();
    proj.getTargets().addSequence(t1);   
    proj.getSettings().addCandidateModuleStage1(dummy);
    proj.getSettings().getDesignParameters().put(TagAllocator.PROP_SPACER_POSITION,"0"); //$NON-NLS-1$
    proj.getSettings().getDesignParameters().put(TagAllocator.PROP_USE_SPACER,"TRUE"); //$NON-NLS-1$
    proj.getSettings().getDesignParameters().put(TagAllocator.PROP_PREFERRED_LENGTH,String.valueOf(61));
    proj.getSettings().getDesignParameters().put(TagAllocator.PROP_SPACER_SEQUENCE,"CT");     //$NON-NLS-1$
    pm.setProject(proj);

    GreedyTagAllocator ta = new GreedyTagAllocator();          
    ProbeDesignTask task = pm.getProbeDesignTask(false, true, false, new GoodAcceptor(), new NoSelector(), new DefaultProbeDesigner(ta), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    //task.addListener(new TaskListener());
    task.run();

    long candCount = task.getCandidatesGenerated();

    //Check the number of candidates tested
    assertEquals("Constant spacer, 10 candidates expected, " + candCount + " generated.", candCount, 10); //$NON-NLS-1$ //$NON-NLS-2$

    proj.getSettings().getDesignParameters().put(TagAllocator.PROP_SPACER_SEQUENCE,""); //$NON-NLS-1$

    ta = new GreedyTagAllocator();
    //ta.setDebug(3,System.out);

    task = pm.getProbeDesignTask(false, true, true, new GoodAcceptor(), new NoSelector(), new DefaultProbeDesigner(ta), new DefaultTSSConstructor() ,new StreamErrorHandler(System.out,true));
    //task.addListener(new TaskListener());
    task.run();

    //Check the number of candidates tested
    candCount = task.getCandidatesGenerated();

    assertTrue("Variable spacer, 40 candidates expected, " + candCount + " generated.", candCount==40); //$NON-NLS-1$ //$NON-NLS-2$

    proj.getSettings().getDesignParameters().put(TagAllocator.PROP_USE_SPACER,"FALSE"); //$NON-NLS-1$
    proj.getSettings().getCandidateModulesStage1().clear();   
  }
View Full Code Here

    proj.getSettings().getCandidateModulesStage1().clear();   
  }

  public void testPairwise() throws DuplicateIDException  {

    Project proj = new Project("Test project");     //$NON-NLS-1$
    proj.setTagSettings(new DefaultTagSettings((libraries1_10)));
    proj.getTargets().addSequence(t1);   
    proj.getSettings().addCandidateModuleStage1(dummy);
    pm.setProject(proj);

    //Run test to fail all    
    ProbeDesignTask task = pm.getProbeDesignTask(false, true, true, new GoodAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));

    task.run();
    long candCount = task.getCandidatesGenerated();

    assertTrue("Pairwise allocation (Stage 1 module), 10 candidates expected, " + candCount + " generated.",candCount == 10); //$NON-NLS-1$ //$NON-NLS-2$

    //Move dummy to arm stage, check that there are no candidates generated
    proj.getSettings().getCandidateModulesStage1().clear();
    proj.getSettings().getArmModules().add(dummy);

    task = pm.getProbeDesignTask(false, true, true, new GoodAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    task.run();   
    candCount = task.getCandidatesGenerated();

    assertTrue("Pairwise allocation (TSS module), 0 candidates expected, " + candCount + " generated.",candCount==0); //$NON-NLS-1$ //$NON-NLS-2$

//  Expand target and test use unique mode, 2 candidates expected
    TargetHandler.expandTargets(pm.getProject().getTargets());
    proj.getSettings().getArmModules().clear();   

    task = pm.getProbeDesignTask(false, true, true, new GoodAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    task.run();
    candCount = task.getCandidatesGenerated();
    Probe p1 = pm.getProject().getProbes().getSequenceAt(0);
    Probe p2 = pm.getProject().getProbes().getSequenceAt(1);

    assertTrue("2 candidates expected, " + candCount + " generated.",candCount == 2); //$NON-NLS-1$ //$NON-NLS-2$
    assertTrue("Same tags allocated in unique mode!",p1.getTagAt(0)!=p2.getTagAt(0)); //$NON-NLS-1$

//  Expand target and test use per group, no modules, 2 candidates expected       
    libraries1_10[0].setMode(TagLibrary.USE_PER_GROUP);          

    task = pm.getProbeDesignTask(false, true, true, new GoodAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    task.run();
    candCount = task.getCandidatesGenerated();
    p1 = pm.getProject().getProbes().getSequenceAt(0);
    p2 = pm.getProject().getProbes().getSequenceAt(1);

    assertTrue("2 candidates expected, " + candCount + " generated.",candCount == 2); //$NON-NLS-1$ //$NON-NLS-2$
    assertTrue("Different tags allocated in group mode!",p1.getTagAt(0)==p2.getTagAt(0)); //$NON-NLS-1$

//  Still expanded targets, per group mode, greedy allocator, dummy module in stage 1.
    //Expect 20 candidates generated
    libraries1_10[0].setMode(TagLibrary.USE_PER_GROUP);          
    proj.getSettings().getCandidateModulesStage1().add(dummy);   
      
    task = pm.getProbeDesignTask(false, true, true, new GoodAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new GreedyTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    task.run();
   
View Full Code Here

    candCount = task.getCandidatesGenerated();   
    assertTrue("20 candidates expected, " + candCount + " generated.",candCount == 20);      //$NON-NLS-1$ //$NON-NLS-2$
  }

  public void testTwoProbesDesign() throws Exception {
    Project proj = new Project("Test project");     //$NON-NLS-1$
    proj.setTagSettings(new DefaultTagSettings(libraries1_1));
   
    //Two probes, single uniqe tag. One good one failed expected.
    proj.getTagAllocationTable().clearUsed();   
    proj.getTargets().addSequence(t1);   
    proj.getTargets().addSequence(t2);   
    pm.setProject(proj);
   
    pm.getProbeDesignTask(false, true, true, new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true)).run();

    Probe p1 = proj.getProbes().getSequenceAt(0);
    Probe p2 = proj.getProbes().getSequenceAt(1);

    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.GOOD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.BAD_QUALITY);

    proj.getTagAllocationTable().clearUsed();
   
    //Two probes single tag unique, with dummy. Expect first ok, second bad
    proj.getSettings().getCandidateModulesStage2().add(dummy);
      
    ProbeDesignTask task = pm.getProbeDesignTask(false, true, true, new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    task.run();
   
    p1 = proj.getProbes().getSequenceAt(0);
    p2 = proj.getProbes().getSequenceAt(1);

    assertEquals(ProbeMakerPropertyUtils.getAllMessages(p1).size(),1);
    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.OK_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.BAD_QUALITY);
    assertEquals(task.getCandidatesGenerated(),1);
   
    proj.getTagAllocationTable().clearUsed();
   
    //Test single-tag use same
    libraries1_1[0].setMode(TagLibrary.USE_SAME_TAG);
    proj.setTagSettings(new DefaultTagSettings(libraries1_1));
    proj.getSettings().getCandidateModulesStage2().clear();
    pm.getProbeDesignTask(false, true, true, new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true)).run();

    p1 = proj.getProbes().getSequenceAt(0);
    p2 = proj.getProbes().getSequenceAt(1);

    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.GOOD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.GOOD_QUALITY);

//  Test single-tag use unique in group with one expanded
    //expect first probe to succeed but be set to bad when second one failed
    //Third probe then set to good
    proj.getTagAllocationTable().clearUsed();
    libraries1_1[0].setMode(TagLibrary.USE_UNIQUE_IN_GROUP);
    proj.setTagSettings(new DefaultTagSettings(libraries1_1));
    proj.getTargets().clear();
    proj.getTargets().addSequence(t1);
    TargetHandler.expandTargets(proj.getTargets());
    proj.getTargets().addSequence(t2);
   
    task = pm.getProbeDesignTask(false, true, true, new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    task.run();

    p1 = proj.getProbes().getSequenceAt(0);
    p2 = proj.getProbes().getSequenceAt(1);
    Probe p3 = proj.getProbes().getSequenceAt(2);

   
    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.BAD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.BAD_QUALITY);
   
    assertEquals(ProbeMakerPropertyUtils.getRank(p3),ProbeMakerConstants.GOOD_QUALITY);
    assertEquals(task.getCandidatesGenerated(),2);
   
    libraries1_1[0].setMode(TagLibrary.USE_UNIQUE_TAG);
   
//  Test single-tag use same with one expanded
    libraries2_1_1[0].setMode(TagLibrary.USE_UNIQUE_TAG);
    libraries2_1_1[1].setMode(TagLibrary.USE_UNIQUE_IN_GROUP);
    proj.setTagSettings(new DefaultTagSettings(libraries2_1_1));

    proj.getTargets().clear();
    proj.getTargets().addSequence(t1);
    TargetHandler.expandTargets(proj.getTargets());
    proj.getTargets().addSequence(t2);
   
    task = pm.getProbeDesignTask(false, true, true, new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    task.run();

    p1 = proj.getProbes().getSequenceAt(0);
    p2 = proj.getProbes().getSequenceAt(1);
    p3 = proj.getProbes().getSequenceAt(2);

    NucleotideSequence tag1 = libraries2_1_1[0].getSequenceAt(0);
   
    assertEquals(proj.getTagAllocationTable().getUserIDs(tag1).contains(p1.getID()),false);
    assertEquals(proj.getTagAllocationTable().getUserIDs(tag1).contains(p3.getID()),true);
   
    assertEquals(2, task.getCandidatesGenerated());
    assertEquals(ProbeMakerPropertyUtils.getRank(p1),ProbeMakerConstants.BAD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p2),ProbeMakerConstants.BAD_QUALITY);
    assertEquals(ProbeMakerPropertyUtils.getRank(p3),ProbeMakerConstants.GOOD_QUALITY);

    libraries2_1_1[0].setMode(TagLibrary.USE_UNIQUE_TAG);
    libraries2_1_1[1].setMode(TagLibrary.USE_UNIQUE_TAG);
    proj.getTagAllocationTable().clearUsed();   
   
  }
View Full Code Here

  }
 
  public void testPairwiseWarnings() throws Exception {


    Project proj = new Project("Test project");     //$NON-NLS-1$
    proj.setTagSettings(new DefaultTagSettings(libraries1_10));
    proj.getTagAllocationTable().clearUsed();
    proj.getTargets().addSequence(t1);   
    proj.getSettings().addCandidateModuleStage1(dummy);
    pm.setProject(proj);
    TargetHandler.expandTargets(pm.getProject().getTargets());

    ProbeDesignTask task = pm.getProbeDesignTask(false, true, true, new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));

    task.run();

    Probe p = proj.getProbes().getSequenceAt(0);
    Probe p2 = proj.getProbes().getSequenceAt(1);

    //Move dummy to arm stage
    proj.getSettings().getCandidateModulesStage1().clear();
    proj.getSettings().addCandidateModuleStage2(dummy);
    task = pm.getProbeDesignTask(false, true, true, new AllAcceptor(),
        new NoSelector(), new DefaultProbeDesigner(new PairwiseTagAllocator()), new DefaultTSSConstructor(), new StreamErrorHandler(System.out,true));
    task.run();

    Probe p3 = proj.getProbes().getSequenceAt(0);
    Probe p4 = proj.getProbes().getSequenceAt(1);

//  Check that both probes of fair rank  
    assertTrue("Probe 1 (stage 1) expected to be of fair quality",ProbeMakerPropertyUtils.getRank(p)==ProbeMakerConstants.OK_QUALITY); //$NON-NLS-1$
    assertTrue("Probe 2 (stage 1) expected to be of fair quality",ProbeMakerPropertyUtils.getRank(p2)==ProbeMakerConstants.OK_QUALITY); //$NON-NLS-1$
View Full Code Here

    Probe[] probes = pm.getProject().getProbes().getSequenceList().toArray(new Probe[5]);
    return probes;
  }
 
  public void testModes() throws DuplicateIDException {
    Project proj = new Project("Test project");     //$NON-NLS-1$
    pm.setProject(proj);
    proj.setTagSettings(new DefaultTagSettings(libraries1_10));
    proj.getTargets().addSequence(t1);
    proj.getTargets().addSequence(t2);
    TargetHandler.expandTargets(pm.getProject().getTargets());
    pm.setProject(proj);
  
    TagLibrary lib = libraries1_10[0];
View Full Code Here

  public void testTagOccurrenceModule() throws Exception {
    tom.setData(DefaultTagOccurrenceModule.KEY_PERCENT_SIMILARITY,new Integer(100));
    tom.getAllTests()[2].setPerform(false);
    tom.getAllTests()[3].setPerform(false);
    pm.setProject(new Project("test project")); //$NON-NLS-1$
    pm.getProject().getSettings().addCandidateModuleStage1(tom);
    pm.getProject().getTargets().addSequence(t1);
    pm.getProject().getTargets().addSequence(t2);
    pm.getProject().getTagAllocationTable().clearUsed();
    lib1.addSequence(new SimpleNucleotideSequence("TAG_A","AAAAAAAAAAAAA")); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

        System.out.println("Done"); //$NON-NLS-1$

        System.out.println("Creating project"); //$NON-NLS-1$

        Project p = new Project("Unnamed",s); //$NON-NLS-1$
        pm.setProject(p);

        String accClassName = props.getProperty("probemaker.acceptor");
        String selClassName = props.getProperty("probemaker.selector");
        String formatClassName = props.getProperty("probemaker.targetInputFormat");
        String outputClassName = props.getProperty("probemaker.probeOutputFormat");
        String targetClassName = props.getProperty("probemaker.targetType");

        if (accClassName == null) {
          System.out.println("No acceptor specified"); //$NON-NLS-1$
          return;
        }

        if (selClassName == null) {
          System.out.println("No selector specified"); //$NON-NLS-1$
          return;
        }

        if (formatClassName == null) {
          System.out.println("No input format specified"); //$NON-NLS-1$
          return;
        }

        ProbeAcceptor acceptor = (ProbeAcceptor) Class.forName(accClassName).newInstance();
        //Check if acceptor requires parameters
        if (acceptor instanceof ParameterPlugIn) {
          ParameterPlugIn paAcceptor = (ParameterPlugIn) acceptor;
          DataDescriptor[] dds = paAcceptor.getDataDescriptors();
          if (dds != null) {
            for (int d = 0;d<dds.length;d++) {
              DataDescriptor dd = dds[d];
              String string = props.getProperty("probemaker.acceptor." + dd.getKey());
              paAcceptor.setData(dd.getKey(), string);
            }
          }
        }
        System.out.println("  Acceptor is: " + acceptor.getClass().getName()); //$NON-NLS-1$

        ProbeSelector selector = (ProbeSelector) Class.forName(selClassName).newInstance();
        if (selector instanceof ParameterPlugIn) {
          ParameterPlugIn paSelector = (ParameterPlugIn) selector;
          DataDescriptor[] dds = paSelector.getDataDescriptors();
          if (dds != null) {
            for (int d = 0;d<dds.length;d++) {
              DataDescriptor dd = dds[d];
              String string = props.getProperty("probemaker.selector." + dd.getKey());
              paSelector.setData(dd.getKey(), string);
            }
          }
        }
        System.out.println("  Selector is: " + selector.getClass().getName());   //$NON-NLS-1$

        SequenceDBDataReader format = (SequenceDBDataReader) Class.forName(formatClassName).newInstance();
        if (format instanceof ParameterPlugIn) {
          ParameterPlugIn paFormat = (ParameterPlugIn) selector;
          DataDescriptor[] dds = paFormat.getDataDescriptors();
          if (dds != null) {
            for (int d = 0;d<dds.length;d++) {
              DataDescriptor dd = dds[d];
              String string = props.getProperty("probemaker.targetInputFormat." + dd.getKey());
              paFormat.setData(dd.getKey(), string);
            }
          }
        }

        if (outputClassName == null) {
          outputClassName = DefaultTextTableFormatter.class.getName();
        }
        Class<?> outputClass = Class.forName(outputClassName);
        TextTableFormatter<Probe> outputformatter = (TextTableFormatter<Probe>) outputClass.newInstance();
       
        if (targetClassName == null) {
          System.err.println("ERROR: Must specify a probemaker.targetType"); //$NON-NLS-1$
          return;
        }
        Class<?> targetClass = Class.forName(targetClassName);
        SequenceBuilder<? extends ProbeMakerTarget> seqBuilder = (SequenceBuilder<? extends ProbeMakerTarget>) targetClass.getMethod("getSequenceBuilder",(Class[])null).invoke(null,(Object[]) null); //$NON-NLS-1$

        System.out.println("  Format is: " + format.getClass().getName()); //$NON-NLS-1$
        System.out.println("  Target type is: " + targetClass.getName()); //$NON-NLS-1$
        System.out.println("  Output format is: " + outputClass.getName()); //$NON-NLS-1$

        TargetInputFormat<? extends ProbeMakerTarget> tif = new DefaultTargetInputFormat("Input format",format,null,seqBuilder,ListSequenceDB.getDefaultBuilder()); //$NON-NLS-1$
       
        System.out.println("  Loading tag libs"); //$NON-NLS-1$

        int ti = 0;
        List<TagLibrary> libs = new ArrayList<TagLibrary>();
        while (props.containsKey("probemaker.taglibrary."+ti)) {
          String taglibString = props.getProperty("probemaker.taglibrary."+ti);
          String[] split = taglibString.split(":");
          byte mode = Byte.parseByte(split[0]);
          String libFileName = split[1];
          File libFile = new File(libFileName);
          if (!libFile.getAbsolutePath().equals(libFile.getPath())) {
            libFile = new File(settingsFile.getAbsoluteFile().getParentFile(),libFile.getPath());
          }
          DefiniteSequenceDB<NucleotideSequence> tagseqs = SequenceIO.readSequenceDB(new FileReader(libFile), new FastaDBFormat<NucleotideSequence>(), null, ListSequenceDB.getDefaultBuilder(),new SimpleDNASequenceBuilder());
          TagLibrary lib = new DefaultTagLibrary(tagseqs,"taglib"+ti); //$NON-NLS-1$
          lib.setMode(mode);
          libs.add(lib);
          ti++;
        }
        TagLibrary[] libraries = libs.toArray(new TagLibrary[libs.size()]);
        int[] order = new int[libraries.length];
        for (int i = 0;i<order.length;i++) order[i] = i;
        TagSettings tagSettings = new DefaultTagSettings(libraries,order);
        p.setTagSettings(tagSettings);

        System.out.println("  Loading targets"); //$NON-NLS-1$

        new TargetIOTask(p,callback,new Reader[] { new FileReader(targetFile) },tif).run();

        System.out.println("Done"); //$NON-NLS-1$

        File logPath = new File(""); //$NON-NLS-1$
        System.out.println("Writing log to: " + logPath); //$NON-NLS-1$

        //Probe design settings
        boolean append = false;

        //Create and start the ProbeDesignerRunner
        TagAllocator ta = (TagAllocator) ProbeMakerPlugIn.defaultTagAllocatorClass.newInstance();
        TSSConstructor tsc = (TSSConstructor) ProbeMakerPlugIn.defaultTSSConstructorClass.newInstance();

        ta.addParameters(s.getDesignParameters());
        tsc.addParameters(s.getDesignParameters());

        ProbeDesigner pd = new DefaultProbeDesigner(ta);
        TSSPairDesigner td = new DefaultTSSPairDesigner(tsc);
        NamingScheme namer = new DefaultNamingScheme();
        DesignLogWriter log = new TextDesignLogWriter(new FileWriter(new File(logPath, p.getName() + ".designlog")));

        ProbeDesignTask runner = pm.getProbeDesignTask(append,false,log,namer,acceptor,selector,pd, td, callback);
        runner.timing = true;
        runner.verbose = true;
        System.out.println("Starting design of " + runner.getMaxProgress() + " probe groups"); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

            CoreMessages.getString("ProbeMakerPlugIn.MESSAGE_DEFAULT_SETTINGS_NOT_READ"),                                       //$NON-NLS-1$
            iox);
      }
    }

    final Project newp = new Project(name);
    newp.setSettings(s);

    //If template was selected, get template properties
    if (template != null) {
      final String fileName = template.getSettingsFileName();
      if (fileName == null || fileName.length() == 0) {
        platform.getUI().sendMessage("No settings file set for this template. Using default settings.", "No settings file", PlatformUI.NO_QUERY);
      }
      else {
        final File f = new File(fileName);
        try {
          final Reader in = new FileReader(f);
          newp.setSettings(SettingsIO.inputSettings(in));
        }
        catch (final FileNotFoundException e) {
          platform.handleError("Template settings file not found: " + f.getAbsolutePath(),e); //$NON-NLS-1$
        }
        catch (final Exception e) {
View Full Code Here

        System.out.println("Done"); //$NON-NLS-1$

        System.out.println("Creating project"); //$NON-NLS-1$

        Project p = new Project("Unnamed",s); //$NON-NLS-1$
        pm.setProject(p);

        String accClassName = props.getProperty("probemaker.acceptor");
        String selClassName = props.getProperty("probemaker.selector");
        String formatClassName = props.getProperty("probemaker.targetInputFormat");
        String outputClassName = props.getProperty("probemaker.probeOutputFormat");
        String targetClassName = props.getProperty("probemaker.targetType");

        if (accClassName == null) {
          System.out.println("No acceptor specified"); //$NON-NLS-1$
          return;
        }

        if (selClassName == null) {
          System.out.println("No selector specified"); //$NON-NLS-1$
          return;
        }

        if (formatClassName == null) {
          System.out.println("No input format specified"); //$NON-NLS-1$
          return;
        }

        ProbeAcceptor acceptor = (ProbeAcceptor) Class.forName(accClassName).newInstance();
        //Check if acceptor requires parameters
        if (acceptor instanceof ParameterPlugIn) {
          ParameterPlugIn paAcceptor = (ParameterPlugIn) acceptor;
          DataDescriptor[] dds = paAcceptor.getDataDescriptors();
          if (dds != null) {
            for (int d = 0;d<dds.length;d++) {
              DataDescriptor dd = dds[d];
              String string = props.getProperty("probemaker.acceptor." + dd.getKey());
              paAcceptor.setData(dd.getKey(), string);
            }
          }
        }
        System.out.println("  Acceptor is: " + acceptor.getClass().getName()); //$NON-NLS-1$

        ProbeSelector selector = (ProbeSelector) Class.forName(selClassName).newInstance();
        if (selector instanceof ParameterPlugIn) {
          ParameterPlugIn paSelector = (ParameterPlugIn) selector;
          DataDescriptor[] dds = paSelector.getDataDescriptors();
          if (dds != null) {
            for (int d = 0;d<dds.length;d++) {
              DataDescriptor dd = dds[d];
              String string = props.getProperty("probemaker.selector." + dd.getKey());
              paSelector.setData(dd.getKey(), string);
            }
          }
        }
        System.out.println("  Selector is: " + selector.getClass().getName());   //$NON-NLS-1$

        SequenceDBDataReader format = (SequenceDBDataReader) Class.forName(formatClassName).newInstance();
        if (format instanceof ParameterPlugIn) {
          ParameterPlugIn paFormat = (ParameterPlugIn) selector;
          DataDescriptor[] dds = paFormat.getDataDescriptors();
          if (dds != null) {
            for (int d = 0;d<dds.length;d++) {
              DataDescriptor dd = dds[d];
              String string = props.getProperty("probemaker.targetInputFormat." + dd.getKey());
              paFormat.setData(dd.getKey(), string);
            }
          }
        }

        if (outputClassName == null) {
          outputClassName = DefaultTextTableFormatter.class.getName();
        }
        Class<?> outputClass = Class.forName(outputClassName);
        TextTableFormatter<Probe> outputformatter = (TextTableFormatter<Probe>) outputClass.newInstance();
       
        if (targetClassName == null) {
          System.err.println("ERROR: Must specify a probemaker.targetType"); //$NON-NLS-1$
          return;
        }
        Class<?> targetClass = Class.forName(targetClassName);
        SequenceBuilder<? extends ProbeMakerTarget> seqBuilder = (SequenceBuilder<? extends ProbeMakerTarget>) targetClass.getMethod("getSequenceBuilder",(Class[])null).invoke(null,(Object[]) null); //$NON-NLS-1$

        System.out.println("  Format is: " + format.getClass().getName()); //$NON-NLS-1$
        System.out.println("  Target type is: " + targetClass.getName()); //$NON-NLS-1$
        System.out.println("  Output format is: " + outputClass.getName()); //$NON-NLS-1$

        TargetInputFormat<? extends ProbeMakerTarget> tif = new DefaultTargetInputFormat("Input format",format,null,seqBuilder,ListSequenceDB.getDefaultBuilder()); //$NON-NLS-1$
       
       
       
        System.out.println("  Loading tag libs"); //$NON-NLS-1$

        int ti = 0;
        List<TagLibrary> libs = new ArrayList<TagLibrary>();
        while (props.containsKey("probemaker.taglibrary."+ti)) {
          String taglibString = props.getProperty("probemaker.taglibrary."+ti);
          String[] split = taglibString.split(":");
          byte mode = Byte.parseByte(split[0]);
          String libFileName = split[1];
          File libFile = new File(libFileName);
          if (!libFile.getAbsolutePath().equals(libFile.getPath())) {
            libFile = new File(settingsFile.getAbsoluteFile().getParentFile(),libFile.getPath());
          }
          DefiniteSequenceDB<NucleotideSequence> tagseqs = SequenceIO.readSequenceDB(new FileReader(libFile), new FastaDBFormat<NucleotideSequence>(), null, ListSequenceDB.getDefaultBuilder(),new SimpleDNASequenceBuilder());
          TagLibrary lib = new DefaultTagLibrary(tagseqs,"taglib"+ti); //$NON-NLS-1$
          lib.setMode(mode);
          libs.add(lib);
          ti++;
        }
        TagLibrary[] libraries = libs.toArray(new TagLibrary[libs.size()]);
        int[] order = new int[libraries.length];
        for (int i = 0;i<order.length;i++) order[i] = i;
        TagSettings tagSettings = new DefaultTagSettings(libraries,order);
        p.setTagSettings(tagSettings);

        System.out.println("  Loading targets"); //$NON-NLS-1$

        new TargetIOTask(p,callback,new Reader[] { new FileReader(targetFile) },tif).run();
View Full Code Here

TOP

Related Classes of org.moltools.apps.probemaker.project.Project

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.