Changeset 3814


Ignore:
Timestamp:
Oct 10, 2007, 2:57:07 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

References #721: Store data in files instead of in the database

  • Experiments are now aware of file-only raw data types
  • Fixed test programs
  • A few remaining Affymetrix issues


Location:
branches/filedb
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/filedb/src/core/common-queries.xml

    r3804 r3814  
    28952895  </query>
    28962896
     2897  <query id="CHANGE_EXPERIMENT_RAWDATATYPE" type="HQL">
     2898    <sql>
     2899      UPDATE ExperimentData
     2900      SET rawDataType = :newRawDataType
     2901      WHERE rawDataType = :oldRawDataType
     2902    </sql>
     2903    <description>
     2904      A HQL query that changes all raw data type for experiments from
     2905      an old value to a new value.
     2906    </description>
     2907  </query>
     2908
    28972909
    28982910</predefined-queries>
  • branches/filedb/src/core/net/sf/basedb/core/Affymetrix.java

    r3807 r3814  
    200200  {
    201201    if (rawBioAssay == null) throw new InvalidUseOfNullException("rawBioAssay");
    202     if (!rawBioAssay.getRawDataType().isAffymetrix())
     202    if (!rawBioAssay.isPlatform(Platform.AFFYMETRIX))
    203203    {
    204204      throw new InvalidDataException("Raw data type for " + rawBioAssay.getName() +
    205       " is not an Affymetrix raw data type");
     205        " is not an Affymetrix raw data type");
    206206    }
    207207    DbControl dc = rawBioAssay.getDbControl();
    208     File celFile = null;
    209     try
    210     {
    211       AnyToAny ata = AnyToAny.getByName(dc, rawBioAssay, CEL_LINK_NAME);
    212       if (ata.getToType() == Item.FILE)
    213       {
    214         celFile = (File)ata.getTo();
    215       }
    216     }
    217     catch (ItemNotFoundException ex)
    218     {}
    219     return celFile;
     208    return FileStoreUtil.getDataFile(dc, rawBioAssay, DataFileType.AFFYMETRIX_CEL);
    220209  }
    221210 
     
    234223  public static void validateCelAndCdf(RawBioAssay rawBioAssay, ArrayDesign design, boolean required)
    235224  {
    236     File celFile = getCelFile(rawBioAssay);
    237     File cdfFile = getCdfFile(design);
     225    DbControl dc = rawBioAssay.getDbControl();
     226    File celFile = FileStoreUtil.getDataFile(dc, rawBioAssay, DataFileType.AFFYMETRIX_CEL);;
     227    File cdfFile = FileStoreUtil.getDataFile(dc, design, DataFileType.AFFYMETRIX_CDF);
    238228    if (celFile != null && cdfFile != null)
    239229    {
    240230      String cdfChipType = cdfFile.getName();
    241       FusionCELData cel = loadCelFile(celFile);
    242       FusionCDFData cdf = loadCdfFile(cdfFile);
     231      FusionCELData cel = new CelFileHandler().loadCelFile(celFile);
     232      FusionCDFData cdf = new CdfFileHandler().loadCdfFile(cdfFile);
    243233      validateCelAndCdf(cel, cdf, cdfChipType);
    244234    }
  • branches/filedb/src/core/net/sf/basedb/core/RawDataType.java

    r3807 r3814  
    5656  private final boolean isAffymetrix;
    5757  private final int channels;
     58  private final int platformId;
     59  private final int variantId;
    5860  private String table;
    5961  private RealTable realTable;
     
    7173    String table, List<RawDataProperty> properties, List<IntensityFormula> formulas)
    7274  {
    73     this(id, name, description, channels, false, false, table, properties, formulas);
    74   }
    75  
     75    this(id, name, description, channels, false, 0, 0, false, table, properties, formulas);
     76  }
     77 
     78  /**
     79    Create a new raw data type representing a file-only platform.
     80    @param platform The platform
     81  */
    7682  RawDataType(PlatformData platform)
    7783  {
    7884    this("platform." + platform.getExternalId(), platform.getName(),
    7985      platform.getDescription(), platform.getChannels(), true,
     86      platform.getId(), 0,
    8087      Platform.AFFYMETRIX.equals(platform.getExternalId()),
    8188      null, null, null);
    8289  }
    8390
     91  /**
     92    Create a new raw data type representing a file-only platform variant.
     93    @param variant The platform variant
     94  */
    8495  RawDataType(PlatformVariantData variant)
    8596  {
    8697    this("variant." + variant.getExternalId(), variant.getName(),
    8798        variant.getDescription(), variant.getChannels(), true,
     99        variant.getPlatform().getId(), variant.getId(),
    88100        Platform.AFFYMETRIX.equals(variant.getPlatform().getExternalId()),
    89101        null, null, null);   
     
    91103 
    92104  private RawDataType(String id, String name, String description, int channels,
    93     boolean fileOnly, boolean isAffymetrix,
     105    boolean fileOnly, int platformId, int variantId, boolean isAffymetrix,
    94106    String table, List<RawDataProperty> properties, List<IntensityFormula> formulas)
    95107  {
     
    99111    this.channels = channels;
    100112    this.fileOnly = fileOnly;
     113    this.platformId = platformId;
     114    this.variantId = variantId;
    101115    this.isAffymetrix = isAffymetrix;
    102116   
     
    158172  /**
    159173    If this raw data type is the Affymetrix raw data type.
    160     @deprecated Use --- instead
     174    @deprecated Use {@link #getPlatform(DbControl)} and compare
     175      the external ID with {@link Platform#AFFYMETRIX}
    161176  */
    162177  public boolean isAffymetrix()
     
    165180  }
    166181 
     182  public Platform getPlatform(DbControl dc)
     183  {
     184    return platformId == 0 ? null : Platform.getById(dc, platformId);
     185  }
     186
     187  public PlatformVariant getVariant(DbControl dc)
     188  {
     189    return variantId == 0 ? null : PlatformVariant.getById(dc, variantId);
     190  }
     191
    167192  /**
    168193    Get the name of this raw data type. This value is the same as the
  • branches/filedb/src/core/net/sf/basedb/core/RawDataTypes.java

    r3807 r3814  
    161161
    162162  /**
    163     Get a collection with all raw data types that has been defined.
     163    Get a collection with all raw data types that has been defined. This method
     164    only returns raw data types that are importable to the database. To
     165    get file-only raw data types use {@link #getFileOnlyRawDataTypes()}
    164166    @return A <code>Collection</code> containing {@link RawDataType} objects
     167      where {@link RawDataType#isStoredInDb()} returns true
    165168  */
    166169  public static Collection<RawDataType> getRawDataTypes()
    167170  {
    168171    return Collections.unmodifiableCollection(rawDataTypes.values());
     172  }
     173 
     174  /**
     175    Get the raw data types that are representations of file-only
     176    {@link Platform}:s.
     177    @return A <code>Collection</code> containing {@link RawDataType} objects
     178      where {@link RawDataType#isStoredInDb()} returns false
     179    @since 2.5
     180  */
     181  public static Collection<RawDataType> getFileOnlyRawDataTypes()
     182  {
     183    return Collections.unmodifiableCollection(platformTypes.values());
    169184  }
    170185
     
    203218    try
    204219    {
     220      session = HibernateUtil.newSession();
     221      tx = HibernateUtil.newTransaction(session);
    205222      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
    206223        "GET_PLATFORM_FOR_EXTERNAL_ID");
     
    228245    try
    229246    {
     247      session = HibernateUtil.newSession();
     248      tx = HibernateUtil.newTransaction(session);
    230249      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
    231250        "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID");
  • branches/filedb/src/core/net/sf/basedb/core/Update.java

    r3807 r3814  
    16601660
    16611661  /**
    1662     Set a platform for array designs and raw bioassays.
    1663     Move CEL and CDF files into FileSet:s
    1664     Remove filters on isAffyChip property
     1662    <ul>
     1663    <li>Set a platform for array designs and raw bioassays
     1664    <li>Change experiment raw data type if it is "affymetrix" to "platform.affymetrix"
     1665    <li>Move CEL and CDF files into FileSet:s
     1666    <li>Remove filters on ArrayDesign.isAffyChip property
     1667    <li>Rename filter on RawBioassay.spots property to RawBioassay.numDbSpots
     1668    <li>Add READ permission to PLATFORM and DATAFILETYPE for all plug-ins
     1669      working with ARRAYDESIGN or RAWBIOASSAY
     1670    </ul>
    16651671  */
    16661672  @SuppressWarnings("deprecation")
     
    17531759      }
    17541760 
     1761      // Change raw data type for 'affymetrix' experiments to 'platform.affymetrix'
     1762      org.hibernate.Query query = HibernateUtil.getPredefinedSQLQuery(session,
     1763        "CHANGE_EXPERIMENT_RAWDATATYPE");
     1764      /*
     1765        UPDATE ExperimentData
     1766        SET rawDataType = :newRawDataType
     1767        WHERE rawDataType = :oldRawDataType
     1768      */
     1769      query.setString("oldRawDataType", "affymetrix");
     1770      query.setString("newRawDataType", "platform.affymetrix");
     1771      HibernateUtil.executeUpdate(query);
     1772     
    17551773      // Remove filters on the 'affyChip' property
    1756       org.hibernate.Query query = HibernateUtil.getPredefinedSQLQuery(session,
     1774      query = HibernateUtil.getPredefinedSQLQuery(session,
    17571775        "DELETE_PROPERTY_FILTER");
    17581776      /*
  • branches/filedb/src/core/net/sf/basedb/core/filehandler/AffymetrixFileHandler.java

    r3807 r3814  
    7070    @param cdfFile The file to load
    7171    @return A FusionCDFData object representing the CDF file
    72     @throws ItemNotFoundException If the actaul file is not on the server
     72    @throws ItemNotFoundException If the actual file is not on the server
    7373    @throws InvalidDataException If the file is not a CDF file
    7474  */
     
    9393  }
    9494 
     95  /**
     96    Load a CEL file using the Affymetric Fusion SDK. This method
     97    checks that the file exists, and read all headers.
     98   
     99    @param celFile The file to load
     100    @return A FusionCELData object representing the CEL file
     101    @throws ItemNotFoundException If the actual file is not on the server
     102    @throws InvalidDataException If the file is not a CEL file
     103  */
    95104  public FusionCELData loadCelFile(File celFile)
    96105  {
  • branches/filedb/src/test/TestDirty.java

    r3783 r3814  
    9292    TestJob.test_delete(jobId);
    9393    TestPluginConfiguration.test_delete(pluginConfigurationId);
    94     TestFile.test_delete(fileId);
    9594    TestRawBioAssay.test_delete(rawBioAssayId);
    9695    TestArrayDesign.test_delete(arrayDesignId);
     96    TestFile.test_delete(fileId);
    9797    TestReporter.test_delete();
    9898    write("++Testing import of dirty data "+(ok ? "OK" : "Failed")+"\n");
  • branches/filedb/www/views/experiments/edit_experiment.jsp

    r3679 r3814  
    5454  import="net.sf.basedb.clients.web.util.HTML"
    5555  import="net.sf.basedb.util.Values"
     56  import="net.sf.basedb.util.Enumeration"
    5657  import="net.sf.basedb.util.formatter.Formatter"
    5758  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     
    151152        frm.name.focus();
    152153        return false;
     154      }
     155      if (frm.rawdatatype)
     156      {
     157        if (frm.rawdatatype[frm.rawdatatype.selectedIndex].value == '')
     158        {
     159          alert("You must select a raw data type");
     160          frm.rawdatatype.focus();
     161          return false;
     162        }
    153163      }
    154164      return true;
     
    334344          if (experiment == null)
    335345          {
    336             %>
    337             <select name="rawdatatype" class="required">
    338             <%
    339             currentRawDataType = currentRawDataType != null ? currentRawDataType : defaultRawDataType;
     346            currentRawDataType = currentRawDataType != null ?
     347              currentRawDataType : defaultRawDataType;
     348            Enumeration<RawDataType, String> rawEnumeration =
     349              new Enumeration<RawDataType, String>();
    340350            for (RawDataType rdt : RawDataTypes.getRawDataTypes())
    341351            {
     352              rawEnumeration.add(rdt, rdt.getName());
     353            }
     354            for (RawDataType rdt : RawDataTypes.getFileOnlyRawDataTypes())
     355            {
     356              rawEnumeration.add(rdt, rdt.getName());
     357            }
     358            rawEnumeration.sortValues();           
     359            %>
     360            <select name="rawdatatype" class="required unchangeable">
     361            <%
     362            for (int i = 0; i < rawEnumeration.size(); ++i)
     363            {
     364              RawDataType rdt = rawEnumeration.getKey(i);
    342365              String selected = rdt.equals(currentRawDataType) ? "selected" : "";
    343366              %>
     
    413436      </tr>
    414437      </table>
    415       <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
     438      <div align=right>
     439        &nbsp;<i><base:icon image="required.gif" /> = required information</i>
     440        <%if (experiment == null) {%><br>
     441        <i><base:icon image="unchangeable.gif" /> = can't be changed later</i>
     442        <%}%>
     443        </div>
    416444    </t:tab>
    417445   
  • branches/filedb/www/views/experiments/list_experiments.jsp

    r3679 r3814  
    226226        rawEnumeration.add(rdt.getId(), HTML.encodeTags(rdt.getName()));
    227227      }
     228      for (RawDataType rdt : RawDataTypes.getFileOnlyRawDataTypes())
     229      {
     230        rawEnumeration.add(rdt.getId(), HTML.encodeTags(rdt.getName()));
     231      }
     232      rawEnumeration.sortValues();
    228233      %>
    229234      <tbl:columndef
  • branches/filedb/www/views/rawbioassays/list_rawbioassays.jsp

    r3807 r3814  
    282282        filterable="true"
    283283        exportable="true"
    284       />        <%
     284      />       
     285      <%
    285286      Enumeration<String, String> rawEnumeration = new Enumeration<String, String>();
    286287      for (RawDataType rdt : RawDataTypes.getRawDataTypes())
     
    288289        rawEnumeration.add(rdt.getId(), HTML.encodeTags(rdt.getName()));
    289290      }
     291      for (RawDataType rdt : RawDataTypes.getFileOnlyRawDataTypes())
     292      {
     293        rawEnumeration.add(rdt.getId(), HTML.encodeTags(rdt.getName()));
     294      }
     295      rawEnumeration.sortValues();
    290296      %>
    291297      <tbl:columndef
Note: See TracChangeset for help on using the changeset viewer.