Changeset 374
- Timestamp:
- Aug 8, 2007, 12:22:46 PM (15 years ago)
- Location:
- trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/AnnotationTypeCvImporter.java
r362 r374 34 34 import net.sf.basedb.util.parser.FlatFileParser; 35 35 import net.sf.basedb.util.parser.Mapper; 36 import uk.ac.ebi.nugo.plugins.util.Values;36 import net.sf.basedb.util.Values; 37 37 38 38 … … 419 419 private ItemResultList<AnnotationTypeCategory> categories; 420 420 private ItemQuery<AnnotationTypeCategory> categoryQuery; 421 private boolean updateExisting, enumeration ,found;421 private boolean updateExisting, enumeration; 422 422 private String separator; 423 423 private int numInserted; -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Tab2MageImporter.java
r362 r374 8 8 import java.io.IOException; 9 9 import java.io.InputStream; 10 import java.net.InetAddress;11 10 import java.util.ArrayList; 12 11 import java.util.Arrays; 13 import java.util.Calendar;14 12 import java.util.Collections; 15 import java.util.Date;16 13 import java.util.List; 17 14 import java.util.Set; … … 19 16 import java.util.zip.ZipInputStream; 20 17 21 import uk.ac.ebi.nugo.plugins.tab2mageimport.io.AnnotationTypesWriter; 22 import uk.ac.ebi.nugo.plugins.tab2mageimport.io.Tab2MageDataImportFactory; 23 import uk.ac.ebi.nugo.plugins.tab2mageimport.io.Tab2MageExperimentWriter; 24 import uk.ac.ebi.nugo.plugins.tab2mageimport.io.Tab2MageWriterFactory; 25 import uk.ac.ebi.nugo.plugins.tab2mageimport.validation.Tab2MageValidationFactory; 26 import uk.ac.ebi.nugo.plugins.tidy.RollBack; 27 import uk.ac.ebi.nugo.plugins.util.NutribasePluginException; 28 import uk.ac.ebi.nugo.plugins.util.Tab2MageHelper; 29 import uk.ac.ebi.nugo.plugins.util.ZipUnpacker; 18 import org.apache.log4j.Logger; 30 19 31 20 import net.sf.basedb.core.BaseException; 32 import net.sf.basedb.core.BooleanParameterType;33 import net.sf.basedb.core.DateParameterType;34 21 import net.sf.basedb.core.DbControl; 35 22 import net.sf.basedb.core.Directory; … … 39 26 import net.sf.basedb.core.Item; 40 27 import net.sf.basedb.core.ItemParameterType; 41 import net.sf.basedb.core.Path;42 import net.sf.basedb.core.PathParameterType;43 28 import net.sf.basedb.core.PluginParameter; 44 29 import net.sf.basedb.core.ProgressReporter; 45 import net.sf.basedb.core.RawBioAssay;46 30 import net.sf.basedb.core.RawDataType; 47 31 import net.sf.basedb.core.RequestInformation; 48 import net.sf.basedb.core.SessionControl;49 32 import net.sf.basedb.core.StringParameterType; 50 33 import net.sf.basedb.core.User; … … 58 41 import net.sf.basedb.core.plugin.Request; 59 42 import net.sf.basedb.core.plugin.Response; 43 import uk.ac.ebi.nugo.plugins.tab2mageimport.io.AnnotationTypesWriter; 44 import uk.ac.ebi.nugo.plugins.tab2mageimport.io.Tab2MageDataImportFactory; 45 import uk.ac.ebi.nugo.plugins.tab2mageimport.io.Tab2MageExperimentWriter; 46 import uk.ac.ebi.nugo.plugins.tab2mageimport.io.Tab2MageWriterFactory; 60 47 import uk.ac.ebi.nugo.plugins.tab2mageimport.mail.Tab2MageEMessaging; 61 import uk.ac.ebi.nugo.plugins.tab2mageimport.ExperimentPlatformsLibrary; 48 import uk.ac.ebi.nugo.plugins.tab2mageimport.validation.Tab2MageValidationFactory; 49 import uk.ac.ebi.nugo.plugins.util.Tab2MageHelper; 50 import uk.ac.ebi.nugo.plugins.util.ZipUnpacker; 62 51 63 52 /** … … 83 72 // the gui email server parameter 84 73 private PluginParameter<String> emailHostParameter; 74 // logger 75 private static Logger log = Logger.getLogger(Tab2MageImporter.class); 85 76 86 77 private static final About about = … … 179 170 { 180 171 response.setError(ex.getMessage(), Arrays.asList(ex)); 181 ex.printStackTrace();182 172 } 183 173 … … 202 192 { 203 193 String message = null; 204 if (context.equals(experimentItemGuiContext)) 205 { 206 if (item == null) 207 { 208 message = "The object is null"; 209 } 210 else if (!(item instanceof Experiment)) 211 { 212 message = "The object is not an Experiment: " + item; 213 } 194 if (item == null) 195 { 196 message = "The object is null"; 197 198 } 199 else if (!(item instanceof Experiment)) 200 { 201 message = "The object is not an Experiment: " + item; 202 } 203 else 204 { 205 Experiment exp = (Experiment)item; 206 RawDataType rawDataType = exp.getRawDataType(); 207 if (!Tab2MageHelper.supportedPlatforms(rawDataType.getId().toLowerCase())) 208 { 209 message="This importer only supports Affymetrix, Agilent and Genepix Platforms. Your experiment's platform is :" + rawDataType.getId().toLowerCase(); 210 } 214 211 } 215 212 return message; … … 250 247 { 251 248 //who is using this plugin 252 //[ DC MESSAGE : dc 1is created ]249 //[ DC MESSAGE : Manager dc is created ] 253 250 dc= sc.newDbControl(); 254 251 User user= User.getById(dc, sc.getLoggedInUserId()); … … 267 264 RawDataType rdt= experiment.getRawDataType(); // experiment platform 268 265 269 boolean supported = Tab2MageHelper.supportedPlatforms(rdt.getId().toLowerCase());270 if (!supported)271 {272 response.setError("IMPORT FAILS: This importer only supports Affymetrix, Agilent and Genepix Platforms" ,Arrays.asList(new Throwable()));273 return;274 }275 266 /* 276 267 create the roll back object here for testing … … 279 270 280 271 /* 281 unzip the files into user directory 282 */ 283 Tab2MageHelper.write("The zipfile name is "+ file.getName()); 284 ZipUnpacker importUnpacker = new ZipUnpacker(file, user, dc); 285 importUnpacker.unpack(); 286 287 // if unzip is sucessfull. (to check this return boolean value, we need to reimplement the util.ZipUnpacker, will affect the affyArrayDesignBatchImporter) 288 289 //[ DC MESSAGE : dc 1 is closed ] 290 291 // check that provided files conform to platform / experiment's platform, exit if not 292 293 // [ DC MESSAGE : dc 2 is created ] 294 272 FILE UNZIP MODULE: unzip the files into user directory 273 */ 274 ZipUnpacker importUnpacker = new ZipUnpacker(file, user, sc); 275 importUnpacker.unpack(); // may change the the util.ZipUnpacker to return a boolean will affect affyArrayDesignBatchImporter too 276 Directory dir= importUnpacker.getUnzippedFilesDirectory(); // this may return the id of the unzipped file directory instead 277 if (dir==null) 278 { 279 response.setError("IMPORT FAILS: The directory containing the unzipped files could not be found. You may NOT have sufficient Disk Space" ,Arrays.asList(new Throwable())); 280 return; 281 } 282 283 // -- end of file unzip module 284 285 /* 286 VALIDATION MODULE 287 */ 288 //[ DC MESSAGE : if the manager dc is no longer available creates a new one. It should be] 295 289 if (dc == null || !dc.isConnected()) dc = sc.newDbControl(); 296 Directory dir= importUnpacker.getUnzippedFilesDirectory(); // this may return the id of the unzipped file direcotyr instead 297 if (dir==null) 298 { 299 response.setError("IMPORT FAILS: The directory containing the unzipped files could not be found. You may NOT have sufficient Disk Space" ,Arrays.asList(new Throwable())); 300 return; 301 } 302 303 Tab2MageHelper.write("The directory containing the unzippped files is: "+ dir.getPath()); 304 290 291 // validate files supplied to platform 305 292 validPlatform=Tab2MageHelper.validatePlatform(dir, dc, rdt); 306 293 if (!validPlatform) … … 310 297 } 311 298 312 // validate image file299 // validate image file 313 300 List<File> imageFiles=Tab2MageHelper.getImageFiles(dir, dc) ; 314 if (imageFiles.isEmpty() || imageFiles!=null) Tab2MageHelper.write("No image file supplied"); // remove or log this later message315 316 301 if (!imageFiles.isEmpty()|| imageFiles==null) 317 302 { … … 324 309 } 325 310 326 // validate the tab2mage file (do initialisation here too)327 Tab2MageValidationFactory validator = new Tab2MageValidationFactory(tab2MageFileName, dc, dir, rdt.getId());311 // validate the tab2mage file (do initialisation here too) 312 Tab2MageValidationFactory validator = new Tab2MageValidationFactory(tab2MageFileName, sc, dir, rdt.getId()); 328 313 validTab2mageFile=validator.getValidated(); 329 314 if (!validTab2mageFile) … … 332 317 return; 333 318 } 334 335 // [ DC MESSAGE : dc 2 is closed ] 336 337 // Do import() of the tab2mage file. 338 339 // Call and initiate the roll back routines 340 341 //create annotation types 319 // -- end of validation module 320 321 /* 322 TAB2MAGE FILE IMPORT MODULE. 323 */ 324 // create annotation types 342 325 AnnotationTypesWriter atWriter= new AnnotationTypesWriter (sc, validator.getAtFile(),progress); 343 326 boolean writtenAT =atWriter.write(); // note if this action failed the transaction is completely rolled back … … 348 331 } 349 332 /* 350 A new db control object necessary here to help with roll back351 */ 352 // write protocols and hybs333 A new db control object may be necessary here to help with roll back 334 */ 335 // write protocols and hybs 353 336 Tab2MageWriterFactory hibernateItemsWriter = new Tab2MageWriterFactory 354 337 (sc,Tab2MageValidationFactory.getCatchedProtocol(), 355 Tab2MageValidationFactory.getCatchedHybs(),rdt ); 356 357 // [ DC MESSAGE : dc 3 is created ] 358 if (dc == null || !dc.isConnected()|| dc.isClosed()) dc = sc.newDbControl(); 359 360 // get raw data file before closing dc is closed 361 List<File> rawDataFiles= Tab2MageHelper.getRawDataFiles(dir, dc, rdt.getId(), tab2MageFileName); 362 363 //NOTE: THIS IS ANOTHER DB TRANSACTION 364 // if the protocol type is not found, write it into the database. 365 // alternative is to fail at validation instead of a warning, if the protocol type 366 // provided in tab2mage file is not in Base2 database. May may have to rework this. 367 hibernateItemsWriter.writeProtocolTypes(dc); // dc is closed here 368 369 // dc 3 is closed 338 Tab2MageValidationFactory.getCatchedHybs(),rdt, 339 Tab2MageValidationFactory.getSampleExtractMap(), 340 Tab2MageValidationFactory.getBioSourceSampleMap(), 341 Tab2MageValidationFactory.getExtractLabeledExtractMap()); 342 343 // if the protocol type is not found, write it into the database. 344 // alternative is to fail at validation instead of a warning, if the protocol type 345 // provided in tab2mage file is not in Base2 database. May may have to rework this. 346 347 hibernateItemsWriter.writeProtocolTypes(sc); 370 348 371 349 boolean writtenHibItems = hibernateItemsWriter.write(); … … 375 353 return; 376 354 } 377 for(String fact : hibernateItemsWriter.getExpFactors()) 378 { 379 Tab2MageHelper.write("\nThe factor values obtained : "+ fact); 380 //TODO need to clear the memory holding expfactor 381 } 382 /* 383 Do Data Import 384 A new db control object necessary here to help with roll back 385 */ 386 355 356 // -- end of Tab2Mage file import module 357 358 /* 359 RAW DATA IMPORT MODULE 360 361 */ 362 //[ DC MESSAGE : if the manager dc is no longer available creates a new one. It should be] 363 if (dc == null || !dc.isConnected()|| dc.isClosed()) dc = sc.newDbControl(); 364 365 // get raw data files 366 List<File> rawDataFiles= Tab2MageHelper.getRawDataFiles(dir, dc, rdt.getId(), tab2MageFileName); 367 368 // do data import 387 369 Tab2MageDataImportFactory dataImport = new Tab2MageDataImportFactory(sc,rdt.getId(),rawDataFiles, 388 370 hibernateItemsWriter.getRbas(), progress); … … 393 375 return; 394 376 } 395 396 /* 397 Configure and load the experiment 398 A new dc is created here for another roll back point. 377 // -- end of raw data import module 378 379 /* 380 EXPERIMENT CONFIGURATION AND LOADING MODULE 381 399 382 */ 383 //write experiment, attaching raw bio-assays 400 384 Tab2MageExperimentWriter expWriter= new Tab2MageExperimentWriter(hibernateItemsWriter.getRbas(),sc, 401 385 experiment,hibernateItemsWriter.getExpFactors(), 402 386 validator.getTExperiment()); 403 387 boolean writtenExp= expWriter.LoadExperiment(); 404 // send an email to the user on the success of the experiment (if email server name and email address are provided) 405 if (hostName!="" && hostName.length()>=5) 406 { 407 if (user.getEmail()!="" && user.getEmail()!=null ) 388 // -- end of experiment configuration and loading module 389 390 /* 391 MESSAGING MODULE 392 */ 393 // send an email to the user on the success of the experiment (if email server name and email address are provided) 394 if (hostName!= null && hostName.length()>=5) 395 { 396 if (!user.getEmail().equals("") && user.getEmail()!=null ) 408 397 { 409 398 Tab2MageEMessaging message= new Tab2MageEMessaging(writtenExp,"", user.getEmail(),tab2MageFileName, user.getName(), experiment.getName(),hostName ); … … 411 400 } 412 401 } 413 414 // release object from memory and do clean up. 415 if (!dir.isRemoved()) dir.setRemoved(true); 402 // -- end of messaging module 403 416 404 response.setDone("Import plugin ended successfully"); 417 405 } … … 419 407 { 420 408 response.setError(tr.getMessage(), Arrays.asList(tr)); 421 tr.printStackTrace(); 422 } 409 } 423 410 finally 424 411 { … … 448 435 catch (Exception e) 449 436 { 450 Tab2MageHelper.write("File is not a zip file and cannot be imported by this plugin."); 451 e.printStackTrace(); 437 log.error("File is not a zip file and cannot be imported by this plugin."); 452 438 return false; 453 439 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/AnnotationTypeFileWriter.java
r362 r374 47 47 catch(Throwable t ) 48 48 { 49 t .printStackTrace();49 throw new NutribasePluginException(t.getMessage()); 50 50 } 51 51 } … … 78 78 catch (IOException ioe) 79 79 { 80 ioe.printStackTrace();81 80 throw new NutribasePluginException(ioe.getMessage()); 82 81 } … … 95 94 if (at==null) 96 95 { 97 System.out.println("\nAT is null\n");98 96 return; 99 97 } … … 115 113 catch (IOException ioe) 116 114 { 117 ioe.printStackTrace();118 115 throw new NutribasePluginException(ioe.getMessage()); 119 116 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/AnnotationTypesWriter.java
r362 r374 69 69 public AnnotationTypesWriter(SessionControl sc, File expFile, ProgressReporter progress) 70 70 { 71 System.out.println("Annotation Type Writer Object Created");72 71 this.sc= sc; 73 72 this.exampleFile= expFile; … … 88 87 return written=false; 89 88 } 90 System.out.println("PluginConfiguration importConfig = " + importConfig);89 log.info("PluginConfiguration importConfig = " + importConfig); 91 90 Job job = null; 92 91 93 92 SimpleProgressReporter spr = new SimpleProgressReporter(progress); 94 93 if (dc ==null) dc = sc.newDbControl(); 95 System.out.println("+++Begin to execute job+++");94 log.info("+++Begin to execute job+++"); 96 95 importConfig = PluginConfiguration.getById(dc, importConfig.getId()); 97 96 job = Job.getNew(dc, importConfig.getPluginDefinition(), importConfig); … … 111 110 { 112 111 written= false; 113 e.printStackTrace();112 log.error(e.getMessage()); 114 113 } 115 114 116 System.out.println("Executing job: " + job.getName());115 log.info("Executing job: " + job.getName()); 117 116 118 117 PluginExecutionRequest request = job.execute(spr, localhost); … … 128 127 throw new BaseException(response.getMessage(), response.getErrorList().get(0)); 129 128 } 130 System.out.println("Job ended successfully: " + response.getMessage());129 log.info("Job ended successfully: " + response.getMessage()); 131 130 return written; 132 131 } … … 134 133 { 135 134 dc.close(); 136 e.printStackTrace();135 log.error(e.getMessage()); 137 136 return false; 138 //throw new Exception(e);139 137 } 140 138 finally -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/Base2Tab2MageFileReader.java
r362 r374 332 332 } 333 333 334 private void createAnnotationTypeFile() throws TAB2MAGEException335 {336 String filename= "anntype.txt";337 try338 {339 // create a file named: anntype.txt into the subdirectory (temp) created above340 atFile = File.getFile(dc, subDir, filename, true);341 atFile.setMimeType(file.getMimeType());342 if (file.getFileType()!=null)343 {344 atFile.setFileType(file.getFileType());345 }346 // if the new file exist in the database,347 if (atFile.isInDatabase())348 {349 throw new ItemAlreadyExistsException("Another file with the same name already exists");350 351 }352 else // save the file to the database.353 {354 dc.saveItem(atFile);355 }356 }357 catch (Throwable e)358 {359 log.error("Error: " + e.getMessage());360 throw new TAB2MAGEException(e.getMessage());361 }362 }363 364 334 private void createExperimentFile() throws TAB2MAGEException 365 335 { … … 697 667 { 698 668 protocol.set( key, rowValues.get(j) ); 699 //System.out.println("This protocol row value thing is : "+rowValues.get(j).toString());700 669 } 701 670 catch(IndexOutOfBoundsException e) 702 671 { 703 672 protocol.set( key, "" ); 704 //System.out.println("This protocol row value thing is null and changed to empty string");705 673 } 706 674 continue cont; -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/RawDataImport.java
r362 r374 26 26 27 27 import org.apache.log4j.Logger; 28 29 import uk.ac.ebi.nugo.plugins.util.Tab2MageHelper;30 28 /** 31 29 This class writes raw data for multi - channel experiments. … … 89 87 public boolean importRawData() throws Exception 90 88 { 91 System.out.println("++++ Importing raw data from file: " + file.getName()); 92 //DbControl dc =null; 93 boolean written = true; 89 log.info("++++ Importing raw data from file: " + file.getName()); 90 boolean written = true; 94 91 try 95 92 { 96 93 Job job = null; 97 94 SimpleProgressReporter spr = new SimpleProgressReporter(progress); 98 Tab2MageHelper.write("+++Begin to execute job+++");95 log.info("+++Begin to execute job+++"); 99 96 importConfig = PluginConfiguration.getById(dc, importConfig.getId()); 100 97 job = Job.getNew(dc, importConfig.getPluginDefinition(), importConfig); … … 120 117 { 121 118 written= false; 122 e.printStackTrace();119 log.error(e.getMessage()); 123 120 } 124 121 125 Tab2MageHelper.write("Executing job: " + job.getName());122 log.info("Executing job: " + job.getName()); 126 123 127 124 PluginExecutionRequest request = job.execute(spr, localhost); … … 137 134 throw new BaseException(response.getMessage(), response.getErrorList().get(0)); 138 135 } 139 System.out.println("Job ended successfully: " + response.getMessage());136 log.info("Job ended successfully: " + response.getMessage()); 140 137 return written; 141 138 } … … 144 141 dc.close(); 145 142 log.error("The raw data plugin could not load raw data"); 146 e.printStackTrace();147 143 return false; 148 144 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/Tab2MageDataImportFactory.java
r362 r374 109 109 this.file =file; 110 110 } 111 //System.out.println("++Raw Data File already set is : "+ file.getName());111 log.info("++Raw Data File already set is : "+ file.getName()); 112 112 } 113 113 … … 119 119 public boolean importData() 120 120 { 121 Tab2MageHelper.write("\n++++Begin Data Import\n");121 log.info("\n++++Begin Data Import\n"); 122 122 DbControl dc =null; 123 123 boolean success= true; … … 127 127 // :) extra validation is good for all 128 128 checkFiles(); 129 //System.out.println("file check is successful");130 129 if (platform.equalsIgnoreCase("affymetrix")) 131 130 { 132 131 if (dc ==null) 133 132 dc = sc.newDbControl(); 134 //System.out.println("adding cel files to raw bioassays");133 log.info("adding cel files to raw bioassays"); 135 134 for (RawBioAssay rbas :rawBioAssays ) 136 135 { … … 140 139 if (file!=null) 141 140 { 142 Tab2MageHelper.write("The file is: " + file.getName() );143 141 // need to attach the cel file to the bioassay object 144 142 Affymetrix.setCelFile(rba, file); … … 149 147 else if (!platform.equalsIgnoreCase("affymetrix"))// 2. import 2-channel -- include checkpoints and rollback points 150 148 { 151 Tab2MageHelper.write(".......beginning ["+platform + "] data loading");149 log.info(".......beginning ["+platform + "] data loading"); 152 150 if (dc ==null) 153 151 dc = sc.newDbControl(); … … 167 165 dc = sc.newDbControl(); 168 166 RawBioAssay rba = RawBioAssay.getById(dc,rbas.getId()); 169 //System.out.println("rba = " + rba.getName());167 170 168 // get the file using file name. the file name is the raw bioassay name 171 169 File file = getFile(rba.getName(), dc); 172 170 if (file!=null) 173 171 { 174 Tab2MageHelper.write("The name of the import configuration being used: "+ importConfig.getName());172 log.info("The name of the import configuration being used: "+ importConfig.getName()); 175 173 RawDataImport rawDataImport = new RawDataImport(dc, importConfig, progress, file, rba); 176 174 boolean writtenRawData = rawDataImport.importRawData(); // Problem: closes the db control … … 184 182 { 185 183 success= false; 186 t.printStackTrace();187 184 log.error("DataImport: writing raw data failed"); 188 185 dc.close(); -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/Tab2MageExperimentWriter.java
r362 r374 19 19 import org.embl.cg.bloader.models.Tab2MAGEExperiment; 20 20 21 import uk.ac.ebi.nugo.plugins.util. Tab2MageHelper;21 import uk.ac.ebi.nugo.plugins.util.ValueFormatter; 22 22 /** 23 23 This class writes an experiment into the BASE 2 / Nutribase Database … … 86 86 { 87 87 //write experiment 88 Tab2MageHelper.write("Loading experiment " + experiment);88 log.info("Loading experiment " + experiment); 89 89 int expID = experiment.getId(); 90 90 Experiment exp = Experiment.getById(dc, expID); … … 93 93 { 94 94 rba = RawBioAssay.getById(dc, rba.getId()); 95 Tab2MageHelper.write("adding raw bioassay to experiment : " + rba);95 log.info("adding raw bioassay to experiment : " + rba); 96 96 exp.addRawBioAssay(rba); 97 97 } … … 101 101 AnnotationType at= getAnnotationTypeByName(factor); 102 102 ats.add(at); 103 //Tab2MageHelper.write("The expr factor to add is : "+ at.toString());104 103 } 105 104 if (!ats.isEmpty()) … … 122 121 exp.setPublication(publication); 123 122 exp.setPublicationDate(Values.getDate(tab2mageExperiment.getPublication_date())); 124 //Tab2MageHelper.write("The pub med id is : "+ Values.getEmptyStringIfNull(tab2mageExperiment.getPubmed_id())); 125 exp.setPubMedId((String)Values.getEmptyStringIfNull(tab2mageExperiment.getPubmed_id())); 123 exp.setPubMedId((String)ValueFormatter.getEmptyStringIfNull(tab2mageExperiment.getPubmed_id())); 126 124 exp.setTitle(tab2mageExperiment.getPublication_title()); 127 125 dc.commit(); … … 129 127 catch (Exception e) 130 128 { 131 e.printStackTrace();132 129 done= false; 133 130 dc.close(); // rollback if any problem arises … … 144 141 } 145 142 146 //remove getAnnotationType and use the common one in the Tab2MageHelper class.147 143 148 144 /** -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/Tab2MageHybWriter.java
r362 r374 36 36 import net.sf.basedb.core.Scan; 37 37 import net.sf.basedb.core.Type; 38 38 import net.sf.basedb.core.BioMaterial; 39 39 40 40 import org.apache.log4j.Logger; … … 109 109 { 110 110 boolean done = true; 111 Tab2MageHelper.write("\n++++ Writing Hybridizations ++++\n");111 log.info ("\n++++ Writing Hybridizations ++++\n"); 112 112 // declare protocols and parameter temporary catche 113 113 Map<String, String> protocolCatche = new HashMap<String, String>(); … … 129 129 for (Tab2MAGEHybridization hyb : hybs) 130 130 { 131 Tab2MageHelper.write("\n------Handling Hybridization :" + hyb.getName()+"------\n");131 log.info("\n------Handling Hybridization :" + hyb.getName()+"------\n"); 132 132 List<LabeledExtract> labeledExtracts = new ArrayList<LabeledExtract>(); 133 133 i++; … … 163 163 for (Map.Entry<String, String> fact : factorMap.entrySet()) 164 164 { 165 //System.out.println(" Factor Value is " + fact.getKey()+ ":" +fact.getValue());166 165 expFactors.add(fact.getKey()); 167 166 } … … 191 190 return done=false; 192 191 } 193 //System.out.println("The array Design is : " + arrayDesign.getName());194 192 dc.reattachItem(arrayDesign); 195 193 … … 205 203 206 204 //write Scan 207 Scan scan = createScan( hyb.getScanner(),newHyb, parameterCatche, protocolCatche);205 Scan scan = createScan( newHyb, parameterCatche, protocolCatche); 208 206 209 207 //write Raw Bio Assay 210 208 RawBioAssay rba = createRawBioAssay(hyb.getFileRaw(), rdt, scan, arrayDesign, parameterCatche, protocolCatche, factorValueCatche); 211 209 rbaCatche.add(rba); 212 //System.out.println("Raw Bio Assay"+ rba.getName()+ "is added to catch");210 213 211 }// end of each Hyb 214 212 } 215 213 catch(Throwable tr) 216 214 { 217 tr.printStackTrace();215 log.warn(tr.getMessage()); 218 216 return done=false; 219 217 } … … 242 240 { 243 241 BioSource bio; 244 Tab2MageHelper.write("--Creating biosource: " + name + "\n");242 log.info("--Creating biosource: " + name + "\n"); 245 243 if (!bioSources.isEmpty() && bioSources.containsKey(name)) 246 244 { 247 245 bio= (BioSource)bioSources.get(name); 248 System.out.println("--The biosource obtained is :" + bio.getName());249 246 } 250 247 else … … 260 257 { 261 258 log.warn("Annotation for BioMaterial Characteristics cannot be set. Check the allowed values for the annotation type"); 262 //roll back done in the write method263 259 } 264 260 dc.saveItem(bio); 265 261 bioSources.put(bio.getName(),bio); 266 System.out.println("--The biosource created is :" + bio.getName());262 log.info("--The biosource created is :" + bio.getName()); 267 263 } 268 264 return bio; … … 281 277 { 282 278 Sample sample; 283 Tab2MageHelper.write("--Creating sample: " + name + "\n");279 log.info("--Creating sample: " + name + "\n"); 284 280 if (!samples.isEmpty() && samples.containsKey(name)) 285 281 { 286 282 sample= (Sample)samples.get(name); 287 Tab2MageHelper.write("--The sample obtained is :" + sample.getName());283 log.info("--The sample obtained is :" + sample.getName()); 288 284 } 289 285 else … … 307 303 { 308 304 log.warn("Annotation for Sampling Protocol cannot be set. Check the allowed values for the annotation type"); 309 //roll back done in the write method310 305 } 311 306 … … 313 308 dc.saveItem(sample); 314 309 samples.put(sample.getName(),sample); 315 Tab2MageHelper.write("--The sample created is :" + sample.getName()+"\n");310 log.info("--The sample created is :" + sample.getName()+"\n"); 316 311 } 317 312 return sample; … … 328 323 private Extract createExtract(String name,Sample sample, Map<String, BasicItem> extracts, Map<String, String> param, Map<String, String> protMap ) 329 324 { 330 Tab2MageHelper.write("--Creating extract: " + name + "\n");325 log.info("--Creating extract: " + name + "\n"); 331 326 Extract extract; 332 327 if (!extracts.isEmpty() && extracts.containsKey(name)) 333 328 { 334 329 extract= (Extract)extracts.get(name); 335 Tab2MageHelper.write("--The extract obtained is :" + extract.getName());330 log.info("--The extract obtained is :" + extract.getName()); 336 331 } 337 332 else … … 352 347 { 353 348 log.warn("Annotation for Extraction Protocol cannot be set.Check the allowed values for the annotation type"); 354 //roll back done in the write method355 349 } 356 350 // add the extract annotations for MAG- TAB sample characteristics 357 351 dc.saveItem(extract); 358 352 extracts.put(extract.getName(),extract); 359 Tab2MageHelper.write("--The extract created is :" + extract.getName()+"\n");353 log.info("--The extract created is :" + extract.getName()+"\n"); 360 354 } 361 355 return extract; … … 374 368 private LabeledExtract createLabeledExtract(String name, String dye, Label lb, Extract extract, Map<String, BasicItem> lExtracts, Map<String, String> param, Map<String, String> protMap) 375 369 { 376 Tab2MageHelper.write("--Creating labeled extract: " + name + "\n");370 log.info("--Creating labeled extract: " + name + "\n"); 377 371 LabeledExtract lextract; 378 372 if (!lExtracts.isEmpty() && lExtracts.containsKey(name)) 379 373 { 380 374 lextract= (LabeledExtract)lExtracts.get(name); 381 Tab2MageHelper.write("--The extract obtained is :" + extract.getName());375 log.info("--The extract obtained is :" + extract.getName()); 382 376 } 383 377 else … … 397 391 { 398 392 log.warn("Annotation for Labeling Protocol cannot be set. Check the allowed values for the annotation type"); 399 //roll back done in the write method400 393 } 401 394 // add the labeled extract annotations for MAG- TAB sample characteristics 402 395 dc.saveItem(lextract); 403 396 lExtracts.put(lextract.getName(),lextract); 404 Tab2MageHelper.write("--The labeled extract created is :" + lextract.getName()+"\n");397 log.info("--The labeled extract created is :" + lextract.getName()+"\n"); 405 398 } 406 399 return lextract; … … 418 411 Map<String, String> parCatche, Map<String,String> proCatche ) 419 412 { 420 Tab2MageHelper.write("--Creating hybridization: " + name + "\n"); 421 // used dc.commitif labelled extract is saved. 413 log.info("--Creating hybridization: " + name + "\n"); 422 414 Hybridization newHyb = Hybridization.getNew(dc); 423 415 newHyb.setName(name); … … 430 422 } 431 423 String accessionNo = getProtocolAccesion(proCatche,"hybridization"); // 432 // temp comment this out and test......433 //BioMaterialEvent newHybEvent=newHyb.getCreationEvent();434 424 bioMaterialEvent.setProtocol(getProtocol(accessionNo)); 435 425 // add the annotation for protocol parameters … … 441 431 { 442 432 log.warn("Annotation for Hybridization Protocol cannot be set. Check that"); 443 //roll back done in the write method444 433 } 445 434 dc.saveItem(newHyb); 446 Tab2MageHelper.write("--The Hybridization created is :" + newHyb.getName()+"\n");435 log.info("--The Hybridization created is :" + newHyb.getName()+"\n"); 447 436 return newHyb; 448 437 } … … 455 444 @return 456 445 */ 457 private Scan createScan(String name, Hybridization hyb, Map<String, String> parCatche, Map<String, String> proCatche) 458 { 459 //Scan scan= hyb.newScan(); 460 Tab2MageHelper.write("--Creating scan: " + name + "\n"); 446 private Scan createScan(Hybridization hyb, Map<String, String> parCatche, Map<String, String> proCatche) 447 { 448 log.info("--Creating scan: " +hyb.getName()+ "\n"); 461 449 Scan scan = Scan.getNew(dc, hyb); 462 if (name!="" && name!= null) 463 scan.setName(name); 464 else 465 scan.setName("scan"+hyb.getName()); //to make scan unique per Hyb add hyb name to the scan name 450 scan.setName("scan"+hyb.getName()); //to make scan unique per Hyb add hyb name to the scan name 466 451 String accessionNo = getProtocolAccesion(proCatche,"scanning"); // 467 452 scan.setProtocol(getProtocol(accessionNo)); … … 474 459 { 475 460 log.warn("Annotation for Scanning Protocol cannot be set. Check that"); 476 //roll back done in the write method477 461 } 478 462 dc.saveItem(scan); 479 Tab2MageHelper.write("--The scan created is :" + scan.getName()+"\n");463 log.info("--The scan created is :" + scan.getName()+"\n"); 480 464 return scan; 481 465 } … … 494 478 Map<String,String> parCatche, Map<String,String> protCatche, Map<String, String>factCatche) 495 479 { 496 Tab2MageHelper.write("--Creating raw bioassay: " + name +"\n");480 log.info("--Creating raw bioassay: " + name +"\n"); 497 481 RawBioAssay rba = RawBioAssay.getNew(dc, rawDataType); 498 482 rba.setName(name); … … 510 494 { 511 495 log.warn("Annotation for Feature Extraction Protocol cannot be set. Check the allowed values for the annotation type"); 512 //roll back done in the write method513 496 } 514 497 // add the raw bioassay annotations for implementing factor value annotation. 515 498 // This is a work around, avoiding the inherited annotation problem: i.e items to inherit factor value 516 // from are not available in tab2mage file neither sithere an association.499 // from are not available in tab2mage file neither is there an association. 517 500 518 //Tab2MageHelper.write(" \n+++++++ Checking out the Content of the Factor Vaue Map +++++\n");519 //for (Map.Entry<String, String> fact : factorValueCatche.entrySet())520 //{521 // Tab2MageHelper.write(" Factor Val is " + fact.getKey()+ ":" +fact.getValue());522 //}523 501 try 524 502 { … … 531 509 } 532 510 dc.saveItem(rba); 533 Tab2MageHelper.write("--The raw bio assay created is :" + rba.getName()+"\n");511 log.info("--The raw bio assay created is :" + rba.getName()+"\n"); 534 512 return rba; 535 513 } … … 549 527 as.setName(arrayDesign.getName()+ "-Slide#" +i); 550 528 dc.saveItem(as); 551 //Tab2MageHelper.write("The new array slide is :" + as.getName());529 log.info("The new array slide is :" + as.getName()); 552 530 } 553 531 return as; … … 580 558 private String getProtocolAccesion(Map<String, String> protMap, String type) 581 559 { 582 //Tab2MageHelper.write(" \n+++++++ Checking out the Hyb Protocols +++++\n");583 560 String accession=""; 584 561 for (Map.Entry<String, String> prot: protMap.entrySet()) 585 562 { 586 //Tab2MageHelper.write(" Hyb Protocol is " + prot.getKey()+ ":" +prot.getValue());587 563 if (prot.getKey().equals(type.toUpperCase())) 588 564 { … … 599 575 private Protocol getProtocol(String protocolAccesion) 600 576 { 601 //Tab2MageHelper.write(" \n+++++++ Getting Protocols +++++\n");602 577 Protocol protocol=null; 603 578 for (Map.Entry<String, Protocol> prot: protocolAccessionMap.entrySet()) 604 579 { 605 //Tab2MageHelper.write(" Protocol Accession Map is: " + prot.getKey()+ ":" +prot.getValue());606 580 if (prot.getKey().equalsIgnoreCase(protocolAccesion)) 607 581 { … … 637 611 for (Map.Entry<AnnotationType, String> annt : annotationTypes.entrySet()) 638 612 { 639 //Tab2MageHelper.write("Annotation type - Value mapping is " + annt.getKey().toString()+ ":" +annt.getValue());640 641 // remove annotations if the annotatable item has annotations already642 // this is because, we consider the annotatable item as a new item that643 // should not reference an already existing annotation of an item with644 //the same name, even if the item has been deleted.645 //if (annotatable.isAnnotated()) annotatable.removeAnnotations();646 613 if (annotatable instanceof RawBioAssay) 647 614 { 648 //Tab2MageHelper.write("YES, IT IS AN INSTANCE OF RAWBIOASSAY");649 615 AnnotationType t = annt.getKey(); 650 616 if (t.isEnabledForItem(Item.RAWBIOASSAY)) // if the annotation type is enable for raw bioassay item, set annotations … … 652 618 AnnotationSet as = annotatable.getAnnotationSet(); 653 619 String values= annt.getValue(); 654 Tab2MageHelper.write("Inserting: "+ annt.getValue()+" annotation for: "+ annotatable.toString());620 log.info("Inserting: "+ annt.getValue()+" annotation for: "+ annotatable.toString()); 655 621 656 622 if (t.getValueType().equals(Type.FLOAT)) 657 623 { 658 Tab2MageHelper.write("YES, the annotation value type is float");659 624 Float v = new Float(Float.parseFloat(values)); 660 625 as.getAnnotation(annt.getKey()).setValue(v); … … 671 636 { 672 637 AnnotationSet as = annotatable.getAnnotationSet(); 673 // Tab2MageHelper.write("Inserting: "+ annt.getValue()+" annotation for: "+ annotatable.toString());638 //log.info("Inserting: "+ annt.getValue()+" annotation for: "+ annotatable.toString()); 674 639 as.getAnnotation(annt.getKey()).setValue(annt.getValue()); 675 640 } … … 689 654 for (Map.Entry<String, String> an : annotationMap.entrySet()) 690 655 { 691 //Tab2MageHelper.write(" Annotation type [BioMat,Param] Value is " + an.getKey()+ ":" +an.getValue());692 656 AnnotationType at =Tab2MageHelper.getAnnotationTypeByName(an.getKey(),dc); 693 657 if (at!=null) … … 705 669 { 706 670 AnnotationSet as = annotatable.getAnnotationSet(); 707 //Tab2MageHelper.write("Inserting: "+ anv.getValue()+" annotation for: "+ annotatable.toString());671 log.info("Inserting: "+ anv.getValue()+" annotation for: "+ annotatable.toString()); 708 672 as.getAnnotation(anv.getKey()).setValue(anv.getValue()); 709 673 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/Tab2MageProtocolWriter.java
r362 r374 65 65 { 66 66 boolean exist= checkIfProtocolExist(protocol, dc); 67 Tab2MageHelper.write(exist? "Protocol Exist " : "Protocol DoNot Exist");67 log.info(exist? "Protocol Exist " : "Protocol DoNot Exist"); 68 68 if (!exist) // if protocol is not found in the protocol table in BASE 2 69 69 { … … 84 84 for (String res : result) 85 85 { 86 Tab2MageHelper.write("The protocol parameter to convert to annotation type is : "+ res);86 log.info("The protocol parameter to convert to annotation type is : "+ res); 87 87 AnnotationType annotationType= getAnnotationTypeFromProtocolParameter(res.trim(), dc); 88 88 try … … 91 91 { 92 92 newProtocol.addParameter(annotationType); 93 System.out.printf("The annotation type: %s is added to protocol\n", annotationType.getName());94 93 } 95 94 } … … 104 103 105 104 dc.saveItem(newProtocol); 106 Tab2MageHelper.write("The protocol name to write is : " + newProtocol.getName());105 log.info("The protocol name to write is : " + newProtocol.getName()); 107 106 } 108 107 } … … 134 133 if (names.contains(prot.getName().toLowerCase())) 135 134 { 136 System.out.printf("The protocol: %s is found in the database\n", prot.getName().toString());137 135 found = true; 138 136 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/io/Tab2MageWriterFactory.java
r362 r374 21 21 import net.sf.basedb.core.ArraySlide; 22 22 import net.sf.basedb.core.BasicItem; 23 import net.sf.basedb.core.BioMaterial; 23 24 import net.sf.basedb.core.BioMaterialEvent; 24 25 import net.sf.basedb.core.BioSource; … … 33 34 import net.sf.basedb.core.Label; 34 35 import net.sf.basedb.core.LabeledExtract; 36 import net.sf.basedb.core.MeasuredBioMaterial; 35 37 import net.sf.basedb.core.Protocol; 36 38 import net.sf.basedb.core.ProtocolType; … … 47 49 import org.embl.cg.bloader.models.Tab2MAGEProtocol; 48 50 51 import uk.ac.ebi.nugo.plugins.tab2mageimport.validation.Tab2MageValidationFactory; 49 52 import uk.ac.ebi.nugo.plugins.util.NutribasePluginException; 50 53 import uk.ac.ebi.nugo.plugins.util.Tab2MageHelper; … … 96 99 private Set<String> expFactors= new HashSet<String>(); 97 100 /** 98 List of protocol object for experiment. 99 */ 100 //private List<Protocol> usedProtocols = new ArrayList<Protocol>(); 101 Map of pooled sample -to- extract. 102 */ 103 private Map<String, List<String>> sampleExtMap = new HashMap<String, List<String>>(); 104 105 /** 106 Map of pooled biosource -to- sample. 107 */ 108 private Map<String, List<String>> bioSourceSamMap = new HashMap<String, List<String>>(); 109 110 /** 111 Map of pooled extract -to- labeled extract. 112 */ 113 private Map<String, List<String>> extractLEMap = new HashMap<String, List<String>>(); 101 114 /** 102 115 creates a new tab2mage writer factory … … 106 119 @param rdt 107 120 */ 108 public Tab2MageWriterFactory(SessionControl sc, Set<Tab2MAGEProtocol> protocols, ArrayList<Tab2MAGEHybridization> hybs, RawDataType rdt) 121 public Tab2MageWriterFactory(SessionControl sc, Set<Tab2MAGEProtocol> protocols, 122 ArrayList<Tab2MAGEHybridization> hybs, RawDataType rdt, 123 Map<String, List<String>> sampleExtract, 124 Map<String, List<String>> bioSourceSample, 125 Map<String, List<String>> extractLabExtract) 109 126 { 110 127 this.hybs= hybs; 111 128 this.rdt= rdt; 112 129 this.protocols = protocols; 113 dc= sc.newDbControl(); // create a single dbcontrol for this writer factory 130 dc= sc.newDbControl(); // create a single db control for this writer factory 131 this.sc= sc; 132 if (sampleExtract!=null && !sampleExtract.isEmpty() ) this.sampleExtMap.putAll(sampleExtract); 133 if (bioSourceSample!=null && !bioSourceSample.isEmpty()) this.bioSourceSamMap.putAll(bioSourceSample); 134 if (extractLabExtract!=null && !extractLabExtract.isEmpty()) this.extractLEMap.putAll(extractLabExtract); 114 135 } 115 136 … … 135 156 return success= false; 136 157 } 158 // store rawbioassay and experimental factors for later use by the experiment writer 137 159 this.rbas=hybWriter.getRbaCatche(); 138 160 this.expFactors=hybWriter.getExpFactors(); … … 142 164 { 143 165 success= false; 144 t.printStackTrace();145 166 log.error("WriterFactory: writing Protocol and Hybridization failed"); 146 167 dc.close(); … … 166 187 } 167 188 189 // this should only be executed if the preceding #write() works fine 190 191 @SuppressWarnings("unchecked") 192 public boolean writePooledMetaData() 193 { 194 boolean done= true; 195 //Tab2MageHelper.write(",,, handling pooled data........"); 196 try 197 { 198 // create a new db control since the last once would have been closed anyway 199 if (dc == null || !dc.isConnected()|| dc.isClosed()) dc = sc.newDbControl(); 200 201 Tab2MageHelper.write("Entering the try loop"); 202 for (Map.Entry<String , List<String>> entry : sampleExtMap.entrySet()) 203 { 204 Tab2MageHelper.write("\n++ The sample extract from the SampleExractMap is : "+entry.getKey()+":"+ entry.getValue()); 205 List<String> parents= entry.getValue(); 206 List<BasicItem> children = new ArrayList<BasicItem>(); 207 for (String parent : parents ) 208 { 209 Tab2MageHelper.write("++The current parent being checked is "+ parent); 210 Sample p = Tab2MageHelper.findSample(dc, parent); // get the parent from the database 211 ItemQuery<Extract> childrenQuery = p.getExtracts(); // get all the extracts ( children of parents -Sample) 212 childrenQuery.include(Include.MINE, Include.NOT_REMOVED); // include those children created by the loggedin user only 213 if (childrenQuery.list(dc).size()!=0) 214 children.add(childrenQuery.list(dc).get(0)); // pick the first child or extract in this case 215 } 216 String childofParent = entry.getKey(); // in this example this is the extract 217 Tab2MageHelper.write("...The key from map is : " + childofParent ); 218 Extract e= Tab2MageHelper.findExtract(dc, childofParent); 219 Tab2MageHelper.write("...the already created object fetched is : " + e.getName() ); 220 dc.reattachItem(e); 221 e.setPooled(true); 222 for (BasicItem<?> child : children) 223 { 224 e.getCreationEvent().addSource((MeasuredBioMaterial) child, Float.parseFloat("0.10")); 225 } 226 227 } 228 dc.commit(); 229 } 230 catch(Throwable tr) 231 { 232 done= false; 233 log.error("WriterFactory: setting pooled items failed"); 234 dc.close(); 235 throw new NutribasePluginException(tr.getMessage()); 236 } 237 finally 238 { 239 if (dc!=null) 240 dc.close(); 241 } 242 done=false; 243 return done; 244 } 245 168 246 /** 169 247 writes the protocol type not found in the database which must be within the allowed range in tab2mage specification … … 171 249 @param localDc 172 250 */ 173 public void writeProtocolTypes(DbControl localDc) 174 { 251 public void writeProtocolTypes(SessionControl sc) 252 { 253 DbControl localDc=sc.newDbControl(); 175 254 try 176 255 { … … 178 257 { 179 258 boolean foundType =Tab2MageHelper.checkIfProtocolTypesExist(protocol,localDc); 180 //System.out.println(foundType? "ProtocolType Exist " : "ProtocolType DoNot Exist");181 259 if (!foundType) 182 260 { … … 192 270 { 193 271 log.error("ProtocolTypes cannot be created"); 194 tr.printStackTrace();195 272 localDc.close(); // if there is an error. the creation of annotation types is rolled back. 196 273 throw new NutribasePluginException(tr.getMessage()); … … 201 278 localDc.close(); 202 279 } 203 }204 205 206 /**207 creates a new array batch if one does not exist already208 @param arrayDesign209 @return array batch210 */211 private ArrayBatch createArrayBatch (ArrayDesign arrayDesign, int i )212 {213 String accession = arrayDesign.getName()+"-Batch#" + i; // accession is thename of the slide214 ArrayBatch arrayBatch = Tab2MageHelper.findArrayBatch(dc, accession);215 if (arrayBatch== null)216 {217 arrayBatch = ArrayBatch.getNew(dc, arrayDesign);218 arrayBatch.setName(accession);219 dc.saveItem(arrayBatch);220 }221 return arrayBatch;222 }223 /**224 creates a raw bioassay225 @param name226 @param rawDataType227 @return228 */229 private RawBioAssay createRawBioAssay( String name, RawDataType rawDataType)230 {231 //System.out.println("Creating raw bioassay: " + name);232 RawBioAssay rba = RawBioAssay.getNew(dc, rawDataType);233 rba.setName(name);234 dc.saveItem(rba);235 return rba;236 }237 /**238 gets the protocol accession number given239 @param protMap, the Hybline protocol map240 @param type, the protocol type241 @return the accession number242 */243 244 private String getProtocolAccesion(Map<String, String> protMap, String type)245 {246 //System.out.println(" \n+++++++ Checking out the Hyb Protocols +++++\n");247 String accession="";248 for (Map.Entry<String, String> prot: protMap.entrySet())249 {250 //System.out.println(" Hyb Protocol is " + prot.getKey()+ ":" +prot.getValue());251 if (prot.getKey().equals(type.toUpperCase()))252 {253 accession =prot.getValue();254 break;255 }256 }257 return accession;258 }259 /**260 get protocol given the protocolname and type261 * @return262 */263 private Protocol getProtocol(String protocolAccesion)264 {265 //System.out.println(" \n+++++++ Getting Protocols +++++\n");266 Protocol protocol=null;267 for (Map.Entry<String, Protocol> prot: protocolAccessionMap.entrySet())268 {269 //System.out.println(" Protocol Accession Map is: " + prot.getKey()+ ":" +prot.getValue());270 if (prot.getKey().equalsIgnoreCase(protocolAccesion))271 {272 protocol =prot.getValue();273 break;274 }275 }276 return protocol;277 280 } 278 281 … … 286 289 } 287 290 288 private void setAnnotations(Annotatable annotatable, Map<String,String>annotationMap)289 {290 Map<AnnotationType, String> annotationTypes = new HashMap<AnnotationType, String>();291 for (Map.Entry<String, String> an : annotationMap.entrySet())292 {293 AnnotationType at =Tab2MageHelper.getAnnotationTypeByName(an.getKey(),dc);294 if (at!=null)295 {296 annotationTypes.put(at, an.getValue());297 }298 }299 if (!annotationTypes.isEmpty())300 {301 for (Map.Entry<AnnotationType, String> annt : annotationTypes.entrySet())302 {303 //System.out.println("Annotation type - Value mapping is " + annt.getKey().toString()+ ":" +annt.getValue());304 305 // remove annotations if the annotatable item has annotations already306 // this is because, we consider the annotatable item as a new item that307 // should not reference an already existing annotation of an item with308 //the same name, even if the item has been deleted.309 //if (annotatable.isAnnotated()) annotatable.removeAnnotations();310 if (annotatable instanceof RawBioAssay)311 {312 //System.out.println("YES, IT IS AN INSTANCE OF RAWBIOASSAY");313 AnnotationType t = annt.getKey();314 if (t.isEnabledForItem(Item.RAWBIOASSAY)) // if the annotation type is enable for raw bioassay item, set annotations315 {316 AnnotationSet as = annotatable.getAnnotationSet();317 String values= annt.getValue();318 System.out.println("Inserting: "+ annt.getValue()+" annotation for: "+ annotatable.toString());319 320 if (t.getValueType().equals(Type.FLOAT))321 {322 System.out.println("YES, the annotation value type is float");323 Float v = new Float(Float.parseFloat(values));324 as.getAnnotation(annt.getKey()).setValue(v);325 326 }327 else //if( t.getValueType().equals(Type.STRING))328 {329 as.getAnnotation(annt.getKey()).setValue(annt.getValue());330 }331 }332 // otherwise do nothing333 }334 else335 {336 AnnotationSet as = annotatable.getAnnotationSet();337 //System.out.println("Inserting: "+ annt.getValue()+" annotation for: "+ annotatable.toString());338 as.getAnnotation(annt.getKey()).setValue(annt.getValue());339 }340 341 }342 }343 }344 345 /**346 sets annotations for protocol parameters347 @param annotatable, the item that uses the protocol348 @param annotationMap, map of [annotation types - value] pair349 */350 private void setParameterAnnotations(Annotatable annotatable, Map<String,String>annotationMap)351 {352 Map<AnnotationType, String> ats = new HashMap<AnnotationType, String>();353 for (Map.Entry<String, String> an : annotationMap.entrySet())354 {355 //System.out.println(" Annotation type [BioMat,Param] Value is " + an.getKey()+ ":" +an.getValue());356 AnnotationType at =Tab2MageHelper.getAnnotationTypeByName(an.getKey(),dc);357 if (at!=null)358 {359 ats.put(at, an.getValue());360 }361 }362 if (!ats.isEmpty())363 {364 for (Map.Entry<AnnotationType, String> anv : ats.entrySet())365 {366 if (annotatable.getProtocol()!=null)367 {368 if (annotatable.getProtocol().isParameter(anv.getKey()))369 {370 AnnotationSet as = annotatable.getAnnotationSet();371 //System.out.println("Inserting: "+ anv.getValue()+" annotation for: "+ annotatable.toString());372 as.getAnnotation(anv.getKey()).setValue(anv.getValue());373 }374 }375 }376 }377 }378 379 291 /** 380 292 get the list of raw bio asssay … … 385 297 return rbas; 386 298 } 387 388 389 299 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/mail/Tab2MageEMessaging.java
r362 r374 20 20 21 21 import org.apache.log4j.Logger; 22 23 import uk.ac.ebi.nugo.plugins.util.NutribasePluginException; 22 24 /** 23 25 This class is the e messaging for the Tab2Mage import and export. This is … … 33 35 private String mailFrom = ""; 34 36 private String mailTo = ""; 35 //private String host = "smtp.ebi.ac.uk";36 37 private String host=""; 37 38 private String body = ""; … … 44 45 this.mailFrom = from; 45 46 this.mailTo= to; 46 if ( fileName!="")tab2MageFileName = fileName;47 if ( userName!="")loggedinUserName=userName;47 if (!fileName.equals("")) tab2MageFileName = fileName; 48 if (!userName.equals("")) loggedinUserName=userName; 48 49 this.host= hostname; 49 50 if (status) // if successful … … 107 108 message.setSentDate(new Date()); 108 109 109 System.out.println("sending message.......");110 log.info("sending message......."); 110 111 //sending the tab2mage message 111 112 Transport.send(message); … … 114 115 { 115 116 log.error("Email message cannot be sent, your email address maybe invalid. Or " +me.getMessage()+ ". Contact your smtp sever adminstrator"); 116 me.printStackTrace(); 117 //throw new NutribasePluginException("Email message cannot be sent, your email address maybe invalid. Or " +me.getMessage()+ ". Contact your smtp sever adminstrator"); 117 throw new NutribasePluginException("Email message cannot be sent, your email address maybe invalid. Or " +me.getMessage()+ ". Contact your smtp sever adminstrator"); 118 118 } 119 119 catch (UnsupportedEncodingException e) 120 120 { 121 121 log.error("You have some unsupported characters in your base/nutribase username or email address."); 122 e.printStackTrace(); 123 //throw new NutribasePluginException(e.getMessage()); 122 throw new NutribasePluginException(e.getMessage()); 124 123 } 125 124 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/AgilentValidation.java
r362 r374 60 60 for (File agFile : agilentFiles ) 61 61 { 62 Tab2MageHelper.write("Validating agilent file : "+ agFile.getName());62 log.info("Validating agilent file : "+ agFile.getName()); 63 63 AgilentRDParser agParser= new AgilentRDParser(agFile, dc); 64 64 String [] headers= agParser.getHeaders(); 65 65 if (headers==null) continue; 66 //Tab2MageHelper.write("\n..........The list of agilent headers\n");67 66 List<String> headerList = Tab2MageHelper.arrayContentToLowercase(headers); 68 //int i=0;69 //for (String header :headerList )70 //{71 // i++;72 // Tab2MageHelper.write("Header " + i + ": "+ header);73 //}74 //Tab2MageHelper.write("End of agilent headers\n");75 67 List<AgilentDataColumns> mandatoryColumns= Arrays.asList(AgilentDataColumns.values()); 76 68 for (AgilentDataColumns man :mandatoryColumns ) -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/GenePixFileValidation.java
r362 r374 71 71 Base2GenePixRDParser gParser= new Base2GenePixRDParser(gprFile, dc); 72 72 String [] headers= gParser.getHeaders(); 73 //Tab2MageHelper.write("\n..........The list of Genepix headers\n");74 73 List<String> headerList = Tab2MageHelper.arrayContentToLowercase(headers); 75 //int i=0;76 //for (String header :headerList )77 //{78 // i++;79 // Tab2MageHelper.write("Header " + i + ": "+ header);80 //}81 // Tab2MageHelper.write("End of Genepix headers\n");82 74 List<GenePixDataColumns> mandatoryColumns= Arrays.asList(GenePixDataColumns.values()); 83 75 for (GenePixDataColumns man :mandatoryColumns ) … … 95 87 success = false; 96 88 log.error("The gpr files cannot be validated"+tr.getMessage()); 97 tr.printStackTrace();98 89 } 99 90 return success; -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/RawDataValidation.java
r362 r374 7 7 8 8 /** 9 This inte face is for the validation of raw data files.9 This interface is for the validation of raw data files. 10 10 Note: seperate implementation to base1/ baseloader 11 11 @author Dominic Oyeniran -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/Tab2MageImportValidatorUtils.java
r362 r374 29 29 import uk.ac.ebi.nugo.plugins.tab2mageimport.AnnotationTypeFileMapping; 30 30 import uk.ac.ebi.nugo.plugins.util.NutribasePluginException; 31 import uk.ac.ebi.nugo.plugins.util.Tab2MageConstants; 31 32 import uk.ac.ebi.nugo.plugins.util.Tab2MageHelper; 32 33 … … 80 81 List<String> annotationTypes = new LinkedList<String>(); 81 82 82 83 //annotate this guy later. 84 private static Map< String, List<String>> BioSourceSamplePoolMap= new HashMap< String, List<String>>(); 85 private static Map< String, List<String>> SampleExractPoolMap= new HashMap< String, List<String>>(); 86 private static Map<String, List<String>> ExractLabeledExtractPoolMap= new HashMap< String, List<String>>(); 87 83 88 /** 84 89 creates the hyb validator util … … 126 131 createAnnotationTypeValueMap(parameterAnnotationType); 127 132 createAnnotationTypeValueMap(factorValueAnnotationType); 133 128 134 } 129 135 } … … 138 144 for(Map.Entry<String, String> e : map.entrySet()) 139 145 { 140 //Tab2MageHelper.write(e.getKey() + ": " + e.getValue());141 146 if (Values.getFloat(e.getValue())== 0) 142 147 { … … 174 179 if (parameterAnnotationType.containsKey(e.getKey())) 175 180 { 176 //Tab2MageHelper.write("Found Parameter key : [" + e.getKey()+ "] and value is :" + parameterAnnotationType.get(e.getKey()));177 181 parameter="true"; 178 182 } 179 //Tab2MageHelper.write(".....checking biomat map");183 180 184 if (bioMaterialAnnotationType.containsKey(e.getKey())) 181 185 { 182 //Tab2MageHelper.write("Found BioMat key: [" + e.getKey()+ "] and value is :" + bioMaterialAnnotationType.get(e.getKey()));183 186 items.add("biosource"); 184 187 } 185 //Tab2MageHelper.write(".....checking factor value map");186 188 if (factorValueAnnotationType.containsKey(e.getKey())) 187 189 { 188 //Tab2MageHelper.write("Found Factor Value key: [" + e.getKey()+ "] and value is :" + factorValueAnnotationType.get(e.getKey()));189 190 items.add("rawbioassay"); 190 191 } 191 192 192 AnnotationTypeFileMapping at = new AnnotationTypeFileMapping(name, valuetype, parameter,items); 193 193 annotationTypeFileMappings.add(at); … … 197 197 { 198 198 log.error("Annotation File cannot be created"); 199 t.printStackTrace(); 200 199 201 200 } 202 201 return annotationTypeFileMappings; … … 233 232 try 234 233 { 235 //Tab2MageHelper.write("creating the subdirectory ....");236 234 if (!Directory.exists(dc, dir, directoryName)) 237 235 { … … 240 238 dc.saveItem(subDir); 241 239 } 242 Tab2MageHelper.write("creating the file.....");240 log.info("creating the file....."); 243 241 // create a file : filename into the subdirectory (temp) created above 244 242 file = File.getFile(dc, subDir, filename, true); … … 263 261 { 264 262 log.error("Error: " + tex.getMessage()); 265 tex.printStackTrace();266 263 throw new NutribasePluginException("Temporary File cannot be created"); 267 264 } … … 278 275 return file; 279 276 } 277 /** 278 check if the hybridization headers contain Protocol[pool] 279 @return TRUE if yes and FALSE otherwise. 280 */ 281 public boolean checkForPoolingProtocol() 282 { 283 boolean pooled = header.contains(Tab2MageConstants.protocol_pool.getName())? true : false; 284 return pooled; 285 } 286 // if pooled do handlepool() 287 public void handlePool() 288 { 289 //call checkForPoolingProtocol and if pooled? 290 Map<String, String> BioSourceSampleMap= new HashMap<String,String>(); 291 Map<String, String> SampleExtractMap= new HashMap<String,String>(); 292 Map<String, String> ExtractLabeledExtractMap= new HashMap<String,String>(); 293 294 // clear maps of parent child relationships 295 if (!BioSourceSampleMap.isEmpty()) BioSourceSampleMap.clear(); 296 if (!SampleExtractMap.isEmpty()) SampleExtractMap.clear(); 297 if (!ExtractLabeledExtractMap.isEmpty()) ExtractLabeledExtractMap.clear(); 298 try 299 { 300 for (Tab2MAGEHybridization hyb: hybs) 301 { 302 for (Tab2MAGEHybridizationLine line : hyb.getLines()) 303 { 304 // populate maps of parent child relationships 305 BioSourceSampleMap.put(line.getBioSource(), line.getSample()); 306 SampleExtractMap.put(line.getSample(), line.getExtract()); 307 ExtractLabeledExtractMap.put(line.getExtract(), line.getLabeledExtract()); 308 } 309 } 310 311 SampleExractPoolMap.putAll(getParentChildMap(SampleExtractMap)); 312 BioSourceSamplePoolMap.putAll(getParentChildMap(BioSourceSampleMap)); 313 ExractLabeledExtractPoolMap.putAll(getParentChildMap(ExtractLabeledExtractMap)); 314 } 315 catch(Throwable tr) 316 { 317 log.error("cannot processing pooling" + tr.getMessage()); 318 } 319 } 320 321 private Map<String, List<String>> getParentChildMap(Map<String, String> childParentMap) 322 { 323 Map<String, List<String>> map = new HashMap<String, List<String>>(); 324 for (Map.Entry<String, String> childParentEntry : childParentMap.entrySet()) 325 { 326 String child= childParentEntry.getValue(); 327 List<String> parents= getParents(child, childParentMap); 328 if (parents.size()>=2) // means that the child has more than one parents 329 { 330 map.put(child, parents); 331 } 332 } 333 return map; 334 } 335 336 private List<String> getParents(String child, Map<String, String> childParentMap) 337 { 338 List<String> parents= new ArrayList<String>(); 339 //if (!child.equals("")|| child.length()>=1 ) 340 if (!child.equals("") && child.length()>=1 ) //ensure that child is not an empty string 341 { 342 for (Map.Entry<String, String> entry : childParentMap.entrySet()) 343 { 344 if (child.equalsIgnoreCase(entry.getValue())) 345 { 346 parents.add(entry.getKey()); 347 } 348 } 349 } 350 return parents; 351 } 352 353 public Map<String, List<String>> getBioSourceSamplePoolMap() 354 { 355 return BioSourceSamplePoolMap; 356 } 357 358 public Map<String, List<String>> getExractLabeledExtractPoolMap() 359 { 360 return ExractLabeledExtractPoolMap; 361 } 362 363 public Map<String, List<String>> getSampleExractPoolMap() 364 { 365 return SampleExractPoolMap; 366 } 280 367 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/tab2mageimport/validation/Tab2MageValidationFactory.java
r362 r374 10 10 import java.util.Arrays; 11 11 import java.util.List; 12 import java.util.Map; 12 13 import java.util.Set; 13 14 … … 52 53 private static Set<Tab2MAGEProtocol> catchedProtocol=null; 53 54 private static ArrayList<Tab2MAGEHybridization> catchedHybs=null; 55 56 private static Map<String , List<String>> sampleExtractMap= null; 57 private static Map<String, List<String>> bioSourceSampleMap =null; 58 private static Map<String, List<String>> extractLabeledExtractMap = null; 59 54 60 /** 55 61 Filename with extension e.g tab2mage.txt … … 60 66 */ 61 67 private Directory dir; 68 /** 69 the db control created from session 70 */ 62 71 private DbControl dc; 72 /** 73 session control passed as parameter on creating this class 74 */ 63 75 private SessionControl sc; 64 76 /** … … 81 93 82 94 private Tab2MAGEExperiment tExperiment; 95 /** 96 variable that indicates if experiment is pooled or not. 97 */ 98 private boolean pooled; 99 83 100 /** 84 101 … … 91 108 @param expPlatform 92 109 */ 93 public Tab2MageValidationFactory(String fileName, DbControl dControl, Directory fileDirectory, String expPlatform)110 public Tab2MageValidationFactory(String fileName, SessionControl sControl, Directory fileDirectory, String expPlatform) 94 111 { 95 112 filename= fileName; 96 dc = dControl;97 sc = dc.getSessionControl();113 dc = sControl.newDbControl(); 114 sc = sControl; 98 115 dir=fileDirectory; 99 116 platform= expPlatform; 100 //this call the Tab2mage file validation routine 101 Tab2MageHelper.write("About to begin tab2mage file validation"); 117 //this calls the Tab2mage file validation routine 102 118 validateTab2MageFile(); 103 119 } … … 152 168 if (isFileValid) 153 169 { 154 //Tab2MageHelper.write("Is the tab2magefile format valid? " + isFileValid);155 170 // parse and read the tab2magefile 156 171 reader = new Base2Tab2MageFileReader(tab2MageFile, dc); … … 158 173 159 174 //validate experiment 160 Tab2MageHelper.write("Begin Experiment validation");175 log.info("Begin Experiment validation"); 161 176 tExperiment= reader.getExperiment(); 162 177 Tab2MageExperimentValidation experimentVal= new Tab2MageExperimentValidation(reader); 163 178 boolean expValidated= experimentVal.validate(); // return true or false 164 179 165 //Tab2MageHelper.write(expValidated ? "yes the exp is validated" : "No exp is not validated");166 180 if (!expValidated) 167 181 { … … 169 183 throw new NutribasePluginException("SORRY: The experiment section of the tab2mage file: " +filename+ " is invalid. Must be rectified to proceed"); 170 184 } 171 Tab2MageHelper.write("Finished experiment validation");185 log.info("Finished experiment validation"); 172 186 173 187 //validate protocols 174 188 if (dc == null || !dc.isConnected() || dc.isClosed()) //dc = dir.getDbControl(); 175 189 dc= sc.newDbControl(); 176 Tab2MageHelper.write("Begin Protocol validation");190 log.info("Begin Protocol validation"); 177 191 Set<Tab2MAGEProtocol> protocols = reader.getProtocols(); // we get all the protocols 178 192 Tab2MageProtocolValidation protocolVal= new Tab2MageProtocolValidation(protocols, dc); … … 183 197 throw new NutribasePluginException("SORRY: The protocol section of the tab2mage file: " +filename+ " is invalid. Must be rectified to proceed. See the log file for more details"); 184 198 } 185 // Display the protocols only for debugging 186 //Tab2MageHelper.write("\n+++++++++++++++++++++++ALL THE PROTOCOLS++++++++++++++++++++++++++++++++++++++\n"); 187 //for (Tab2MAGEProtocol p : protocols) 188 //{ 189 // Tab2MageHelper.write(p.getAccession()+ "\t" +p.getText()+ "\t" +p.getName() + "\t" +p.getType()+ "\t" +p.getParameters()); 190 //} 191 //Display all the parameters, only for debugging 192 193 //Tab2MageHelper.write("\n++++++++++++++++++++ The parameters ++++++++++++++\n"); 194 //List<String> params= protocolVal.getProtocolParameters(); 195 //for (String p : params) 196 //{ 197 // Tab2MageHelper.write(p); 198 //} 199 200 Tab2MageHelper.write("Finished protocol validation"); 199 200 log.info("Finished protocol validation"); 201 201 202 202 /* … … 204 204 */ 205 205 if (dc == null || !dc.isConnected()) dc = sc.newDbControl(); 206 Tab2MageHelper.write("Begin Hybridization validation");206 log.info("Begin Hybridization validation"); 207 207 ArrayList<Tab2MAGEHybridization> hybs = reader.getHybridizations(); 208 208 209 //Tab2MageHelper.write( "Finished getting hybs from the reader object, now +++++ listing hyb names+++++ ");210 //for (Tab2MAGEHybridization hyb : hybs)211 //{212 // System.out.printf("\nThe hyridization name for this hyb is %s\n",hyb.getName());213 //}214 209 // validate headers 215 210 boolean validateHeaders= Tab2MageHybridizationValidation.validateHeader(new ArrayList<String>(Arrays.asList(reader.getHeaders()))); … … 220 215 } 221 216 //validate rows /lines 222 //Tab2MageHelper.write("Begin validate hyb rows after headers"); //NOTE: the db control is closed here217 223 218 Tab2MageHybridizationValidation validateHyb = new Tab2MageHybridizationValidation(dir, platform, hybs, reader, dc); 224 219 if (!validateHyb.validate()) … … 227 222 throw new ValidationException("There is an error in the Tab2Mage Hybridization section!"); 228 223 } 229 Tab2MageHelper.write("Finished Hybridization validation");224 log.info("Finished Hybridization validation"); 230 225 //NOTE: the db control is closed here 231 226 … … 233 228 234 229 if (dc == null || !dc.isConnected() || dc.isClosed()) dc = sc.newDbControl(); 235 //Tab2MageHelper.write("\n+++++++++++ List AT - value type map ++++++++++++++\n ");230 236 231 Tab2MageImportValidatorUtils utils = new Tab2MageImportValidatorUtils(hybs, new ArrayList<String>(Arrays.asList(reader.getHeaders()))); 237 232 utils.initialiseMaps(); … … 239 234 240 235 tab2MageFile= File.getByPath(dc, tab2MageFile.getPath(), false); 241 //Tab2MageHelper.write("create file and directory");236 242 237 String filename= "anntype.txt"; 243 Tab2MageHelper.write("The ta2mage file mime and file type is: " + tab2MageFile.getMimeType()+ " -- "+tab2MageFile.getFileType());244 245 238 utils.createFile(sc, dir, "tempAT", tab2MageFile.getMimeType(),tab2MageFile.getFileType() , filename); 246 //Tab2MageHelper.write("Finished createFiles()");247 239 atFile = utils.getFile(); 248 240 … … 253 245 writer.writeFile(); 254 246 dc.commit(); 255 Tab2MageHelper.write("Writing file :"+atFile.getName()+ "completed!"); 247 248 log.info("Writing temporary annotation type file :"+atFile.getName()+ "completed!"); 256 249 257 250 /* … … 259 252 260 253 */ 261 //System.out.println("The experiment platform is :"+ platform); 254 255 // [ create a new DC here because the last one has been closed] 256 262 257 if (dc == null || !dc.isConnected() || dc.isClosed()) dc = sc.newDbControl(); 263 258 dir= Directory.getByPath(dc, dir.getPath()); 264 259 if (platform.equalsIgnoreCase("genepix")) 265 260 { 266 Tab2MageHelper.write("Begin GenePix File validation");261 log.info("Begin GenePix File validation"); 267 262 List<File> gprFiles= Tab2MageHelper.getRawDataFiles(dir, dc, platform, filename); 268 263 GenePixFileValidation gprValidation= new GenePixFileValidation(gprFiles, dc); … … 273 268 } 274 269 GenePixValidation.validateRawFiles(hybs); 275 Tab2MageHelper.write("Finished GenePix File validation");270 log.info("Finished GenePix File validation"); 276 271 } 277 272 /* … … 283 278 // we need to parse the headers 284 279 // obtain and check if the headers is within the allowed range 285 Tab2MageHelper.write("Begin Agilent File validation");280 log.info("Begin Agilent File validation"); 286 281 List<File> agFiles= Tab2MageHelper.getRawDataFiles(dir, dc, platform, filename); 287 282 AgilentValidation agValidation= new AgilentValidation(agFiles,dc); … … 291 286 throw new ValidationException("An agilent file is missing once or more mandatory columns!"); 292 287 } 293 Tab2MageHelper.write("Finished Agilent File validation");288 log.info("Finished Agilent File validation"); 294 289 } 295 290 … … 320 315 } 321 316 /** 322 returns true if validation is succes ful and false otherwise.317 returns true if validation is successful and false otherwise. 323 318 @return validated; 324 319 */ … … 363 358 get the protocols in the tab2mage File 364 359 @return protocols. 365 */360 */ 366 361 public static Set<Tab2MAGEProtocol> getCatchedProtocol() 367 362 { … … 381 376 return tExperiment; 382 377 } 378 379 /** 380 check if experiment is pooled , indicated by the protocol header. 381 @return pooled TRUE if pooled indicated by Protocol[pool] and false otherwise. 382 */ 383 public boolean isPooled() 384 { 385 return pooled; 386 } 387 388 /** 389 get Sample -to- List of Extract map. 390 @return Map<String, List<String> 391 */ 392 public static Map<String, List<String>> getSampleExtractMap() 393 { 394 return sampleExtractMap; 395 } 396 /** 397 get BioSource -to- List of Sample map. 398 @return map 399 */ 400 public static Map<String, List<String>> getBioSourceSampleMap() 401 { 402 return bioSourceSampleMap; 403 } 404 /** 405 get Extract -to- List of Labeled Extract map. 406 @return map 407 */ 408 public static Map<String, List<String>> getExtractLabeledExtractMap() 409 { 410 return extractLabeledExtractMap; 411 } 383 412 } -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/util/PluginConfigDetector.java
r362 r374 84 84 public PluginConfiguration detectPluginConfig(File exampleFile) throws Exception 85 85 { 86 System.out.println("auto-detecting PluginConfiguration");86 log.info("auto-detecting PluginConfiguration"); 87 87 88 88 DbControl dc = sc.newDbControl(); … … 126 126 { 127 127 log.error("No suitable plugin configuration found for this plugin. Please ensure you have a valid " + pluginType!=null? pluginType.toString(): "" + " configuration in Base2"); 128 x.printStackTrace();128 129 129 throw new Exception("No suitable plugin configuration found for this plugin. Please ensure you have a valid " + pluginType!=null? pluginType.toString(): "" + " configuration in Base2"); 130 130 } … … 173 173 if (importer.isImportable(in)) 174 174 configs.add(config); 175 System.out.println("The name of the plugin configurationis: "+config.getName());175 log.info("The name of the plugin configuration found is: "+config.getName()); 176 176 } 177 177 else if(pluginType== DetectablePluginTypes.ANNOTATIONTYPES) … … 190 190 configs.add(config); 191 191 } 192 193 //close the stream 192 //close the stream 194 193 in.close(); 195 194 } … … 197 196 catch (Exception x) 198 197 { 199 x.printStackTrace();198 log.error(x.getMessage()); 200 199 } 201 200 return configs; -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/util/Tab2MageHelper.java
r362 r374 255 255 // try to locate the files in subdirectories too. /home/dominic/test/test/ instead 256 256 if (fileQuery.count(dc)==0) 257 //dir.getSubDirectories(); 257 { 258 System.out.println( "The direcrtory may already exist");//dir.getSubDirectories(); 258 259 return validPlatform; 260 } 259 261 ItemResultList<File> fileList = fileQuery.list(dc); 260 262 System.out.println("The number of files in Dir : " + dir.getPath()+ " is : " +fileList.size()); … … 271 273 if (!ext.equalsIgnoreCase(ExperimentPlatformsLibrary.TXT.getFileExtension())) 272 274 { 273 System.out.println("++++ Now checking platform +++++++++++");275 //System.out.println("++++ Now checking platform +++++++++++"); 274 276 ExperimentPlatformsLibrary platform = ExperimentPlatformsLibrary.fromExtension(ext); 275 277 if (platform!=null) // platform (raw data files provided) is supported … … 277 279 if (platform.getPlatformName().equalsIgnoreCase(rdt.getId())) //does the files match experiment platform? 278 280 { 279 System.out.println("Platform ["+ platform.getPlatformName() +"] is supported" );281 //System.out.println("Platform ["+ platform.getPlatformName() +"] is supported" ); 280 282 validPlatform= true; 281 283 } 282 284 } else if (platform == null) //raw data files -platforms are not supported. 283 285 { 284 System.out.println("Platform not supported. Check the zip file content");286 //System.out.println("Platform not supported. Check the zip file content"); 285 287 validPlatform= false; 286 288 } … … 292 294 catch (Throwable t) 293 295 { 294 t.printStackTrace();296 // t.printStackTrace(); 295 297 return false; 296 298 } … … 364 366 catch (Throwable t) 365 367 { 366 t.printStackTrace();368 //t.printStackTrace(); 367 369 throw new NutribasePluginException(t.getMessage()); 368 370 } … … 401 403 catch (Throwable t) 402 404 { 403 t.printStackTrace();405 //t.printStackTrace(); 404 406 throw new NutribasePluginException(t.getMessage()); 405 407 } … … 586 588 return s; 587 589 } 588 590 /** 591 * 592 * @param dc 593 * @param sampleName 594 */ 595 596 public static Sample findSample(DbControl dc, String sampleName) 597 { 598 Sample s= null; 599 ItemQuery<Sample> query = Sample.getQuery(); 600 //query.include(Include.MINE, Include.IN_PROJECT, Include.NOT_REMOVED); 601 query.include(Include.MINE, Include.NOT_REMOVED); 602 query.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(sampleName))); 603 if (query.list(dc).size()!=0) 604 return query.list(dc).get(0); 605 else 606 return s; 607 608 609 } 610 public static Extract findExtract(DbControl dc, String extractName) 611 { 612 Extract e= null; 613 ItemQuery<Extract> query = Extract.getQuery(); 614 //query.include(Include.MINE, Include.IN_PROJECT, Include.NOT_REMOVED); 615 query.include(Include.MINE, Include.NOT_REMOVED); 616 query.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(extractName))); 617 if (query.list(dc).size()!=0) 618 return query.list(dc).get(0); 619 else 620 return e; 621 622 } 589 623 590 624 -
trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/util/ZipUnpacker.java
r362 r374 9 9 import java.io.IOException; 10 10 import java.io.InputStream; 11 import java.text.SimpleDateFormat;12 import java.util.Date;13 import java.util.Locale;14 11 import java.util.zip.ZipEntry; 15 12 import java.util.zip.ZipInputStream; 16 17 import org.apache.log4j.Logger;18 19 import uk.ac.ebi.nugo.plugins.tab2mageimport.validation.Tab2MageValidationFactory;20 13 21 14 import net.sf.basedb.core.DbControl; … … 23 16 import net.sf.basedb.core.File; 24 17 import net.sf.basedb.core.Location; 25 import net.sf.basedb.core.Path; 26 import net.sf.basedb.core.SessionControl; 27 import net.sf.basedb.core.Path.Type; 18 import net.sf.basedb.core.PluginDefinition; 28 19 import net.sf.basedb.core.Quota; 29 20 import net.sf.basedb.core.QuotaType; 21 import net.sf.basedb.core.SessionControl; 30 22 import net.sf.basedb.core.SystemItems; 31 23 import net.sf.basedb.core.User; 32 import net.sf.basedb.core.PluginDefinition;33 24 import net.sf.basedb.util.zip.FileUnpacker; 25 26 import org.apache.log4j.Logger; 34 27 35 28 … … 46 39 public class ZipUnpacker 47 40 { 48 protected static Logger log = Logger.getLogger( Tab2MageValidationFactory.class);41 protected static Logger log = Logger.getLogger(ZipUnpacker.class); 49 42 private User user; 50 43 private File file; … … 55 48 private SessionControl sc; 56 49 57 public ZipUnpacker(File zipFile, User user, DbControl dc)50 public ZipUnpacker(File zipFile, User user, SessionControl sc) 58 51 { 59 52 this.user = user; 60 this.dc= dc;53 this.dc=sc.newDbControl(); 61 54 this.file= zipFile; 62 this.sc= dc.getSessionControl();55 //this.sc= dc.getSessionControl(); 63 56 } 64 57 /** 65 58 Unpacks a zip file, checking that there is enough space to accommodate 66 59 the zip file once it is unpacked. 67 *@throws NutribasePluginException60 @throws NutribasePluginException 68 61 */ 69 62 public void unpack() throws NutribasePluginException 70 63 { 71 System.out.println("Begin to unpack the files");64 log.info("Begin to unpack the files"); 72 65 try 73 66 { … … 94 87 catch (Throwable exc) 95 88 { 89 dc.close(); 90 log.info("File cannot be unpacked", exc); 96 91 new NutribasePluginException(exc.getMessage()); 97 92 } 98 93 finally 99 94 { 100 95 if (dc!=null) 96 dc.close(); 101 97 } 102 98 } … … 160 156 catch (IOException ioe) 161 157 { 162 ioe.printStackTrace(); 158 //ioe.printStackTrace(); 159 log.error(ioe.getMessage()); 163 160 } 164 161 return totalSize; 165 162 } 166 163 /** 164 create a sub-directory to contain the unzip files 165 @param zipFile, the zip file to unpack 166 @param user, currently logged-in user 167 @param dc, the database control 168 */ 167 169 public void createSubDirectory(File zipFile, User user , DbControl dc) 168 170 { … … 170 172 171 173 Directory zipFileDir = zipFile.getDirectory(); 172 System.out.println("zipFile is located in dir " + zipFileDir.toString());174 log.info("zipFile is located in dir " + zipFileDir.toString()); 173 175 Directory subDir = Directory.getNew(dc, zipFileDir); 174 176 String fileName = zipFile.getName();
Note: See TracChangeset
for help on using the changeset viewer.