diff -r 837aabec314e tools/data_source/upload.py
--- a/tools/data_source/upload.py	Tue Jun 08 13:25:15 2010 -0400
+++ b/tools/data_source/upload.py	Mon Jun 21 17:00:04 2010 -0400
@@ -118,15 +118,13 @@
         return ( False, False, None )
     zip_file = zipfile.ZipFile( temp_name, "r" )
     # Make sure the archive consists of valid files.  The current rules are:
-    # 1. Archives can only include .ab1, .scf or .txt files
+    # 1. Archives can only include any 'unsniffable_binary_formats' (binseq.zip), 'txt' (txtseq.zip) or just one file in any other extension
     # 2. All file extensions within an archive must be the same
     name = zip_file.namelist()[0]
     try:
         test_ext = name.split( "." )[1].strip().lower()
     except:
         return ( True, False, None )
-    if not ( test_ext in unsniffable_binary_formats or test_ext == 'txt' ):
-        return ( True, False, test_ext )
     for name in zip_file.namelist():
         ext = name.split( "." )[1].strip().lower()
         if ext != test_ext:
@@ -210,18 +208,46 @@
                 return
             elif is_zipped and is_valid:
                 # Currently, we force specific tools to handle this case.  We also require the user
-                # to manually set the incoming file_type
+                # to manually set the incoming file_type (only for 'binseq.zip' and 'txtseq.zip'
                 if ( test_ext in unsniffable_binary_formats ) and dataset.file_type != 'binseq.zip':
                     file_err( "Invalid 'File Format' for archive consisting of binary files - use 'Binseq.zip'", dataset, json_file )
                     return
                 elif test_ext == 'txt' and dataset.file_type != 'txtseq.zip':
                     file_err( "Invalid 'File Format' for archive consisting of text files - use 'Txtseq.zip'", dataset, json_file )
                     return
-                if not ( dataset.file_type == 'binseq.zip' or dataset.file_type == 'txtseq.zip' ):
-                    file_err( "You must manually set the 'File Format' to either 'Binseq.zip' or 'Txtseq.zip' when uploading zip files", dataset, json_file )
-                    return
-                data_type = 'zip'
-                ext = dataset.file_type
+                else :
+				    dataset.file_type = test_ext
+
+                # Extract file if it's neither 'binseq.zip' nor 'txtseq.zip'
+                if dataset.file_type != 'binseq.zip' and dataset.file_type != 'txtseq.zip':
+                     # Extract one file from Zip. Note: this should be improved
+                     ext = dataset.file_type
+                     data_type = ext
+                     zippedFile = zipfile.ZipFile(dataset.path)
+                     unzippedFiles = 0;
+                     for i, name in enumerate(zippedFile.namelist()):
+                         if not name.endswith('/'):
+                             # Only allow one file per zip archive. Note: This should be improved
+                             if unzippedFiles >= 1 : 
+                                 file_err( "Invalid 'File Format': Only one file per zip archive is allowed", dataset, json_file )
+                                 return
+
+                             fd, uncompressed = tempfile.mkstemp( prefix='data_id_%s_upload_zip_' % dataset.dataset_id, dir=os.path.dirname( dataset.path ), text=False )
+                             try:
+                                 # Extract a zipped file
+                                 outfile = open(uncompressed, 'wb')
+                                 outfile.write(zippedFile.read(name))
+                                 outfile.flush()
+                                 outfile.close()
+                                 shutil.move( uncompressed, dataset.path )
+                                 dataset.name = name
+                                 unzippedFiles += 1
+                             except IOError:
+                                 os.close( fd )
+                                 os.remove( uncompressed )
+                                 file_err( 'Problem decompressing zipped data', dataset, json_file )
+                                 return
+
         if not data_type:
             if check_binary( dataset.path ):
                 # We have a binary dataset, but it is not Bam or Sff
