annotate cuffdata.py @ 9:b6427cdbf6d4

Add MAplot and csDendro
author Jim Johnson <jj@umn.edu>
date Fri, 12 Oct 2012 09:56:02 -0500
parents 9d25b0fd882b
children 45275147ac1e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
1 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
2 CuffData
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
3 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
4 import logging
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
5 import os,os.path,re
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
6 import galaxy.datatypes.data
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
7 from galaxy.datatypes.images import Html
5
9d25b0fd882b Add cuffdatadb datatype (cummeRbund SQLite DB) to cuffdata.py
Jim Johnson <jj@umn.edu>
parents: 1
diff changeset
8 from galaxy.datatypes.binary import Binary
1
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
9 from galaxy import util
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
10 from galaxy.datatypes.metadata import MetadataElement
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
11
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
12 log = logging.getLogger(__name__)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
13
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
14 class CuffDiffData( Html ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
15 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
16 CuffDiff output files:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
17 run.info
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
18 read_groups.info
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
19 cds.count_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
20 cds.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
21 cds.fpkm_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
22 cds.read_group_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
23 cds_exp.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
24 gene_exp.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
25 genes.count_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
26 genes.fpkm_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
27 genes.read_group_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
28 isoform_exp.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
29 isoforms.count_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
30 isoforms.fpkm_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
31 isoforms.read_group_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
32 promoters.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
33 splicing.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
34 tss_group_exp.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
35 tss_groups.count_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
36 tss_groups.fpkm_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
37 tss_groups.read_group_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
38 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
39 file_ext = 'cuffdata'
5
9d25b0fd882b Add cuffdatadb datatype (cummeRbund SQLite DB) to cuffdata.py
Jim Johnson <jj@umn.edu>
parents: 1
diff changeset
40 is_binary = False
1
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
41 composite_type = 'auto_primary_file'
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
42 allow_datatype_change = False
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
43
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
44 def generate_primary_file( self, dataset = None ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
45 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
46 This is called only at upload to write the html file
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
47 cannot rename the datasets here - they come with the default unfortunately
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
48 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
49 return '<html><head></head><body>AutoGenerated Primary File for Composite Dataset</body></html>'
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
50
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
51 def regenerate_primary_file(self,dataset):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
52 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
53 cannot do this until we are setting metadata
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
54 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
55 flist = os.listdir(dataset.extra_files_path)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
56 rval = ['<html><head><title>CuffDiff Output</title></head>']
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
57 rval.append('<body>')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
58 rval.append('<p/>CuffDiff Outputs:<p/><ul>')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
59 for i,fname in enumerate(flist):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
60 sfname = os.path.split(fname)[-1]
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
61 rval.append( '<li><a href="%s" type="text/html">%s</a>' % ( sfname, sfname ) )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
62 rval.append( '</ul></body></html>' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
63 f = file(dataset.file_name,'w')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
64 f.write("\n".join( rval ))
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
65 f.write('\n')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
66 f.close()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
67
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
68 def set_meta( self, dataset, **kwd ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
69 Html.set_meta( self, dataset, **kwd )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
70 self.regenerate_primary_file(dataset)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
71
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
72 def sniff( self, filename ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
73 return False
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
74
5
9d25b0fd882b Add cuffdatadb datatype (cummeRbund SQLite DB) to cuffdata.py
Jim Johnson <jj@umn.edu>
parents: 1
diff changeset
75 class CuffDataDB( Binary ):
9d25b0fd882b Add cuffdatadb datatype (cummeRbund SQLite DB) to cuffdata.py
Jim Johnson <jj@umn.edu>
parents: 1
diff changeset
76 file_ext = 'cuffdata'
9d25b0fd882b Add cuffdatadb datatype (cummeRbund SQLite DB) to cuffdata.py
Jim Johnson <jj@umn.edu>
parents: 1
diff changeset
77 is_binary = True
9d25b0fd882b Add cuffdatadb datatype (cummeRbund SQLite DB) to cuffdata.py
Jim Johnson <jj@umn.edu>
parents: 1
diff changeset
78 allow_datatype_change = False