annotate compressed.py @ 1:ddf34b1d55c8 default tip

fix wrong Tgdb format
author cmonjeau
date Fri, 11 Sep 2015 07:59:36 +0000
parents 9e4c4b66b4a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
1
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
2 """
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
3 Compressed classes
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
4 """
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
5
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
6 import mimetypes, logging, os, os.path, sys, time, tempfile, shutil, string, glob, re, zipfile, tarfile
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
7
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
8 from galaxy.datatypes.data import Data
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
9 from galaxy.datatypes.sniff import *
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
10 from cgi import escape
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
11 from inspect import isclass
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
12 from galaxy import util
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
13 from galaxy.datatypes.metadata import MetadataElement #import directly to maintain ease of use in Datatype class definitions
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
14 from galaxy.util import inflector
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
15 from galaxy.util.bunch import Bunch
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
16 from galaxy.util.odict import odict
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
17 from galaxy.util.sanitize_html import sanitize_html
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
18 from galaxy.datatypes.checkers import *
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
19 from galaxy.datatypes import data
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
20
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
21
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
22 log = logging.getLogger(__name__)
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
23
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
24 class Zip( Data ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
25 file_ext = "zip"
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
26
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
27 def set_peek( self, dataset, is_multi_byte=False ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
28 """Set the peek and blurb text"""
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
29 if not dataset.dataset.purged:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
30 dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
31 else:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
32 dataset.peek = 'file does not exist'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
33 dataset.blurb = 'file purged from disk'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
34
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
35 def sniff( self, filename ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
36 if (check_zip( filename )):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
37 return True
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
38 return False
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
39
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
40
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
41 class Tgz( Data ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
42 file_ext = "tar.gz"
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
43
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
44 def set_peek( self, dataset, is_multi_byte=False ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
45 """Set the peek and blurb text"""
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
46 if not dataset.dataset.purged:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
47 dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
48 else:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
49 dataset.peek = 'file does not exist'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
50 dataset.blurb = 'file purged from disk'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
51
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
52 def sniff( self, filename ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
53 is_gzipped, is_valid = check_gzip( filename )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
54 is_tar = tarfile.is_tarfile( filename )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
55 return (is_gzipped and is_valid and is_tar)
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
56
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
57
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
58 class Tbz2( Data ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
59 file_ext = "tar.bz2"
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
60
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
61 def set_peek( self, dataset, is_multi_byte=False ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
62 """Set the peek and blurb text"""
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
63 if not dataset.dataset.purged:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
64 dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
65 else:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
66 dataset.peek = 'file does not exist'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
67 dataset.blurb = 'file purged from disk'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
68
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
69 def sniff( self, filename ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
70 is_bzipped, is_valid = check_bz2( filename )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
71 is_tar = tarfile.is_tarfile( filename )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
72 return (is_bzipped and is_valid and is_tar)
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
73
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
74
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
75 class Fastqgz( Data ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
76 file_ext = "fastq.gz"
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
77
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
78 def set_peek( self, dataset, is_multi_byte=False ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
79 """Set the peek and blurb text"""
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
80 if not dataset.dataset.purged:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
81 dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
82 else:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
83 dataset.peek = 'file does not exist'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
84 dataset.blurb = 'file purged from disk'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
85
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
86 def sniff( self, filename ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
87 is_gzipped, is_valid = check_gzip( filename )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
88 is_tar = tarfile.is_tarfile( filename )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
89 return (is_gzipped and is_valid and not is_tar)
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
90
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
91 class Fastqbz2( Data ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
92 file_ext = "fastq.bz2"
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
93
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
94 def set_peek( self, dataset, is_multi_byte=False ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
95 """Set the peek and blurb text"""
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
96 if not dataset.dataset.purged:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
97 dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
98 else:
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
99 dataset.peek = 'file does not exist'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
100 dataset.blurb = 'file purged from disk'
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
101
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
102 def sniff( self, filename ):
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
103 is_bzipped, is_valid = check_bz2( filename )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
104 is_tar = tarfile.is_tarfile( filename )
9e4c4b66b4a0 Imported from capsule None
cmonjeau
parents:
diff changeset
105 return (is_bzipped and is_valid and not is_tar)