Changeset 472


Ignore:
Timestamp:
Nov 12, 2007, 5:50:07 PM (14 years ago)
Author:
dominic
Message:

added newly changed code. This source code is not in sycn with the current released version of the tab2mage importer.

Location:
trunk/uk/ac/ebi/Tab2MageImporter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/uk/ac/ebi/Tab2MageImporter/README.txt

    r457 r472  
    6363  When the import has finished, you can check and review the uploaded experiment by navigating through base2 web client, using the menu. If you have provided your email server name. You would receive an email message on the status of the import.
    6464
     65=========================================================
     66Pooling Implementation
     67--------------------------------
     68The tab2mage importer runs in a pooled or non- pooled state.
     69A pooling protocol - Protocol[pool] must be specified for experiments that involve pooling, otherwise the importer would run in a non-pool state.
     70
     71One stage pooling - > biosource to sample, sample to extract or extract to labeled extract is fully supported
     72
     73Multiple stage pooling: biosource to sample and sample to extract supported.  Note that Multi stage pooling involving labeled extract is not supported.
     74
     75Please check pooling notes link on the download page for more information
     76
     77For usability and consistency on the biomaterial user interface, do run the same experiment twice. An imported experiment (with raw data and meta-data) that involves pooling may only be loaded once.
     78
    6579 ===========================================================
    6680AnnotationTypes and Cv Importer
  • trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/Helper.java

    r463 r472  
    8282      }
    8383      Path path = new Path(pathString, Path.Type.FILE);   
    84      
    8584      file= File.getByPath(dc, path, true);
    8685      file.setMimeType("text/plain"); //set the type of the file
     
    135134   {
    136135     String fileName= file.getName();
    137      //System.out.println("\nThe file name is: " + fileName );
    138136     String ext= fileName.substring(fileName.lastIndexOf(".") + 1);
    139137     ext = ext.toLowerCase();
    140      //System.out.printf("The file ext is: %s\n", ext);
    141      return ext;
     138      return ext;
    142139   }
    143140   
     
    370367    return p;
    371368  }
     369 
     370  /**
     371    validates the directory parameter specified by user
     372    @param file, the zip file. its directory, is checked for the existence of directoryName given by the user
     373    @param directoryName, the name of the directory specified by the user
     374    @return TRUE if directory exist and FALSE otherwise
     375  */
     376  public static boolean validateDirectory (SessionControl sc ,File file, String directoryName)
     377  {
     378    DbControl dc = sc.newDbControl();
     379    try
     380    {
     381      file = File.getById(dc, file.getId());
     382      return Directory.exists(dc, file.getDirectory(), directoryName);
     383    }
     384    finally
     385    {
     386      if (dc != null) dc.close();
     387    }
     388  }
    372389}
  • trunk/uk/ac/ebi/Tab2MageImporter/src/uk/ac/ebi/nugo/plugins/ZipUnpacker.java

    r463 r472  
    99import java.io.IOException;
    1010import java.io.InputStream;
     11import java.text.SimpleDateFormat;
    1112import java.util.Date;
     13import java.util.Locale;
    1214import java.util.zip.ZipEntry;
    1315import java.util.zip.ZipInputStream;
    1416
    15 import net.sf.basedb.core.DatabaseException;
     17import net.sf.basedb.core.BaseException;
    1618import net.sf.basedb.core.DbControl;
    1719import net.sf.basedb.core.Directory;
    1820import net.sf.basedb.core.File;
     21import net.sf.basedb.core.ItemAlreadyExistsException;
    1922import net.sf.basedb.core.Location;
    2023import net.sf.basedb.core.PluginDefinition;
     
    5760    Unpacks a zip file, checking that there is enough space to accommodate
    5861    the zip file once it is unpacked.
    59       @throws NutribasePluginException
    60    */
    61   public void unpack() throws NutribasePluginException
     62    */
     63  public void unpack(String dirName)
    6264  {
    6365    log.info("Begin to unpack the files");
     
    7375      if (hasSpace)
    7476      {
     77        createSubDirectory( file, user, dirName);
     78        // now call the method to unpack the zip files
     79        PluginDefinition zipFilePlugin = PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.ZipFileUnpacker");
     80        FileUnpacker unpacker = zipFilePlugin.newInstance(net.sf.basedb.plugins.ZipFileUnpacker.class, null, dc.getSessionControl(), null, null);
     81        numUnpackedFiles=unpacker.unpack(dc, unzippedFilesDirectory,file.getDownloadStream(0), false,null);
     82      }
     83      else // if space is not enough
     84      {
     85        throw new BaseException("User do not have the required Disk Space. Please contact your BASE administrator or remove some files");
     86      }
     87      dc.commit();
     88      inStream.close();
     89    }
     90    catch (Throwable exc)
     91    {
     92      dc.close();
     93      log.info("File cannot be unpacked", exc);
     94      new BaseException("File cannot be unpacked :" +exc.getMessage());
     95    }
     96    finally
     97    {
     98      if (dc!=null)
     99        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      {
    75123        createSubDirectory( file, user);
    76124        // now call the method to unpack the zip files
     
    81129      else // if space is not enough
    82130      {
    83         throw new NutribasePluginException("User do not have the required Disk Space. Please contact your NutriBASE administrator or remove some files");
     131        throw new BaseException("User do not have the required Disk Space. Please contact your BASE administrator or remove some files");
    84132      }
    85133      dc.commit();
     
    90138      dc.close();
    91139      log.info("File cannot be unpacked", exc);
    92       new NutribasePluginException(exc.getMessage());
     140      new BaseException(exc.getMessage());
    93141    }
    94142    finally
     
    98146    }
    99147  }
    100  
     148
    101149  /**
    102150    checks user quota
     
    122170    {
    123171      log.error("[disk space: "+remainingSpace+ " ] insufficient for unzipping of file size [" +zipFileSize + "] -- please contact your BASE administrator or remove some files");
    124       throw new NutribasePluginException("[disk space: "+remainingSpace+ " ] insufficient for unzipping of file size [" +zipFileSize + "] -- please contact your BASE administrator or remove some files");
     172      throw new BaseException("[disk space: "+remainingSpace+ " ] insufficient for unzipping of file size [" +zipFileSize + "] -- please contact your BASE administrator or remove some files");
    125173    }
    126174    else if ( remainingSpace > zipFileSize || quotaValue==-1 )
     
    153201      catch (IOException ioe)
    154202      {
    155         throw new NutribasePluginException("zip file size could not be obtained " + ioe.getMessage());
     203        throw new BaseException("zip file size could not be obtained " + ioe.getMessage());
    156204      }
    157205      return totalSize;
     
    161209      @param zipFile, the zip file to unpack
    162210      @param user, currently logged-in user
     211      @param
     212   
     213   */
     214  public void createSubDirectory(File zipFile, User user, String dirName)
     215  {
     216    DbControl dc=null;
     217    try
     218    {
     219      dc = sc.newDbControl();
     220      //get the parent directory
     221      Directory zipFileDir = zipFile.getDirectory();
     222      log.info("zipFile is located in dir " + zipFile.getPath());
     223      Directory d = Directory.getById(dc, zipFileDir.getId());
     224      //String timeStamp = getTime("ddMMyy_HHmmss"); // can be added to the time directory name
     225      Directory subDir = d.newSubDirectory();
     226      subDir.setName(dirName);
     227        subDir.setDescription("Unzippped directory created at "+new Date());
     228      if (subDir.isInDatabase())
     229      {
     230        throw new ItemAlreadyExistsException("The Directory ["+ subDir.getPath().toString()+ "] already exists");
     231      }
     232      else if (!subDir.isInDatabase())
     233      {
     234        dc.saveItem(subDir);
     235      }
     236      dc.commit();
     237        setUnzippedFilesDirectory(subDir);
     238    }
     239    catch (Throwable ex)
     240    {
     241      log.error("--Create subdirectory FAILED", ex);
     242    }
     243    finally
     244    {
     245      if (dc!=null) dc.close();
     246    }
     247           
     248   }
     249
     250  /**
     251    create a sub-directory to contain the unzip files
     252      @param zipFile, the zip file to unpack
     253      @param user, currently logged-in user
     254      @param
    163255   
    164256   */
     
    174266      Directory d = Directory.getById(dc, zipFileDir.getId());
    175267      Directory subDir = d.newSubDirectory();
     268      String fileName = zipFile.getName();
     269        String fileNameNoExt = fileName.substring(0, fileName.indexOf("."));
     270        subDir.setName(fileNameNoExt);
     271        subDir.setDescription("Unzippped directory created at "+new Date());
    176272      if (subDir.isInDatabase())
    177273      {
    178         throw new DatabaseException("The Directory ["+ subDir.getPath().toString()+ "] already exists");
     274        throw new ItemAlreadyExistsException("The Directory ["+ subDir.getPath().toString()+ "] already exists");
    179275      }
    180276      else if (!subDir.isInDatabase())
    181277      {
    182         String fileName = zipFile.getName();
    183           String fileNameNoExt = fileName.substring(0, fileName.indexOf("."));
    184           subDir.setName(fileNameNoExt);
    185           subDir.setDescription("Unzippped directory created at "+new Date());
    186           dc.saveItem(subDir);
     278        dc.saveItem(subDir);
    187279      }
    188280      dc.commit();
     
    192284    {
    193285      log.error("--Create subdirectory FAILED", ex);
     286      //throw new BaseException();
    194287    }
    195288    finally
     
    200293   }
    201294
    202 
    203295  void setUnzippedFilesDirectory(Directory unzippedFilesDirectory)
    204296  {
     
    210302    return unzippedFilesDirectory;
    211303  }
     304 
     305  private String getTime(String pattern)
     306  {
     307    SimpleDateFormat formatter;
     308    Locale currentLocale = Locale.getDefault();
     309    formatter = new SimpleDateFormat(pattern, currentLocale);
     310    String timeStamp = formatter.format(new Date());
     311    return timeStamp;
     312  }
    212313}
Note: See TracChangeset for help on using the changeset viewer.