Changeset 5239
- Timestamp:
- Feb 9, 2010, 1:27:41 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/DataFileType.java
r4791 r5239 116 116 */ 117 117 public static String BASEFILE_MATRIX = "basefile.matrix"; 118 119 /** 120 The external ID for the file type representing a BFS 121 metadata file. The metadata file may reference additional 122 files. 123 @since 2.15 124 */ 125 public static String BFS_METADATA = "bfs.metadata"; 118 126 119 127 /** -
trunk/src/core/net/sf/basedb/core/Install.java
r5214 r5239 781 781 "A matrix BASEFile with spot data", 782 782 Item.BIOASSAYSET, null, spotDataType, null, null); 783 DataFileTypeData bfsMetadataFile = createDataFileType( 784 DataFileType.BFS_METADATA, "BFS metadata file", 785 "The metadata file of a BASE file set. The metadata " + 786 "file may reference additional files in the [files] section.", 787 Item.BIOASSAYSET, null, spotDataType, null, null); 783 788 DataFileTypeData mevTdmsFile = createDataFileType( 784 789 DataFileType.MEV_TDMS, "MeV TDMS", -
trunk/src/plugins/core/net/sf/basedb/plugins/ManualTransformCreator.java
r5216 r5239 33 33 import net.sf.basedb.core.DataFileType; 34 34 import net.sf.basedb.core.DbControl; 35 import net.sf.basedb.core.Directory; 35 36 import net.sf.basedb.core.File; 36 37 import net.sf.basedb.core.FileParameterType; 37 38 import net.sf.basedb.core.FileSet; 39 import net.sf.basedb.core.InvalidDataException; 38 40 import net.sf.basedb.core.Item; 39 41 import net.sf.basedb.core.ItemNotFoundException; … … 61 63 import net.sf.basedb.core.query.Restrictions; 62 64 import net.sf.basedb.util.basefile.BaseFileParser; 65 import net.sf.basedb.util.bfs.BaseInputStreamLocator; 66 import net.sf.basedb.util.bfs.GenericExtraFileImporter; 67 import net.sf.basedb.util.bfs.MetadataParser; 63 68 import net.sf.basedb.util.importer.spotdata.BaseFileImporter; 69 import net.sf.basedb.util.importer.spotdata.BfsImporter; 64 70 65 71 /** … … 78 84 private RequestInformation configurePlugin; 79 85 private List<PluginParameter<?>> toolParameters; 86 87 private List<String> importableFileTypes = Arrays.asList( 88 DataFileType.BASEFILE_MATRIX, 89 DataFileType.BASEFILE_SERIAL, 90 DataFileType.BFS_METADATA); 80 91 81 92 public ManualTransformCreator() … … 144 155 if (importSpotData) 145 156 { 146 File file = getBaseFile();147 if (file == null)148 { 149 throw new ItemNotFoundException(" No serial or matrix BASEfile selected");150 } 151 BaseFileImporter importer = new BaseFileImporter();152 BaseFileParser parser = importer.getBaseFileParser();153 if ( !useBase1ColumnNames)154 { 155 parser.setRedefinedColumnName("spots", "position", "Position");156 parser.setRedefinedColumnName("spots", "reporter", "Internal id");157 for (int ch = 1; ch <= source.getRawDataType().getChannels(); ++ch)157 String fileType = getImportFileType(); 158 if (fileType == null) 159 { 160 throw new ItemNotFoundException("You have not selected a file to import from"); 161 } 162 File file = (File)job.getValue("file." + fileType); 163 file = File.getById(dc, file.getId()); 164 if (fileType.startsWith("basefile.")) 165 { 166 BaseFileImporter importer = new BaseFileImporter(); 167 BaseFileParser parser = importer.getBaseFileParser(); 168 if (!useBase1ColumnNames) 158 169 { 159 parser.setRedefinedColumnName("spots", "intensity" + ch, "Ch " + ch); 170 parser.setRedefinedColumnName("spots", "position", "Position"); 171 parser.setRedefinedColumnName("spots", "reporter", "Internal id"); 172 for (int ch = 1; ch <= source.getRawDataType().getChannels(); ++ch) 173 { 174 parser.setRedefinedColumnName("spots", "intensity" + ch, "Ch " + ch); 175 } 160 176 } 161 } 162 importer.setDbControl(dc); 163 importer.setSourceFile(file); 164 importer.setProgressReporter(progress); 165 importer.setTransformation(t); 166 child = importer.doImport(); 177 importer.setDbControl(dc); 178 importer.setSourceFile(file); 179 importer.setProgressReporter(progress); 180 importer.setTransformation(t); 181 child = importer.doImport(); 182 } 183 else if (fileType.startsWith("bfs.")) 184 { 185 Directory dir = file.getDirectory(); 186 BfsImporter importer = new BfsImporter(); 187 importer.setDbControl(dc); 188 importer.setMetadataParser(MetadataParser.create(file)); 189 importer.setInputStreamLocator(new BaseInputStreamLocator(dc, dir)); 190 importer.setExtraFileImporter(new GenericExtraFileImporter(dc, dir, false)); 191 importer.setProgressReporter(progress); 192 importer.setTransformation(t); 193 child = importer.doImport(); 194 } 195 else 196 { 197 throw new InvalidDataException("Unknown file type: " + fileType); 198 } 167 199 } 168 200 if (child == null) … … 192 224 fs.setMember(file, ft); 193 225 } 194 fs.validate(dc, true);195 }226 } 227 fs.validate(dc, true); 196 228 } 197 229 if (allowMoreFiles) … … 287 319 if (importSpotData) 288 320 { 289 File file = getBaseFile();290 if (file == null)291 { 292 response.setError(" No serial or matrix BASEfile selected", null);321 String fileType = getImportFileType(); 322 if (fileType == null) 323 { 324 response.setError("You have not selected a file to import from", null); 293 325 } 294 326 else … … 354 386 BioAssaySet source = getCurrentBioAssaySet(dc); 355 387 388 // Check if any of the used file types can be imported 389 boolean hasImportableFileType = false; 356 390 boolean hasBaseFileType = false; 357 391 for (DataFileType dft : fileTypes) 358 392 { 359 393 String fileTypeId = dft.getExternalId(); 360 if ( DataFileType.BASEFILE_SERIAL.equals(fileTypeId) ||361 DataFileType.BASEFILE_MATRIX.equals(fileTypeId))362 { 363 has BaseFileType = true;394 if (fileTypeId.startsWith("basefile.")) hasBaseFileType = true; 395 if (importableFileTypes.contains(fileTypeId)) 396 { 397 hasImportableFileType = true; 364 398 break; 365 399 } … … 370 404 parameters.add(getSourceBioAssaySetParameter(null, null)); 371 405 372 if (hasDbData || has BaseFileType)406 if (hasDbData || hasImportableFileType) 373 407 { 374 408 List<String> options = new ArrayList<String>(); 375 if (has BaseFileType) options.add("import");409 if (hasImportableFileType) options.add("import"); 376 410 if (hasDbData) options.add("keep"); 377 411 options.add("none"); … … 381 415 "Select the procedure for creating in-databaes spot data for the " + 382 416 "child bioassay set:\n\n" + 383 "import = import spot data from a serial or matrix BASEfile " + 384 "(this option is only available if the tool generates a BASEfile)\n" + 417 "import = import spot data from the selected file(s) " + 418 "(this option is only available if the tool generates a BASEfile or " + 419 "BFS data)\n" + 385 420 "keep = keep the spot data from the parent bioassay set\n" + 386 421 "none = do not create any spot data in the database", … … 392 427 "columnNames", 393 428 "Column names", 394 "If you have selected Spot data=import er, you may specify which " +429 "If you have selected Spot data=import, you may specify which " + 395 430 "type of BASEfile you have:\n\n" + 396 431 "base1 = The file uses BASE 1 column names\n" + … … 574 609 } 575 610 576 private File getBaseFile() 577 { 578 File file = (File)job.getValue("file." + DataFileType.BASEFILE_MATRIX); 579 if (file == null) 580 { 581 file = (File)job.getValue("file." + DataFileType.BASEFILE_SERIAL); 582 } 583 return file; 611 private String getImportFileType() 612 { 613 for (String fileType : importableFileTypes) 614 { 615 if (job.getValue("file." + fileType) != null) return fileType; 616 } 617 return null; 584 618 } 585 619 }
Note: See TracChangeset
for help on using the changeset viewer.