當前位置: 首頁>>代碼示例>>Python>>正文


Python MotifConfig.get_seqlogo方法代碼示例

本文整理匯總了Python中gimmemotifs.config.MotifConfig.get_seqlogo方法的典型用法代碼示例。如果您正苦於以下問題:Python MotifConfig.get_seqlogo方法的具體用法?Python MotifConfig.get_seqlogo怎麽用?Python MotifConfig.get_seqlogo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gimmemotifs.config.MotifConfig的用法示例。


在下文中一共展示了MotifConfig.get_seqlogo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from gimmemotifs.config import MotifConfig [as 別名]
# 或者: from gimmemotifs.config.MotifConfig import get_seqlogo [as 別名]
    def run(self):
        from gimmemotifs.config import MotifConfig
        
        cfg = MotifConfig(use_config=self.build_cfg)

        data_dir = self.remove_nonsense(os.path.abspath(self.install_dir))
        
        cfg.set_template_dir(os.path.join(data_dir, 'gimmemotifs/templates'))
        cfg.set_gene_dir(os.path.join(data_dir, 'gimmemotifs/genes'))
        cfg.set_score_dir(os.path.join(data_dir, 'gimmemotifs/score_dists'))
        cfg.set_index_dir(os.path.join(data_dir, 'gimmemotifs/genome_index'))
        cfg.set_motif_dir(os.path.join(data_dir, 'gimmemotifs/motif_databases'))
        cfg.set_bg_dir(os.path.join(data_dir, 'gimmemotifs/bg'))
        cfg.set_tools_dir(os.path.join(data_dir, 'gimmemotifs/tools'))
        
        final_tools_dir = self.remove_nonsense(self.install_tools_dir)
        for program in MOTIF_CLASSES:
            m = eval(program)()
            if cfg.is_configured(m.name):
                bin = cfg.bin(m.name).replace(self.build_tools_dir, final_tools_dir) 
                dir = cfg.dir(m.name)
                if dir:
                    dir = dir.replace(self.build_tools_dir, final_tools_dir)
                cfg.set_program(m.name, {"bin":bin, "dir":dir})
            
        dir = cfg.get_seqlogo()
        dir = dir.replace(self.build_tools_dir, final_tools_dir)
        cfg.set_seqlogo(dir)

        # Use a user-specific configfile if any other installation scheme is used
#        if os.path.abspath(self.install_dir) == "/usr/share":
        config_file = os.path.join(self.install_dir, "gimmemotifs/%s" % CONFIG_NAME)
        self.outfiles = [config_file] 


        if os.path.exists(config_file):
            new_config = config_file + ".tmp"
            dlog.info("INFO: Configfile %s already exists!" % config_file)
            dlog.info("INFO: Will create %s, which contains the new config." % new_config)
            dlog.info("INFO: If you want to use the newly generated config you can move %s to %s, otherwise you can delete %s.\n" % (new_config, config_file, new_config))

            f =  open(new_config, "wb")
            cfg.write(f)
        else: 
            dlog.info("writing configuration file %s" % config_file)
            f =  open(config_file, "wb")
            cfg.write(f)
        
        if os.path.abspath(self.install_dir) != "/usr/share":
            dlog.info("PLEASE NOTE: GimmeMotifs is installed in a non-standard location.")
            dlog.info("PLEASE NOTE: This is fine, but then every user should have a file called ~/.gimmemotifs.cfg")
            dlog.info("PLEASE NOTE: The file %s is fully configured during install and can be used for that purpose." % config_file)
開發者ID:georgeg9,項目名稱:gimmemotifs,代碼行數:54,代碼來源:setup.py

示例2: run

# 需要導入模塊: from gimmemotifs.config import MotifConfig [as 別名]
# 或者: from gimmemotifs.config.MotifConfig import get_seqlogo [as 別名]
    def run(self):
        from gimmemotifs.config import MotifConfig
        
        cfg = MotifConfig(use_config=self.build_cfg)

        data_dir = self.remove_nonsense(os.path.abspath(self.install_dir))
        
        cfg.set_template_dir(os.path.join(data_dir, 'gimmemotifs/templates'))
        cfg.set_gene_dir(os.path.join(data_dir, 'gimmemotifs/genes'))
        cfg.set_score_dir(os.path.join(data_dir, 'gimmemotifs/score_dists'))
        cfg.set_index_dir(os.path.join(data_dir, 'gimmemotifs/genome_index'))
        cfg.set_motif_dir(os.path.join(data_dir, 'gimmemotifs/motif_databases'))
        cfg.set_bg_dir(os.path.join(data_dir, 'gimmemotifs/bg'))
        cfg.set_tools_dir(os.path.join(data_dir, 'gimmemotifs/tools'))
        
        final_tools_dir = self.remove_nonsense(self.install_tools_dir)
        for program in MOTIF_CLASSES:
            m = eval(program)()
            if cfg.is_configured(m.name):
                bin = cfg.bin(m.name).replace(self.build_tools_dir, final_tools_dir) 
                dir = cfg.dir(m.name)
                if dir:
                    dir = dir.replace(self.build_tools_dir, final_tools_dir)
                cfg.set_program(m.name, {"bin":bin, "dir":dir})
            
        dir = cfg.get_seqlogo()
        dir = dir.replace(self.build_tools_dir, final_tools_dir)
        cfg.set_seqlogo(dir)

        # Use a user-specific configfile if any other installation scheme is used
#        if os.path.abspath(self.install_dir) == "/usr/share":
        config_file = os.path.join(self.install_dir, "gimmemotifs/%s" % CONFIG_NAME)
        self.outfiles = [config_file] 

        if os.path.exists(config_file):
            timestr = time.strftime("%Y%m%d-%H%M%S")        
            old_config = "{}.{}".format(config_file, timestr)
            shutil.move(config_file, old_config)
            dlog.info("INFO: Configfile %s already existed!", config_file)
            dlog.info("INFO: This config has been saved as %s", old_config)
         
        dlog.info("writing configuration file %s" % config_file)
        f =  open(config_file, "wb")
        cfg.write(f)
開發者ID:YichaoOU,項目名稱:gimmemotifs,代碼行數:46,代碼來源:setup.py

示例3: Motif

# 需要導入模塊: from gimmemotifs.config import MotifConfig [as 別名]
# 或者: from gimmemotifs.config.MotifConfig import get_seqlogo [as 別名]
class Motif(object):
    PSEUDO_PFM_COUNT = 1000 # Jaspar mean
    PSEUDO_PWM = 1e-6

    def __init__(self, pfm=None):
        if pfm is None:
            pfm = []

        if len(pfm) > 0:
            if np.sum(pfm[0]) > 2:
                self.pfm = [list(x) for x in pfm]
                self.pwm = self.pfm_to_pwm(pfm)
            else:
                self.pwm = [list(x) for x in pfm]
                self.pfm = [[n * self.PSEUDO_PFM_COUNT for n in col] for col in pfm]
        else:
            self.pwm = []
            self.pfm = []
        self.seqs = []
        self.consensus = ""
        self.id = ""
        self.config = MotifConfig()
        self.seqlogo = self.config.get_seqlogo()

        self.nucs = "ACGT"
        
        self.iupac_rev = {
            'CG': 'S',
            'AG': 'R',
            'AT': 'W',
            'CT': 'Y',
            'GT': 'K',
            'AC': 'M',
            'CGT': 'B',
            'ACT': 'H',
            'AGT': 'D',
            'ACG': 'V'
        }

        self.iupac = {
            'A':['A'],
            'C':['C'],
            'G':['G'],
            'T':['T'],
            'S':['C','G'],
            'R':['A','G'],
            'W':['A','T'],
            'Y':['C','T'],
            'K':['G','T'],
            'M':['A','C'],
            'B':['C','G','T'],
            'H':['A','C','T'],
            'D':['A','G','T'],
            'V':['A','C','G'],
            'N':['A','C','G','T']
        }
        self.iupac_pwm = {
            'A':[1, 0, 0, 0],    
            'C':[0, 1, 0, 0],    
            'G':[0, 0, 1, 0],    
            'T':[0, 0, 0, 1],    
            'S':[0, 0.5, 0.5, 0],
            'R':[0.5, 0, 0.5, 0],
            'W':[0.5, 0, 0, 0.5],
            'Y':[0, 0.5, 0, 0.5],
            'K':[0, 0, 0.5, 0.5],
            'M':[0.5, 0.5, 0, 0],
            'B':[0, 0.33, 0.33, 0.33],
            'H':[0.33, 0.33, 0, 0.33],
            'D':[0.33, 0, 0.33, 0.33],
            'V':[0.33, 0.33, 0.33, 0],
            'N':[0.25, 0.25, 0.25, 0.25]
        }
    
    
    def __getitem__(self, x):
        m = Motif()
        if self.pwm:
            m.pwm = self.pwm[x]
        if self.pfm:   
            m.pfm = self.pfm[x]
        if self.seqs:
            m.seqs = [seq[x] for seq in self.seqs]
        if self.consensus:
            m.consensus = self.consensus[x]
        return m
            
    def __len__(self):
        return len(self.to_consensus())

    def __repr__(self):
        return "%s\t%s" % (self.id, self.to_consensus())

    def information_content(self):
        ic = 0
        for row in self.pwm:
            ic += 2.0 + np.sum([row[x] * log(row[x])/log(2) for x in range(4) if row[x] > 0])
        return ic

    def pwm_min_score(self):
#.........這裏部分代碼省略.........
開發者ID:YichaoOU,項目名稱:gimmemotifs,代碼行數:103,代碼來源:motif.py

示例4: Motif

# 需要導入模塊: from gimmemotifs.config import MotifConfig [as 別名]
# 或者: from gimmemotifs.config.MotifConfig import get_seqlogo [as 別名]
class Motif(object):
    
    """
    Representation of a transcription factor binding motif.

    Examples
    --------

    >>> motif = Motif([[0,1,0,0], [0.5,0,0,0.5], [0,0,1,0]])
    >>> print(motif.to_pwm())
    >
    0   1   0   0
    0.5 0   0   0.5
    0   0   1   0
    >>> print(motif.to_consensus())
    CwG
    
    """
    
    PSEUDO_PFM_COUNT = 1000 # Jaspar mean
    PSEUDO_PWM = 1e-6
    G = 0.25
    Z = 0.01

    def __init__(self, pfm=None):
        if pfm is None:
            pfm = []

        if len(pfm) > 0:
            if np.sum(pfm[0]) > 2:
                self.pfm = [list(x) for x in pfm]
                self.pwm = self.pfm_to_pwm(pfm)
            else:
                self.pwm = [list(x) for x in pfm]
                self.pfm = [[n * self.PSEUDO_PFM_COUNT for n in col] for col in pfm]
            self.logodds = [[np.log(n / self.G + self.Z) for n in col] for col in self.pwm]
        else:
            self.pwm = []
            self.pfm = []
        
        self.wiggled_pwm = None
        self.factors = {DIRECT_NAME:[], INDIRECT_NAME:[]}
        self.seqs = []
        self.consensus = ""
        self.min_score = None
        self.max_score = None
        
        self.id = ""
        self.config = MotifConfig()
        self.seqlogo = self.config.get_seqlogo()

        self.nucs = "ACGT"
        
        self.iupac_rev = {
            'CG': 'S',
            'AG': 'R',
            'AT': 'W',
            'CT': 'Y',
            'GT': 'K',
            'AC': 'M',
            'CGT': 'B',
            'ACT': 'H',
            'AGT': 'D',
            'ACG': 'V'
        }

        self.iupac = {
            'A':['A'],
            'C':['C'],
            'G':['G'],
            'T':['T'],
            'S':['C','G'],
            'R':['A','G'],
            'W':['A','T'],
            'Y':['C','T'],
            'K':['G','T'],
            'M':['A','C'],
            'B':['C','G','T'],
            'H':['A','C','T'],
            'D':['A','G','T'],
            'V':['A','C','G'],
            'N':['A','C','G','T']
        }
        self.iupac_pwm = {
            'A':[1, 0, 0, 0],    
            'C':[0, 1, 0, 0],    
            'G':[0, 0, 1, 0],    
            'T':[0, 0, 0, 1],    
            'S':[0, 0.5, 0.5, 0],
            'R':[0.5, 0, 0.5, 0],
            'W':[0.5, 0, 0, 0.5],
            'Y':[0, 0.5, 0, 0.5],
            'K':[0, 0, 0.5, 0.5],
            'M':[0.5, 0.5, 0, 0],
            'B':[0, 0.33, 0.33, 0.33],
            'H':[0.33, 0.33, 0, 0.33],
            'D':[0.33, 0, 0.33, 0.33],
            'V':[0.33, 0.33, 0.33, 0],
            'N':[0.25, 0.25, 0.25, 0.25]
        }
#.........這裏部分代碼省略.........
開發者ID:simonvh,項目名稱:gimmemotifs,代碼行數:103,代碼來源:motif.py


注:本文中的gimmemotifs.config.MotifConfig.get_seqlogo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。