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

ProteinFoldingResult, XYZ files and plotting of folded Proteins for ProteinFoldingProblem. #655

Merged
merged 136 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
cdcdbfe
Adding files modified. Dependencies not Checked
MarcDrudis Apr 19, 2022
d6249be
Fixed one Dependency
MarcDrudis Apr 19, 2022
cca12b5
Passing ProteinFoldingProblem as attribute to ProteinFoldingResult. A…
MarcDrudis Apr 20, 2022
ed5c283
Some details
MarcDrudis Apr 20, 2022
7b45c25
Merge branch 'Qiskit:main' into ProteinFoldingInterpretMethod
MarcDrudis Apr 20, 2022
a21e325
Created more test cases in test_protein_folding_result
MarcDrudis Apr 22, 2022
875762b
Added comments in the unittest
MarcDrudis Apr 22, 2022
980d8f6
Quick changes
MarcDrudis Apr 25, 2022
2f224f4
Separated unittests, and small modifications
MarcDrudis Apr 28, 2022
9235a1b
Fixed bug side turns
MarcDrudis Apr 28, 2022
04ed820
Added letters to the plotter
MarcDrudis Apr 29, 2022
1679fa6
Fixed format and documentation
MarcDrudis May 2, 2022
ab1ca3e
Added release note
MarcDrudis May 2, 2022
f23508d
Corrected indentation and typos
MarcDrudis May 2, 2022
5689bae
Changed legend location
MarcDrudis May 3, 2022
b12b489
Updated header's date
MarcDrudis May 3, 2022
6a4fa03
Updated header's date
MarcDrudis May 3, 2022
c0e91aa
Update qiskit_nature/results/protein_folding_tools/__init__.py
MarcDrudis May 3, 2022
197e581
Update qiskit_nature/results/protein_folding_result.py
MarcDrudis May 3, 2022
31b126c
Update qiskit_nature/results/protein_folding_tools/protein_decoder.py
MarcDrudis May 3, 2022
b6aeb4e
Update qiskit_nature/results/protein_folding_tools/protein_decoder.py
MarcDrudis May 3, 2022
4c84f75
Update qiskit_nature/results/protein_folding_tools/protein_plotter.py
MarcDrudis May 3, 2022
9770070
Update qiskit_nature/results/protein_folding_result.py
MarcDrudis May 3, 2022
222a497
Updated header's date
MarcDrudis May 3, 2022
ebd0f12
Updated header's date
MarcDrudis May 3, 2022
7b708ce
Update protein_decoder.py
MarcDrudis May 3, 2022
201c3eb
Changed peptide getter docstring.
MarcDrudis May 3, 2022
c32c8d3
Update qiskit_nature/results/protein_folding_result.py
MarcDrudis May 3, 2022
c6b2622
Update qiskit_nature/results/protein_folding_result.py
MarcDrudis May 3, 2022
573d94f
Fixed multiple things
MarcDrudis May 3, 2022
1b0247b
Update qiskit_nature/results/protein_folding_tools/protein_xyz.py
MarcDrudis May 3, 2022
6401ab1
Update qiskit_nature/results/protein_folding_tools/protein_xyz.py
MarcDrudis May 3, 2022
c90c342
Update releasenotes/notes/protein-folding-result-b344ac3c7f48e3ca.yaml
MarcDrudis May 3, 2022
0800d03
Update qiskit_nature/results/protein_folding_result.py
MarcDrudis May 3, 2022
e7a5bad
Merge branch 'main' into ProteinFoldingInterpretMethod
MarcDrudis May 3, 2022
4153303
Update qiskit_nature/results/protein_folding_tools/protein_xyz.py
MarcDrudis May 4, 2022
48a2aec
Modularized ProteinPlotter
MarcDrudis May 4, 2022
72e5aae
Merge branch 'ProteinFoldingInterpretMethod' of https://github.com/Ma…
MarcDrudis May 4, 2022
a47e0aa
Merge branch 'main' into ProteinFoldingInterpretMethod
MarcDrudis May 12, 2022
39fa104
Changed documentation
MarcDrudis May 12, 2022
63532f7
pylint
MarcDrudis May 12, 2022
0e95408
Exposed main_turns
MarcDrudis May 12, 2022
5efca5b
Fixed make
MarcDrudis May 13, 2022
f28ffac
Fixed codeb
MarcDrudis May 13, 2022
cd4148d
Update qiskit_nature/results/protein_folding_result.py
MarcDrudis May 27, 2022
066a469
Changed class description
MarcDrudis May 27, 2022
7948c11
Reformated Unittests
MarcDrudis May 27, 2022
c090d43
Refactored unittests
MarcDrudis May 30, 2022
1e6545f
Adding matplotlib
MarcDrudis May 30, 2022
ad3b34c
Added Matplotlib requirement
MarcDrudis May 30, 2022
28b93b7
Accidentaly removed pylintdict
MarcDrudis May 30, 2022
b3bafdc
Merge branch 'main' into ProteinFoldingInterpretMethod
MarcDrudis May 30, 2022
219ca7f
Fixed circular import
MarcDrudis May 30, 2022
a8f4256
Merge branch 'ProteinFoldingInterpretMethod' of https://github.com/Ma…
MarcDrudis May 30, 2022
8b3a566
Update qiskit_nature/results/utils/protein_decoder.py
MarcDrudis May 30, 2022
1e07725
Update qiskit_nature/results/utils/protein_decoder.py
MarcDrudis May 30, 2022
91da0b9
Update qiskit_nature/results/utils/protein_decoder.py
MarcDrudis May 30, 2022
bed182f
Update qiskit_nature/results/protein_folding_result.py
MarcDrudis May 30, 2022
372937d
Fixed lint
MarcDrudis May 31, 2022
9b3940a
Merge branch 'ProteinFoldingInterpretMethod' of https://github.com/Ma…
MarcDrudis May 31, 2022
3c2292d
Refactored unittest
MarcDrudis May 31, 2022
cc00e7e
best_sequence -> turns_sequence
MarcDrudis May 31, 2022
9d57665
Update qiskit_nature/problems/sampling/protein_folding/protein_foldin…
MarcDrudis May 31, 2022
8da85a1
Update test/results/test_protein_folding_result.py
MarcDrudis May 31, 2022
9680743
Update setup.py
MarcDrudis May 31, 2022
a35a8f8
Update qiskit_nature/results/protein_folding_result.py
MarcDrudis May 31, 2022
7ba7045
Fixes
MarcDrudis May 31, 2022
ff7bc5d
Merge branch 'ProteinFoldingInterpretMethod' of https://github.com/Ma…
MarcDrudis May 31, 2022
c111d8c
black
MarcDrudis May 31, 2022
1ba6ff4
minor changes
MarcDrudis May 31, 2022
f461587
Fixed intentations
MarcDrudis May 31, 2022
ca25f6a
Removed TODO comment
MarcDrudis May 31, 2022
5490d9d
minor changes
MarcDrudis May 31, 2022
7a08295
Changed header XYZ file
MarcDrudis May 31, 2022
3ae4f4c
fixed style
MarcDrudis Jun 1, 2022
fada16c
Return figure instead of plotting
MarcDrudis Jun 1, 2022
008d321
Removed files
MarcDrudis Jun 1, 2022
3ef2482
Returns in doc ploter
MarcDrudis Jun 1, 2022
fe84675
Fixed codeblocks and reno
MarcDrudis Jun 1, 2022
131f57c
RENO
MarcDrudis Jun 1, 2022
83bc7c3
Merge branch 'main' into ProteinFoldingInterpretMethod
woodsp-ibm Jun 1, 2022
ff097c3
changed matplotlib requirements
MarcDrudis Jun 2, 2022
21065cb
Added unittest for creating files
MarcDrudis Jun 2, 2022
6e90d5f
Changed header xyz files
MarcDrudis Jun 2, 2022
def5b85
changed direcotry name
MarcDrudis Jun 2, 2022
4957349
typo
MarcDrudis Jun 2, 2022
ca00a19
Merge branch 'main' into ProteinFoldingInterpretMethod
manoelmarques Jun 2, 2022
0301116
Make matplotlib optional
manoelmarques Jun 3, 2022
c7c59cf
Merge branch 'main' into ProteinFoldingInterpretMethod
mrossinek Jun 3, 2022
67c3f26
Fixed comments
MarcDrudis Jun 3, 2022
673cd2e
merged
MarcDrudis Jun 3, 2022
1426156
Changed type hint
MarcDrudis Jun 3, 2022
e489791
typehint
MarcDrudis Jun 3, 2022
3a6d46f
This version gives a circular import error. The reason is explained i…
MarcDrudis Jun 3, 2022
e91e97e
Attempts
MarcDrudis Jun 3, 2022
3066f62
Fix errors
manoelmarques Jun 3, 2022
d2e3676
Changed Documentation and get_figure
MarcDrudis Jun 3, 2022
bce50af
Made more changes to RENO
MarcDrudis Jun 3, 2022
881d47a
RENO
MarcDrudis Jun 3, 2022
95212e6
reno
MarcDrudis Jun 3, 2022
6e1b6dd
Reno
MarcDrudis Jun 3, 2022
c1927fb
Fixed make html
MarcDrudis Jun 3, 2022
b7702ec
Fix sphinx
woodsp-ibm Jun 3, 2022
a4f82b3
Update releasenotes/notes/protein-folding-result-b344ac3c7f48e3ca.yaml
woodsp-ibm Jun 4, 2022
2f57462
Fixed bug with letters on plot
MarcDrudis Jun 7, 2022
fc70651
Not plotting side chains when there are no side chains
MarcDrudis Jun 7, 2022
4151961
Fixed default values for plotting
MarcDrudis Jun 7, 2022
8d5b925
Make black
MarcDrudis Jun 7, 2022
df2363a
Changed import order
MarcDrudis Jun 7, 2022
c4f39bf
Fixes
MarcDrudis Jun 10, 2022
12364a8
Apply suggestions from code review
MarcDrudis Jun 10, 2022
9802735
Fixed spelling and writing bug
MarcDrudis Jun 10, 2022
957b078
Changes in notebook
MarcDrudis Jun 10, 2022
93008da
Add .editorconfig (#685)
manoelmarques Jun 8, 2022
2dc8937
Overwriting files
MarcDrudis Jun 9, 2022
ff97d71
Notebook
MarcDrudis Jun 9, 2022
27aafcd
Format
MarcDrudis Jun 9, 2022
436e53f
Max's comments
MarcDrudis Jun 10, 2022
8c200ee
Fixed Notebook and changed name get_xyz_data()
MarcDrudis Jun 13, 2022
b402f0d
Merge branch 'main' into ProteinFoldingInterpretMethod
MarcDrudis Jun 13, 2022
0fee680
turn_sequence and tempfile
MarcDrudis Jun 14, 2022
23b666c
Merge branch 'ProteinFoldingInterpretMethod' of https://github.com/Ma…
MarcDrudis Jun 14, 2022
eeee35a
Trailing Whitespace
MarcDrudis Jun 14, 2022
be6d822
make black
MarcDrudis Jun 14, 2022
5e1e398
Changed notebook
MarcDrudis Jun 14, 2022
37f6124
Documentation git_result...
MarcDrudis Jun 15, 2022
ea9950e
black
MarcDrudis Jun 15, 2022
96e22b3
Merge branch 'main' into ProteinFoldingInterpretMethod
MarcDrudis Jun 15, 2022
cc31309
Removed file
MarcDrudis Jun 15, 2022
3480dcf
Merge branch 'ProteinFoldingInterpretMethod' of https://github.com/Ma…
MarcDrudis Jun 15, 2022
e4fac51
Merge branch 'main' into ProteinFoldingInterpretMethod
woodsp-ibm Jun 15, 2022
f45c34e
Fixes
MarcDrudis Jun 16, 2022
96cb57b
Merge branch 'ProteinFoldingInterpretMethod' of https://github.com/Ma…
MarcDrudis Jun 16, 2022
1c34bab
Changed reno
MarcDrudis Jun 16, 2022
1c59ea9
Changed capital letters on testfiles
MarcDrudis Jun 16, 2022
fffea04
Update releasenotes/notes/protein-folding-result-b344ac3c7f48e3ca.yaml
woodsp-ibm Jun 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
# (C) Copyright IBM 2021,2022.
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -10,9 +10,14 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""Defines a protein folding problem that can be passed to algorithms."""
from __future__ import annotations

from typing import Union, List

from qiskit.opflow import PauliSumOp, PauliOp
from qiskit.algorithms import MinimumEigensolverResult

import qiskit_nature.results.protein_folding_result as pfr

from .peptide.peptide import Peptide
from .interactions.interaction import Interaction
Expand Down Expand Up @@ -88,12 +93,21 @@ def _qubit_op_full(self) -> Union[PauliOp, PauliSumOp]:
qubit_operator = self._qubit_op_builder._build_qubit_op()
return qubit_operator

# TODO will be implemented in another issue, including the type hint
def interpret(self):
pass
def interpret(self, raw_result: MinimumEigensolverResult) -> pfr.ProteinFoldingResult:
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
"""
Returns a ProteinFoldingResult object that will allow us to interpret the result obtained.
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
For now we are only interested in the sequence with the biggest amplitude from the eigenstate.
"""
best_sequence = max(raw_result.eigenstate, key=raw_result.eigenstate.get)
return pfr.ProteinFoldingResult(self, best_sequence)

@property
def unused_qubits(self) -> List[int]:
"""Returns the list of indices for qubits in the original problem formulation that were
removed during compression."""
return self._unused_qubits

@property
def peptide(self) -> Peptide:
"""Returns the peptide defining the protein subject to the folding problem."""
return self._peptide
5 changes: 4 additions & 1 deletion qiskit_nature/problems/sampling/sampling_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from typing import Union

from qiskit.opflow import PauliSumOp, PauliOp
from qiskit.algorithms import MinimumEigensolverResult

from qiskit_nature.results import EigenstateResult


class SamplingProblem(ABC):
Expand All @@ -26,6 +29,6 @@ def qubit_op(self) -> Union[PauliOp, PauliSumOp]:

# TODO type hint will be addressed later on
@abstractmethod
def interpret(self):
def interpret(self, raw_result: MinimumEigensolverResult) -> EigenstateResult:
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
"""Interprets results of an optimization."""
pass
87 changes: 76 additions & 11 deletions qiskit_nature/results/protein_folding_result.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021.
# (C) Copyright IBM 2021,2022.
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -10,32 +10,70 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""The protein folding result."""
from __future__ import annotations
from typing import Union
import numpy as np

from qiskit.opflow import PauliOp

from qiskit_nature.problems.sampling.protein_folding.protein_folding_problem import (
ProteinFoldingProblem,
)
import qiskit_nature.problems.sampling.protein_folding.protein_folding_problem as pfp

from qiskit_nature.results import EigenstateResult
from .protein_folding_tools.protein_decoder import ProteinDecoder
from .protein_folding_tools.protein_xyz import ProteinXYZ
from .protein_folding_tools.protein_plotter import ProteinPlotter


class ProteinFoldingResult(EigenstateResult):
"""The protein folding result."""
"""
The Protein Folding Result.
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
"""

def __init__(
self,
protein_folding_problem: ProteinFoldingProblem,
protein_folding_problem: pfp.ProteinFoldingProblem,
best_sequence: Union[str, PauliOp],
) -> None:
"""
Args:
protein_folding_problem: The protein folding problem that led to the result.
best_sequence: The best sequence in the result eigenstate.
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved

"""
super().__init__()
self._protein_folding_problem = protein_folding_problem
self._best_sequence: str = best_sequence
self._best_sequence = best_sequence
self._unused_qubits = self._protein_folding_problem.unused_qubits
self._main_chain_lenght = len(
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
self._protein_folding_problem.peptide.get_main_chain.main_chain_residue_sequence
)
self._side_chain_hot_vector = (
self._protein_folding_problem.peptide.get_side_chain_hot_vector()
)

self._protein_decoder = ProteinDecoder(
best_sequence=self._best_sequence,
side_chain_hot_vector=self._side_chain_hot_vector,
fifth_bit=5 in self._unused_qubits[:6],
)

self._protein_xyz = ProteinXYZ(
self.protein_decoder.get_main_turns(),
self.protein_decoder.get_side_turns(),
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
self._protein_folding_problem.peptide,
)

@property
def protein_decoder(self) -> ProteinDecoder:
"""Returns a ProteinDecoder.
This class will interpret the result bitstring and return the encoded information."""
return self._protein_decoder

@property
def protein_folding_problem(self) -> ProteinFoldingProblem:
"""Returns the protein folding problem."""
return self._protein_folding_problem
def protein_xyz(self) -> ProteinXYZ:
"""Returns a ProteinXYZ. This class will take the encoded turns and
generate the position of every bead in the main and side chains."""
return self._protein_xyz

@property
def best_sequence(self) -> str:
Expand All @@ -48,7 +86,7 @@ def get_result_binary_vector(self) -> str:
number of qubits in the original objective function. This method calculates the original
version of the solution vector. Bits that can take any value without changing the
solution are denoted by '*'."""
unused_qubits = self._protein_folding_problem.unused_qubits
unused_qubits = self._unused_qubits
result = []
offset = 0
size = len(self._best_sequence)
Expand All @@ -60,3 +98,30 @@ def get_result_binary_vector(self) -> str:
result.append(self._best_sequence[index])

return "".join(result[::-1])

def get_xyz_file(self, name: str = None, output_data: bool = False) -> np.ndarray:
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
"""
Generates an xyz_file and returns an array with the data in that file.
Args:
name: Name of the file to be generated.
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
output_data: Boolean indicating whether we want to generate the file or not.
Returns:
An array with the data to be stored in the xyz file.
"""
if name is None:
name = str(self._protein_folding_problem.peptide.get_main_chain.main_chain_residue_sequence)
return self.protein_xyz.get_xyz_file(name, output_data)

def plot_folded_protein(
self, title: str = "Protein Structure", ticks: bool = True, grid: bool = False
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
"""
Plots the molecule in 3D
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
Args:
title: The title of the plot
ticks: Boolean for showing ticks in the graphic
grid: Boolean for showing the grid in the graphic
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved

"""
protein_plotter = ProteinPlotter(self)
protein_plotter.plot(title=title, ticks=ticks, grid=grid)
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions qiskit_nature/results/protein_folding_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
107 changes: 107 additions & 0 deletions qiskit_nature/results/protein_folding_tools/protein_decoder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""An auxiliary class that gets the turns in the main and side chain of a molecule
in ProteinFoldingResult """
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
from typing import Union, List, Tuple


class ProteinDecoder:

"""This class handles the decoding of the compact solution in ProteinFoldingProblem
and returns the information encoded in the result about the turns
associated to the main and side chains.
"""

def __init__(
self, best_sequence: str, side_chain_hot_vector: List[bool], fifth_bit: bool
) -> None:
"""
Args:
best_sequence: Will be the sequence decoded.
side_chain_hot_vector: boolean list with the position of the side chains
unused_qubits: list of qubits compressed in the ProteinFoldingProblem.
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
"""
self._best_sequence = best_sequence
self._side_chain_hot_vector = side_chain_hot_vector
self._fifth_bit = fifth_bit
self._main_chain_lenght = len(side_chain_hot_vector)

def _bitstring_to_turns(self, bitstring: str) -> List[int]:
"""
Takes a bitstring encoding the turns of a chain and retuns the turns as a list of int.

Args:
bitstring: string containing the encoded information.
Returns:
A list of integers decoding the bitstring.
"""
bitstring = bitstring[::-1]
encoding = {"00": 0, "01": 1, "10": 2, "11": 3}
lenght_turns = len(bitstring) // 2
return [encoding[bitstring[2 * i : 2 * (i + 1)]] for i in range(lenght_turns)]

def _split_bitstring(self) -> Tuple[int, int]:
"""Returns the amount of bits in the compact solution corresponding
to each property they encode."""
n_qbits_encoding_main_turns = 2 * (self._main_chain_lenght - 3) - (self._fifth_bit)
n_qbits_encoding_side_turns = 2 * sum(self._side_chain_hot_vector)
return n_qbits_encoding_main_turns, n_qbits_encoding_side_turns

def get_main_turns(self) -> List[int]:
"""
Returns the list of turns for the molecule corresponding to best_sequence.
The first element of the list corresponds to the turn of the second aminoacid in the peptide.
Returns:
A list of integers representing the sequence of turns on the molecule

Notes:
The bitstring will end in 0010 corresponding to turn1=(01) and turn2=(00)
If the second bead doesn't have a side chain the 6th bit
can be set to 1 without loss of generality.
In that case index (5) will belong to the list of unused qubits.
The amount of qubits needed to encode the turns will be 2(N-3) - 1
if no side chain on second main bead or 2(N-3) otherwise.
"""

main_turns_bitstring = self._best_sequence[-self._split_bitstring()[0] :] + "0010"

if self._fifth_bit:
main_turns_bitstring = main_turns_bitstring[:-5] + "1" + main_turns_bitstring[-5:]

return self._bitstring_to_turns(main_turns_bitstring)

def get_side_turns(self) -> List[Union[None, int]]:
MarcDrudis marked this conversation as resolved.
Show resolved Hide resolved
"""
Returns the list of turns from the main bead corresponding to the side chains.
None corresponds to no side chain from that main bead.

Returns:
A list with either an number associated to a turn from
the main bead or None if there is no side bead.

"""
n, m = self._split_bitstring()

side_turns_bitstring = self._best_sequence[-n - m : -n]

side_turns = self._bitstring_to_turns(side_turns_bitstring)

result = []
counter = 0
for element in self._side_chain_hot_vector:
if element:
result.append(side_turns[counter])
counter += 1
else:
result.append(None)

return result
Loading