Skip to content

Instantly share code, notes, and snippets.

@bjonnh
Created February 3, 2019 01:16
Show Gist options
  • Save bjonnh/4b1c975457e426b21dc684649c4230a8 to your computer and use it in GitHub Desktop.
Save bjonnh/4b1c975457e426b21dc684649c4230a8 to your computer and use it in GitHub Desktop.
from enum import Enum
from dataclasses import dataclass, field
from typing import List
class TYPES(Enum):
STD = "std"
WW = "W/W"
HH = "H/H"
SS = "S/S"
WH = "W/H"
WS = "W/S"
HS = "H/S"
STACKED = "stacked"
def create_interactions(basepairs, interactions):
return [basepair
for basepair in basepairs.deck
if basepair.interaction_type in interactions
]
@dataclass
class BasePair:
deck = []
pass
@dataclass
class BasePairs:
"""
Deck of BasePair
"""
deck: List[BasePair] = field(default_factory=list)
interaction_types = [t for t in TYPES]
def __init__(self, basepairs):
self.deck = create_interactions(basepairs, self.interaction_types)
@dataclass
class WS(BasePairs):
interaction_types = [TYPES.WS]
@dataclass
class HS(BasePairs):
interaction_types = [TYPES.HS]
a=WS(BasePair())
print(a)
print(a.interaction_types)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment