Mercurial > repos > bgruening > upload_testing
comparison homer.py @ 56:07a5042bbe90
Uploaded
author | bgruening |
---|---|
date | Mon, 12 Aug 2013 14:25:53 -0400 |
parents | e9cd105a8856 |
children |
comparison
equal
deleted
inserted
replaced
55:e9cd105a8856 | 56:07a5042bbe90 |
---|---|
1 """ | 1 """ |
2 HOMER special datatypes | 2 HOMER special datatypes |
3 """ | 3 """ |
4 | 4 import os |
5 from galaxy.datatypes.data import get_file_peek | 5 from galaxy.datatypes.data import get_file_peek |
6 from galaxy.datatypes.data import Text, Data | 6 from galaxy.datatypes.data import Text, Data |
7 from galaxy.datatypes.metadata import MetadataElement | 7 from galaxy.datatypes.metadata import MetadataElement |
8 from galaxy.datatypes.images import Html | 8 from galaxy.datatypes.images import Html |
9 | 9 |
10 | 10 |
11 class TagDirectory( Text ): | 11 class TagDirectory( Html ): |
12 """Base class for HOMER's Tag Directory datatype.""" | 12 """Base class for HOMER's Tag Directory datatype.""" |
13 | 13 |
14 file_ext = 'homer_tagdir' | 14 file_ext = 'homer_tagdir' |
15 composite_type = 'auto_primary_file' | 15 composite_type = 'auto_primary_file' |
16 allow_datatype_change = False | 16 allow_datatype_change = False |
17 | 17 |
18 def __init__(self, **kwd): | 18 def __init__(self, **kwd): |
19 Text.__init__( self, **kwd ) | 19 Html.__init__( self, **kwd ) |
20 #self.add_composite_file('tagInfo.txt', description = 'basic configuration information', mimetype = 'text/html') # Contains basic configuration information | 20 #self.add_composite_file('tagInfo.txt', description = 'basic configuration information', mimetype = 'text/html') # Contains basic configuration information |
21 self.add_composite_file('tagLengthDistribution.txt', description = 'histogram of read lengths used for alignment', mimetype = 'text/html') # File contains a histogram of read lengths used for alignment. | 21 self.add_composite_file('tagLengthDistribution.txt', description = 'histogram of read lengths used for alignment', mimetype = 'text/html') # File contains a histogram of read lengths used for alignment. |
22 self.add_composite_file('tagCountDistribution.txt', description = 'histogram of clonal read depth, showing the number of reads per unique position', mimetype = 'text/html') # File contains a histogram of clonal read depth, showing the number of reads per unique position. | 22 self.add_composite_file('tagCountDistribution.txt', description = 'histogram of clonal read depth, showing the number of reads per unique position', mimetype = 'text/html') # File contains a histogram of clonal read depth, showing the number of reads per unique position. |
23 self.add_composite_file('tagAutocorrelation.txt', description = 'distribution of distances between adjacent reads in the genome', mimetype = 'text/html') # The autocorrelation routine creates a distribution of distances between adjacent reads in the genome. | 23 self.add_composite_file('tagAutocorrelation.txt', description = 'distribution of distances between adjacent reads in the genome', mimetype = 'text/html') # The autocorrelation routine creates a distribution of distances between adjacent reads in the genome. |
24 self.add_composite_file('tagFreq.txt', description = "nucleotide and dinucleotide frequencies as a function of distance from the 5' end of all reads", mimetype = 'text/html', optional=True) # Calculates the nucleotide and dinucleotide frequencies as a function of distance from the 5' end of all reads. | 24 self.add_composite_file('tagFreq.txt', description = "nucleotide and dinucleotide frequencies as a function of distance from the 5' end of all reads", mimetype = 'text/html', optional=True) # Calculates the nucleotide and dinucleotide frequencies as a function of distance from the 5' end of all reads. |
27 self.add_composite_file('genomeGCcontent.txt', description = 'Distribution of fragment GC%-content at each location in the genome', mimetype = 'text/html', optional=True) # Distribution of fragment GC%-content at each location in the genome. | 27 self.add_composite_file('genomeGCcontent.txt', description = 'Distribution of fragment GC%-content at each location in the genome', mimetype = 'text/html', optional=True) # Distribution of fragment GC%-content at each location in the genome. |
28 | 28 |
29 | 29 |
30 def regenerate_primary_file(self,dataset): | 30 def regenerate_primary_file(self,dataset): |
31 """ | 31 """ |
32 cannot do this until we are setting metadata | 32 regenerate the index file after metadata generation |
33 """ | 33 """ |
34 flist = os.listdir(dataset.extra_files_path) | 34 rval = ['<html><head><title>HOMER database files</title></head>'] |
35 rval = ['<html><head><title>CuffDiff Output</title></head>'] | |
36 rval.append('<body>') | 35 rval.append('<body>') |
37 rval.append('<p/>CuffDiff Outputs:<p/><ul>') | 36 rval.append('<p/>CuffDiff Outputs:<p/><ul>') |
38 for i,fname in enumerate(flist): | 37 for fname in os.listdir(dataset.extra_files_path): |
39 sfname = os.path.split(fname)[-1] | 38 sfname = os.path.split(fname)[-1] |
40 rval.append( '<li><a href="%s" type="text/html">%s</a>' % ( sfname, sfname ) ) | 39 rval.append( '<li><a href="%s" type="text/html">%s</a>' % ( sfname, sfname ) ) |
41 rval.append( '</ul></body></html>' ) | 40 rval.append( '</ul></body></html>' ) |
42 f = file(dataset.file_name,'w') | 41 f = file( dataset.file_name, 'w' ) |
43 f.write("\n".join( rval )) | 42 f.write( '%s\n' % '\n'.join( rval ) ) |
44 f.write('\n') | |
45 f.close() | 43 f.close() |
46 | 44 if not dataset.info: |
47 def set_meta( self, dataset, **kwd ): | 45 dataset.info = 'HOMER datatype object' |
48 Text.set_meta( self, dataset, **kwd ) | 46 if not dataset.blurb: |
49 self.regenerate_primary_file(dataset) | 47 dataset.blurb = 'Composite file - HOMER' |
50 | 48 return True |
51 | 49 |
52 def generate_primary_file( self, dataset = None ): | 50 def generate_primary_file( self, dataset = None ): |
53 rval = ['<html><head><title>HOMER database files</title></head><ul>'] | 51 rval = ['<html><head><title>HOMER database files</title></head><ul>'] |
54 for composite_name, composite_file in self.get_composite_files( dataset = dataset ).iteritems(): | 52 for composite_name, composite_file in self.get_composite_files( dataset = dataset ).iteritems(): |
55 opt_text = '' | 53 opt_text = '' |
56 if composite_file.optional: | 54 if composite_file.optional: |
57 opt_text = ' (optional)' | 55 opt_text = ' (optional)' |
58 rval.append( '<li><a href="%s">%s</a>%s' % ( composite_name, composite_name, opt_text ) ) | 56 rval.append( '<li><a href="%s">%s</a>%s' % ( composite_name, composite_name, opt_text ) ) |
59 rval.append( '</ul></html>' ) | 57 rval.append( '</ul></html>' ) |
60 return "\n".join( rval ) | 58 return "\n".join( rval ) |
59 | |
60 def set_meta( self, dataset, **kwd ): | |
61 Html.set_meta( self, dataset, **kwd ) | |
62 self.regenerate_primary_file(dataset) | |
63 | |
61 | 64 |
62 def display_data(self, trans, data, preview=False, filename=None, | 65 def display_data(self, trans, data, preview=False, filename=None, |
63 to_ext=None, size=None, offset=None, **kwd): | 66 to_ext=None, size=None, offset=None, **kwd): |
64 """Apparently an old display method, but still gets called. | 67 """Apparently an old display method, but still gets called. |
65 | 68 |