Changeset 654
- Timestamp:
- Apr 11, 2008, 5:40:25 PM (15 years ago)
- Location:
- plugins/base2/uk.ac.ebi.tab2mage/branches/tab2mageimporter
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/base2/uk.ac.ebi.tab2mage/branches/tab2mageimporter/jsp/uk/ac/ebi/nugo/plugins/experiment.jsp
r639 r654 186 186 <tr class="noBorder"> 187 187 <td style="border-style: none;"><select name="accession" onchange="arrayDesignOnChange()"> 188 <option selected="selected">Agilent potato POCI 1x44k</option>188 <option selected="selected">Agilent1</option> 189 189 </select></td> 190 190 <td style="border-style: none;"> -
plugins/base2/uk.ac.ebi.tab2mage/branches/tab2mageimporter/jsp/uk/ac/ebi/nugo/plugins/hybridizations.jsp
r643 r654 158 158 <td class="input"> 159 159 <select name="platform"> 160 <option onclick="hideTwoChannelQuestions();" >Affymetrix</option>161 <option onclick="showTwoChannelQuestions();" selected="selected">Agilent</option>160 <option onclick="hideTwoChannelQuestions();" selected="selected" >Affymetrix</option> 161 <option onclick="showTwoChannelQuestions();" >Agilent</option> 162 162 <option onclick="showTwoChannelQuestions();">AIDA</option> 163 163 <option onclick="showTwoChannelQuestions();">BZScan</option> … … 178 178 <tr> 179 179 <td class="boldText">Experimental organism:<font color="red"><b> *</b></font></td> 180 <td class="input"><input type="text" size="50" name="organism" value=" Mus musculus"/></td>180 <td class="input"><input type="text" size="50" name="organism" value="Homo sapiens"/></td> 181 181 <td>The full scientific name of the experimental organism used.</td> 182 182 </tr> … … 185 185 <tr> 186 186 <td class="boldText">Number of hybridizations:<font color="red"><b> *</b></font></td> 187 <td class="input"><input type="text" size="3" name="numHybs" value=" 12"/></td>187 <td class="input"><input type="text" size="3" name="numHybs" value="32"/></td> 188 188 <td>The total number of hybridizations in the experiment. <b>Please note: for two-channel experiments there are two hybridizations per chip.</b> 189 189 </td> … … 193 193 <tr> 194 194 <td class="boldText">Experimental factors:<font color="red"><b> *</b></font> </td> 195 <td class="input"><textarea rows="7" cols="35" name="expFactors" > Genotype(wild type,PGC-1 beta transgenic)</textarea></td>195 <td class="input"><textarea rows="7" cols="35" name="expFactors" ></textarea></td> 196 196 <td>Please list all experimental factors and value ranges using the following format (one per 197 197 line):<br> … … 215 215 <tr> 216 216 <td class="boldText">Target tissues:<font color="red"><b> *</b></font></td> 217 <td class="input"><textarea rows="4" cols="32" name="tissues"> heart</textarea></td>217 <td class="input"><textarea rows="4" cols="32" name="tissues">blood</textarea></td> 218 218 <td>List all target tissues -- one per line, in no particular order, each tissue once only.</td> 219 219 </tr> … … 228 228 <tr class="noBorder" > 229 229 230 <td style="vertical-align: middle;border-style: none;"><input type="text" name="path" size="35" value=" /home/michab/E-MEXP-1340.raw.zip"></td>230 <td style="vertical-align: middle;border-style: none;"><input type="text" name="path" size="35" value=""></td> 231 231 232 232 <td style="vertical-align: middle;border-style: none;"> -
plugins/base2/uk.ac.ebi.tab2mage/branches/tab2mageimporter/src/uk/ac/ebi/nugo/common/ZipUnpacker.java
r477 r654 4 4 Developed at the EBI , Cambridge. 5 5 Author: Dominic Oyeniran: oyeniran@ebi.ac.uk 6 */6 */ 7 7 package uk.ac.ebi.nugo.common; 8 8 … … 60 60 Unpacks a zip file, checking that there is enough space to accommodate 61 61 the zip file once it is unpacked. 62 62 */ 63 63 public void unpack(String dirName) 64 64 { 65 65 log.info("Begin to unpack the files"); 66 67 InputStream inStream = null; 66 68 DbControl dc=null; 67 69 try … … 69 71 dc= sc.newDbControl(); 70 72 if (file==null) 73 { 74 log.debug("file is null -- returning"); 71 75 return; 72 InputStream inStream = file.getDownloadStream(0); 76 } 77 log.debug("getting input stream for file " + file.getName()); 78 79 int bytesAvailable = 0; 80 while(inStream == null || bytesAvailable==0) 81 { 82 try 83 { 84 log.debug("trying to get input stream for file " + file.getName()); 85 inStream =file.getDownloadStream(0); 86 log.debug("inStream = " + inStream); 87 if(inStream != null) 88 { 89 bytesAvailable = inStream.available(); 90 log.debug("bytes available from this input stream = " + bytesAvailable); 91 } 92 } 93 catch (Exception e) 94 { 95 e.printStackTrace(); 96 } 97 } 98 99 zipFileSize = getZipfileEntriesSize(inStream); 100 log.info("size of zip file = " + zipFileSize); 73 101 //check if the logged in user has sufficient disk space. if yes go ahead with the unpacking 74 102 boolean hasSpace= checkUserQuota(inStream, dc); 75 103 if (hasSpace) 76 104 { 105 log.debug("space is sufficient -- unpacking"); 77 106 createSubDirectory( file, user, dirName); 78 107 // now call the method to unpack the zip files … … 80 109 FileUnpacker unpacker = zipFilePlugin.newInstance(net.sf.basedb.plugins.ZipFileUnpacker.class, null, dc.getSessionControl(), null, null); 81 110 numUnpackedFiles=unpacker.unpack(dc, unzippedFilesDirectory,file.getDownloadStream(0), false,null); 111 log.debug("numUnpackedFiles = " + numUnpackedFiles); 82 112 } 83 113 else // if space is not enough 84 114 { 115 log.debug("User do not have the required Disk Space. Please contact your BASE administrator or remove some files"); 85 116 throw new BaseException("User do not have the required Disk Space. Please contact your BASE administrator or remove some files"); 86 117 } … … 90 121 catch (Throwable exc) 91 122 { 123 exc.printStackTrace(); 92 124 dc.close(); 93 125 log.info("File cannot be unpacked", exc); … … 98 130 if (dc!=null) 99 131 dc.close(); 100 } 101 } 102 103 104 /** 105 Unpacks a zip file, checking that there is enough space to accommodate 106 the zip file once it is unpacked. 107 @throws NutribasePluginException 108 */ 109 public void unpack() 110 { 111 log.info("Begin to unpack the files"); 112 DbControl dc=null; 113 try 114 { 115 dc= sc.newDbControl(); 116 if (file==null) 117 return; 118 InputStream inStream = file.getDownloadStream(0); 119 //check if the logged in user has sufficient disk space. if yes go ahead with the unpacking 120 boolean hasSpace= checkUserQuota(inStream, dc); 121 if (hasSpace) 122 { 123 createSubDirectory( file, user); 124 // now call the method to unpack the zip files 125 PluginDefinition zipFilePlugin = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.ZipFileUnpacker"); 126 FileUnpacker unpacker = zipFilePlugin.newInstance(net.sf.basedb.plugins.ZipFileUnpacker.class, null, dc.getSessionControl(), null, null); 127 numUnpackedFiles=unpacker.unpack(dc, unzippedFilesDirectory,file.getDownloadStream(0), false,null); 128 } 129 else // if space is not enough 130 { 131 throw new BaseException("User do not have the required Disk Space. Please contact your BASE administrator or remove some files"); 132 } 133 dc.commit(); 134 inStream.close(); 135 } 136 catch (Throwable exc) 137 { 138 dc.close(); 139 log.info("File cannot be unpacked", exc); 140 new BaseException(exc.getMessage()); 141 } 142 finally 143 { 144 if (dc!=null) 145 dc.close(); 146 } 147 } 148 132 if(inStream !=null) 133 try 134 { 135 inStream.close(); 136 } 137 catch (IOException e) 138 { 139 e.printStackTrace(); 140 } 141 } 142 } 143 144 149 145 /** 150 146 checks user quota … … 156 152 { 157 153 boolean hasDiskSpace= false; 158 zipFileSize = getZipfileEntriesSize(inStream);159 154 //get the user's current disk usage and quota 160 155 Quota quota = user.getQuota(); … … 164 159 log.info("the quota value of the user: " + user.getName()+ " is: "+quotaValue ); 165 160 long currentDiskUsage = user.getDiskUsage(totalQuotaType, Location.PRIMARY); 166 161 //check whether remaining disk space and zip file size are compatible 167 162 long remainingSpace = quotaValue - currentDiskUsage; 168 163 log.info("the remaining space for user: " + user.getName()+ " is: "+remainingSpace ); … … 176 171 hasDiskSpace=true; 177 172 } 173 log.debug("hasDiskSpace = "+ hasDiskSpace); 178 174 return hasDiskSpace; 179 175 } … … 184 180 @return long - the total size of the zip file uncompressed, in bytes 185 181 186 182 */ 187 183 public static long getZipfileEntriesSize(InputStream fileInputStream) 188 184 { 189 185 long totalSize =0; 190 try 191 { 192 ZipInputStream zipStream = new ZipInputStream(fileInputStream); 193 ZipEntry entry = zipStream.getNextEntry(); 194 while(entry!=null) 195 { 196 long size = entry.getSize(); 197 totalSize += size; 198 entry = zipStream.getNextEntry(); 199 } 200 } 201 catch (IOException ioe) 202 { 203 throw new BaseException("zip file size could not be obtained " + ioe.getMessage()); 204 } 205 return totalSize; 206 } 186 try 187 { 188 ZipInputStream zipStream = new ZipInputStream(fileInputStream); 189 ZipEntry entry = zipStream.getNextEntry(); 190 while(entry!=null) 191 { 192 long size = entry.getSize(); 193 log.debug("checking next zip file entry - size is " + size); 194 totalSize += size; 195 entry = zipStream.getNextEntry(); 196 } 197 } 198 catch (Exception e) 199 { 200 e.printStackTrace(); 201 } 202 return totalSize; 203 } 207 204 /** 208 205 create a sub-directory to contain the unzip files … … 225 222 Directory subDir = d.newSubDirectory(); 226 223 subDir.setName(dirName); 227 224 subDir.setDescription("Unzippped directory created at "+new Date()); 228 225 if (subDir.isInDatabase()) 229 226 { … … 235 232 } 236 233 dc.commit(); 237 234 setUnzippedFilesDirectory(subDir); 238 235 } 239 236 catch (Throwable ex) … … 245 242 if (dc!=null) dc.close(); 246 243 } 247 248 249 244 245 } 246 250 247 /** 251 248 create a sub-directory to contain the unzip files … … 267 264 Directory subDir = d.newSubDirectory(); 268 265 String fileName = zipFile.getName(); 269 270 271 266 String fileNameNoExt = fileName.substring(0, fileName.indexOf(".")); 267 subDir.setName(fileNameNoExt); 268 subDir.setDescription("Unzippped directory created at "+new Date()); 272 269 if (subDir.isInDatabase()) 273 270 { … … 279 276 } 280 277 dc.commit(); 281 278 setUnzippedFilesDirectory(subDir); 282 279 } 283 280 catch (Throwable ex) … … 290 287 if (dc!=null) dc.close(); 291 288 } 292 293 294 289 290 } 291 295 292 void setUnzippedFilesDirectory(Directory unzippedFilesDirectory) 296 293 { 297 294 this.unzippedFilesDirectory = unzippedFilesDirectory; 298 295 } 299 296 300 297 public Directory getUnzippedFilesDirectory() 301 298 { -
plugins/base2/uk.ac.ebi.tab2mage/branches/tab2mageimporter/src/uk/ac/ebi/nugo/plugins/Tab2MageImporter.java
r639 r654 205 205 206 206 String message = null; 207 if (item == null) 208 { 209 message = "The object is null"; 210 211 } 212 else if (!(item instanceof Experiment)) 213 { 214 message = "The object is not an Experiment: " + item; 215 } 216 else 217 { 218 Experiment exp = (Experiment)item; 219 RawDataType rawDataType = exp.getRawDataType(); 220 if (!Tab2MageHelper.supportedPlatforms(rawDataType.getId().toLowerCase())) 221 { 222 message = "This importer only supports Affymetrix, Agilent and Genepix Platforms. Your experiment's platform is :" + rawDataType.getId().toLowerCase(); 223 } 207 try 208 { 209 if (item == null) 210 { 211 message = "The object is null"; 212 213 } 214 else if (!(item instanceof Experiment)) 215 { 216 message = "The object is not an Experiment: " + item; 217 } 218 else 219 { 220 Experiment exp = (Experiment)item; 221 RawDataType rawDataType = exp.getRawDataType(); 222 if (!Tab2MageHelper.supportedPlatforms(rawDataType.getName().toLowerCase())) 223 { 224 message = "This importer only supports Affymetrix, Agilent and Genepix Platforms. Your experiment's platform is :" + rawDataType.getId().toLowerCase(); 225 System.out.println("platform not supported"); 226 } 227 } 228 } 229 catch (Exception e) 230 { 231 e.printStackTrace(); 224 232 } 225 233 return message; … … 417 425 418 426 // validate files supplied to platform 427 System.out.println("raw data type = " + rdt.getName()); 419 428 validPlatform=Tab2MageHelper.validatePlatform(dir, dc, rdt); 420 429 if (!validPlatform) -
plugins/base2/uk.ac.ebi.tab2mage/branches/tab2mageimporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/Tab2MageDataImportFactory.java
r558 r654 109 109 String ext = Helper.getFileExtension(file); 110 110 // check if the file actually contains the extension we approved. 111 if (! ExperimentPlatformsLibrary.fromExtension(ext).getPlatformName().equalsIgnoreCase(platform))112 throw new NutribasePluginException("data file [" + file.getName() + "] do not match platform [" + platform + "] specified");111 if (!platform.endsWith(ExperimentPlatformsLibrary.fromExtension(ext).getPlatformName())) 112 throw new NutribasePluginException("data file [" + file.getName() + "] does not match platform [" + platform + "] specified"); 113 113 this.file = file; 114 114 } … … 122 122 { 123 123 log.info("\n+++ Begin Data Import +++\n"); 124 log.debug("platform = " + platform); 124 125 DbControl dc = null; 125 126 boolean success = true; … … 130 131 checkFile(exampleFile); 131 132 log.debug("file check is successful"); 132 if (platform.e qualsIgnoreCase("affymetrix"))133 if (platform.endsWith("affymetrix")) 133 134 { 134 135 if (dc == null) … … 149 150 dc.commit(); 150 151 } 151 else if (!platform.e qualsIgnoreCase("affymetrix"))// 2. import 2-channel -- include checkpoints and rollback points152 else if (!platform.endsWith("affymetrix"))// 2. import 2-channel -- include checkpoints and rollback points 152 153 { 153 154 log.info(".......beginning [" + platform + "] data loading"); -
plugins/base2/uk.ac.ebi.tab2mage/branches/tab2mageimporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/Tab2MageHybWriter.java
r471 r654 209 209 catch(Throwable tr) 210 210 { 211 tr.printStackTrace(); 211 212 return done=false; 212 213 } -
plugins/base2/uk.ac.ebi.tab2mage/branches/tab2mageimporter/src/uk/ac/ebi/nugo/plugins/util/tab2mage/Tab2MageHelper.java
r558 r654 16 16 import net.sf.basedb.core.RawDataType; 17 17 18 import org.apache.log4j.Logger; 18 19 import org.embl.cg.bloader.models.Tab2MAGEProtocol; 19 20 20 21 import uk.ac.ebi.nugo.common.Helper; 21 22 import uk.ac.ebi.nugo.common.NutribasePluginException; 23 import uk.ac.ebi.nugo.common.ZipUnpacker; 22 24 import uk.ac.ebi.nugo.plugins.tab2mageimport.ExperimentPlatformsLibrary; 23 25 import uk.ac.ebi.nugo.plugins.tab2mageimport.ImageLibrary; 24 26 25 27 /** 26 A plugin utils class for the tab2mage export and export.27 [TODO] This class may be merged to other utils in the main base 2 source code28 @author DominicOyeniran29 30 */31 32 public class Tab2MageHelper 28 * A plugin utils class for the tab2mage export and export. [TODO] This class may be merged to other utils in the main base 2 source code 29 * 30 * @author Dominic Oyeniran 31 * @version 1.0 32 */ 33 34 public class Tab2MageHelper 33 35 { 34 /** 35 validates the raw data file supplied with experment platform i.e the raw data type 36 @param dir, a base2 directory containing the raw files 37 @param dc, database control for database access 38 @param rdt, the raw data type for the experiment. 39 @return validPlatform, true if file is validated and false if not 40 */ 41 public static boolean validatePlatform(Directory dir, DbControl dc, RawDataType rdt) 42 { 43 boolean validPlatform =false; 44 try 45 { 46 Directory directory = Directory.getByPath(dc, dir.getPath()); 47 ItemQuery<File> fileQuery = directory.getFiles(); 48 fileQuery.include(Include.MINE, Include.NOT_REMOVED, Include.IN_PROJECT); 49 if (fileQuery.count(dc)==0) 50 //dir.getSubDirectories(); 51 return validPlatform; 52 ItemResultList<File> fileList = fileQuery.list(dc); 53 System.out.println("The number of files in Dir : " + directory.getPath()+ " is : " +fileList.size()); 54 String agilent= ExperimentPlatformsLibrary.TXT.getPlatformName(); 55 for (File file: fileList) 56 { 57 // get the file extension 36 37 protected static Logger log = Logger.getLogger(Tab2MageHelper.class); 38 39 /** 40 * validates the raw data file supplied with experment platform i.e the raw data type 41 * 42 * @param dir, 43 * a base2 directory containing the raw files 44 * @param dc, 45 * database control for database access 46 * @param rdt, 47 * the raw data type for the experiment. 48 * @return validPlatform, true if file is validated and false if not 49 */ 50 public static boolean validatePlatform(Directory dir, DbControl dc, RawDataType rdt) 51 { 52 boolean validPlatform = false; 53 try 54 { 55 Directory directory = Directory.getByPath(dc, dir.getPath()); 56 ItemQuery<File> fileQuery = directory.getFiles(); 57 fileQuery.include(Include.MINE, Include.NOT_REMOVED, Include.IN_PROJECT); 58 if (fileQuery.count(dc) == 0) 59 { 60 log.debug("no files found - return false"); 61 return validPlatform; 62 } 63 ItemResultList<File> fileList = fileQuery.list(dc); 64 log.debug("The number of files in dir : " + directory.getPath() + " is : " + fileList.size()); 65 String agilent = ExperimentPlatformsLibrary.TXT.getPlatformName(); 66 for (File file : fileList) 67 { 68 // get the file extension 58 69 String ext = Helper.getFileExtension(file); 70 log.debug("ext = " + ext); 59 71 /* 60 We accept all files with .txt cos of the ambiquity caused by agilent raw data file (.txt) format. 61 Tab2mage file also has a .txt extension 62 */ 63 72 * We accept all files with .txt cos of the ambiquity caused by agilent raw data file (.txt) format. Tab2mage file also has a .txt extension 73 */ 74 64 75 if (!ext.equalsIgnoreCase(ExperimentPlatformsLibrary.TXT.getFileExtension())) 65 { 66 //System.out.println("++++ Now checking platform +++++++++++");67 ExperimentPlatformsLibrary platform = ExperimentPlatformsLibrary.fromExtension(ext); 68 if (platform !=null) // platform (raw data files provided) is supported69 { 70 if (platform.getPlatformName().equalsIgnoreCase(rdt.get Id())) //does the files match experiment platform?76 { 77 log.debug("++++ Now checking platform +++++++++++"); 78 ExperimentPlatformsLibrary platform = ExperimentPlatformsLibrary.fromExtension(ext); 79 if (platform != null) // platform (raw data files provided) is supported 80 { 81 if (platform.getPlatformName().equalsIgnoreCase(rdt.getName())) // does the files match experiment platform? 71 82 { 72 validPlatform= true; 83 log.debug("setting validPlatform to true"); 84 validPlatform = true; 73 85 } 74 } else if (platform == null) //raw data files -platforms are not supported. 75 { 76 validPlatform= false; 77 } 78 }else if (ext.equalsIgnoreCase(ExperimentPlatformsLibrary.TXT.getFileExtension()) && agilent.equalsIgnoreCase(rdt.getId()) ) 79 validPlatform= true; 80 } 86 } 87 else 88 if (platform == null) // raw data files -platforms are not supported. 89 { 90 log.debug("platform object is null -- platform not supported"); 91 validPlatform = false; 92 } 93 } 94 else 95 if (ext.equalsIgnoreCase(ExperimentPlatformsLibrary.TXT.getFileExtension()) && agilent.equalsIgnoreCase(rdt.getName())) 96 { 97 log.debug("setting validPlatform to true"); 98 validPlatform = true; 99 } 100 else 101 { 102 log.debug("ignoring this file"); 103 } 104 } 105 log.debug("returning validPlatform = " + validPlatform); 81 106 return validPlatform; 82 } 83 catch (Throwable t) 84 { 85 return false; 86 } 87 } 88 /** 89 validates the image file supplied with experment platform i.e the raw data type 90 @param imageFiles, the list of images. The List<file> must be checked to contain files 91 and not null by the calling method. 92 @param rdt, the raw data type for the experiment. 93 @return valid, true if image file is validated and supported and false otherwise 94 */ 95 public static boolean validateImages(List<File> imageFiles, RawDataType rdt) 96 { 97 boolean valid = false; 98 for (File imageFile : imageFiles) 99 { 100 String ext = Helper.getFileExtension(imageFile); 101 ImageLibrary image = ImageLibrary.fromExtension(ext); 102 if (image == null) 103 { 104 valid= false; 105 } 106 else if (image!=null) 107 { 108 if (image.getSupportedPlatform().equalsIgnoreCase(rdt.getId())) 109 { 110 valid =true; 111 } 112 } 113 } 114 return valid; 115 } 116 /** 117 retrieves all image files 118 @param dir, directory containing the image files 119 @param dc 120 @return list of image files 121 */ 122 public static List<File> getImageFiles(Directory dir, DbControl dc) 123 { 124 List<File> imageFiles = new ArrayList<File>(); 125 try 126 { 127 ItemQuery<File> fileQuery = dir.getFiles(); 128 if (fileQuery.count(dc)==0) 129 return imageFiles; 130 ItemResultList<File> fileList = fileQuery.list(dc); 131 //System.out.println("The number of files in Dir : " + dir.getPath()+ " is : " +fileList.size()); 132 for (File file: fileList) 133 { 134 String ext = Helper.getFileExtension(file); 135 // get all image files: these are files that have a.tiff and.dat extension 136 if ( ext.equals(ImageLibrary.TIFF.getExtension()) || ext.equals(ImageLibrary.DAT.getExtension())) 107 } 108 catch (Throwable t) 109 { 110 t.printStackTrace(); 111 return false; 112 } 113 } 114 115 /** 116 * validates the image file supplied with experment platform i.e the raw data type 117 * 118 * @param imageFiles, 119 * the list of images. The List<file> must be checked to contain files and not null by the calling method. 120 * @param rdt, 121 * the raw data type for the experiment. 122 * @return valid, true if image file is validated and supported and false otherwise 123 */ 124 public static boolean validateImages(List<File> imageFiles, RawDataType rdt) 125 { 126 boolean valid = false; 127 for (File imageFile : imageFiles) 128 { 129 String ext = Helper.getFileExtension(imageFile); 130 ImageLibrary image = ImageLibrary.fromExtension(ext); 131 if (image == null) 132 { 133 valid = false; 134 } 135 else 136 if (image != null) 137 { 138 if (image.getSupportedPlatform().equalsIgnoreCase(rdt.getId())) 139 { 140 valid = true; 141 } 142 } 143 } 144 return valid; 145 } 146 147 /** 148 * retrieves all image files 149 * 150 * @param dir, 151 * directory containing the image files 152 * @param dc 153 * @return list of image files 154 */ 155 public static List<File> getImageFiles(Directory dir, DbControl dc) 156 { 157 List<File> imageFiles = new ArrayList<File>(); 158 try 159 { 160 ItemQuery<File> fileQuery = dir.getFiles(); 161 if (fileQuery.count(dc) == 0) 162 return imageFiles; 163 ItemResultList<File> fileList = fileQuery.list(dc); 164 // System.out.println("The number of files in Dir : " + dir.getPath()+ " is : " +fileList.size()); 165 for (File file : fileList) 166 { 167 String ext = Helper.getFileExtension(file); 168 // get all image files: these are files that have a.tiff and.dat extension 169 if (ext.equals(ImageLibrary.TIFF.getExtension()) || ext.equals(ImageLibrary.DAT.getExtension())) 137 170 { 138 171 imageFiles.add(file); 139 172 } 140 } 141 } 142 catch (Throwable t) 143 { 144 throw new NutribasePluginException(t.getMessage()); 145 } 146 return imageFiles; 147 } 148 /** 149 gets all raw data files 150 @param dir, directory containing the data files 151 @param dc, the db control 152 @param platform, the experiment platform 153 @param tab2mageFileName, the tab2mage file name. 154 @return list of raw data files matching the platform 155 */ 156 public static List<File> getRawDataFiles(Directory dir, DbControl dc, String platform, String tab2mageFileName) 157 { 158 List<File> rawDataFiles = new ArrayList<File>(); 159 try 160 { 161 ItemQuery<File> fileQuery = dir.getFiles(); 162 if (fileQuery.count(dc)==0) 163 return rawDataFiles; 164 ItemResultList<File> fileList = fileQuery.list(dc); 165 for (File file: fileList) 166 { 167 String ext = Helper.getFileExtension(file); 168 // check if the ext is cel gpr or agilent and get the correct file. 169 if (ext.equals(ExperimentPlatformsLibrary.GPR.getFileExtension())) 170 { 171 rawDataFiles.add(file); 172 } 173 else if (ext.equals(ExperimentPlatformsLibrary.TXT.getFileExtension()) && 174 platform.equalsIgnoreCase(ExperimentPlatformsLibrary.fromExtension(ext).getPlatformName())) 175 { 176 if (!file.getName().equalsIgnoreCase(tab2mageFileName)) 177 rawDataFiles.add(file); 178 } 179 else if (ext.equals(ExperimentPlatformsLibrary.CEL.getFileExtension())) 180 { 181 rawDataFiles.add(file); 182 } 183 } 184 } 185 catch (Throwable t) 186 { 173 } 174 } 175 catch (Throwable t) 176 { 187 177 throw new NutribasePluginException(t.getMessage()); 188 } 178 } 179 return imageFiles; 180 } 181 182 /** 183 * gets all raw data files 184 * 185 * @param dir, 186 * directory containing the data files 187 * @param dc, 188 * the db control 189 * @param platform, 190 * the experiment platform 191 * @param tab2mageFileName, 192 * the tab2mage file name. 193 * @return list of raw data files matching the platform 194 */ 195 public static List<File> getRawDataFiles(Directory dir, DbControl dc, String platform, String tab2mageFileName) 196 { 197 List<File> rawDataFiles = new ArrayList<File>(); 198 try 199 { 200 ItemQuery<File> fileQuery = dir.getFiles(); 201 if (fileQuery.count(dc) == 0) 202 return rawDataFiles; 203 ItemResultList<File> fileList = fileQuery.list(dc); 204 for (File file : fileList) 205 { 206 String ext = Helper.getFileExtension(file); 207 // check if the ext is cel gpr or agilent and get the correct file. 208 if (ext.equals(ExperimentPlatformsLibrary.GPR.getFileExtension())) 209 { 210 rawDataFiles.add(file); 211 } 212 else 213 if (ext.equals(ExperimentPlatformsLibrary.TXT.getFileExtension()) && platform.equalsIgnoreCase(ExperimentPlatformsLibrary.fromExtension( 214 ext).getPlatformName())) 215 { 216 if (!file.getName().equalsIgnoreCase(tab2mageFileName)) 217 rawDataFiles.add(file); 218 } 219 else 220 if (ext.equals(ExperimentPlatformsLibrary.CEL.getFileExtension())) 221 { 222 rawDataFiles.add(file); 223 } 224 } 225 } 226 catch (Throwable t) 227 { 228 throw new NutribasePluginException(t.getMessage()); 229 } 189 230 return rawDataFiles; 190 } 191 /** 192 checks if the protocol type in the <code> Tab2MAGEProtocol</code> object exists in BASE 193 @param prot, the Tab2MAGEProtocol object that abstracts the tab2mage protocol section 194 @param dc, the db control 195 @return true if the protocol exist, false if not. 196 */ 197 public static boolean checkIfProtocolTypesExist(Tab2MAGEProtocol prot, DbControl dc) 198 { 199 boolean found = false; 200 List<String> names = new ArrayList<String>(); 201 ItemResultList<ProtocolType> protocolTypes= ProtocolType.getQuery().list(dc); 202 for (ProtocolType protocolType : protocolTypes) 203 { 204 names.add(protocolType.getName().toLowerCase().trim()); 205 } 206 if (names.contains(prot.getType().toLowerCase())) 207 { 208 //System.out.printf("The protocol type:[ %s ] is found in the database\n", prot.getType().toString()); 209 found = true; 210 } 211 return found; 212 } 213 214 /** 215 finds Ta2Mage Accession or Serial in the array Information Map 216 @param arrayInformationMap, the map that contains the tab2mage file array acession and array serial information 217 @param stringToFind, the string to match to a key in the map 218 @return, the value that matches the key : stringToFind 219 */ 220 @SuppressWarnings("unchecked") 221 public static String findTab2MageAccessionOrSerial(HashMap arrayInformationMap, String stringToFind) 222 { 223 String value=""; 231 } 232 233 /** 234 * checks if the protocol type in the <code> Tab2MAGEProtocol</code> object exists in BASE 235 * 236 * @param prot, 237 * the Tab2MAGEProtocol object that abstracts the tab2mage protocol section 238 * @param dc, 239 * the db control 240 * @return true if the protocol exist, false if not. 241 */ 242 public static boolean checkIfProtocolTypesExist(Tab2MAGEProtocol prot, DbControl dc) 243 { 244 boolean found = false; 245 List<String> names = new ArrayList<String>(); 246 ItemResultList<ProtocolType> protocolTypes = ProtocolType.getQuery().list(dc); 247 for (ProtocolType protocolType : protocolTypes) 248 { 249 names.add(protocolType.getName().toLowerCase().trim()); 250 } 251 if (names.contains(prot.getType().toLowerCase())) 252 { 253 // System.out.printf("The protocol type:[ %s ] is found in the database\n", prot.getType().toString()); 254 found = true; 255 } 256 return found; 257 } 258 259 /** 260 * finds Ta2Mage Accession or Serial in the array Information Map 261 * 262 * @param arrayInformationMap, 263 * the map that contains the tab2mage file array acession and array serial information 264 * @param stringToFind, 265 * the string to match to a key in the map 266 * @return, the value that matches the key : stringToFind 267 */ 268 @SuppressWarnings("unchecked") 269 public static String findTab2MageAccessionOrSerial(HashMap arrayInformationMap, String stringToFind) 270 { 271 String value = ""; 224 272 HashMap<String, String> map = new HashMap<String, String>(); 225 map = arrayInformationMap;226 for (Map.Entry<String, String> entry: map.entrySet())227 228 229 230 231 232 273 map = arrayInformationMap; 274 for (Map.Entry<String, String> entry : map.entrySet()) 275 { 276 if (entry.getKey().equalsIgnoreCase(stringToFind)) 277 { 278 value = entry.getValue(); 279 } 280 } 233 281 return value; 234 282 } 235 283 236 284 /** 237 checks that the experiment's raw data type is a supported platforms for thetab2mage importer 238 @param rawDataType. the experiment raw data type type 239 @return True if supported , false otherwise. 285 * checks that the experiment's raw data type is a supported platforms for thetab2mage importer 286 * 287 * @param rawDataType. 288 * the experiment raw data type type 289 * @return True if supported , false otherwise. 240 290 */ 241 291 public static boolean supportedPlatforms(String rawDataType) 242 292 { 243 boolean s = false;244 List<String> p = new ArrayList<String>();245 List<ExperimentPlatformsLibrary> platforms = Arrays.asList(ExperimentPlatformsLibrary.values());293 boolean s = false; 294 List<String> p = new ArrayList<String>(); 295 List<ExperimentPlatformsLibrary> platforms = Arrays.asList(ExperimentPlatformsLibrary.values()); 246 296 for (ExperimentPlatformsLibrary plat : platforms) 247 297 { … … 249 299 } 250 300 if (p.contains(rawDataType.toLowerCase())) 251 s= true;301 s = true; 252 302 253 303 return s; 254 304 } 255 305 256 257 306 }
Note: See TracChangeset
for help on using the changeset viewer.