annotate CADDSuite-1.5/galaxyconfigs/molFiles.py @ 16:1a24aef40d01 draft

Deleted selected files
author marcel
date Tue, 24 Jul 2012 11:10:07 -0400
parents ac342506cd4e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
2
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
3 import data
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
4 import logging
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
5 from galaxy.datatypes.sniff import *
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
6 import commands
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
7
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
8 log = logging.getLogger(__name__)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
9
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
10 class GenericMolFile( data.Text ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
11 file_ext = "mol2/sdf/drf"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
12 def check_filetype( self,filename ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
13 self.no_mols = commands.getstatusoutput("grep -c \\$\\$\\$\\$ "+filename)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
14 if (self.no_mols[0] == 0) & (self.no_mols[1] > 0):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
15 self.file_ext="sdf"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
16 return True
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
17 self.no_mols = commands.getstatusoutput("grep -c @\<TRIPOS\>MOLECULE "+filename)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
18 if (self.no_mols[0] == 0) & (self.no_mols[1] > 0):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
19 self.file_ext="mol2"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
20 return True
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
21 self.no_mols = commands.getstatusoutput("grep -c \"ligand id\" "+filename)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
22 if (self.no_mols[0] == 0) & (self.no_mols[1] > 0):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
23 self.file_ext="drf"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
24 return True
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
25 self.no_mols = commands.getstatusoutput("grep -c HEADER "+filename)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
26 if (self.no_mols[0] == 0) & (self.no_mols[1] > 0):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
27 self.file_ext="pdb"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
28 return True
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
29 return False
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
30
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
31 def set_peek( self, dataset, is_multi_byte=False ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
32 if not dataset.dataset.purged:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
33 if(self.check_filetype(dataset.file_name)) :
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
34 if (self.no_mols[1] == '1'):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
35 dataset.blurb = "1 molecule"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
36 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
37 dataset.blurb = "%s molecules"%self.no_mols[1]
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
38 dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte )
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
39 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
40 dataset.peek = 'file does not exist'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
41 dataset.blurb = 'file purged from disk'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
42
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
43 def get_mime(self):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
44 return 'text/plain'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
45
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
46
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
47 class GenericMultiMolFile( GenericMolFile ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
48 def set_peek( self, dataset, is_multi_byte=False ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
49 if not dataset.dataset.purged:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
50 self.sniff(dataset.file_name)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
51 if (self.no_mols[1] == '1'):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
52 dataset.blurb = "1 molecule"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
53 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
54 dataset.blurb = "%s molecules"%self.no_mols[1]
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
55 dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte )
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
56 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
57 dataset.peek = 'file does not exist'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
58 dataset.blurb = 'file purged from disk'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
59
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
60 class SDF( GenericMultiMolFile ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
61 file_ext = "sdf"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
62 def sniff( self, filename ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
63 self.no_mols = commands.getstatusoutput("grep -c \\$\\$\\$\\$ "+filename)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
64 if (self.no_mols[0] == 0) & (self.no_mols[1] > 0):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
65 return True
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
66 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
67 return False
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
68
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
69 class MOL2( GenericMultiMolFile ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
70 file_ext = "mol2"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
71 def sniff( self, filename ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
72 self.no_mols = commands.getstatusoutput("grep -c @\<TRIPOS\>MOLECULE "+filename)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
73 if (self.no_mols[0] == 0) & (self.no_mols[1] > 0):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
74 return True
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
75 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
76 return False
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
77
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
78 class DRF( GenericMultiMolFile ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
79 file_ext = "drf"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
80 def sniff( self, filename ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
81 self.no_mols = commands.getstatusoutput("grep -c \"ligand id\" "+filename)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
82 if (self.no_mols[0] == 0) & (self.no_mols[1] > 0):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
83 return True
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
84 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
85 return False
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
86
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
87 class PDB( GenericMolFile ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
88 file_ext = "pdb"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
89 def sniff( self, filename ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
90 self.no_mols = commands.getstatusoutput("grep -c HEADER "+filename)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
91 if (self.no_mols[0] == 0) & (self.no_mols[1] > 0):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
92 return True
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
93 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
94 return False
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
95 def set_peek( self, dataset, is_multi_byte=False ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
96 #def set_peek( self, dataset, line_count=None, is_multi_byte=False ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
97 if not dataset.dataset.purged:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
98 res = commands.getstatusoutput("lib/galaxy/datatypes/countResidues.sh "+dataset.file_name)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
99 dataset.peek = res[1]
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
100 self.sniff(dataset.file_name)
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
101 if (self.no_mols[1] == '1'):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
102 dataset.blurb = "1 protein structure"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
103 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
104 dataset.blurb = "%s protein structures"%self.no_mols[1]
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
105 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
106 dataset.peek = 'file does not exist'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
107 dataset.blurb = 'file purged from disk'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
108
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
109 class grd ( data.Text ) :
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
110 file_ext = "grd"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
111 def set_peek( self, dataset, is_multi_byte=False ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
112 if not dataset.dataset.purged:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
113 #dataset.peek = ""
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
114 dataset.blurb = "score-grids for docking"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
115 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
116 dataset.peek = 'file does not exist'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
117 dataset.blurb = 'file purged from disk'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
118
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
119 class grdtgz ( data.Text ) :
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
120 file_ext = "grd.tgz"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
121 def set_peek( self, dataset, is_multi_byte=False ):
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
122 if not dataset.dataset.purged:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
123 #dataset.peek = ""
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
124 dataset.blurb = "compressed score-grids for docking"
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
125 else:
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
126 dataset.peek = 'file does not exist'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
127 dataset.blurb = 'file purged from disk'
ac342506cd4e CADDSuite version 1.5
Marcel Schumann <schumann.marcel@gmail.com>
parents:
diff changeset
128