Ejemplo n.º 1
0
def test_m80_init(m80_Fasta):
    '''
    Test init from a m80 object.
    Needs to inherit from m80_Fasta,
    but dont use it directly, use the m80
    API instead
    '''
    # grab from mm80
    f = lp.Fasta('ACGT')
    assert len(f['chr1']) == 100
Ejemplo n.º 2
0
def test_chrom_attrs(smpl_fasta, m80_Fasta):
    c1 = smpl_fasta['chr1']
    assert 'foobar' in c1._attrs
    c2 = lp.Fasta('ACGT')
    assert 'foo' in c2['chr1']._attrs
import os 
import minus80 as m80
import locuspocus as lp

from minus80.RawFile import RawFile

ids = dict()  
with open('ensemble_id_map.txt','r') as IN:                  
    for line in IN:                                          
        i,j = line.strip().split()                        
        ids[i] = j     
if m80.Tools.available('EquCab3',dtype='Fasta'): 
    ec3 = lp.Fasta('EquCab3')
else:
    ec3 = lp.Fasta.from_file('EquCab3','EquCab3.fa.gz')

if not os.path.exists('EquCab3_nice.fasta'):
    with open('EquCab3_nice.fasta','w') as OUT:                                                                                                        
        for chrom_name in ec3.chrom_names():                                        
            print(f'Printing out {chrom_name}')
            chrom = ec3[chrom_name]                                                 
            # try to get easy_id
            if chrom_name in ids:
                chrom_name = f"{ids[chrom_name]} {chrom_name}"
            # Keep track of lengths 
            start_length = len(chrom)
            printed_length = 0
            # Loop and print
            print(f'>{chrom_name} {" ".join(chrom._attrs)}',file=OUT)     
            for i in range(0,len(chrom),70):                                        
                sequence = chrom.seq[i:i+70]