Mercurial > repos > iuc > snpeff
view lib/galaxy/datatypes/snpeff.py @ 0:e8adfc4c0a6b draft
Uploaded
author | iuc |
---|---|
date | Wed, 11 Dec 2013 08:53:32 -0500 |
parents | |
children |
line wrap: on
line source
""" SnpEff datatypes """ import os,os.path,re,sys import galaxy.datatypes.data from galaxy.datatypes.data import Text from galaxy.datatypes.metadata import MetadataElement class SnpEffDb( Text ): """Class describing an IGV tiled data file (TDF) .tdf binary file""" file_ext = "snpeffdb" MetadataElement( name="genome_version", default=None, desc="Genome Version", readonly=True, visible=True, no_value=None ) MetadataElement( name="regulation", default=[], desc="Regulation Names", readonly=True, visible=True, no_value=[] ) MetadataElement( name="annotation", default=[], desc="Annotation Names", readonly=True, visible=True, no_value=[] ) def __init__( self, **kwd ): Text.__init__( self, **kwd ) def set_meta( self, dataset, **kwd ): Text.set_meta(self, dataset, **kwd ) data_dir = dataset.extra_files_path ## search data_dir/genome_version for files regulation_pattern = 'regulation_(.+).bin' # annotation files that are included in snpEff by a flag annotations_dict = {'nextProt.bin' : '-nextprot','motif.bin': '-motif'} regulations = [] annotations = [] if data_dir and os.path.isdir(data_dir): for root, dirs, files in os.walk(data_dir): for fname in files: if fname.startswith('snpEffectPredictor'): # if snpEffectPredictor.bin download succeeded genome_version = os.path.basename(root) dataset.metadata.genome_version = genome_version else: m = re.match(regulation_pattern,fname) if m: name = m.groups()[0] regulations.append(name) elif fname in annotations_dict: value = annotations_dict[fname] name = value.lstrip('-') annotations.append(name) dataset.metadata.regulation = regulations dataset.metadata.annotation = annotations