<commit_before>import forgi_bulge_graph as fbg

'''

for testing you want to do something like this:

def rfam_uri(family_id):
    return 'http://rfam.xfam.org/family/%s/alignment?acc=%s&format=fastau&download=0'%(family_id,family_id)

def get_graphs(rfam_id = 'RF00005'):
    seqs = fasta_to_sequence(rfam_uri(rfam_id))
    graphs = rnafold_to_eden(seqs, shape_type=5, energy_range=30, max_num=3)
    return graphs

g=annotate_single(get_graphs().next())
draw(g)

'''


def annotate_single(graph):
    '''
    input is a graph that has a 'structure' attribute and the first node has id 0.
    when done all the node have an 'entity' attribute that indicates the structural element it is part of.
    there is also entity_short which cuts the entity down to a single letter for prettier printing.
    '''<commit_msg>better comments for rna annotator<commit_after>import forgi_bulge_graph as fbg

'''

localeden is eden. i just put a symlink to the git folder..
so that i dont have to update my real eden :) 

import localeden.modifier.rna.structureannotation as san
from localeden.converter.fasta import fasta_to_sequence
from localeden.util.display import draw_graph
from localeden.converter.rna.rnafold import rnafold_to_eden

def rfam_uri(family_id):
    return 'http://rfam.xfam.org/family/%s/alignment?acc=%s&format=fastau&download=0'%(family_id,family_id)

def get_graphs(rfam_id = 'RF00005'):
    seqs = fasta_to_sequence(rfam_uri(rfam_id))
    graphs = rnafold_to_eden(seqs, shape_type=5, energy_range=30, max_num=3)
    return graphs

g = get_graphs().next()
san.annotate_single(g)
draw_graph(g,vertex_label='entity_short')
'''


def annotate_single(graph):
    '''
    input is a graph that has a 'structure' attribute and the first node has id 0.
    when done all the node have an 'entity' attribute that indicates the structural element it is part of.
    there is also entity_short which cuts the entity down to a single letter for prettier printing.
    '''
{'fraction_non_alphanumeric': 0.09178498985801217, 'fraction_numerical': 0.011156186612576065, 'mean_word_length': 4.785923753665689, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2964150', 'n_tokens_mistral': 675, 'n_tokens_neox': 658, 'n_words': 201}