Mercurial > repos > bgruening > upload_testing
comparison homer.py @ 54:675d25a0b9d4
Uploaded
| author | bgruening |
|---|---|
| date | Mon, 12 Aug 2013 08:16:21 -0400 |
| parents | |
| children | e9cd105a8856 |
comparison
equal
deleted
inserted
replaced
| 53:a281b5931ffb | 54:675d25a0b9d4 |
|---|---|
| 1 """ | |
| 2 HOMER special datatypes | |
| 3 """ | |
| 4 | |
| 5 from galaxy.datatypes.data import get_file_peek | |
| 6 from galaxy.datatypes.data import Text, Data | |
| 7 from galaxy.datatypes.metadata import MetadataElement | |
| 8 from galaxy.datatypes.images import Html | |
| 9 | |
| 10 | |
| 11 class TagDirectory(object): | |
| 12 """Base class for HOMER's Tag Directory datatype.""" | |
| 13 | |
| 14 file_ext = 'homer_tagdir' | |
| 15 composite_type = 'auto_primary_file' | |
| 16 allow_datatype_change = False | |
| 17 | |
| 18 def __init__(self, **kwd): | |
| 19 Text.__init__( self, **kwd ) | |
| 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. | |
| 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. | |
| 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. | |
| 25 self.add_composite_file('tagFreqUniq.txt', description = "nucleotide and dinucleotide frequencies as a function of distance from the 5' end of all reads (counted only once)", mimetype = 'text/html', optional=True) # Same as tagFreq.txt, however individual genomic positions are only counted once. | |
| 26 self.add_composite_file('tagGCcontent.txt', description = 'Distribution of fragment GC%-content', mimetype = 'text/html', optional=True) # Distribution of fragment GC%-content. | |
| 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 | |
| 29 def generate_primary_file( self, dataset = None ): | |
| 30 rval = ['<html><head><title>HOMER database files</title></head><ul>'] | |
| 31 for composite_name, composite_file in self.get_composite_files( dataset = dataset ).iteritems(): | |
| 32 opt_text = '' | |
| 33 if composite_file.optional: | |
| 34 opt_text = ' (optional)' | |
| 35 rval.append( '<li><a href="%s">%s</a>%s' % ( composite_name, composite_name, opt_text ) ) | |
| 36 rval.append( '</ul></html>' ) | |
| 37 return "\n".join( rval ) | |
| 38 | |
| 39 def display_data(self, trans, data, preview=False, filename=None, | |
| 40 to_ext=None, size=None, offset=None, **kwd): | |
| 41 """Apparently an old display method, but still gets called. | |
| 42 | |
| 43 This allows us to format the data shown in the central pane via the "eye" icon. | |
| 44 """ | |
| 45 return "This is a HOMER database." | |
| 46 | |
| 47 def set_peek( self, dataset, is_multi_byte=False ): | |
| 48 """Set the peek and blurb text.""" | |
| 49 if not dataset.dataset.purged: | |
| 50 dataset.peek = "HOMER database (multiple files)" | |
| 51 dataset.blurb = "HOMER database (multiple files)" | |
| 52 else: | |
| 53 dataset.peek = 'file does not exist' | |
| 54 dataset.blurb = 'file purged from disk' | |
| 55 | |
| 56 def display_peek( self, dataset ): | |
| 57 """Create HTML content, used for displaying peek.""" | |
| 58 try: | |
| 59 return dataset.peek | |
| 60 except: | |
| 61 return "HOMER database (multiple files)" | |
| 62 | |
| 63 def get_mime(self): | |
| 64 """Returns the mime type of the datatype (pretend it is text for peek)""" | |
| 65 return 'text/plain' | |
| 66 | |
| 67 def merge(split_files, output_file): | |
| 68 """Merge HOMER databases (not implemented).""" | |
| 69 raise NotImplementedError("Merging HOMER databases is not supported") | |
| 70 | |
| 71 def split( cls, input_datasets, subdir_generator_function, split_params): | |
| 72 """Split a HOMER database (not implemented).""" | |
| 73 if split_params is None: | |
| 74 return None | |
| 75 raise NotImplementedError("Can't split HOMER databases") | |
| 76 |
