Changeset 4791


Ignore:
Timestamp:
Feb 25, 2009, 10:55:44 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

References #1237: BioAssaySetExporter? should attach generated files to the bioassayset

The basic functionality is in place.

Location:
trunk/src
Files:
5 edited

Legend:

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

    r4594 r4791  
    103103  public static String GENERIC_EXTRAVALUE_DATA = "generic.extravaluedata";
    104104
     105  /**
     106    The external ID for the file type representing
     107    a serial BASEFile.
     108    @since 2.11
     109  */
     110  public static String BASEFILE_SERIAL = "basefile.serial";
     111 
     112  /**
     113    The external ID for the file type representing
     114    a matrix BASEFile.
     115    @since 2.11
     116  */
     117  public static String BASEFILE_MATRIX = "basefile.matrix";
     118 
     119  /**
     120    The external ID for the file type representing
     121    a MeV TDMS (Tab-Delimited Multiple Sample) file.
     122    @since 2.11
     123  */
     124  public static String MEV_TDMS = "mev.tdms";
     125 
    105126  /**
    106127    The maximum length of the file extension that can be stored in the database.
  • trunk/src/core/net/sf/basedb/core/Install.java

    r4732 r4791  
    744744        "Generic file that contains extra value data",
    745745        Item.EXTRAVALUE, null, extraValueType, null, null);
     746      DataFileTypeData baseFileSerial = createDataFileType(
     747        DataFileType.BASEFILE_SERIAL, "Serial BASEFile",
     748        "A serial BASEFile with spot data",
     749        Item.BIOASSAYSET, null, spotDataType, null, null);
     750      DataFileTypeData baseFileMatrix = createDataFileType(
     751        DataFileType.BASEFILE_MATRIX, "Matrix BASEFile",
     752        "A matrix BASEFile with spot data",
     753        Item.BIOASSAYSET, null, spotDataType, null, null);
     754      DataFileTypeData mevTdmsFile = createDataFileType(
     755        DataFileType.MEV_TDMS, "MeV TDMS",
     756        "A MeV Tab-Delimited Multiple Sample file",
     757        Item.BIOASSAYSET, null, spotDataType, null, null);
    746758     
    747759      // Platforms and variants
  • trunk/src/core/net/sf/basedb/core/plugin/ExportOutputStream.java

    r4523 r4791  
    2424import java.io.IOException;
    2525import java.io.OutputStream;
     26
     27import net.sf.basedb.core.File;
    2628
    2729/**
     
    119121  {}
    120122 
     123  /**
     124    If the export stream is going to a BASE {@link File} object,
     125    use this method to access it. This class always return null,
     126    subclasses may override this method.
     127    @return A File object or null
     128    @since 2.11
     129  */
     130  public File getFile()
     131  {
     132    return null;
     133  }
    121134}
  • trunk/src/core/net/sf/basedb/util/FileExportOutputStream.java

    r4523 r4791  
    9191    if (!ignoreFilename) file.setName(filename);
    9292  }
     93
     94  /**
     95    @return The file given to the constructor.
     96  */
     97  @Override
     98  public File getFile()
     99  {
     100    return file;
     101  }
    93102  // -------------------------------------------
    94103}
  • trunk/src/plugins/core/net/sf/basedb/plugins/BioAssaySetExporter.java

    r4711 r4791  
    3131import net.sf.basedb.core.BooleanParameterType;
    3232import net.sf.basedb.core.Config;
     33import net.sf.basedb.core.DataFileType;
    3334import net.sf.basedb.core.DbControl;
    3435import net.sf.basedb.core.DynamicResultIterator;
     
    3940import net.sf.basedb.core.ExtraValueType;
    4041import net.sf.basedb.core.File;
     42import net.sf.basedb.core.FileSetMember;
     43import net.sf.basedb.core.FileStoreUtil;
    4144import net.sf.basedb.core.Formula;
    4245import net.sf.basedb.core.Include;
     
    158161
    159162        storeValue(job, request, bioAssaySetParameter);
     163        storeValue(job, request, formatParameter);
    160164        storeValue(job, request, ri.getParameter(SAVE_AS));
    161165        storeValue(job, request, ri.getParameter(OVERWRITE));
    162         storeValue(job, request, formatParameter);
     166        storeValue(job, request, ri.getParameter("attachToBioAssaySet"));
    163167       
    164         if (request.getParameterValue(formatParameter.getName()).equals(FORMAT_BASEFILE))
     168        String fileFormat = (String)request.getParameterValue(formatParameter.getName());
     169        if (FORMAT_BASEFILES.contains(fileFormat))
    165170        {
    166171          response.setContinue(COMMAND_CONFIGURE_BASEFILE);
     
    192197       
    193198        storeValue(job, request, geneAveragesParameter);
    194         storeValue(job, request, serialFormatParameter);
    195199        storeValues(job, request, usedFieldsParameter);
    196200        storeValues(job, request, usedColumnsParameter);
     
    10451049            "Average on reporters within each assay.",
    10461050            new BooleanParameterType(false, true));
    1047        
    1048         Enumeration<Boolean, String> serialFormat = new Enumeration<Boolean, String>();
    1049         serialFormat.add(false, "Normal BASEfile (one big matrix)");
    1050         serialFormat.add(true, "Serial BASEfile (one section per assay)");
    1051         serialFormatParameter = new PluginParameter<Boolean>
    1052           ( "serialFormat",
    1053             "Export as matrix or serial basefile.",
    1054             "The data can be exported as a matrix with all data in the same section or in a " +
    1055             "serial format where the data is separated for each assay.",
    1056             new BooleanParameterType(false, true, 1, serialFormat));
    1057        
     1051             
    10581052        Enumeration<String, String> fields = new Enumeration<String, String>();
    10591053        BioAssaySet bas = (BioAssaySet) job.getValue(bioAssaySetParameter.getName());
     
    10931087       
    10941088        parameters.add(geneAveragesParameter);
    1095         parameters.add(serialFormatParameter);
    10961089        parameters.add(usedFieldsParameter);
    10971090        parameters.add(usedColumnsParameter);
     
    11511144     
    11521145      Enumeration<String, String> formats = new Enumeration<String, String>();
    1153       formats.add(FORMAT_MEV, "MultiExperiment Viewer (MeV)");
    1154       formats.add(FORMAT_BASEFILE, "BASEfile");
     1146      formats.add(FORMAT_BASEFILE_SERIAL, "Serial BASEfile");
     1147      formats.add(FORMAT_BASEFILE_MATRIX, "Matrix BASEfile");
     1148      formats.add(FORMAT_MEV_TDMS, "MeV TDMS");
    11551149      /**
    11561150         Plain matrix export is currently not supported from the web
     
    11681162          new StringParameterType(255, null, true, 1, 0, 0, formats) );
    11691163
     1164      PluginParameter<Boolean> attachToBasParameter =
     1165        new PluginParameter<Boolean>(
     1166        "attachToBioAssaySet",
     1167        "Attach file to bioassay set",
     1168        "Deselect this option if you don't want the generated file to " +
     1169        "become attached to the current bioassay set. This option is ignored " +
     1170        "if the file isn't saved in the BASE file system.",
     1171        new BooleanParameterType(true, false)
     1172        );
     1173     
    11701174      parameters.add(bioAssaySetParameter);
     1175      parameters.add(formatParameter);
    11711176      parameters.add(getSaveAsParameter(null, null, defaultPath, requireFile));
    11721177      parameters.add(getOverwriteParameter(null, null));
    1173       parameters.add(formatParameter);
     1178      parameters.add(attachToBasParameter);
    11741179
    11751180      configureJob = new RequestInformation
     
    12231228      permissions.add(new Permissions(Item.USER, null, EnumSet.of(Permission.READ)));
    12241229      permissions.add(new Permissions(Item.EXTRAVALUETYPE, null, EnumSet.of(Permission.READ)));
     1230      permissions.add(new Permissions(Item.DATAFILETYPE, null, EnumSet.of(Permission.READ)));
    12251231    }
    12261232    return permissions;
     
    12911297      bas = (BioAssaySet)job.getValue("bioAssaySet");
    12921298      bas = BioAssaySet.getById(dc, bas.getId());
     1299      boolean attachToBioAssaySet = Boolean.TRUE.equals(job.getValue("attachToBioAssaySet"));
    12931300      out.setMimeType("text/plain");
    12941301      String filename = Path.makeSafeFilename(bas.getName() + ".export.", "").toLowerCase() + "txt";
    12951302      out.setFilename(filename);
    12961303      out.setCharacterSet(Config.getCharset());
     1304      File exportFile = out.getFile();
     1305      String dataFileTypeId = null;
    12971306     
    1298   //      AnyToAny ata = AnyToAny.getNew(dc, bioassayset, file, file.getPath().toString(), false);
    1299   //      if (!ata.isInDatabase()) dc.saveItem(ata);
    1300  
    13011307      if (progress != null) progress.display(0, "Exporting ...");
    13021308 
    13031309      // Add other export formats here
    13041310      String format = (String) job.getValue("fileformat");
    1305       if (format.equals(FORMAT_MEV))
     1311      if (FORMAT_MEV_TDMS.equals(format))
    13061312      {
    13071313        exportMeV(bas, out, progress);
    1308       }
    1309       else if (format.equals(FORMAT_BASEFILE))
     1314        dataFileTypeId = DataFileType.MEV_TDMS;
     1315      }
     1316      else if (FORMAT_BASEFILES.contains(format))
    13101317      {
    13111318        List<String> reporterFields = (List<String>)job.getValues("usedColumns");
     
    13171324        boolean geneAverage = (Boolean) job.getValue("geneAverages");
    13181325       
    1319         if ((Boolean) job.getValue("serialFormat"))
     1326        if (FORMAT_BASEFILE_SERIAL.equals(format))
    13201327        {
    13211328          exportBaseFileSerial(bas, out, Collections.EMPTY_MAP, reporterFields, spotFields, geneAverage);
     1329          dataFileTypeId = DataFileType.BASEFILE_SERIAL;
    13221330        }
    13231331        else
    13241332        {
    13251333          exportBaseFileMatrix(bas, out, Collections.EMPTY_MAP, reporterFields, spotFields, geneAverage);
    1326         }
    1327       }
    1328       else if (format.equals(FORMAT_PLAIN_MATRIX))
     1334          dataFileTypeId = DataFileType.BASEFILE_MATRIX;
     1335        }
     1336      }
     1337      else if (FORMAT_PLAIN_MATRIX.equals(format))
    13291338      {
    13301339        exportPlainMatrix(bas, out, progress);
     
    13331342      {
    13341343        throw new BaseException("Unknown format. "+format);
     1344      }
     1345     
     1346      if (attachToBioAssaySet && exportFile != null && dataFileTypeId != null)
     1347      {
     1348        FileSetMember file = FileStoreUtil.setDataFile(dc, bas, dataFileTypeId, exportFile);
     1349        file.setValid(true, null);
     1350        bas.setNumFileSpots(bas.getNumSpots());
     1351        bas.setNumFileReporters(bas.getNumReporters());
     1352        for (BioAssay ba : bas.getBioAssays().list(dc))
     1353        {
     1354          ba.setNumFileSpots(ba.getNumSpots());
     1355        }
    13351356      }
    13361357    }
     
    13861407 
    13871408  //BaseFile parameters
    1388   private PluginParameter<Boolean> serialFormatParameter;
    13891409  private PluginParameter<Boolean> geneAveragesParameter;
    13901410  private PluginParameter<String> usedFieldsParameter;
     
    13931413  // Constants
    13941414  private static final String COMMAND_CONFIGURE_BASEFILE = "configure_basefile";
    1395   private static final String FORMAT_BASEFILE = "BASEfile";
    1396   private static final String FORMAT_MEV = "MeV";
    1397   private static final String FORMAT_PLAIN_MATRIX = "Plain Matrix";
     1415  private static final String FORMAT_BASEFILE_SERIAL = "basefile.serial";
     1416  private static final String FORMAT_BASEFILE_MATRIX = "basefile.matrix";
     1417  private static final String FORMAT_MEV_TDMS = "mev.tdms";
     1418  private static final String FORMAT_PLAIN_MATRIX = "plain.matrix";
    13981419 
     1420  private static final Set<String> FORMAT_BASEFILES = new HashSet<String>(
     1421      Arrays.asList(FORMAT_BASEFILE_SERIAL, FORMAT_BASEFILE_MATRIX));
    13991422
    14001423  public class QueryItem
Note: See TracChangeset for help on using the changeset viewer.