Changeset 1119 for extensions/net.sf.basedb.genepattern
- Timestamp:
- Jun 10, 2009, 1:36:40 PM (14 years ago)
- Location:
- extensions/net.sf.basedb.genepattern/trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/GenePattern.java
r1091 r1119 1 1 package net.sf.basedb.genepattern; 2 3 import net.sf.basedb.clients.web.extensions.ExtensionsControl; 4 import net.sf.basedb.core.Presets; 5 import net.sf.basedb.core.SessionControl; 2 6 3 7 /** … … 36 40 public static final String GCT_FILE = "genepattern.gct"; 37 41 42 /** 43 Get the home directory URL for the GenePattern extension. 44 */ 45 public static final String getHomeUrl() 46 { 47 return ExtensionsControl.getHomeUrl("net.sf.basedb.genepattern.options"); 48 } 49 38 50 } -
extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/plugin/GenePatternAnalysisPlugin.java
r1110 r1119 1 1 package net.sf.basedb.genepattern.plugin; 2 2 3 import java.net.URL;4 3 import java.util.ArrayList; 5 4 import java.util.Arrays; 6 5 import java.util.Date; 7 6 import java.util.List; 8 import java.util.Map; 9 10 import org.genepattern.client.GPClient; 11 import org.genepattern.webservice.JobResult; 7 12 8 import org.genepattern.webservice.Parameter; 13 import org.genepattern.webservice.ParameterInfo;14 9 import org.genepattern.webservice.WebServiceException; 15 10 … … 25 20 import net.sf.basedb.core.Experiment; 26 21 import net.sf.basedb.core.File; 27 import net.sf.basedb.core.FileParameterType;28 import net.sf.basedb.core.FloatParameterType;29 import net.sf.basedb.core.IntegerParameterType;30 22 import net.sf.basedb.core.Item; 31 23 import net.sf.basedb.core.ItemQuery; … … 54 46 import net.sf.basedb.core.signal.SignalTarget; 55 47 import net.sf.basedb.core.signal.ThreadSignalHandler; 48 import net.sf.basedb.genepattern.GPServer; 56 49 import net.sf.basedb.genepattern.GenePattern; 57 50 import net.sf.basedb.genepattern.file.BaseFileProxy; 58 51 import net.sf.basedb.genepattern.file.FileTransferGateway; 59 import net.sf.basedb.util.Enumeration; 60 import net.sf.basedb.util.Values; 52 import net.sf.basedb.genepattern.wrapper.GPClient; 53 import net.sf.basedb.genepattern.wrapper.JobResult; 54 import net.sf.basedb.genepattern.wrapper.ParameterInfo; 61 55 62 56 public class GenePatternAnalysisPlugin … … 122 116 checkInterrupted(); 123 117 String gpModule = (String)configuration.getValue("gpModule"); 124 Presets.Preset gpServer = getSelectedGpServer((String)job.getValue("gpServer")); 125 126 GPClient gp = new GPClient(gpServer.getName(), 127 gpServer.getSetting("server.login"), 128 gpServer.getSetting("server.password")); 129 ParameterInfo[] info = gp.getParameters(gpModule); 118 GPServer gpServer = GPServer.get(sc, (String)job.getValue("gpServer")); 119 120 GPClient gp = new GPClient(gpServer); 121 ParameterInfo[] info = gp.getParameters(gpModule, null); 130 122 Parameter[] parameters = new Parameter[info.length]; 131 123 int index = 0; … … 163 155 if (progress != null) 164 156 { 165 progress.display(25, "Running analysis on GenePattern server: " + gpServer.get Name());157 progress.display(25, "Running analysis on GenePattern server: " + gpServer.getUrl()); 166 158 } 167 159 checkInterrupted(); 168 160 int jobId = gp.runAnalysisNoWait(gpModule, parameters); 169 161 JobResult result = null; 170 while (true) 171 { 172 if (gp.isComplete(jobId)) 173 { 174 result = gp.createJobResult(jobId); 175 break; 176 } 177 try 178 { 179 Thread.sleep(5000); 180 } 181 catch (InterruptedException ex) 182 { 183 throw new SignalException("Aborted by user"); 184 } 185 } 186 162 try 163 { 164 result = gp.waitFor(jobId, 5000); 165 } 166 catch (InterruptedException ex) 167 { 168 throw new SignalException("Aborted by user"); 169 } 187 170 checkInterrupted(); 188 171 … … 235 218 { 236 219 checkInterrupted(); 237 URL url = result.getURLForFileName(f);238 220 File baseFile = File.getFile(dc, dir, f, true); 239 221 if (!baseFile.isInDatabase()) dc.saveItem(baseFile); … … 488 470 parameters.add(new PluginParameter<String>( 489 471 "gpModule", 490 " GenePattern module/pipeline",472 "Module/pipeline", 491 473 "Enter the name or LSID of a GenePattern module or pipeline", 492 474 new StringParameterType(255, null, true) … … 502 484 configurePlugin = new RequestInformation( 503 485 Request.COMMAND_CONFIGURE_PLUGIN, 504 " GenePattern module/pipeline",486 "Configure GenePattern module/pipeline", 505 487 "Select a GenePattern module or pipeline to run " + 506 488 "when this configuration is selected.", 507 parameters 489 parameters, 490 GenePattern.getHomeUrl() + "/configure_plugin.jsp" 508 491 ); 509 492 510 511 493 return configurePlugin; 512 494 } … … 517 499 if (configureGpParameters != null) return configureGpParameters; 518 500 String gpModule = (String)configuration.getValue("gpModule"); 519 Presets.Preset gpServer = getSelectedGpServer(501 GPServer gpServer = GPServer.get(sc, 520 502 context == null ? (String)configuration.getValue("gpServer") : (String)job.getValue("gpServer")); 521 503 522 504 try 523 505 { 524 GPClient gp = new GPClient(gpServer.getName(), 525 gpServer.getSetting("server.login"), gpServer.getSetting("server.password")); 526 527 ParameterInfo[] info = gp.getParameters(gpModule); 506 GPClient gp = new GPClient(gpServer); 507 508 ParameterInfo[] info = gp.getParameters(gpModule, null); 528 509 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(info.length); 529 510 530 511 for (ParameterInfo pi : info) 531 512 { 532 PluginParameter<?> pp = convertToPluginParameter(pi, context != null); 533 if (pp != null) parameters.add(pp); 513 if (context != null || !pi.isInputFile()) 514 { 515 PluginParameter<?> pp = pi.createPluginParameter("gp."); 516 if (pp != null) parameters.add(pp); 517 } 534 518 } 535 519 … … 569 553 } 570 554 571 protected Presets.Preset getSelectedGpServer(String server) 572 { 573 String presetsXml = sc.getUserDefaultSetting("net.sf.basedb.genepattern.options"); 574 System.out.println("xml=" + presetsXml); 575 Presets presets = new Presets(); 576 if (presetsXml != null) presets.loadFrom(presetsXml); 577 return presets.getPreset(server); 578 } 579 580 581 protected PluginParameter<?> convertToPluginParameter(ParameterInfo pi, boolean forJob) 582 { 583 String name = pi.getName(); 584 String type = (String)pi.getAttributes().get("type"); 585 Map<String, String> choices = pi.getChoices(); 586 PluginParameter<?> parameter = null; 587 if (pi.isInputFile()) 588 { 589 if (forJob) 590 { 591 parameter = new PluginParameter<File>( 592 "gp." + name, 593 name, 594 pi.getDescription(), 595 new FileParameterType(null, !pi.isOptional(), 1) 596 ); 597 } 598 } 599 else if (choices != null && !choices.isEmpty()) 600 { 601 Enumeration<String, String> options = convertChoicesToEnumeration(choices); 602 parameter = new PluginParameter<String>( 603 "gp." + name, 604 name, 605 pi.getDescription(), 606 new StringParameterType(255, pi.getDefaultValue(), !pi.isOptional(), 1, 0, 0, options) 607 ); 608 } 609 else if (type.equals("java.lang.String")) 610 { 611 parameter = new PluginParameter<String>( 612 "gp." + name, 613 name, 614 pi.getDescription(), 615 new StringParameterType(255, Values.getStringOrNull(pi.getDefaultValue()), !pi.isOptional()) 616 ); 617 } 618 else if (type.equals("java.lang.Integer")) 619 { 620 parameter = new PluginParameter<Integer>( 621 "gp." + name, 622 name, 623 pi.getDescription(), 624 new IntegerParameterType(null, null, 625 Values.getInteger(pi.getDefaultValue(), null), !pi.isOptional()) 626 ); 627 } 628 else if (type.equals("java.lang.Float")) 629 { 630 parameter = new PluginParameter<Float>( 631 "gp." + name, 632 name, 633 pi.getDescription(), 634 new FloatParameterType(null, null, 635 Values.getFloat(pi.getDefaultValue(), null), !pi.isOptional()) 636 ); 637 } 638 return parameter; 639 } 640 641 protected Enumeration<String, String> convertChoicesToEnumeration(Map<String, String> choices) 642 { 643 if (choices == null || choices.isEmpty()) return null; 644 Enumeration<String, String> options = new Enumeration<String, String>(); 645 for (Map.Entry<String, String> entry : choices.entrySet()) 646 { 647 options.add(entry.getValue(), entry.getKey()); 648 } 649 return options; 650 } 555 651 556 }
Note: See TracChangeset
for help on using the changeset viewer.