def results(self, process, temp_dir, filename):
        """This will generate a list of size 1 because RNAalifold only
        generates a single structure. The result will be a Dot-Bracket parser
        with a sequence property set the consensus produced by RNAalifold and
        an energy property of the energy line given by RNAalifold.

        :process: The process object.
        :temp_dir: The directory all work was done in.
        :filename: Input filename.
        """
        self.raw = process.stdout.readlines()
        if len(self.raw) != 3 and len(self.raw) != 2:
            raise FoldingFailedError("No valid output")
        consensus = self.raw[0].rstrip()
        structure_line = self.raw[1].rstrip()
        parts = structure_line.split(' ', 1)
        parser = DotBracket(parts[0])
        parser.sequence = consensus
        parser.energy = parts[1]

        ps_parser = self._load_locations(temp_dir, filename)
        parser.locations = ps_parser.locations
        parser.box = ps_parser.box

        return [parser]
Beispiel #2
0
    def results(self, process, temp_dir, filename):
        """This will generate a list of size 1 because RNAalifold only
        generates a single structure. The result will be a Dot-Bracket parser
        with a sequence property set the consensus produced by RNAalifold and
        an energy property of the energy line given by RNAalifold.

        :process: The process object.
        :temp_dir: The directory all work was done in.
        :filename: Input filename.
        """
        self.raw = process.stdout.readlines()
        if len(self.raw) != 3 and len(self.raw) != 2:
            raise FoldingFailedError("No valid output")
        consensus = self.raw[0].rstrip()
        structure_line = self.raw[1].rstrip()
        parts = structure_line.split(' ', 1)
        parser = DotBracket(parts[0])
        parser.sequence = consensus
        parser.energy = parts[1]

        ps_parser = self._load_locations(temp_dir, filename)
        parser.locations = ps_parser.locations
        parser.box = ps_parser.box

        return [parser]
import sys

# Just mess with path a little so we can run this from anywhere.
here = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(here)

from rnastructure.secondary.pseudoknot import RemovePseudoknots
from rnastructure.secondary.dot_bracket import Parser as DotParser
from rnastructure.secondary.dot_bracket import Writer as DotWriter

rfam_pseudoknots = "<<<<<..AA..>>>>>aa"
rfam_sequence = "CCCCCAAGGUUGGGGGCC"

# Create a dot-bracket parser that can handle rfam's format.
parser = DotParser(rfam_pseudoknots, dialect="rfam")
parser.sequence = rfam_sequence

print(
    """
Note that RemovePseudoknots needs to have an enviroment variable DATAPATH set.
This must lead to the data tables provided with RNAstructure. Below is where
mine are, change as needed.
os.putenv('DATAPATH', '/Users/blake/lab/programs/RNAstructure/data_tables')
"""
)

# Remove all pseudoknots and return a new parser for the new structure.
remover = RemovePseudoknots()
stripped = remover(parser)

# Show the indices
import sys

# Just mess with path a little so we can run this from anywhere.
here = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(here)

from rnastructure.secondary.pseudoknot import RemovePseudoknots
from rnastructure.secondary.dot_bracket import Parser as DotParser
from rnastructure.secondary.dot_bracket import Writer as DotWriter

rfam_pseudoknots = '<<<<<..AA..>>>>>aa'
rfam_sequence = 'CCCCCAAGGUUGGGGGCC'

# Create a dot-bracket parser that can handle rfam's format.
parser = DotParser(rfam_pseudoknots, dialect='rfam')
parser.sequence = rfam_sequence

print("""
Note that RemovePseudoknots needs to have an enviroment variable DATAPATH set.
This must lead to the data tables provided with RNAstructure. Below is where
mine are, change as needed.
os.putenv('DATAPATH', '/Users/blake/lab/programs/RNAstructure/data_tables')
""")

# Remove all pseudoknots and return a new parser for the new structure.
remover = RemovePseudoknots()
stripped = remover(parser)

# Show the indices
print(stripped.indices())
# => {'external': [([16, 17],)], 'hairpin': [([5, 6, 7, 8, 9, 10],)]}