root/galaxy-central/lib/galaxy/datatypes/ngsindex.py @ 2

リビジョン 2, 2.7 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1"""
2NGS indexes
3"""
4import logging
5from metadata import MetadataElement
6from images import Html
7
8log = logging.getLogger(__name__)
9
10class BowtieIndex( Html ):
11    """
12    base class for BowtieIndex
13    is subclassed by BowtieColorIndex and BowtieBaseIndex
14    """
15    MetadataElement( name="base_name", desc="base name for this index set", default='galaxy_generated_bowtie_index', set_in_upload=True, readonly=True )
16    MetadataElement( name="sequence_space", desc="sequence_space for this index set", default='unknown', set_in_upload=True, readonly=True )
17   
18    file_ext = 'bowtie_index'
19    is_binary = True
20    composite_type = 'auto_primary_file'
21    allow_datatype_change = False
22
23    def generate_primary_file( self, dataset = None ):
24        """
25        This is called only at upload to write the html file
26        cannot rename the datasets here - they come with the default unfortunately
27        """
28        return '<html><head></head><body>AutoGenerated Primary File for Composite Dataset</body></html>'
29   
30    def regenerate_primary_file(self,dataset):
31        """
32        cannot do this until we are setting metadata
33        """
34        bn = dataset.metadata.base_name
35        flist = os.listdir(dataset.extra_files_path)
36        rval = ['<html><head><title>Files for Composite Dataset %s</title></head><p/>Comprises the following files:<p/><ul>' % (bn)]
37        for i,fname in enumerate(flist):
38            sfname = os.path.split(fname)[-1]
39            rval.append( '<li><a href="%s">%s</a>' % ( sfname, sfname ) )
40        rval.append( '</ul></html>' )
41        f = file(dataset.file_name,'w')
42        f.write("\n".join( rval ))
43        f.write('\n')
44        f.close()
45
46    def set_peek( self, dataset, is_multi_byte=False ):
47        if not dataset.dataset.purged:
48            dataset.peek  = "Bowtie index file (%s)" % ( dataset.metadata.sequence_space )
49            dataset.blurb = "%s space" % ( dataset.metadata.sequence_space )
50        else:
51            dataset.peek = 'file does not exist'
52            dataset.blurb = 'file purged from disk'
53    def display_peek( self, dataset ):
54        try:
55            return dataset.peek
56        except:
57            return "Bowtie index file"
58    def sniff( self, filename ):
59        return False
60
61class BowtieColorIndex( BowtieIndex ):
62    """
63    Bowtie color space index
64    """
65    MetadataElement( name="sequence_space", desc="sequence_space for this index set", default='color', set_in_upload=True, readonly=True )
66   
67    file_ext = 'bowtie_color_index'
68   
69class BowtieBaseIndex( BowtieIndex ):
70    """
71    Bowtie base space index
72    """
73    MetadataElement( name="sequence_space", desc="sequence_space for this index set", default='base', set_in_upload=True, readonly=True )
74   
75    file_ext = 'bowtie_base_index'
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。