def get_subtype_reference_alignment_consensus(region,
                                              subtype='B',
                                              refname='HXB2',
                                              type='nuc',
                                              VERBOSE=0):
    '''Get filename of consensus of subtype reference alignment'''
    from Bio import SeqIO
    from hivwholeseq.cross_sectional.filenames import (
        get_subtype_reference_alignment_consensus_filename)

    fn = get_subtype_reference_alignment_consensus_filename(region,
                                                            subtype=subtype,
                                                            refname=refname,
                                                            type=type,
                                                            VERBOSE=VERBOSE)
    return SeqIO.read(fn, 'fasta')
Пример #2
0
def get_subtype_reference_alignment_consensus(region,
                                              subtype='B',
                                              refname='HXB2',
                                              type='nuc',
                                              VERBOSE=0):
    '''Get filename of consensus of subtype reference alignment'''
    from Bio import SeqIO
    from hivwholeseq.cross_sectional.filenames import (
        get_subtype_reference_alignment_consensus_filename)

    fn = get_subtype_reference_alignment_consensus_filename(region,
                                                            subtype=subtype,
                                                            refname=refname,
                                                            type=type,
                                                            VERBOSE=VERBOSE)
    return SeqIO.read(fn, 'fasta')
                                                                      VERBOSE=VERBOSE)
            afs = np.load(fn_in)


            if VERBOSE >= 2:
                print 'Calculate consensus'
            
            consm = alphabet[afs[:5].argmax(axis=0)]
            consrec = SeqRecord(Seq(''.join(consm), alphabet_bio),
                                id='consensus_subtype'+subtype+'_refto_'+refname,
                                name='consensus_subtype'+subtype+'_refto_'+refname,
                                description=('Consensus of subtype '+subtype+
                                             ' reference alignment to '+refname),
                               )

            if VERBOSE >= 2:
                print 'Save to file'
            fn_out = get_subtype_reference_alignment_consensus_filename(region,
                                                               subtype=subtype,
                                                               refname=refname,
                                                               type=alitype,
                                                               VERBOSE=VERBOSE)
            SeqIO.write(consrec, fn_out, 'fasta')

        else:
            consrec = get_subtype_reference_alignment_consensus(region,
                                                               subtype=subtype,
                                                               refname=refname,
                                                               type=alitype,
                                                               VERBOSE=VERBOSE)
Пример #4
0
            if VERBOSE >= 2:
                print 'Calculate consensus'

            consm = alphabet[afs[:5].argmax(axis=0)]
            consrec = SeqRecord(
                Seq(''.join(consm), alphabet_bio),
                id='consensus_subtype' + subtype + '_refto_' + refname,
                name='consensus_subtype' + subtype + '_refto_' + refname,
                description=('Consensus of subtype ' + subtype +
                             ' reference alignment to ' + refname),
            )

            if VERBOSE >= 2:
                print 'Save to file'
            fn_out = get_subtype_reference_alignment_consensus_filename(
                region,
                subtype=subtype,
                refname=refname,
                type=alitype,
                VERBOSE=VERBOSE)
            SeqIO.write(consrec, fn_out, 'fasta')

        else:
            consrec = get_subtype_reference_alignment_consensus(
                region,
                subtype=subtype,
                refname=refname,
                type=alitype,
                VERBOSE=VERBOSE)