Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem encountered: to_neato_string() #42

Open
stevewu2001 opened this issue Aug 4, 2022 · 0 comments
Open

Problem encountered: to_neato_string() #42

stevewu2001 opened this issue Aug 4, 2022 · 0 comments

Comments

@stevewu2001
Copy link

The following code would produce a KeyError:

"""
import forgi.graph.bulge_graph as fgb
import sys
import os

class RedirectStdStreams(object):
def init(self, stdout=None, stderr=None):
self._stdout = stdout or sys.stdout
self._stderr = stderr or sys.stderr
def enter(self):
self.old_stdout, self.old_stderr = sys.stdout, sys.stderr
self.old_stdout.flush(); self.old_stderr.flush()
sys.stdout, sys.stderr = self._stdout, self._stderr
def exit(self, exc_type, exc_value, traceback):
self._stdout.flush(); self._stderr.flush()
sys.stdout = self.old_stdout
sys.stderr = self.old_stderr

def create_bg_from_db(db_str):
devnull = open(os.devnull, 'w')
with RedirectStdStreams(stdout=devnull):
bg = fgb.BulgeGraph.from_dotbracket(db_str)
return bg

db_str = ".................."
bg = create_bg_from_db(db_str)
print(bg.to_neato_string())
"""

If the dot-bracket string does not have any brackets (no stems), there will be a missing key 's0'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant