示例#1
0
def save_custom_reference(record, reference, format='fasta', molecule='DNA'):
    '''Save a custom reference'''
    if format in ['gb' , 'genbank']:
        correct_genbank_features_save(record, molecule='DNA')

    return SeqIO.write(record,
                       get_custom_reference_filename(reference, format=format),
                       format)
示例#2
0
def load_custom_reference(reference, format='fasta', region=None):
    '''Load a custom reference'''
    if region is not None:
        format = 'gb'

    record = SeqIO.read(get_custom_reference_filename(reference, format=format), format)

    # BUG: feature id is lost during write, fake it with the 'note' qualifier
    if format in ['gb' , 'genbank']:
        correct_genbank_features_load(record)

    if region is not None:
        for feature in record.features:
            if feature.id == region:
                return feature.extract(record)

    return record