view termenrichment.py @ 1:646b05282962

Uploaded
author jorrit
date Tue, 12 Feb 2013 13:46:10 -0500
parents
children
line wrap: on
line source

"""
Term enrichment datatypes

"""
import pkg_resources
pkg_resources.require( "bx-python" )

import logging, os, sys, time, tempfile, shutil
import data
from galaxy import util
from galaxy.datatypes.sniff import *
from galaxy.web import url_for
from cgi import escape
import urllib
from bx.intervals.io import *
from galaxy.datatypes import metadata
from galaxy.datatypes.metadata import MetadataElement
from galaxy.datatypes.tabular import Tabular
import math

log = logging.getLogger(__name__)

class TermEnrichmentResult( data.Text ):
    """Any term enrichment format"""
    file_ext = "enrichment"

    def init_meta( self, dataset, copy_from=None ):
        data.Text.init_meta( self, dataset, copy_from=copy_from )


class TerfTab( TermEnrichmentResult ):
    """TERF TSV Format"""
    file_ext = "terf"

    def init_meta( self, dataset, copy_from=None ):
        data.Text.init_meta( self, dataset, copy_from=copy_from )
    def sniff( self, filename ):
        """
        Determines whether the file is in TERF format
        """
        headers = get_headers( filename, '\n' )
        try:
            for hdr in headers:
                if hdr and hdr[0].startswith( '##terf-version' ) :
                    return True
            return False
        except:
            return False