Changeset 577


Ignore:
Timestamp:
Feb 8, 2008, 1:33:31 PM (13 years ago)
Author:
Martin Svensson
Message:

References #89 Installation plug-in is now able to create Illumina scanner in the installation process. Also changed some text/options in a couple of parameters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/net/sf/basedb/illumina/src/net/sf/basedb/illumina/install/Install.java

    r572 r577  
    3030import net.sf.basedb.core.DbControl;
    3131import net.sf.basedb.core.FileType;
     32import net.sf.basedb.core.Hardware;
     33import net.sf.basedb.core.HardwareType;
    3234import net.sf.basedb.core.InvalidDataException;
    3335import net.sf.basedb.core.Item;
     
    109111  private static final Set<Permissions> permissions = new HashSet<Permissions>();
    110112
    111   /*TODO
    112   private static final PluginParameter<Boolean> installSnpVariantParameter = new PluginParameter<Boolean>
    113     (
    114       "installSnp",
    115       "SNP variant",
    116       "TRUE if he SNP variant of Illumina should be installed, FALSE otherwise.",
    117       new BooleanParameterType(true, true)
    118     );
     113  /*TODO SNP
     114  private static final PluginParameter<Boolean> installSnpVariantParameter
    119115  */   
    120   private static final PluginParameter<Boolean> installExp1VariantParameter = new PluginParameter<Boolean>
     116  private PluginParameter<String> installExp1VariantParameter;
     117  private PluginParameter<String> installExp2VariantParameter;
     118 
     119  private PluginParameter<String> installScannerParameter;
     120  private PluginParameter<String> scannerNameParameter;
     121  private PluginParameter<String> scannerVersionParameter;
     122 
     123   
     124  //Parameter section headers
     125  private static final PluginParameter<String> variantSection = new PluginParameter<String>
    121126  (
    122     "installExp1",
    123     "Expression 1",
    124     "TRUE if the Expression 1 variant of Illumina should be installed, FALSE otherwise.\n" +
    125     "Expression 1 has one strip on each array.",
    126     new BooleanParameterType(true, true)
    127   ); 
    128   private static final PluginParameter<Boolean> installExp2VariantParameter = new PluginParameter<Boolean>
     127    "variantSection",
     128    "Variants",
     129    "Variants available to be installed",
     130    null
     131  );
     132  private static final PluginParameter<String> hardwareSection = new PluginParameter<String>
    129133  (
    130     "installExp2",
    131     "Expression2",
    132     "TRUE if the Expression 2 variant of Illumina should be installed, FALSE otherwise.\n" +
    133     "Expression 2 has two strips on each array.",
    134     new BooleanParameterType(true, true)
     134    "hardwareSection",
     135    "Hardware",
     136    "Hardware used with the Illumina platform",
     137    null
     138  );
     139  private static final PluginParameter<String> errorSection = new PluginParameter<String>
     140  (
     141    "errorSection",
     142    "Error handling",
     143    "Settings how to handling when errors occur",
     144    null
    135145  );
    136146     
    137147  public static final String SKIP_OPTION = "skip";
    138148  public static final String ABORT_OPTION = "abort";
     149 
     150  private static final String YES_OPTION = "yes";
     151  private static final String NO_OPTION = "no";
    139152 
    140153  private static final String BGX_FILEYTPE_EXTENSION = "bgx";
     
    203216        boolean installSnp = (Boolean)job.getValue("installSnp");
    204217        */
    205         boolean installExp1 = (Boolean)job.getValue("installExp1");
    206         boolean installExp2 = (Boolean)job.getValue("installExp2");
     218        boolean installExp1 = ((String)job.getValue("installExp1")).equals(YES_OPTION);
     219        boolean installExp2 = ((String)job.getValue("installExp2")).equals(YES_OPTION);       
     220        boolean installScanner = ((String)job.getValue("installScanner")).equals(YES_OPTION);
    207221        String alreadyExistingItem = (String)job.getValue("alreadyInstalledError");
    208222
     
    211225        if (installExp2) expressionTypes.add(2);
    212226       
    213         installIlluminaItems(null, expressionTypes, alreadyExistingItem.equals(SKIP_OPTION), progress);
     227        Map<String, Object> scannerProperties = null;
     228        if (installScanner)
     229        {
     230          scannerProperties = new HashMap<String, Object>();
     231          scannerProperties.put("name", (String)job.getValue("scannerName"));
     232          scannerProperties.put("version", (String)job.getValue("scannerVersion"));
     233          scannerProperties.put("description", "The Illumina BeadArray Reader is a " +
     234              "scanner that can read arrays including Illumina Sentrix BeadChips and " +
     235              "Sentrix Array Matrices (SAMs).");
     236        }
     237       
     238        installIlluminaItems(null, expressionTypes, scannerProperties, alreadyExistingItem.equals(SKIP_OPTION), progress);
    214239      }
    215240      catch(Throwable ex)
     
    273298        return;
    274299      }
     300      if (((String)request.getParameterValue(installScannerParameter.getName())).equals(YES_OPTION) &&
     301          request.getParameterValue(scannerNameParameter.getName()) == null)
     302      {
     303        response.setError("The scanner to create must have a name. Please specify a name in 'Scanner name'-parameter", null);
     304        return;
     305      }
    275306      storeValue(job, request, alreadyInstalledErrorParameter);
    276307      storeValue(job, request, installExp1VariantParameter);
     
    280311      */
    281312     
     313      storeValue(job, request, installScannerParameter);
     314      storeValue(job, request, scannerNameParameter);
     315      storeValue(job, request, scannerVersionParameter);
     316     
    282317      response.setDone("The job configuration is complete.");
    283318    }
     
    308343    @param expressionTypes A set of numbers. A expression variant will be created for each object in the set
    309344      and the number itself represent the number of strip(s) in an array of the variant to create.
     345    @param scannerProperties A map with properties to set on a scanner/hardware when it is created. Null if no hardware should be installed.
    310346    @param ignoreExistingItems TRUE if items already existing should be ignored and the rest should be installed.
    311347       FALSE if NO items should be created when there is one or more already existing in BASE.
    312348    @throws ItemAlreadyExistsException If ignoreInstalledItems = FALSE and one of the
    313349   */
    314   public void installIlluminaItems(Boolean installSNP, Set<Integer> expressionTypes, boolean ignoreExistingItems, ProgressReporter progress)
     350  public void installIlluminaItems(Boolean installSNP, Set<Integer> expressionTypes, Map<String, Object> scannerProperties, boolean ignoreExistingItems, ProgressReporter progress)
    315351    throws ItemAlreadyExistsException
    316352  {   
     
    345381      dc = sc.newDbControl();
    346382 
     383      Hardware scanner = null;
     384      if (scannerProperties != null)
     385      {
     386        String name = (String)scannerProperties.get("name");
     387        String scannerVersion = (String)scannerProperties.get("version");
     388        String description = (String)scannerProperties.get("description");
     389        int typeId = SystemItems.getId(HardwareType.SCANNER);
     390        scanner = Hardware.getNew(dc, HardwareType.getById(dc, typeId));
     391        dc.saveItem(scanner);
     392        scanner.setName(name == null ? "Illumina hardware" : name);
     393        scanner.setVersionString(scannerVersion);
     394        scanner.setDescription(description);
     395      }
     396     
    347397      reporterMapType = FileType.getById(dc, SystemItems.getId("net.sf.basedb.core.FileType.REPORTER_MAP"));
    348398      rawDataType = FileType.getById(dc, SystemItems.getId("net.sf.basedb.core.FileType.RAW_DATA"));
    349399
    350       Map<String, DataFileType> dataFileTypes = new HashMap<String, DataFileType>();
    351      
     400      //Data file types
     401      Map<String, DataFileType> dataFileTypes = new HashMap<String, DataFileType>();     
    352402      DataFileType bgx = createDataFileType(dc,
    353403        Illumina.BGX_FILE_ID, "BGX file", "Illumina Sentrix Array binary manifest file",
     
    355405      bgx.setValidatorClass(Illumina.BGX_VALIDATOR_METADATAREADER);
    356406      bgx.setMetadataReaderClass(Illumina.BGX_VALIDATOR_METADATAREADER);
    357 
    358407      for (int i = 1; i <= largestNumOfStrips; i++ )
    359408      {
     
    367416      //TODO Create data file type for SNP filer.
    368417     
     418      //Platform and variants
    369419      Platform illuminaPlatform = createPlatform(dc, Illumina.PLATFORM_ID, "Illumina", ignoreExistingItems);
    370420      if (illuminaPlatform.getDescription() == null || illuminaPlatform.getDescription().equals(""))
     
    403453        platformVariants.add(pfv);       
    404454      }
    405       */     
     455      */ 
     456     
    406457      dc.commit();
    407458    }
     
    419470    if (configureJob == null)
    420471    {
     472      boolean firstTimeInstallation = isFirstTimeInstallation();
     473      String[] options = {YES_OPTION, NO_OPTION};
     474      StringParameterType installOptionType = new StringParameterType
     475      (
     476        255,
     477        firstTimeInstallation ? YES_OPTION : NO_OPTION,
     478        true,
     479        1, 0, 0,
     480        Arrays.asList(options)
     481      );
     482     
     483      installExp1VariantParameter = new PluginParameter<String>
     484      (
     485          "installExp1",
     486          "Create Expression 1",
     487          "Select '" + YES_OPTION + "' to create an Illumina expression variant with one strip/array.",
     488          installOptionType
     489        ); 
     490     
     491      installExp2VariantParameter = new PluginParameter<String>
     492      (
     493          "installExp2",
     494          "Create Expression 2",
     495          "Select '" + YES_OPTION + "' to create an Illumina expression variant with two strips/array.",
     496          installOptionType
     497        );
     498     
     499      installScannerParameter = new PluginParameter<String>
     500      (
     501        "installScanner",
     502        "Install scanner",
     503        "Choose '" + YES_OPTION + "' to create a scanner in BASE, or '" + NO_OPTION + "' otherwise",
     504        installOptionType
     505      );
     506      scannerNameParameter = new PluginParameter<String>
     507      (
     508        "scannerName",
     509        "Scanner name",
     510        "A name to assign to the scanner if this should be created. " +
     511        "This could only be left empty if 'Install scanner' is set to '"+NO_OPTION+"'",
     512        new StringParameterType
     513        (
     514          255,
     515          firstTimeInstallation ? "Illumina BeadArray Reader" : null,
     516          false,
     517          1,0,0         
     518        )
     519      );
     520      scannerVersionParameter = new PluginParameter<String>
     521      (
     522        "scannerVersion",
     523        "Scanner version",
     524        "Version of the scanner to create. This has no effect if 'Install scanner' is set to '" + NO_OPTION + "'",
     525        new StringParameterType
     526        (
     527          255,
     528          null,
     529          false,
     530          1,0,0
     531        )
     532      );
     533     
    421534      List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
    422535      /*TODO SNP
    423536      parameters.add(installSnpVariantParameter);
    424537      */
     538      parameters.add(variantSection);
    425539      parameters.add(installExp1VariantParameter);
    426540      parameters.add(installExp2VariantParameter);
     541     
     542      parameters.add(hardwareSection);
     543      parameters.add(installScannerParameter);
     544      parameters.add(scannerNameParameter);
     545      parameters.add(scannerVersionParameter);
     546     
     547      parameters.add(errorSection);
    427548      parameters.add(alreadyInstalledErrorParameter);
    428549     
     
    439560  }
    440561 
     562  private boolean isFirstTimeInstallation()
     563  {
     564    DbControl dc = null;
     565    try
     566    {
     567      dc = sc.newDbControl();
     568      Platform illuminaPlatform = Platform.getByExternalId(dc, Illumina.PLATFORM_ID);
     569      return illuminaPlatform == null;
     570    }
     571    catch (ItemNotFoundException infex)
     572    {
     573      return true;
     574    }
     575    finally
     576    {
     577      if (dc != null) dc.close();
     578    }
     579  }
     580 
    441581  private DataFileType createDataFileType(DbControl dc, String externalId, String name,
    442582    String description, Item itemType, String extension, FileType genericType, boolean ignoreExistingItem)
Note: See TracChangeset for help on using the changeset viewer.