Beispiel #1
0
def action(args):
    if args.seqname:
        seqname = args.seqname
    else:
        seqname = 'consensus' if args.infile is sys.stdin \
                  else splitext(basename(args.infile.name))[0]

    seqs = list(fastalite(args.infile, 'fasta'))

    if args.rlefile:
        rledict = json.load(args.rlefile)
        rlelist = [rledict[s.id] for s in seqs]
        cons = consensus(seqs, rlelist, degap=not args.gaps)
    else:
        cons = consensus(seqs, degap=not args.gaps)

    args.outfile.write('>{}\n{}\n'.format(seqname, cons))
Beispiel #2
0
def action(args):
    if args.seqname:
        seqname = args.seqname
    else:
        seqname = 'consensus' if args.infile is sys.stdin \
                  else splitext(basename(args.infile.name))[0]

    seqs = list(fastalite(args.infile, 'fasta'))

    if args.rlefile:
        rledict = json.load(args.rlefile)
        rlelist = [rledict[s.id] for s in seqs]
        cons = consensus(seqs, rlelist, degap=not args.gaps)
    else:
        cons = consensus(seqs, degap=not args.gaps)

    args.outfile.write('>{}\n{}\n'.format(seqname, cons))
Beispiel #3
0
def align_and_consensus(chunk):
    """Wraps functions for alignment and consensus generation. Does not
    perform alignment for clusters of length 1.

    """

    i, (cluster, rlelist) = chunk

    if len(cluster) == 1:
        # no need to align...
        seq = cluster[0]
        rle = rlelist[0] if rlelist else None
        cons = homodecode(seq, rle) if rle else seq.seq
    else:
        log.debug('aligning cluster {} len {}'.format(i, len(cluster)))
        cons = consensus(run_muscle(cluster), rlelist)

    return cluster, cons
Beispiel #4
0
def align_and_consensus(chunk):
    """Wraps functions for alignment and consensus generation. Does not
    perform alignment for clusters of length 1.

    """

    i, (cluster, rlelist) = chunk

    if len(cluster) == 1:
        # no need to align...
        seq = cluster[0]
        rle = rlelist[0] if rlelist else None
        cons = homodecode(seq, rle) if rle else seq.seq
    else:
        log.debug('aligning cluster {} len {}'.format(i, len(cluster)))
        cons = consensus(run_muscle(cluster), rlelist)

    return cluster, cons