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