commit/galaxy-central: 7 new changesets
7 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/5046a675329b/ Changeset: 5046a675329b Branch: snpeff_datatype User: BjoernGruening Date: 2015-01-16 20:38:18+00:00 Summary: add SnpEffDb datatype Affected #: 1 file diff -r b5c7266dbb69f81864d96247ff11be42246e94de -r 5046a675329b6ff33b79a412f4a195b5932dec96 lib/galaxy/datatypes/text.py --- a/lib/galaxy/datatypes/text.py +++ b/lib/galaxy/datatypes/text.py @@ -18,7 +18,6 @@ import logging log = logging.getLogger(__name__) - class Json( Text ): file_ext = "json" @@ -259,3 +258,52 @@ dataset.metadata.comment_lines = comment_lines dataset.metadata.columns = column_count + +class SnpEffDb( Text ): + """Class describing a SnpEff genome build""" + 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=[], optional=True) + MetadataElement( name="annotation", default=[], desc="Annotation Names", readonly=True, visible=True, no_value=[], optional=True) + + 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 + try: + fh = file(dataset.file_name,'w') + fh.write("%s\n" % genome_version) + if annotations: + fh.write("annotations: %s\n" % ','.join(annotations)) + if regulations: + fh.write("regulations: %s\n" % ','.join(regulations)) + fh.close() + except: + pass + https://bitbucket.org/galaxy/galaxy-central/commits/2ce557458f86/ Changeset: 2ce557458f86 Branch: snpeff_datatype User: BjoernGruening Date: 2015-01-16 20:42:08+00:00 Summary: activate snpeffdb and snpeffdbv4 Affected #: 1 file diff -r 5046a675329b6ff33b79a412f4a195b5932dec96 -r 2ce557458f868a44d068b148651cf4c9af6f573f config/datatypes_conf.xml.sample --- a/config/datatypes_conf.xml.sample +++ b/config/datatypes_conf.xml.sample @@ -176,6 +176,8 @@ </datatype><datatype extension="scf" type="galaxy.datatypes.binary:Scf" mimetype="application/octet-stream" display_in_upload="true" description="A binary sequence file in 'scf' format with a '.scf' file extension. You must manually select this 'File Format' when uploading the file." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Scf"/><datatype extension="Sequences" type="galaxy.datatypes.assembly:Sequences" display_in_upload="false"/> + <datatype extension="snpeffdb" type="galaxy.datatypes.snpeff:SnpEffDb" display_in_upload="True"/> + <datatype extension="snpeffdbv4" type="galaxy.datatypes.snpeff:SnpEffDb" subclass="True" display_in_upload="True"/><datatype extension="sff" type="galaxy.datatypes.binary:Sff" mimetype="application/octet-stream" display_in_upload="true" description="A binary file in 'Standard Flowgram Format' with a '.sff' file extension." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Sff"/><datatype extension="svg" type="galaxy.datatypes.images:Image" mimetype="image/svg+xml"/><datatype extension="taxonomy" type="galaxy.datatypes.tabular:Taxonomy" display_in_upload="true"/> https://bitbucket.org/galaxy/galaxy-central/commits/e161cc633e06/ Changeset: e161cc633e06 Branch: snpeff_datatype User: BjoernGruening Date: 2015-01-16 21:07:41+00:00 Summary: add SnpSiftDbNSFP datatype Affected #: 1 file diff -r 2ce557458f868a44d068b148651cf4c9af6f573f -r e161cc633e066626e93ad5892170e22e9d198579 lib/galaxy/datatypes/text.py --- a/lib/galaxy/datatypes/text.py +++ b/lib/galaxy/datatypes/text.py @@ -2,7 +2,6 @@ """ Clearing house for generic text datatypes that are not XML or tabular. """ - from galaxy.datatypes.data import Text from galaxy.datatypes.data import get_file_peek from galaxy.datatypes.data import nice_size @@ -12,6 +11,7 @@ import tempfile import subprocess import json +import gzip import os import re @@ -307,3 +307,72 @@ except: pass + +class SnpSiftDbNSFP( Text ): + """Class describing a dbNSFP database prepared fpr use by SnpSift dbnsfp """ + MetadataElement( name='reference_name', default='dbSNFP' , desc='Reference Name', readonly=True, visible=True, set_in_upload=True, no_value='dbSNFP' ) + MetadataElement( name="bgzip", default=None, desc="dbNSFP bgzip", readonly=True, visible=True, no_value=None ) + MetadataElement( name="index", default=None, desc="Tabix Index File", readonly=True, visible=True, no_value=None) + MetadataElement( name="annotation", default=[], desc="Annotation Names", readonly=True, visible=True, no_value=[] ) + file_ext = "snpsiftdbnsfp" + composite_type = 'auto_primary_file' + allow_datatype_change = False + """ + ## The dbNSFP file is a tabular file with 1 header line + ## The first 4 columns are required to be: chrom pos ref alt + ## These match columns 1,2,4,5 of the VCF file + ## SnpSift requires the file to be block-gzipped and the indexed with samtools tabix + ## Example: + ## Compress using block-gzip algorithm + bgzip dbNSFP2.3.txt + ## Create tabix index + tabix -s 1 -b 2 -e 2 dbNSFP2.3.txt.gz + """ + def __init__( self, **kwd ): + Text.__init__( self, **kwd ) + self.add_composite_file( '%s.grp', description = 'Group File', substitute_name_with_metadata = 'reference_name', is_binary = False ) + self.add_composite_file( '%s.ti', description = '', substitute_name_with_metadata = 'reference_name', is_binary = False ) + def init_meta( self, dataset, copy_from=None ): + Text.init_meta( self, dataset, copy_from=copy_from ) + def generate_primary_file( self, dataset = None ): + """ + This is called only at upload to write the html file + cannot rename the datasets here - they come with the default unfortunately + """ + regenerate_primary_file( self, dataset) + def regenerate_primary_file(self,dataset): + """ + cannot do this until we are setting metadata + """ + annotations = "dbNSFP Annotations: %s\n" % ','.join(dataset.metadata.annotation) + f = open(dataset.file_name,'a') + if dataset.metadata.bgzip: + bn = dataset.metadata.bgzip + f.write(bn) + f.write('\n') + f.write(annotations) + f.close() + def set_meta( self, dataset, overwrite=True, **kwd ): + try: + efp = dataset.extra_files_path + if os.path.exists(efp): + flist = os.listdir(efp) + for i,fname in enumerate(flist): + if fname.endswith('.gz'): + dataset.metadata.bgzip = fname + try: + fh = gzip.open(os.path.join(efp,fname),'r') + buf = fh.read(5000) + lines = buf.splitlines() + headers = lines[0].split('\t') + dataset.metadata.annotation = headers[4:] + except Exception,e: + log.warn("set_meta fname: %s %s" % (fname,str(e))) + finally: + fh.close() + if fname.endswith('.tbi'): + dataset.metadata.index = fname + self.regenerate_primary_file(dataset) + except Exception,e: + log.warn("set_meta fname: %s %s" % (dataset.file_name if dataset and dataset.file_name else 'Unkwown',str(e))) + https://bitbucket.org/galaxy/galaxy-central/commits/11491dfccddb/ Changeset: 11491dfccddb Branch: snpeff_datatype User: BjoernGruening Date: 2015-01-16 21:08:29+00:00 Summary: activate SnpSiftDbNSFP and dbnsfp.tabular Affected #: 1 file diff -r e161cc633e066626e93ad5892170e22e9d198579 -r 11491dfccddbf671a96ea73d78d42666521e4a53 config/datatypes_conf.xml.sample --- a/config/datatypes_conf.xml.sample +++ b/config/datatypes_conf.xml.sample @@ -113,7 +113,7 @@ <converter file="interval_to_bed12_converter.xml" target_datatype="bed12"/><converter file="interval_to_bgzip_converter.xml" target_datatype="bgzip"/><converter file="interval_to_tabix_converter.xml" target_datatype="tabix" depends_on="bgzip"/> - <converter file="interval_to_bigwig_converter.xml" target_datatype="bigwig"/> + <converter file="interval_to_bigwig_converter.xml" target_datatype="bigwig"/><!-- <display file="ucsc/interval_as_bed.xml" inherit="True" /> --><display file="ensembl/ensembl_interval_as_bed.xml" inherit="True"/><display file="gbrowse/gbrowse_interval_as_bed.xml" inherit="True"/> @@ -151,11 +151,11 @@ <datatype extension="mafcustomtrack" type="galaxy.datatypes.sequence:MafCustomTrack"><display file="ucsc/maf_customtrack.xml" /></datatype> - <datatype extension="encodepeak" type="galaxy.datatypes.interval:ENCODEPeak" display_in_upload="True"> - <converter file="encodepeak_to_tabix_converter.xml" target_datatype="tabix" depends_on="bgzip"/> - <converter file="encodepeak_to_bgzip_converter.xml" target_datatype="bgzip"/> - <converter file="bed_gff_or_vcf_to_bigwig_converter.xml" target_datatype="bigwig"/> - </datatype> + <datatype extension="encodepeak" type="galaxy.datatypes.interval:ENCODEPeak" display_in_upload="True"> + <converter file="encodepeak_to_tabix_converter.xml" target_datatype="tabix" depends_on="bgzip"/> + <converter file="encodepeak_to_bgzip_converter.xml" target_datatype="bgzip"/> + <converter file="bed_gff_or_vcf_to_bigwig_converter.xml" target_datatype="bigwig"/> + </datatype><datatype extension="pdf" type="galaxy.datatypes.images:Pdf" mimetype="application/pdf"/><datatype extension="pileup" type="galaxy.datatypes.tabular:Pileup" display_in_upload="true"><converter file="interval_to_bgzip_converter.xml" target_datatype="bgzip"/> @@ -171,13 +171,17 @@ <datatype extension="qual454" type="galaxy.datatypes.qualityscore:QualityScore454" display_in_upload="true"/><datatype extension="Roadmaps" type="galaxy.datatypes.assembly:Roadmaps" display_in_upload="false"/><datatype extension="sam" type="galaxy.datatypes.tabular:Sam" display_in_upload="true"> - <converter file="sam_to_bam.xml" target_datatype="bam"/> - <converter file="sam_to_bigwig_converter.xml" target_datatype="bigwig"/> - </datatype> + <converter file="sam_to_bam.xml" target_datatype="bam"/> + <converter file="sam_to_bigwig_converter.xml" target_datatype="bigwig"/> + </datatype><datatype extension="scf" type="galaxy.datatypes.binary:Scf" mimetype="application/octet-stream" display_in_upload="true" description="A binary sequence file in 'scf' format with a '.scf' file extension. You must manually select this 'File Format' when uploading the file." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Scf"/><datatype extension="Sequences" type="galaxy.datatypes.assembly:Sequences" display_in_upload="false"/> - <datatype extension="snpeffdb" type="galaxy.datatypes.snpeff:SnpEffDb" display_in_upload="True"/> - <datatype extension="snpeffdbv4" type="galaxy.datatypes.snpeff:SnpEffDb" subclass="True" display_in_upload="True"/> + <datatype extension="snpeffdb" type="galaxy.datatypes.text:SnpEffDb" display_in_upload="True"/> + <datatype extension="snpeffdbv4" type="galaxy.datatypes.text:SnpEffDb" subclass="True" display_in_upload="True"/> + <datatype extension="snpsiftdbnsfp" type="galaxy.datatypes.txt:SnpSiftDbNSFP" display_in_upload="True"/> + <datatype extension="dbnsfp.tabular" type="galaxy.datatypes.tabular:Tabular" subclass="True" display_in_upload="True"> + <converter file="tabular_to_dbnsfp.xml" target_datatype="snpsiftdbnsfp"/> + </datatype><datatype extension="sff" type="galaxy.datatypes.binary:Sff" mimetype="application/octet-stream" display_in_upload="true" description="A binary file in 'Standard Flowgram Format' with a '.sff' file extension." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Sff"/><datatype extension="svg" type="galaxy.datatypes.images:Image" mimetype="image/svg+xml"/><datatype extension="taxonomy" type="galaxy.datatypes.tabular:Taxonomy" display_in_upload="true"/> https://bitbucket.org/galaxy/galaxy-central/commits/f4c5ac446f19/ Changeset: f4c5ac446f19 Branch: snpeff_datatype User: BjoernGruening Date: 2015-01-16 21:59:04+00:00 Summary: add converters Affected #: 1 file diff -r 11491dfccddbf671a96ea73d78d42666521e4a53 -r f4c5ac446f191b504ef2d9f31c9e3d33aa29c52e lib/galaxy/datatypes/converters/tabular_to_dbnsfp.xml --- /dev/null +++ b/lib/galaxy/datatypes/converters/tabular_to_dbnsfp.xml @@ -0,0 +1,12 @@ +<tool id="tabular_to_dbnsfp" name="Convert tabular to dbnsfp" version="1.0.0"> + <description></description> + <command interpreter="python">tabular_to_dbnsfp.py $input $dbnsfp.extra_files_path/dbNSFP.gz</command> + <inputs> + <param format="tabular" name="input" type="data" label="Choose a dbnsfp tabular file"/> + </inputs> + <outputs> + <data format="snpsiftdbnsfp" name="dbnsfp"/> + </outputs> + <help> + </help> +</tool> https://bitbucket.org/galaxy/galaxy-central/commits/c862a73eb896/ Changeset: c862a73eb896 Branch: snpeff_datatype User: BjoernGruening Date: 2015-01-17 13:05:44+00:00 Summary: Remove not needed datatype, we now can filter datatypes by metadata. Affected #: 1 file diff -r f4c5ac446f191b504ef2d9f31c9e3d33aa29c52e -r c862a73eb8967624ccfb9c2847a030176a7c4981 config/datatypes_conf.xml.sample --- a/config/datatypes_conf.xml.sample +++ b/config/datatypes_conf.xml.sample @@ -177,7 +177,6 @@ <datatype extension="scf" type="galaxy.datatypes.binary:Scf" mimetype="application/octet-stream" display_in_upload="true" description="A binary sequence file in 'scf' format with a '.scf' file extension. You must manually select this 'File Format' when uploading the file." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Scf"/><datatype extension="Sequences" type="galaxy.datatypes.assembly:Sequences" display_in_upload="false"/><datatype extension="snpeffdb" type="galaxy.datatypes.text:SnpEffDb" display_in_upload="True"/> - <datatype extension="snpeffdbv4" type="galaxy.datatypes.text:SnpEffDb" subclass="True" display_in_upload="True"/><datatype extension="snpsiftdbnsfp" type="galaxy.datatypes.txt:SnpSiftDbNSFP" display_in_upload="True"/><datatype extension="dbnsfp.tabular" type="galaxy.datatypes.tabular:Tabular" subclass="True" display_in_upload="True"><converter file="tabular_to_dbnsfp.xml" target_datatype="snpsiftdbnsfp"/> https://bitbucket.org/galaxy/galaxy-central/commits/482d85dda5d3/ Changeset: 482d85dda5d3 User: jmchilton Date: 2015-01-23 17:12:43+00:00 Summary: Merged in BjoernGruening/galaxy-central-1/snpeff_datatype (pull request #640) Add SnpEff datatypes Affected #: 3 files diff -r 2fd8714c4faeb580f3ccf1591003f10e821397a1 -r 482d85dda5d3546e1d6e9cca6d712d7af8c772ba config/datatypes_conf.xml.sample --- a/config/datatypes_conf.xml.sample +++ b/config/datatypes_conf.xml.sample @@ -113,7 +113,7 @@ <converter file="interval_to_bed12_converter.xml" target_datatype="bed12"/><converter file="interval_to_bgzip_converter.xml" target_datatype="bgzip"/><converter file="interval_to_tabix_converter.xml" target_datatype="tabix" depends_on="bgzip"/> - <converter file="interval_to_bigwig_converter.xml" target_datatype="bigwig"/> + <converter file="interval_to_bigwig_converter.xml" target_datatype="bigwig"/><!-- <display file="ucsc/interval_as_bed.xml" inherit="True" /> --><display file="ensembl/ensembl_interval_as_bed.xml" inherit="True"/><display file="gbrowse/gbrowse_interval_as_bed.xml" inherit="True"/> @@ -152,11 +152,11 @@ <datatype extension="mafcustomtrack" type="galaxy.datatypes.sequence:MafCustomTrack"><display file="ucsc/maf_customtrack.xml" /></datatype> - <datatype extension="encodepeak" type="galaxy.datatypes.interval:ENCODEPeak" display_in_upload="True"> - <converter file="encodepeak_to_tabix_converter.xml" target_datatype="tabix" depends_on="bgzip"/> - <converter file="encodepeak_to_bgzip_converter.xml" target_datatype="bgzip"/> - <converter file="bed_gff_or_vcf_to_bigwig_converter.xml" target_datatype="bigwig"/> - </datatype> + <datatype extension="encodepeak" type="galaxy.datatypes.interval:ENCODEPeak" display_in_upload="True"> + <converter file="encodepeak_to_tabix_converter.xml" target_datatype="tabix" depends_on="bgzip"/> + <converter file="encodepeak_to_bgzip_converter.xml" target_datatype="bgzip"/> + <converter file="bed_gff_or_vcf_to_bigwig_converter.xml" target_datatype="bigwig"/> + </datatype><datatype extension="pdf" type="galaxy.datatypes.images:Pdf" mimetype="application/pdf"/><datatype extension="pileup" type="galaxy.datatypes.tabular:Pileup" display_in_upload="true"><converter file="interval_to_bgzip_converter.xml" target_datatype="bgzip"/> @@ -172,11 +172,16 @@ <datatype extension="qual454" type="galaxy.datatypes.qualityscore:QualityScore454" display_in_upload="true"/><datatype extension="Roadmaps" type="galaxy.datatypes.assembly:Roadmaps" display_in_upload="false"/><datatype extension="sam" type="galaxy.datatypes.tabular:Sam" display_in_upload="true"> - <converter file="sam_to_bam.xml" target_datatype="bam"/> - <converter file="sam_to_bigwig_converter.xml" target_datatype="bigwig"/> - </datatype> + <converter file="sam_to_bam.xml" target_datatype="bam"/> + <converter file="sam_to_bigwig_converter.xml" target_datatype="bigwig"/> + </datatype><datatype extension="scf" type="galaxy.datatypes.binary:Scf" mimetype="application/octet-stream" display_in_upload="true" description="A binary sequence file in 'scf' format with a '.scf' file extension. You must manually select this 'File Format' when uploading the file." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Scf"/><datatype extension="Sequences" type="galaxy.datatypes.assembly:Sequences" display_in_upload="false"/> + <datatype extension="snpeffdb" type="galaxy.datatypes.text:SnpEffDb" display_in_upload="True"/> + <datatype extension="snpsiftdbnsfp" type="galaxy.datatypes.txt:SnpSiftDbNSFP" display_in_upload="True"/> + <datatype extension="dbnsfp.tabular" type="galaxy.datatypes.tabular:Tabular" subclass="True" display_in_upload="True"> + <converter file="tabular_to_dbnsfp.xml" target_datatype="snpsiftdbnsfp"/> + </datatype><datatype extension="sff" type="galaxy.datatypes.binary:Sff" mimetype="application/octet-stream" display_in_upload="true" description="A binary file in 'Standard Flowgram Format' with a '.sff' file extension." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Sff"/><datatype extension="svg" type="galaxy.datatypes.images:Image" mimetype="image/svg+xml"/><datatype extension="taxonomy" type="galaxy.datatypes.tabular:Taxonomy" display_in_upload="true"/> diff -r 2fd8714c4faeb580f3ccf1591003f10e821397a1 -r 482d85dda5d3546e1d6e9cca6d712d7af8c772ba lib/galaxy/datatypes/converters/tabular_to_dbnsfp.xml --- /dev/null +++ b/lib/galaxy/datatypes/converters/tabular_to_dbnsfp.xml @@ -0,0 +1,12 @@ +<tool id="tabular_to_dbnsfp" name="Convert tabular to dbnsfp" version="1.0.0"> + <description></description> + <command interpreter="python">tabular_to_dbnsfp.py $input $dbnsfp.extra_files_path/dbNSFP.gz</command> + <inputs> + <param format="tabular" name="input" type="data" label="Choose a dbnsfp tabular file"/> + </inputs> + <outputs> + <data format="snpsiftdbnsfp" name="dbnsfp"/> + </outputs> + <help> + </help> +</tool> diff -r 2fd8714c4faeb580f3ccf1591003f10e821397a1 -r 482d85dda5d3546e1d6e9cca6d712d7af8c772ba lib/galaxy/datatypes/text.py --- a/lib/galaxy/datatypes/text.py +++ b/lib/galaxy/datatypes/text.py @@ -2,7 +2,6 @@ """ Clearing house for generic text datatypes that are not XML or tabular. """ - from galaxy.datatypes.data import Text from galaxy.datatypes.data import get_file_peek from galaxy.datatypes.data import nice_size @@ -12,13 +11,13 @@ import tempfile import subprocess import json +import gzip import os import re import logging log = logging.getLogger(__name__) - class Json( Text ): file_ext = "json" @@ -259,3 +258,121 @@ dataset.metadata.comment_lines = comment_lines dataset.metadata.columns = column_count + +class SnpEffDb( Text ): + """Class describing a SnpEff genome build""" + 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=[], optional=True) + MetadataElement( name="annotation", default=[], desc="Annotation Names", readonly=True, visible=True, no_value=[], optional=True) + + 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 + try: + fh = file(dataset.file_name,'w') + fh.write("%s\n" % genome_version) + if annotations: + fh.write("annotations: %s\n" % ','.join(annotations)) + if regulations: + fh.write("regulations: %s\n" % ','.join(regulations)) + fh.close() + except: + pass + + +class SnpSiftDbNSFP( Text ): + """Class describing a dbNSFP database prepared fpr use by SnpSift dbnsfp """ + MetadataElement( name='reference_name', default='dbSNFP' , desc='Reference Name', readonly=True, visible=True, set_in_upload=True, no_value='dbSNFP' ) + MetadataElement( name="bgzip", default=None, desc="dbNSFP bgzip", readonly=True, visible=True, no_value=None ) + MetadataElement( name="index", default=None, desc="Tabix Index File", readonly=True, visible=True, no_value=None) + MetadataElement( name="annotation", default=[], desc="Annotation Names", readonly=True, visible=True, no_value=[] ) + file_ext = "snpsiftdbnsfp" + composite_type = 'auto_primary_file' + allow_datatype_change = False + """ + ## The dbNSFP file is a tabular file with 1 header line + ## The first 4 columns are required to be: chrom pos ref alt + ## These match columns 1,2,4,5 of the VCF file + ## SnpSift requires the file to be block-gzipped and the indexed with samtools tabix + ## Example: + ## Compress using block-gzip algorithm + bgzip dbNSFP2.3.txt + ## Create tabix index + tabix -s 1 -b 2 -e 2 dbNSFP2.3.txt.gz + """ + def __init__( self, **kwd ): + Text.__init__( self, **kwd ) + self.add_composite_file( '%s.grp', description = 'Group File', substitute_name_with_metadata = 'reference_name', is_binary = False ) + self.add_composite_file( '%s.ti', description = '', substitute_name_with_metadata = 'reference_name', is_binary = False ) + def init_meta( self, dataset, copy_from=None ): + Text.init_meta( self, dataset, copy_from=copy_from ) + def generate_primary_file( self, dataset = None ): + """ + This is called only at upload to write the html file + cannot rename the datasets here - they come with the default unfortunately + """ + regenerate_primary_file( self, dataset) + def regenerate_primary_file(self,dataset): + """ + cannot do this until we are setting metadata + """ + annotations = "dbNSFP Annotations: %s\n" % ','.join(dataset.metadata.annotation) + f = open(dataset.file_name,'a') + if dataset.metadata.bgzip: + bn = dataset.metadata.bgzip + f.write(bn) + f.write('\n') + f.write(annotations) + f.close() + def set_meta( self, dataset, overwrite=True, **kwd ): + try: + efp = dataset.extra_files_path + if os.path.exists(efp): + flist = os.listdir(efp) + for i,fname in enumerate(flist): + if fname.endswith('.gz'): + dataset.metadata.bgzip = fname + try: + fh = gzip.open(os.path.join(efp,fname),'r') + buf = fh.read(5000) + lines = buf.splitlines() + headers = lines[0].split('\t') + dataset.metadata.annotation = headers[4:] + except Exception,e: + log.warn("set_meta fname: %s %s" % (fname,str(e))) + finally: + fh.close() + if fname.endswith('.tbi'): + dataset.metadata.index = fname + self.regenerate_primary_file(dataset) + except Exception,e: + log.warn("set_meta fname: %s %s" % (dataset.file_name if dataset and dataset.file_name else 'Unkwown',str(e))) + Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org