Changeset 5729


Ignore:
Timestamp:
Sep 8, 2011, 3:35:22 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1620: Implement a 'Manual derived bioassay creator' plug-in

The plug-in can be used and it is possible to put restrictions on the parent bioassay subtype. There are no parameters for setting protocol, hardware or software... This might be needed, but I don't know if it should be on the configuration or in the job wizard. This could be an enhancement for a later BASE version.

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/DerivedBioAssay.java

    r5697 r5729  
    102102      permission checking and database access
    103103    @param bioAssay The parent physical bioassay
     104    @param job The job that created the new bioassay
    104105    @return A new DerivedBioAssay item
    105106  */
    106   public static DerivedBioAssay getNew(DbControl dc, PhysicalBioAssay bioAssay)
     107  public static DerivedBioAssay getNew(DbControl dc, PhysicalBioAssay bioAssay, Job job)
    107108  {
    108109    if (bioAssay == null) throw new InvalidUseOfNullException("bioAssay");
     
    113114    dbas.getData().setPhysicalBioAssay(bioAssay.getData());
    114115    dbas.getData().setEntryDate(new Date());
     116    dbas.getData().setJob(job == null ? null : job.getData());
    115117    return dbas;
    116118  }
     
    121123      permission checking and database access
    122124    @param parent The parent bioassay
     125    @param job The job that created the new bioassay
    123126    @return A new DerivedBioAssay item
    124127  */
    125   public static DerivedBioAssay getNew(DbControl dc, DerivedBioAssay parent)
     128  public static DerivedBioAssay getNew(DbControl dc, DerivedBioAssay parent, Job job)
    126129  {
    127130    if (parent == null) throw new InvalidUseOfNullException("parent");
     
    134137    dbas.getData().setExtract(parent.getData().getExtract());
    135138    dbas.getData().setEntryDate(new Date());
     139    dbas.getData().setJob(job == null ? null : job.getData());
    136140    return dbas;
    137141  }
  • trunk/src/core/net/sf/basedb/core/plugin/AbstractAnalysisPlugin.java

    r5610 r5729  
    3030import net.sf.basedb.core.BioAssaySet;
    3131import net.sf.basedb.core.DbControl;
     32import net.sf.basedb.core.DerivedBioAssay;
    3233import net.sf.basedb.core.DynamicSpotQuery;
    3334import net.sf.basedb.core.Experiment;
     
    7576 
    7677  /**
     78    GuiContext = [Item.DERIVEDBIOASSAY, GuiContext.Type.ITEM]
     79    @since 3.0
     80  */
     81  protected static final GuiContext CONTEXT_DERIVEDBIOASSAY =
     82    new GuiContext(Item.DERIVEDBIOASSAY, GuiContext.Type.ITEM);
     83 
     84  /**
    7785    The default gui contexts where it makes sense to use an analysis plugin.
    7886    Override for the {@link InteractivePlugin#getGuiContexts()} method to
     
    108116 
    109117  /**
    110     The source parameter.
     118    The source parameter for bioassay set.
    111119    @see #getSourceBioAssaySetParameter(String, String)
    112120  */
    113   private PluginParameter<BioAssaySet> sourceParameter = null;
     121  private PluginParameter<BioAssaySet> sourceBioAssaySetParameter = null;
     122
     123
     124  /**
     125    The parameter type for the source derived bioassay.
     126    @since 3.0
     127  */
     128  private static final ItemParameterType<DerivedBioAssay> sourceDerivedBioAssayType =
     129    new ItemParameterType<DerivedBioAssay>(DerivedBioAssay.class, null, true, 1, null);
     130 
     131
     132  /**
     133    The source parameter for derived bioassay.
     134    @see #getSourceDerivedBioAssayParameter(String, String)
     135    @since 3.0
     136  */
     137  private PluginParameter<DerivedBioAssay> sourceDerivedBioAssayParameter = null;
     138
    114139 
    115140  /**
     
    148173  }
    149174  /**
    150     Check that the item is a bioassayset and that the logged in user has
    151     permission to use the current experiment.
     175    Check that the item is a bioassayset/derived bioassay and that the
     176    logged in user has permission to use the current item.
    152177      @param context Current guicontext
    153178      @param item The item to check.
    154     @return null if the item is a bioassayset, an error message otherwise
     179    @return null if the item is a valid item, an error message otherwise
    155180    @throws net.sf.basedb.core.PermissionDeniedException If the logged in user dosen't have
    156181      permission to use the Experiment
     
    176201      }
    177202    }
     203    else if (context.equals(CONTEXT_DERIVEDBIOASSAY))
     204    {
     205      if (item == null)
     206      {
     207        message = "The object is null";
     208      }
     209      else if (!(item instanceof DerivedBioAssay))
     210      {
     211        message = "The object is not a DerivedBioAssay: " + item;
     212      }
     213      else
     214      {
     215        DerivedBioAssay dba = (DerivedBioAssay)item;
     216        dba.checkPermission(Permission.USE);
     217      }
     218    }
    178219    else
    179220    {
     
    206247  protected PluginParameter<BioAssaySet> getSourceBioAssaySetParameter(String label, String description)
    207248  {
    208     if (sourceParameter == null)
     249    if (sourceBioAssaySetParameter == null)
    209250    {
    210251      if (label == null) label = "Source bioassay set";
    211252      if (description == null) description = "The bioassay set that is used as the data source for this job.";
    212       sourceParameter = new PluginParameter<BioAssaySet>
     253      sourceBioAssaySetParameter = new PluginParameter<BioAssaySet>
    213254        (
    214255          SOURCE_BIOASSAYSET, label, description, sourceBioAssaySetType
    215256        );
    216257    }
    217     return sourceParameter;
    218   }
     258    return sourceBioAssaySetParameter;
     259  }
     260 
     261  protected static final String SOURCE_DERIVEDBIOASSAY = "source";
     262 
     263  /**
     264    Get a plugin parameter that asks for a derived bioassay to use as data source for
     265    the plugin. Calling this method multiple times return the same plugin parameter object.
     266    The label and description for the first call is always used.
     267   
     268    @param label The parameter label, or null to use the default (Source bioassay)
     269    @param description The parameter description, or null to use the default
     270      (The derived bioassay that is used as the data source for this job.)
     271  */
     272  protected PluginParameter<DerivedBioAssay> getSourceDerivedBioAssayParameter(String label, String description)
     273  {
     274    if (sourceDerivedBioAssayParameter == null)
     275    {
     276      if (label == null) label = "Source bioassay";
     277      if (description == null) description = "The derived  bioassay set that is used as the data source for this job.";
     278      sourceDerivedBioAssayParameter = new PluginParameter<DerivedBioAssay>
     279        (
     280            SOURCE_DERIVEDBIOASSAY, label, description, sourceDerivedBioAssayType
     281        );
     282    }
     283    return sourceDerivedBioAssayParameter;
     284  }
     285
    219286 
    220287  protected static final String SOURCE_BIOASSAYS = "bioAssays";
     
    398465 
    399466  /**
     467    Get the current source derived bioassay. We first check the job's parameter
     468    values with the {@link #getSourceDerivedBioAssay(DbControl)} method. If this
     469    returns null we check the information in the current context:
     470    <code>SessionControl.getCurrentContext(Item.DERIVEDBIOASSAY)</code>. Note
     471    that this information is normally only available during the configuration
     472    phase of a plugin, not during the execution phase.
     473   
     474    @param dc The DbControl to use for database access
     475    @return The current derived bioassay or null
     476    @see #getSourceBioAssaySet(DbControl)
     477    @since 3.0
     478  */
     479  protected DerivedBioAssay getCurrentDerivedBioAssay(DbControl dc)
     480  {
     481    DerivedBioAssay current = getSourceDerivedBioAssay(dc);
     482    if (current == null)
     483    {
     484      int currentId = sc.getCurrentContext(Item.DERIVEDBIOASSAY).getId();
     485      if (currentId != 0) current = DerivedBioAssay.getById(dc, currentId);
     486    }
     487    return current;
     488  }
     489 
     490  /**
     491    Get the derived bioassay that is used as the source for the plugin.
     492    The source bioassay is only available in the execution phase
     493    if the plugin has saved it as a job parameter during the configuration
     494    of a job.
     495   
     496    @return The source derived bioassay or null
     497    @see #getSourceDerivedBioAssayParameter(String, String)
     498    @since 3.0
     499  */
     500  protected DerivedBioAssay getSourceDerivedBioAssay(DbControl dc)
     501  {
     502    DerivedBioAssay source = (DerivedBioAssay)job.getValue(SOURCE_DERIVEDBIOASSAY);
     503    if (source != null) source = DerivedBioAssay.getById(dc, source.getId());
     504    return source;
     505  }
     506
     507 
     508  /**
    400509    Generate a name for the transformation based on the plugin and it's
    401510    configuration. The name is created by taking the name of the plugin from the
  • trunk/src/plugins/core/core-plugins.xml

    r5696 r5729  
    483483  </plugin-definition>
    484484
     485  <plugin-definition id="ManualDerivedBioAssayCreator">
     486    <about>
     487      <name>Manual derived bioassay creator</name>
     488      <description>
     489        This plug-in allows a user to manually register an external
     490        analysis procedure that has happened outside of BASE and to
     491        register the parameters used and the output files that was
     492        generated. Before this plug-in can be used a configuration
     493        that represents the external tool must be created. The
     494        configuration will be used to register possible parameters
     495        and output files.
     496      </description>
     497    </about>
     498    <plugin-class>net.sf.basedb.plugins.ManualDerivedBioAssayCreator</plugin-class>
     499    <settings>
     500      <property name="everyone-use">1</property>
     501      <property name="immediate-execution">1</property>
     502    </settings>
     503  </plugin-definition>
     504
    485505  <plugin-definition id="BioSourceImporter">
    486506    <about>
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/DerivedBioAssayImporter.java

    r5719 r5729  
    306306    {
    307307      DerivedBioAssay parent = findDerivedBioAssay(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, parentSubtype);
    308       bioAssay = DerivedBioAssay.getNew(dc, parent);
     308      bioAssay = DerivedBioAssay.getNew(dc, parent, job.getJob());
    309309    }
    310310    else
    311311    {
    312312      PhysicalBioAssay pba = findPhysicalBioAssay(dc, FallbackIdMethod.NAME_OR_ID, nameOrId, parentSubtype);
    313       bioAssay = DerivedBioAssay.getNew(dc, pba);
     313      bioAssay = DerivedBioAssay.getNew(dc, pba, job.getJob());
    314314    }
    315315   
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/ScanImporter.java

    r5719 r5729  
    213213      hyb = findHybridization(dc, FallbackIdMethod.NAME_OR_ID, hybridizationMapper.getValue(data));
    214214    }
    215     DerivedBioAssay scan = DerivedBioAssay.getNew(dc, hyb);
     215    DerivedBioAssay scan = DerivedBioAssay.getNew(dc, hyb, job.getJob());
    216216    scan.setItemSubtype(ItemSubtype.getById(dc, SystemItems.getId(DerivedBioAssay.SCAN)));
    217217    updateItem(dc, scan, data);
  • trunk/src/test/TestDerivedBioAssay.java

    r5720 r5729  
    9292    {
    9393      dc = TestUtil.getDbControl();
    94       DerivedBioAssay dbas = DerivedBioAssay.getNew(dc, PhysicalBioAssay.getById(dc, bioAssayId));
     94      DerivedBioAssay dbas = DerivedBioAssay.getNew(dc, PhysicalBioAssay.getById(dc, bioAssayId), null);
    9595      dbas.setName(name);
    9696      dbas.setDescription("Added at "+new Date());
     
    140140    {
    141141      dc = TestUtil.getDbControl();
    142       DerivedBioAssay dbas = DerivedBioAssay.getNew(dc, DerivedBioAssay.getById(dc, parentId));
     142      DerivedBioAssay dbas = DerivedBioAssay.getNew(dc, DerivedBioAssay.getById(dc, parentId), null);
    143143      dbas.setName(name);
    144144      dbas.setDescription("Added at "+new Date());
  • trunk/src/test/net/sf/basedb/test/roles/UserTest.java

    r5700 r5729  
    547547  {
    548548    TestUtil.write("--Creating scan: " + name + "\n");
    549     DerivedBioAssay scan = DerivedBioAssay.getNew(dc, hyb);
     549    DerivedBioAssay scan = DerivedBioAssay.getNew(dc, hyb, null);
    550550    scan.setItemSubtype(ItemSubtype.getById(dc, SystemItems.getId(DerivedBioAssay.SCAN)));
    551551    scan.setName(name);
     
    570570  {
    571571    TestUtil.write("--Creating root bioassay: " + name + "\n");
    572     DerivedBioAssay bioAssay = DerivedBioAssay.getNew(dc, parent);
     572    DerivedBioAssay bioAssay = DerivedBioAssay.getNew(dc, parent, null);
    573573    bioAssay.setItemSubtype(ItemSubtype.getById(dc, SystemItems.getId(subtype)));
    574574    bioAssay.setName(name);
     
    587587  {
    588588    TestUtil.write("--Creating derived bioassay: " + name + "\n");
    589     DerivedBioAssay bioAssay = DerivedBioAssay.getNew(dc, parent);
     589    DerivedBioAssay bioAssay = DerivedBioAssay.getNew(dc, parent, null);
    590590    bioAssay.setItemSubtype(ItemSubtype.getById(dc, SystemItems.getId(subtype)));
    591591    bioAssay.setName(name);
  • trunk/www/views/derivedbioassays/index.jsp

    r5721 r5729  
    182182      {
    183183        PhysicalBioAssay bioAssay = PhysicalBioAssay.getById(dc, physicalBioAssayId);
    184         bas = DerivedBioAssay.getNew(dc, bioAssay);
     184        bas = DerivedBioAssay.getNew(dc, bioAssay, null);
    185185        cc.setRecent(bioAssay, maxRecent);
    186186      }
     
    188188      {
    189189        DerivedBioAssay parent = DerivedBioAssay.getById(dc, parentId);
    190         bas = DerivedBioAssay.getNew(dc, parent);
     190        bas = DerivedBioAssay.getNew(dc, parent, null);
    191191        cc.setRecent(parent, maxRecent);
    192192      }
  • trunk/www/views/derivedbioassays/view_bioassay.jsp

    r5727 r5729  
    610610        <jsp:param name="item_type" value="<%=itemType.name()%>" />
    611611        <jsp:param name="item_id" value="<%=itemId%>" />
    612         <jsp:param name="title" value="Other items related to this bioassay set" />
     612        <jsp:param name="title" value="Other items related to this bioassay" />
    613613      </jsp:include>
    614614      </div>
Note: See TracChangeset for help on using the changeset viewer.