annotate cuffdata.py @ 4:77ca14d2bb3d

cuffdiff_mds_plot description
author Jim Johnson <jj@umn.edu>
date Mon, 08 Oct 2012 16:20:35 -0500
parents 6a9bc26ab8d9
children 9d25b0fd882b
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
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
8 from galaxy import util
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
9 from galaxy.datatypes.metadata import MetadataElement
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
10
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
11 log = logging.getLogger(__name__)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
12
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
13 class CuffDiffData( Html ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
14 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
15 CuffDiff output files:
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
16 run.info
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
17 read_groups.info
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
18 cds.count_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
19 cds.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
20 cds.fpkm_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
21 cds.read_group_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
22 cds_exp.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
23 gene_exp.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
24 genes.count_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
25 genes.fpkm_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
26 genes.read_group_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
27 isoform_exp.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
28 isoforms.count_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
29 isoforms.fpkm_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
30 isoforms.read_group_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
31 promoters.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
32 splicing.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
33 tss_group_exp.diff
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
34 tss_groups.count_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
35 tss_groups.fpkm_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
36 tss_groups.read_group_tracking
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
37 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
38 file_ext = 'cuffdata'
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
39 is_binary = True
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
40 composite_type = 'auto_primary_file'
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
41 allow_datatype_change = False
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
42
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
43 def generate_primary_file( self, dataset = None ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
44 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
45 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
46 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
47 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
48 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
49
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
50 def regenerate_primary_file(self,dataset):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
51 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
52 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
53 """
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
54 flist = os.listdir(dataset.extra_files_path)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
55 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
56 rval.append('<body>')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
57 rval.append('<p/>CuffDiff Outputs:<p/><ul>')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
58 for i,fname in enumerate(flist):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
59 sfname = os.path.split(fname)[-1]
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
60 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
61 rval.append( '</ul></body></html>' )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
62 f = file(dataset.file_name,'w')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
63 f.write("\n".join( rval ))
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
64 f.write('\n')
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
65 f.close()
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
66
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
67 def set_meta( self, dataset, **kwd ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
68 Html.set_meta( self, dataset, **kwd )
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
69 self.regenerate_primary_file(dataset)
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
70
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
71 def sniff( self, filename ):
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
72 return False
6a9bc26ab8d9 Added cuffdata and cuffdatadb datatypes, cuffdiff multiselect outputs
Jim Johnson <jj@umn.edu>
parents:
diff changeset
73