当前位置: 首页>>代码示例>>Python>>正文


Python BtLog.error方法代码示例

本文整理汇总了Python中lib.BtLog.error方法的典型用法代码示例。如果您正苦于以下问题:Python BtLog.error方法的具体用法?Python BtLog.error怎么用?Python BtLog.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.BtLog的用法示例。


在下文中一共展示了BtLog.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parseFasta

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
    def parseFasta(self, fasta_f, fasta_type):
        print BtLog.status_d['1'] % ('FASTA', fasta_f)
        self.assembly_f = abspath(fasta_f)
        if (fasta_type):
            # Set up CovLibObj for coverage in assembly header
            self.covLibs[fasta_type] = CovLibObj(fasta_type, fasta_type, fasta_f)

        for name, seq in BtIO.readFasta(fasta_f):
            blObj = BlObj(name, seq)
            if not blObj.name in self.dict_of_blobs:
                self.seqs += 1
                self.length += blObj.length
                self.n_count += blObj.n_count
                
                if (fasta_type):
                    cov = BtIO.parseCovFromHeader(fasta_type, blObj.name)
                    self.covLibs[fasta_type].cov_sum += cov
                    blObj.addCov(fasta_type, cov)

                self.order_of_blobs.append(blObj.name)
                self.dict_of_blobs[blObj.name] = blObj
            else:
                BtLog.error('5', blObj.name)
        
        if self.seqs == 0 or self.length == 0:
            BtLog.error('1')
开发者ID:hyphaltip,项目名称:blobtools,代码行数:28,代码来源:BtCore.py

示例2: parseCatColour

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def parseCatColour(catcolour_f):
    catcolour_dict = {}
    with open(catcolour_f) as fh:
        for l in fh:
            try:
                seq_name, category = l.rstrip("\n").split(",")
                catcolour_dict[seq_name] = category
            except:
                BtLog.error('23', catcolour_f)
    return catcolour_dict
开发者ID:greatfireball,项目名称:blobtools,代码行数:12,代码来源:BtPlot.py

示例3: parseRefCov

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def parseRefCov(refcov_f):
    refcov_dict = {}
    with open(refcov_f) as fh:
        for l in fh:
            try:
                cov_lib, reads_total_ref, reads_mapped_ref = l.split(",")
                refcov_dict[cov_lib] = {
                                        'reads_total' : int(reads_total_ref), 
                                        'reads_mapped' : int(reads_mapped_ref)
                                       }
            except:
                BtLog.error('21', refcov_f)
    return refcov_dict
开发者ID:greatfireball,项目名称:blobtools,代码行数:15,代码来源:BtPlot.py

示例4: parseCovFile

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def parseCovFile(cov_f):
    cov_dict = {}
    with open(cov_f) as fh:
        for l in fh:
            try:
                seq_name, cov = l.rstrip("\n").split("\t")
                if float(cov) < 0.02:
                    cov_dict[seq_name] = 0.02
                else:
                    cov_dict[seq_name] = float(cov)
            except:
                BtLog.error('25', cov_f)
    return cov_dict
开发者ID:BioInfoTools,项目名称:blobtools,代码行数:15,代码来源:BtPlot.py

示例5: checkBam

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def checkBam(infile):
    print BtLog.status_d['10']
    if not (which('samtools')):
        BtLog.error('7')
    reads_mapped_re = re.compile(r"(\d+)\s\+\s\d+\smapped")
    reads_total_re = re.compile(r"(\d+)\s\+\s\d+\sin total")
    reads_total, reads_mapped = 0, 0
    output = ''
    command = "samtools flagstat " + infile
    for line in runCmd(command):
        output += line
    reads_mapped = int(reads_mapped_re.search(output).group(1))
    reads_total = int(reads_total_re.search(output).group(1))
    print BtLog.status_d['11'] % ('{:,}'.format(reads_mapped), '{:,}'.format(reads_total), '{0:.1%}'.format(reads_mapped/reads_total))
    return reads_total, reads_mapped
开发者ID:hyphaltip,项目名称:blobtools,代码行数:17,代码来源:BtIO.py

示例6: parse_labels

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def parse_labels(labels):
    label_d = {}
    name, groups = '', ''
    if (labels):
        try:
            for label in labels:
                name, groups = str(label).split("=")
                if "," in groups:
                    for group in groups.split(","):
                        label_d[group] = name
                else:
                    label_d[groups] = name
        except:
            BtLog.error('17', labels)
    return label_d
开发者ID:greatfireball,项目名称:blobtools,代码行数:17,代码来源:BtPlot.py

示例7: checkCas

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def checkCas(infile):
    print BtLog.status_d['12']
    if not (which('clc_mapping_info')):
        BtLog.error('20')
    seqs_total_re = re.compile(r"\s+Contigs\s+(\d+)")
    reads_total_re = re.compile(r"\s+Reads\s+(\d+)")
    reads_mapping_re = re.compile(r"\s+Mapped reads\s+(\d+)\s+(\d+.\d+)\s+\%")
    seqs_total, reads_total, reads_mapping, mapping_rate = 0, 0, 0, 0.0
    output = ''
    command = "clc_mapping_info -s " + infile
    for line in runCmd(command):
        output += line
    seqs_total = int(seqs_total_re.search(output).group(1))
    reads_mapped = int(reads_mapping_re.search(output).group(1))
    reads_total = int(reads_total_re.search(output).group(1))
    print BtLog.status_d['11'] % ('{:,}'.format(reads_mapped), '{:,}'.format(reads_total), '{0:.1%}'.format(reads_mapped/reads_total))
    return seqs_total, reads_total, reads_mapped
开发者ID:hyphaltip,项目名称:blobtools,代码行数:19,代码来源:BtIO.py

示例8: readTax

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def readTax(infile, set_of_blobs):
    '''
    If more fields need to be parsed:
        - change hit_line_re
        - catch matches in variables
        - add as key-value pairs to hitDict
    '''
    hit_line_re = re.compile(r"^(\S+)\s+(\d+)[\;?\d+]*\s+(\d+\.*\d*)") # TEST TEST , if not split it afterwards
    with open(infile) as fh:
        for line in fh:
            match = hit_line_re.search(line)
            if match:
                hitDict = {
                    'name' : match.group(1),
                    'taxId' : match.group(2), # string because if int, conversion is a nightmare ...
                    'score' : float(match.group(3))
                    }
                if hitDict['name'] not in set_of_blobs:
                    BtLog.error('19', hitDict['name'], infile)
                if hitDict['taxId'] == 'N/A':
                    BtLog.error('22', infile)
                yield hitDict
开发者ID:hyphaltip,项目名称:blobtools,代码行数:24,代码来源:BtIO.py

示例9: parseCovFile

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def parseCovFile(cov_f):
    cov_dict = {}
    old_format = 1
    seq_name = ''
    cov = 0.0
    with open(cov_f) as fh:
        for l in fh:
            if l.startswith("#"):
                old_format = 0
            else:
                try:
                    field = l.rstrip("\n").split("\t")
                    if not (old_format):
                        seq_name, cov = field[0], field[2]
                    else:
                        seq_name, cov = field[0], field[1]
                    if float(cov) < 0.02:
                        cov_dict[seq_name] = 0.02
                    else:
                        cov_dict[seq_name] = float(cov)
                except:
                    BtLog.error('25', cov_f)
    return cov_dict
开发者ID:evolgenomology,项目名称:blobtools,代码行数:25,代码来源:BtPlot.py

示例10: getNodesDB

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def getNodesDB(**kwargs):
    '''
    Parsing names.dmp and nodes.dmp into the 'nodes_db' dict of dicts that 
    gets JSON'ed into blobtools/data/nodes_db.json if this file 
    does not exist. This file is used if neither "--names" and "--nodes" 
    nor "--db" is specified.
    '''
    nodesDB = {}
    nodesDB_f = ''    
    if (kwargs['names'] and kwargs['nodes']):
        print BtLog.status_d['3'] % (kwargs['nodes'], kwargs['names'])
        nodesDB = {}
        nodes_count = 0
        with open(kwargs['nodes']) as fh:
            for line in fh:
                nodes_col = line.split("\t")
                node = {}
                node_id = nodes_col[0] 
                node['parent'] = nodes_col[2]
                node['rank'] = nodes_col[4]
                nodesDB[node_id] = node
                nodes_count += 1
        with open(kwargs['names']) as fh:
            for line in fh:
                names_col = line.split("\t")
                if names_col[6] == "scientific name":
                   nodesDB[names_col[0]]['name'] = names_col[2]
        nodesDB_f = kwargs['nodesDB']
        nodesDB['nodes_count'] = nodes_count
    elif(kwargs['nodesDB']):
        print BtLog.status_d['4'] % (kwargs['nodesDB'])
        nodesDB = readNodesDB(kwargs['nodesDB'])
        nodesDB_f = kwargs['nodesDB']
    else:
        BtLog.error('3')
    return nodesDB, nodesDB_f
开发者ID:hyphaltip,项目名称:blobtools,代码行数:38,代码来源:BtIO.py

示例11: dirname

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
    TAXRULES = ['bestsum', 'bestsumorder']
    RANKS = ['species', 'genus', 'family', 'order', 'phylum', 'superkingdom', 'all']

    main_dir = dirname(__file__)
    #print data_dir
    args = docopt(__doc__)
    blobdb_f = args['--input']
    out_f = args['--out'] 
    ranks = args['--rank']
    taxrule = args['--taxrule']
    hits_flag = args['--hits']
    seq_list = args['--list']

    # Does blobdb_f exist ?
    if not isfile(blobdb_f):
        BtLog.error('0', blobdb_f)

    # Are ranks sane ?
    for rank in ranks:
        if rank not in RANKS:
            BtLog.error('9', rank)
    if 'all' in ranks:
        ranks = RANKS[0:-1]            

    # Is list a list of sequence names or a file?
    seqs = []
    if (seq_list):
        if isfile(seq_list):
            seqs = BtIO.parseList(seq_list)
        elif "," in seq_list:
            seqs = seq_list.split(",")
开发者ID:greatfireball,项目名称:blobtools,代码行数:33,代码来源:view.py

示例12: readFasta

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
    for name in readFasta(infile):
        fasta_order.append(name)
        fasta_dict[name] = 0.0
    return fasta_dict, fasta_order

if __name__ == '__main__':
    main_dir = dirname(__file__)
    #print data_dir
    args = docopt(__doc__)
    assembly_f = args['--infile']
    cov_fs = args['--cov']
    
    fasta_dict = {}
    fasta_order = []
    if not isfile(assembly_f):
        BtLog.error('0', assembly_f)
    else:
        fasta_dict, fasta_order = parseFasta(assembly_f)
    
    for cov_f in cov_fs:
        if not isfile(cov_f):
            BtLog.error('0', cov_f)
        else:
            lib_cov_dict = BtPlot.parseCovFile(cov_f)
            for name in fasta_order:
                fasta_dict[name] = fasta_dict.get(name, 0.0) + lib_cov_dict[name]
                    
    
    for name in fasta_order:
        print "%s\t%s" % (name, fasta_dict[name])
开发者ID:evolgenomology,项目名称:blobtools,代码行数:32,代码来源:sumcov.py

示例13: if

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
    if (out_f):
        out_f = "%s.%s" % (out_f, "BlobDB.json")
    else:
        out_f = "%s" % ("BlobDB.json")
    nodesDB_f = args['--db']
    names_f = args['--names']
    nodes_f = args['--nodes']
    taxrules = args['--taxrule']
    title = args['--title'] if (args['--title']) else os.path.basename(".".join(fasta_f.split('.')[0:-1]))


    # Do files exist ?
    files = [x for x in list([fasta_f] + sam_fs + bam_fs + cov_fs + cas_fs + [names_f] + [nodes_f] + hit_fs) if x is not None]
    for f in files:
        if not os.path.isfile(f):
            BtLog.error('0', f)

    # Is taxonomy provided?
    if nodesDB_f == "data/nodesDB.txt":
        nodesDB_f = os.path.join(main_dir, nodesDB_f)
    if not os.path.isfile(nodesDB_f) and not ((names_f) and (nodes_f)):
        BtLog.error('3')

    if not (hit_fs):
        BtLog.error('18')

    # can FASTA parser deal with assemblies
    if not fasta_type in ASSEMBLY_TYPES:
        BtLog.error('2', ",".join(ASSEMBLY_TYPES[1:]))

    # Is coverage provided?
开发者ID:greatfireball,项目名称:blobtools,代码行数:33,代码来源:create.py

示例14: isfile

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
    taxrule = args['--taxrule']
    hist_type = args['--hist']
    plot_title = args['--title']
    ignore_contig_length = args['--noscale']
    #labels = args['--label']
    #colour_f = args['--colours']
    #exclude_groups = args['--exclude']
    format = args['--format'] 
    #no_plot_blobs = args['--noblobs']
    #no_plot_reads = args['--noreads']
    #refcov_f = args['--refcov']
    #catcolour_f = args['--catcolour']

    # Does blobdb_f exist ?
    if not isfile(blobdb_f):
        BtLog.error('0', blobdb_f)

    # Does cov_f exist ?
    if not isfile(cov_f):
        BtLog.error('0', cov_f)
    # parse cov file in dict 
    cov_dict = BtPlot.parseCovFile(cov_f)
    
    # Are ranks sane ?
    if rank not in RANKS:
        BtLog.error('9', rank)

    # Are sort_order and hist_type sane?
    if not sort_order in ['span', 'count']:
        BtLog.error('14', sort_order)
    if not hist_type in ['span', 'count']:            
开发者ID:hyphaltip,项目名称:blobtools,代码行数:33,代码来源:comparecov.py

示例15: validate_input_create

# 需要导入模块: from lib import BtLog [as 别名]
# 或者: from lib.BtLog import error [as 别名]
def validate_input_create(main_dir, args):
    '''
    Accepts: 
        - main_dir
        - docopt args
    Returns:
        - title
        - fasta_f
        - fasta_type
        - cov_libs
        - hit_libs
        - nodesDB_f
        - taxrules
        - out_f
    '''
    ASSEMBLY_TYPES = [None, 'spades', 'soap', 'abyss', 'velvet']

    fasta_f = args['--infile']
    fasta_type = args['--type']
    sam_fs = args['--sam']
    bam_fs = args['--bam']
    cov_fs = args['--cov']
    cas_fs = args['--cas']
    hit_fs = args['--taxfile']
    out_f = args['--out']
    if (out_f):
        out_f = "%s.%s" % (os.path.basename(out_f), "BlobDB.json")
    else:
        out_f = "%s" % ("BlobDB.json")
    nodesDB_f = args['--db']
    names_f = args['--names']
    nodes_f = args['--nodes']
    taxrules = args['--taxrule']
    title = args['--title'] if (args['--title']) else out_f
    
    # Do files exist ?
    files = [x for x in list([fasta_f] + sam_fs + bam_fs + cov_fs + cas_fs + [names_f] + [nodes_f] + hit_fs) if x is not None]
    for f in files:
        if not os.path.isfile(f):
            BtLog.error('0', f)

    # Is taxonomy provided?
    if nodesDB_f == "data/nodesDB.txt":
        nodesDB_f = os.path.join(main_dir, nodesDB_f)
    if not os.path.isfile(nodesDB_f) and not ((names_f) and (nodes_f)):
        BtLog.error('3')
    if not (hit_fs):
        BtLog.error('18')
    # can FASTA parser deal with assemblies
    if not fasta_type in ASSEMBLY_TYPES:
        BtLog.error('2', ",".join(ASSEMBLY_TYPES[1:]))
    # Is coverage provided?
    if not (fasta_type) and not bam_fs and not sam_fs and not cov_fs and not cas_fs:
        BtLog.error('1')
    cov_libs = [bt.CovLibObj('bam' + str(idx), 'bam', lib_f) for idx, lib_f in enumerate(bam_fs)] + \
               [bt.CovLibObj('sam' + str(idx), 'sam', lib_f) for idx, lib_f in enumerate(sam_fs)] + \
               [bt.CovLibObj('cas' + str(idx), 'cas', lib_f) for idx, lib_f in enumerate(cas_fs)] + \
               [bt.CovLibObj('cov' + str(idx), 'cov', lib_f) for idx, lib_f in enumerate(cov_fs)] 

    hit_libs = [bt.hitLibObj('tax' + str(idx), 'tax', lib_f) for idx, lib_f in enumerate(hit_fs)]

    return title, fasta_f, fasta_type, cov_libs, hit_libs, taxrules, nodesDB_f, nodes_f, names_f, out_f
开发者ID:evolgenomology,项目名称:blobtools,代码行数:64,代码来源:BtInput.py


注:本文中的lib.BtLog.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。