body_hash
stringlengths 64
64
| body
stringlengths 23
109k
| docstring
stringlengths 1
57k
| path
stringlengths 4
198
| name
stringlengths 1
115
| repository_name
stringlengths 7
111
| repository_stars
float64 0
191k
| lang
stringclasses 1
value | body_without_docstring
stringlengths 14
108k
| unified
stringlengths 45
133k
|
---|---|---|---|---|---|---|---|---|---|
ed10752e000837919b1e11ea53534f4ee52d23f576088dad7a6f1111af492813 | def down(self, field):
u'下への移動。場合によって固着する。\n '
self.__is_commanded = True
moved = self.move(field, _const.DOWN)
if (not moved):
self.rest(field)
return moved | 下への移動。場合によって固着する。 | Source/pieces/falling.py | down | LucXyMan/starseeker | 0 | python | def down(self, field):
u'\n '
self.__is_commanded = True
moved = self.move(field, _const.DOWN)
if (not moved):
self.rest(field)
return moved | def down(self, field):
u'\n '
self.__is_commanded = True
moved = self.move(field, _const.DOWN)
if (not moved):
self.rest(field)
return moved<|docstring|>下への移動。場合によって固着する。<|endoftext|> |
8a12d65e6eb413eba5fb0cbcac7fb0502e1771e60baf5d800a656ddc28f2fc22 | def to_bottom(self, field):
u'ピースをfield底辺に。\n '
if (not self.__is_rested):
while True:
if (not self.move(field, _const.DOWN)):
return | ピースをfield底辺に。 | Source/pieces/falling.py | to_bottom | LucXyMan/starseeker | 0 | python | def to_bottom(self, field):
u'\n '
if (not self.__is_rested):
while True:
if (not self.move(field, _const.DOWN)):
return | def to_bottom(self, field):
u'\n '
if (not self.__is_rested):
while True:
if (not self.move(field, _const.DOWN)):
return<|docstring|>ピースをfield底辺に。<|endoftext|> |
d896b8695babcb6d5354a63c3c9fba4075df7601455e2f0ad51aa3509a30491d | def drop(self, field):
u'フィールド一番下に落下。\n コマンドを一度入力しなければ反応しない。\n '
if self.__is_commanded:
self.to_bottom(field)
self.rest(field)
else:
self.__is_commanded = True | フィールド一番下に落下。
コマンドを一度入力しなければ反応しない。 | Source/pieces/falling.py | drop | LucXyMan/starseeker | 0 | python | def drop(self, field):
u'フィールド一番下に落下。\n コマンドを一度入力しなければ反応しない。\n '
if self.__is_commanded:
self.to_bottom(field)
self.rest(field)
else:
self.__is_commanded = True | def drop(self, field):
u'フィールド一番下に落下。\n コマンドを一度入力しなければ反応しない。\n '
if self.__is_commanded:
self.to_bottom(field)
self.rest(field)
else:
self.__is_commanded = True<|docstring|>フィールド一番下に落下。
コマンドを一度入力しなければ反応しない。<|endoftext|> |
66170b994fc228e9de168057659a3c967f3a5e64a59709103c756b3659290730 | def __rotate(self, field, clock_wise):
u'回転処理。\n '
def __get_rotation_order(form, angle, clock_wise):
u'回転順序取得。\n '
rotation = (self.__I_ROTATION if (form == 'I') else self.__BASE_ROTATION)
return ((_const.CENTER,) + rotation[clock_wise][angle])
if (not self.__is_rested):
self.__is_commanded = True
old_angle = self.angle
self._pattern.angle = (self._pattern.angle + (1 if clock_wise else (- 1)))
for pos in __get_rotation_order(self._pattern.form, old_angle, clock_wise):
if self.move(field, pos):
return True
self.clear()
self._pattern.rotate(old_angle)
self._create()
return False | 回転処理。 | Source/pieces/falling.py | __rotate | LucXyMan/starseeker | 0 | python | def __rotate(self, field, clock_wise):
u'\n '
def __get_rotation_order(form, angle, clock_wise):
u'回転順序取得。\n '
rotation = (self.__I_ROTATION if (form == 'I') else self.__BASE_ROTATION)
return ((_const.CENTER,) + rotation[clock_wise][angle])
if (not self.__is_rested):
self.__is_commanded = True
old_angle = self.angle
self._pattern.angle = (self._pattern.angle + (1 if clock_wise else (- 1)))
for pos in __get_rotation_order(self._pattern.form, old_angle, clock_wise):
if self.move(field, pos):
return True
self.clear()
self._pattern.rotate(old_angle)
self._create()
return False | def __rotate(self, field, clock_wise):
u'\n '
def __get_rotation_order(form, angle, clock_wise):
u'回転順序取得。\n '
rotation = (self.__I_ROTATION if (form == 'I') else self.__BASE_ROTATION)
return ((_const.CENTER,) + rotation[clock_wise][angle])
if (not self.__is_rested):
self.__is_commanded = True
old_angle = self.angle
self._pattern.angle = (self._pattern.angle + (1 if clock_wise else (- 1)))
for pos in __get_rotation_order(self._pattern.form, old_angle, clock_wise):
if self.move(field, pos):
return True
self.clear()
self._pattern.rotate(old_angle)
self._create()
return False<|docstring|>回転処理。<|endoftext|> |
200b66beacd92ddd362d000affe51139fe1b316272532f34dd13e0843ef5018b | def rotate(self, field, clock_wise=True):
u'通常使用する回転処理。\n '
import material.sound as __sound
old_state = self.state
if self.__is_rotatable:
is_rotated = self.__rotate(field, clock_wise)
if is_rotated:
self.__is_t_spin = (True if (self.is_t and self.is_three_corner(field) and (old_state != self.state)) else False)
self.__rotated += 1
return is_rotated
else:
__sound.SE.play('error')
return False | 通常使用する回転処理。 | Source/pieces/falling.py | rotate | LucXyMan/starseeker | 0 | python | def rotate(self, field, clock_wise=True):
u'\n '
import material.sound as __sound
old_state = self.state
if self.__is_rotatable:
is_rotated = self.__rotate(field, clock_wise)
if is_rotated:
self.__is_t_spin = (True if (self.is_t and self.is_three_corner(field) and (old_state != self.state)) else False)
self.__rotated += 1
return is_rotated
else:
__sound.SE.play('error')
return False | def rotate(self, field, clock_wise=True):
u'\n '
import material.sound as __sound
old_state = self.state
if self.__is_rotatable:
is_rotated = self.__rotate(field, clock_wise)
if is_rotated:
self.__is_t_spin = (True if (self.is_t and self.is_three_corner(field) and (old_state != self.state)) else False)
self.__rotated += 1
return is_rotated
else:
__sound.SE.play('error')
return False<|docstring|>通常使用する回転処理。<|endoftext|> |
24181be4c1c6c9a54a8db41afcafb58d17a43b6ab267335fdc52079f4899fe9d | def detect_rotation(self, field, clock_wise=True):
u'AI用回転処理。\n '
old_state = self.state
if ((not self.__is_rotatable) or (not self.__rotate(field, clock_wise))):
return _const.UNROTATABLE
rotated = self.state
if (not self.__rotate(field, (not clock_wise))):
self.__rotated += 1
return _const.ROTATABLE
elif (old_state.top < rotated.top):
self.state = rotated
self.__rotated += 1
return _const.SHIFTED
elif (self.state == old_state):
self.state = rotated
self.__rotated += 1
return _const.FLEXIBLE
else:
self.state = rotated
self.__rotated += 1
return _const.ROTATABLE | AI用回転処理。 | Source/pieces/falling.py | detect_rotation | LucXyMan/starseeker | 0 | python | def detect_rotation(self, field, clock_wise=True):
u'\n '
old_state = self.state
if ((not self.__is_rotatable) or (not self.__rotate(field, clock_wise))):
return _const.UNROTATABLE
rotated = self.state
if (not self.__rotate(field, (not clock_wise))):
self.__rotated += 1
return _const.ROTATABLE
elif (old_state.top < rotated.top):
self.state = rotated
self.__rotated += 1
return _const.SHIFTED
elif (self.state == old_state):
self.state = rotated
self.__rotated += 1
return _const.FLEXIBLE
else:
self.state = rotated
self.__rotated += 1
return _const.ROTATABLE | def detect_rotation(self, field, clock_wise=True):
u'\n '
old_state = self.state
if ((not self.__is_rotatable) or (not self.__rotate(field, clock_wise))):
return _const.UNROTATABLE
rotated = self.state
if (not self.__rotate(field, (not clock_wise))):
self.__rotated += 1
return _const.ROTATABLE
elif (old_state.top < rotated.top):
self.state = rotated
self.__rotated += 1
return _const.SHIFTED
elif (self.state == old_state):
self.state = rotated
self.__rotated += 1
return _const.FLEXIBLE
else:
self.state = rotated
self.__rotated += 1
return _const.ROTATABLE<|docstring|>AI用回転処理。<|endoftext|> |
5631eeb589de642191956f54f2a763401c1fff9a733d7345635ff9a73f4761ac | def get_target(self, field):
u'ターゲットピース取得。\n '
class _Target(_Operatable):
u'ターゲットピース。\n '
__slots__ = ()
def __init__(self, pattern, pos):
u'コンストラクタ。\n '
super(_Target, self).__init__(pattern.get_target(), pos)
self._create()
def _create(self):
u'ブロック作成。\n '
for block in self._pattern.get_blocks((self.left, self.top)):
block.piece = self
self._blocks.append(block)
for block in self._blocks:
block.set_piece_edge()
if (not self.__is_rested):
old_topleft = self.topleft
self.to_bottom(field)
bottom = self.topleft
self.topleft = old_topleft
return _Target(self._pattern, bottom) | ターゲットピース取得。 | Source/pieces/falling.py | get_target | LucXyMan/starseeker | 0 | python | def get_target(self, field):
u'\n '
class _Target(_Operatable):
u'ターゲットピース。\n '
__slots__ = ()
def __init__(self, pattern, pos):
u'コンストラクタ。\n '
super(_Target, self).__init__(pattern.get_target(), pos)
self._create()
def _create(self):
u'ブロック作成。\n '
for block in self._pattern.get_blocks((self.left, self.top)):
block.piece = self
self._blocks.append(block)
for block in self._blocks:
block.set_piece_edge()
if (not self.__is_rested):
old_topleft = self.topleft
self.to_bottom(field)
bottom = self.topleft
self.topleft = old_topleft
return _Target(self._pattern, bottom) | def get_target(self, field):
u'\n '
class _Target(_Operatable):
u'ターゲットピース。\n '
__slots__ = ()
def __init__(self, pattern, pos):
u'コンストラクタ。\n '
super(_Target, self).__init__(pattern.get_target(), pos)
self._create()
def _create(self):
u'ブロック作成。\n '
for block in self._pattern.get_blocks((self.left, self.top)):
block.piece = self
self._blocks.append(block)
for block in self._blocks:
block.set_piece_edge()
if (not self.__is_rested):
old_topleft = self.topleft
self.to_bottom(field)
bottom = self.topleft
self.topleft = old_topleft
return _Target(self._pattern, bottom)<|docstring|>ターゲットピース取得。<|endoftext|> |
58aeac52cbaacab974749562586fda437b90c710831a988402d3bfd7fb531144 | def is_collide(self, field):
u'接触テスト。\n '
return (field.is_outer(self) or field.is_collide(self)) | 接触テスト。 | Source/pieces/falling.py | is_collide | LucXyMan/starseeker | 0 | python | def is_collide(self, field):
u'\n '
return (field.is_outer(self) or field.is_collide(self)) | def is_collide(self, field):
u'\n '
return (field.is_outer(self) or field.is_collide(self))<|docstring|>接触テスト。<|endoftext|> |
7c99add6f08b34a39a658759cb13fe99e624c758c325497ce41f3e5ea3b34ba4 | def is_three_corner(self, field):
u'角に3つ以上の壁が存在する場合に真。\n '
def __is_wall(point):
u'壁判定。\n '
cell = field.table.get_cell(point)
return ((not cell) or cell.is_block)
return (3 <= sum((1 for point in ((self._left, self._top), (((self._left + self.width) - 1), self._top), (self._left, ((self._top + self.height) - 1)), (((self._left + self.width) - 1), ((self._top + self.height) - 1))) if __is_wall(point)))) | 角に3つ以上の壁が存在する場合に真。 | Source/pieces/falling.py | is_three_corner | LucXyMan/starseeker | 0 | python | def is_three_corner(self, field):
u'\n '
def __is_wall(point):
u'壁判定。\n '
cell = field.table.get_cell(point)
return ((not cell) or cell.is_block)
return (3 <= sum((1 for point in ((self._left, self._top), (((self._left + self.width) - 1), self._top), (self._left, ((self._top + self.height) - 1)), (((self._left + self.width) - 1), ((self._top + self.height) - 1))) if __is_wall(point)))) | def is_three_corner(self, field):
u'\n '
def __is_wall(point):
u'壁判定。\n '
cell = field.table.get_cell(point)
return ((not cell) or cell.is_block)
return (3 <= sum((1 for point in ((self._left, self._top), (((self._left + self.width) - 1), self._top), (self._left, ((self._top + self.height) - 1)), (((self._left + self.width) - 1), ((self._top + self.height) - 1))) if __is_wall(point))))<|docstring|>角に3つ以上の壁が存在する場合に真。<|endoftext|> |
f15f4a2a6254c69e1ab01b25cbd65fc4805ed58423c5eb7bf14edcbdf15e1fc2 | def is_flexible(self, field):
u'逆回転可能判定。\n '
old_state = self.state
for is_clock_wise in (True, False):
if (_const.FLEXIBLE == self.detect_rotation(field, is_clock_wise)):
self.state = old_state
return True
self.state = old_state
return False | 逆回転可能判定。 | Source/pieces/falling.py | is_flexible | LucXyMan/starseeker | 0 | python | def is_flexible(self, field):
u'\n '
old_state = self.state
for is_clock_wise in (True, False):
if (_const.FLEXIBLE == self.detect_rotation(field, is_clock_wise)):
self.state = old_state
return True
self.state = old_state
return False | def is_flexible(self, field):
u'\n '
old_state = self.state
for is_clock_wise in (True, False):
if (_const.FLEXIBLE == self.detect_rotation(field, is_clock_wise)):
self.state = old_state
return True
self.state = old_state
return False<|docstring|>逆回転可能判定。<|endoftext|> |
cb72d0b110aed5da0ababab3470a8c520784d8758995212e311eb5d1666dfac5 | @property
def virtual(self):
u'AI計算用ピース取得。\n '
return self.__class__(self._pattern, self.topleft, True) | AI計算用ピース取得。 | Source/pieces/falling.py | virtual | LucXyMan/starseeker | 0 | python | @property
def virtual(self):
u'\n '
return self.__class__(self._pattern, self.topleft, True) | @property
def virtual(self):
u'\n '
return self.__class__(self._pattern, self.topleft, True)<|docstring|>AI計算用ピース取得。<|endoftext|> |
e8fe45e544f4ccd9118417f405b55600d0ee7101182d170d12c5350d9bbc6275 | @property
def parameter(self):
u'ピース生成パラメータ取得。\n '
piece = self.virtual
piece.topleft = (0, 0)
return (piece.size, piece._pattern.pruning, tuple((block.parameter for block in piece._blocks))) | ピース生成パラメータ取得。 | Source/pieces/falling.py | parameter | LucXyMan/starseeker | 0 | python | @property
def parameter(self):
u'\n '
piece = self.virtual
piece.topleft = (0, 0)
return (piece.size, piece._pattern.pruning, tuple((block.parameter for block in piece._blocks))) | @property
def parameter(self):
u'\n '
piece = self.virtual
piece.topleft = (0, 0)
return (piece.size, piece._pattern.pruning, tuple((block.parameter for block in piece._blocks)))<|docstring|>ピース生成パラメータ取得。<|endoftext|> |
0e918ca1bc4dc5f24cbcd09952e3bdf90b4f9f2f5de82e15ad95023b9ca6d37b | @property
def topleft(self):
u'ピースの左上座標を取得。\n '
return (self._left, self._top) | ピースの左上座標を取得。 | Source/pieces/falling.py | topleft | LucXyMan/starseeker | 0 | python | @property
def topleft(self):
u'\n '
return (self._left, self._top) | @property
def topleft(self):
u'\n '
return (self._left, self._top)<|docstring|>ピースの左上座標を取得。<|endoftext|> |
e221463c19d6c2aabe5b803d5b149879478bab7696c799f17915303d9502f7a3 | @topleft.setter
def topleft(self, value):
u'ピースの左上座標を設定。\n '
self.clear()
(self._left, self._top) = tuple(value)
self._create() | ピースの左上座標を設定。 | Source/pieces/falling.py | topleft | LucXyMan/starseeker | 0 | python | @topleft.setter
def topleft(self, value):
u'\n '
self.clear()
(self._left, self._top) = tuple(value)
self._create() | @topleft.setter
def topleft(self, value):
u'\n '
self.clear()
(self._left, self._top) = tuple(value)
self._create()<|docstring|>ピースの左上座標を設定。<|endoftext|> |
eca7b570b589e79caa7c2e6ee9b4e17643678b5d827f6913a22685095af386a1 | @property
def bottomleft(self):
u'左上位置取得。\n '
return tuple((self._left, (self._top + self.height))) | 左上位置取得。 | Source/pieces/falling.py | bottomleft | LucXyMan/starseeker | 0 | python | @property
def bottomleft(self):
u'\n '
return tuple((self._left, (self._top + self.height))) | @property
def bottomleft(self):
u'\n '
return tuple((self._left, (self._top + self.height)))<|docstring|>左上位置取得。<|endoftext|> |
add41db3be0c9fe069d4e44cd85b70cbfd1070623bb723bb1c46212503c548d7 | @bottomleft.setter
def bottomleft(self, value):
u'左上位置設定。\n '
(left, bottom) = value
self.clear()
(self._left, self._top) = (left, (bottom - self.height))
self._create() | 左上位置設定。 | Source/pieces/falling.py | bottomleft | LucXyMan/starseeker | 0 | python | @bottomleft.setter
def bottomleft(self, value):
u'\n '
(left, bottom) = value
self.clear()
(self._left, self._top) = (left, (bottom - self.height))
self._create() | @bottomleft.setter
def bottomleft(self, value):
u'\n '
(left, bottom) = value
self.clear()
(self._left, self._top) = (left, (bottom - self.height))
self._create()<|docstring|>左上位置設定。<|endoftext|> |
e5496460427c99ccdf0f8ddbab28e188d59be352a39ec08ef5a91229ec804786 | @property
def centerx(self):
u'中心x取得。\n '
return (self.left + (self.width >> 1)) | 中心x取得。 | Source/pieces/falling.py | centerx | LucXyMan/starseeker | 0 | python | @property
def centerx(self):
u'\n '
return (self.left + (self.width >> 1)) | @property
def centerx(self):
u'\n '
return (self.left + (self.width >> 1))<|docstring|>中心x取得。<|endoftext|> |
157f154060045e0a13ec70ef5dd6afc0b6b95e5be6eb0f5b4d5ec197e0327597 | @property
def centery(self):
u'中心y取得。\n '
return (self.top + (self.height >> 1)) | 中心y取得。 | Source/pieces/falling.py | centery | LucXyMan/starseeker | 0 | python | @property
def centery(self):
u'\n '
return (self.top + (self.height >> 1)) | @property
def centery(self):
u'\n '
return (self.top + (self.height >> 1))<|docstring|>中心y取得。<|endoftext|> |
dd37c17abb623d346dbbefc94670dc4df99a2dd32c4a3ea4e5d97fb3e1fdfee4 | @property
def angle(self):
u'角度取得。\n '
return self._pattern.angle | 角度取得。 | Source/pieces/falling.py | angle | LucXyMan/starseeker | 0 | python | @property
def angle(self):
u'\n '
return self._pattern.angle | @property
def angle(self):
u'\n '
return self._pattern.angle<|docstring|>角度取得。<|endoftext|> |
d46c00361782110c92219b85c2891662255f939328c80b14af3d7543fbd028ce | @angle.setter
def angle(self, value):
u'角度設定。\n '
self.clear()
self._pattern.angle = value
self._create() | 角度設定。 | Source/pieces/falling.py | angle | LucXyMan/starseeker | 0 | python | @angle.setter
def angle(self, value):
u'\n '
self.clear()
self._pattern.angle = value
self._create() | @angle.setter
def angle(self, value):
u'\n '
self.clear()
self._pattern.angle = value
self._create()<|docstring|>角度設定。<|endoftext|> |
841aae0bb0ae0f67a3e845d211df672f1055b55d0ba927f680810e25c067b2b1 | @property
def state(self):
u'状態を取得。\n '
return _piece.State(self.topleft, self.angle) | 状態を取得。 | Source/pieces/falling.py | state | LucXyMan/starseeker | 0 | python | @property
def state(self):
u'\n '
return _piece.State(self.topleft, self.angle) | @property
def state(self):
u'\n '
return _piece.State(self.topleft, self.angle)<|docstring|>状態を取得。<|endoftext|> |
6d4c98704d2b7bae49182806ba8f3bd2fb57c15dc437b6fd97b5af52154d5799 | @state.setter
def state(self, value):
u'状態を設定。\n '
self.topleft = value.topleft
self.angle = value.angle | 状態を設定。 | Source/pieces/falling.py | state | LucXyMan/starseeker | 0 | python | @state.setter
def state(self, value):
u'\n '
self.topleft = value.topleft
self.angle = value.angle | @state.setter
def state(self, value):
u'\n '
self.topleft = value.topleft
self.angle = value.angle<|docstring|>状態を設定。<|endoftext|> |
5ecd5488d346e382ac91247ef5a8da01ef994e0cc9e15288dcb3cdc3352fcadd | @property
def form(self):
u'ブロックの形を取得。\n '
return self._pattern.form | ブロックの形を取得。 | Source/pieces/falling.py | form | LucXyMan/starseeker | 0 | python | @property
def form(self):
u'\n '
return self._pattern.form | @property
def form(self):
u'\n '
return self._pattern.form<|docstring|>ブロックの形を取得。<|endoftext|> |
058f5ffbd22c8039046d08a1673789e0d0f8ab7ef3ad1a5e78c3f5e164627d0e | @property
def pruning(self):
u'枝きり種類取得。\n '
return self._pattern.pruning | 枝きり種類取得。 | Source/pieces/falling.py | pruning | LucXyMan/starseeker | 0 | python | @property
def pruning(self):
u'\n '
return self._pattern.pruning | @property
def pruning(self):
u'\n '
return self._pattern.pruning<|docstring|>枝きり種類取得。<|endoftext|> |
2aef1f537006ec237405b127bef34b585407f65f9594759ce07e64806bccfaf2 | @property
def angles(self):
u'回転パターンの数を取得。\n '
return self._pattern.angles | 回転パターンの数を取得。 | Source/pieces/falling.py | angles | LucXyMan/starseeker | 0 | python | @property
def angles(self):
u'\n '
return self._pattern.angles | @property
def angles(self):
u'\n '
return self._pattern.angles<|docstring|>回転パターンの数を取得。<|endoftext|> |
9b19df949d8fd58263b1a66d56721f02d74563ddfaa70361cfe50dcf2c832860 | @property
def __is_rotatable(self):
u'回転可能の場合に真。\n '
return (self.__rotated < self.__ROTATE_LIMIT) | 回転可能の場合に真。 | Source/pieces/falling.py | __is_rotatable | LucXyMan/starseeker | 0 | python | @property
def __is_rotatable(self):
u'\n '
return (self.__rotated < self.__ROTATE_LIMIT) | @property
def __is_rotatable(self):
u'\n '
return (self.__rotated < self.__ROTATE_LIMIT)<|docstring|>回転可能の場合に真。<|endoftext|> |
b953d30732cdc2d81323129b0ccc755eb58c58cee125fd5b7117d0bbea6063dd | @property
def is_rested(self):
u'下に落ちた場合に真。\n '
return self.__is_rested | 下に落ちた場合に真。 | Source/pieces/falling.py | is_rested | LucXyMan/starseeker | 0 | python | @property
def is_rested(self):
u'\n '
return self.__is_rested | @property
def is_rested(self):
u'\n '
return self.__is_rested<|docstring|>下に落ちた場合に真。<|endoftext|> |
4f40d2ef0d9486c80e0cecaee56a26014773529d0ba9ab5587cd1b0da9b2e7e7 | @property
def is_t(self):
u'形がTの場合に真。\n '
return (self._pattern.form == 'T') | 形がTの場合に真。 | Source/pieces/falling.py | is_t | LucXyMan/starseeker | 0 | python | @property
def is_t(self):
u'\n '
return (self._pattern.form == 'T') | @property
def is_t(self):
u'\n '
return (self._pattern.form == 'T')<|docstring|>形がTの場合に真。<|endoftext|> |
02487f8b21c97a622f608fae4a4d42ee7d6936252e0391dab2486e4fa3f57d87 | @property
def is_t_spin(self):
u'T-Spin状態取得。\n '
return self.__is_t_spin | T-Spin状態取得。 | Source/pieces/falling.py | is_t_spin | LucXyMan/starseeker | 0 | python | @property
def is_t_spin(self):
u'\n '
return self.__is_t_spin | @property
def is_t_spin(self):
u'\n '
return self.__is_t_spin<|docstring|>T-Spin状態取得。<|endoftext|> |
4b0654afdeb850f9b208ae3ee983c36bd501acd95deb0999694b091d5083b62d | def __get_rotation_order(form, angle, clock_wise):
u'回転順序取得。\n '
rotation = (self.__I_ROTATION if (form == 'I') else self.__BASE_ROTATION)
return ((_const.CENTER,) + rotation[clock_wise][angle]) | 回転順序取得。 | Source/pieces/falling.py | __get_rotation_order | LucXyMan/starseeker | 0 | python | def __get_rotation_order(form, angle, clock_wise):
u'\n '
rotation = (self.__I_ROTATION if (form == 'I') else self.__BASE_ROTATION)
return ((_const.CENTER,) + rotation[clock_wise][angle]) | def __get_rotation_order(form, angle, clock_wise):
u'\n '
rotation = (self.__I_ROTATION if (form == 'I') else self.__BASE_ROTATION)
return ((_const.CENTER,) + rotation[clock_wise][angle])<|docstring|>回転順序取得。<|endoftext|> |
c2b554050ee4f8ca5e32dbdf5b38ba2cfd7f84527aef23d90bf23fb0fe7793ae | def __is_wall(point):
u'壁判定。\n '
cell = field.table.get_cell(point)
return ((not cell) or cell.is_block) | 壁判定。 | Source/pieces/falling.py | __is_wall | LucXyMan/starseeker | 0 | python | def __is_wall(point):
u'\n '
cell = field.table.get_cell(point)
return ((not cell) or cell.is_block) | def __is_wall(point):
u'\n '
cell = field.table.get_cell(point)
return ((not cell) or cell.is_block)<|docstring|>壁判定。<|endoftext|> |
77a9c87c1ce6a3491846215543de6c411697085240aa7a470df717b599b406a9 | def __init__(self, pattern, pos):
u'コンストラクタ。\n '
super(_Target, self).__init__(pattern.get_target(), pos)
self._create() | コンストラクタ。 | Source/pieces/falling.py | __init__ | LucXyMan/starseeker | 0 | python | def __init__(self, pattern, pos):
u'\n '
super(_Target, self).__init__(pattern.get_target(), pos)
self._create() | def __init__(self, pattern, pos):
u'\n '
super(_Target, self).__init__(pattern.get_target(), pos)
self._create()<|docstring|>コンストラクタ。<|endoftext|> |
5809bdfa240f91bdea8e82208740ad00e630fe9c49e999c513d4d7b67f9908ec | def _create(self):
u'ブロック作成。\n '
for block in self._pattern.get_blocks((self.left, self.top)):
block.piece = self
self._blocks.append(block)
for block in self._blocks:
block.set_piece_edge() | ブロック作成。 | Source/pieces/falling.py | _create | LucXyMan/starseeker | 0 | python | def _create(self):
u'\n '
for block in self._pattern.get_blocks((self.left, self.top)):
block.piece = self
self._blocks.append(block)
for block in self._blocks:
block.set_piece_edge() | def _create(self):
u'\n '
for block in self._pattern.get_blocks((self.left, self.top)):
block.piece = self
self._blocks.append(block)
for block in self._blocks:
block.set_piece_edge()<|docstring|>ブロック作成。<|endoftext|> |
6e55d8fb772b9ec4a9de102cd38eae9fef8d411237071f1f0d0dd996c0f310f1 | def normalize(profiles, features='infer', meta_features='infer', samples='all', method='standardize', output_file='none', compression=None, float_format=None, whiten_center=True, whiten_method='ZCA'):
'\n Normalize features\n\n Arguments:\n profiles - either pandas DataFrame or a file that stores profile data\n features - list of cell painting features [default: "infer"]\n if "infer", then assume cell painting features are those that do not\n start with "Cells", "Nuclei", or "Cytoplasm"\n meta_features - if specified, then output these with specified features\n [default: "infer"]\n samples - string indicating which metadata column and values to use to subset\n the control samples are often used here [default: \'all\']\n the format of this variable will be used in a pd.query() function. An\n example is "Metadata_treatment == \'control\'" (include all quotes)\n method - string indicating how the dataframe will be normalized\n [default: \'standardize\']\n output_file - [default: "none"] if provided, will write annotated profiles to file\n if not specified, will return the annotated profiles. We recommend\n that this output file be suffixed with "_normalized.csv".\n compression - the mechanism to compress [default: None]\n float_format - decimal precision to use in writing output file [default: None]\n For example, use "%.3g" for 3 decimal precision.\n whiten_center - if data should be centered before whitening transform [default: True]\n (only used if method = "whiten")\n whiten_method - the type of whitening normalization used [default: \'ZCA\']\n (only used if method = "whiten")\n\n Return:\n A normalized DataFrame\n '
profiles = load_profiles(profiles)
method = method.lower()
avail_methods = ['standardize', 'robustize', 'mad_robustize', 'whiten']
assert (method in avail_methods), 'operation must be one {}'.format(avail_methods)
if (method == 'standardize'):
scaler = StandardScaler()
elif (method == 'robustize'):
scaler = RobustScaler()
elif (method == 'mad_robustize'):
scaler = RobustMAD()
elif (method == 'whiten'):
scaler = Whiten(center=whiten_center, method=whiten_method)
if (features == 'infer'):
features = infer_cp_features(profiles)
feature_df = profiles.loc[(:, features)]
if (meta_features == 'infer'):
meta_features = infer_cp_features(profiles, metadata=True)
meta_df = profiles.loc[(:, meta_features)]
if (samples == 'all'):
fitted_scaler = scaler.fit(feature_df)
else:
fitted_scaler = scaler.fit(profiles.query(samples).loc[(:, features)])
feature_df = pd.DataFrame(fitted_scaler.transform(feature_df), columns=feature_df.columns, index=feature_df.index)
normalized = meta_df.merge(feature_df, left_index=True, right_index=True)
if (output_file != 'none'):
output(df=normalized, output_filename=output_file, compression=compression, float_format=float_format)
else:
return normalized | Normalize features
Arguments:
profiles - either pandas DataFrame or a file that stores profile data
features - list of cell painting features [default: "infer"]
if "infer", then assume cell painting features are those that do not
start with "Cells", "Nuclei", or "Cytoplasm"
meta_features - if specified, then output these with specified features
[default: "infer"]
samples - string indicating which metadata column and values to use to subset
the control samples are often used here [default: 'all']
the format of this variable will be used in a pd.query() function. An
example is "Metadata_treatment == 'control'" (include all quotes)
method - string indicating how the dataframe will be normalized
[default: 'standardize']
output_file - [default: "none"] if provided, will write annotated profiles to file
if not specified, will return the annotated profiles. We recommend
that this output file be suffixed with "_normalized.csv".
compression - the mechanism to compress [default: None]
float_format - decimal precision to use in writing output file [default: None]
For example, use "%.3g" for 3 decimal precision.
whiten_center - if data should be centered before whitening transform [default: True]
(only used if method = "whiten")
whiten_method - the type of whitening normalization used [default: 'ZCA']
(only used if method = "whiten")
Return:
A normalized DataFrame | pycytominer/normalize.py | normalize | hillsbury/pycytominer | 0 | python | def normalize(profiles, features='infer', meta_features='infer', samples='all', method='standardize', output_file='none', compression=None, float_format=None, whiten_center=True, whiten_method='ZCA'):
'\n Normalize features\n\n Arguments:\n profiles - either pandas DataFrame or a file that stores profile data\n features - list of cell painting features [default: "infer"]\n if "infer", then assume cell painting features are those that do not\n start with "Cells", "Nuclei", or "Cytoplasm"\n meta_features - if specified, then output these with specified features\n [default: "infer"]\n samples - string indicating which metadata column and values to use to subset\n the control samples are often used here [default: \'all\']\n the format of this variable will be used in a pd.query() function. An\n example is "Metadata_treatment == \'control\'" (include all quotes)\n method - string indicating how the dataframe will be normalized\n [default: \'standardize\']\n output_file - [default: "none"] if provided, will write annotated profiles to file\n if not specified, will return the annotated profiles. We recommend\n that this output file be suffixed with "_normalized.csv".\n compression - the mechanism to compress [default: None]\n float_format - decimal precision to use in writing output file [default: None]\n For example, use "%.3g" for 3 decimal precision.\n whiten_center - if data should be centered before whitening transform [default: True]\n (only used if method = "whiten")\n whiten_method - the type of whitening normalization used [default: \'ZCA\']\n (only used if method = "whiten")\n\n Return:\n A normalized DataFrame\n '
profiles = load_profiles(profiles)
method = method.lower()
avail_methods = ['standardize', 'robustize', 'mad_robustize', 'whiten']
assert (method in avail_methods), 'operation must be one {}'.format(avail_methods)
if (method == 'standardize'):
scaler = StandardScaler()
elif (method == 'robustize'):
scaler = RobustScaler()
elif (method == 'mad_robustize'):
scaler = RobustMAD()
elif (method == 'whiten'):
scaler = Whiten(center=whiten_center, method=whiten_method)
if (features == 'infer'):
features = infer_cp_features(profiles)
feature_df = profiles.loc[(:, features)]
if (meta_features == 'infer'):
meta_features = infer_cp_features(profiles, metadata=True)
meta_df = profiles.loc[(:, meta_features)]
if (samples == 'all'):
fitted_scaler = scaler.fit(feature_df)
else:
fitted_scaler = scaler.fit(profiles.query(samples).loc[(:, features)])
feature_df = pd.DataFrame(fitted_scaler.transform(feature_df), columns=feature_df.columns, index=feature_df.index)
normalized = meta_df.merge(feature_df, left_index=True, right_index=True)
if (output_file != 'none'):
output(df=normalized, output_filename=output_file, compression=compression, float_format=float_format)
else:
return normalized | def normalize(profiles, features='infer', meta_features='infer', samples='all', method='standardize', output_file='none', compression=None, float_format=None, whiten_center=True, whiten_method='ZCA'):
'\n Normalize features\n\n Arguments:\n profiles - either pandas DataFrame or a file that stores profile data\n features - list of cell painting features [default: "infer"]\n if "infer", then assume cell painting features are those that do not\n start with "Cells", "Nuclei", or "Cytoplasm"\n meta_features - if specified, then output these with specified features\n [default: "infer"]\n samples - string indicating which metadata column and values to use to subset\n the control samples are often used here [default: \'all\']\n the format of this variable will be used in a pd.query() function. An\n example is "Metadata_treatment == \'control\'" (include all quotes)\n method - string indicating how the dataframe will be normalized\n [default: \'standardize\']\n output_file - [default: "none"] if provided, will write annotated profiles to file\n if not specified, will return the annotated profiles. We recommend\n that this output file be suffixed with "_normalized.csv".\n compression - the mechanism to compress [default: None]\n float_format - decimal precision to use in writing output file [default: None]\n For example, use "%.3g" for 3 decimal precision.\n whiten_center - if data should be centered before whitening transform [default: True]\n (only used if method = "whiten")\n whiten_method - the type of whitening normalization used [default: \'ZCA\']\n (only used if method = "whiten")\n\n Return:\n A normalized DataFrame\n '
profiles = load_profiles(profiles)
method = method.lower()
avail_methods = ['standardize', 'robustize', 'mad_robustize', 'whiten']
assert (method in avail_methods), 'operation must be one {}'.format(avail_methods)
if (method == 'standardize'):
scaler = StandardScaler()
elif (method == 'robustize'):
scaler = RobustScaler()
elif (method == 'mad_robustize'):
scaler = RobustMAD()
elif (method == 'whiten'):
scaler = Whiten(center=whiten_center, method=whiten_method)
if (features == 'infer'):
features = infer_cp_features(profiles)
feature_df = profiles.loc[(:, features)]
if (meta_features == 'infer'):
meta_features = infer_cp_features(profiles, metadata=True)
meta_df = profiles.loc[(:, meta_features)]
if (samples == 'all'):
fitted_scaler = scaler.fit(feature_df)
else:
fitted_scaler = scaler.fit(profiles.query(samples).loc[(:, features)])
feature_df = pd.DataFrame(fitted_scaler.transform(feature_df), columns=feature_df.columns, index=feature_df.index)
normalized = meta_df.merge(feature_df, left_index=True, right_index=True)
if (output_file != 'none'):
output(df=normalized, output_filename=output_file, compression=compression, float_format=float_format)
else:
return normalized<|docstring|>Normalize features
Arguments:
profiles - either pandas DataFrame or a file that stores profile data
features - list of cell painting features [default: "infer"]
if "infer", then assume cell painting features are those that do not
start with "Cells", "Nuclei", or "Cytoplasm"
meta_features - if specified, then output these with specified features
[default: "infer"]
samples - string indicating which metadata column and values to use to subset
the control samples are often used here [default: 'all']
the format of this variable will be used in a pd.query() function. An
example is "Metadata_treatment == 'control'" (include all quotes)
method - string indicating how the dataframe will be normalized
[default: 'standardize']
output_file - [default: "none"] if provided, will write annotated profiles to file
if not specified, will return the annotated profiles. We recommend
that this output file be suffixed with "_normalized.csv".
compression - the mechanism to compress [default: None]
float_format - decimal precision to use in writing output file [default: None]
For example, use "%.3g" for 3 decimal precision.
whiten_center - if data should be centered before whitening transform [default: True]
(only used if method = "whiten")
whiten_method - the type of whitening normalization used [default: 'ZCA']
(only used if method = "whiten")
Return:
A normalized DataFrame<|endoftext|> |
ca6e8978b45cf2278c88def5eea54eb408df5e2b6f4634c97f85998ed86a53a0 | def extract_seq_desc(desc):
'Extract from description the seq id, the origin sequence, start, end and\n strand from a predicted CDS\n\n :param desc: description of a prediced CDS with Prodigal\n\n :return: id of predicted CDS\n :return: id of the origin sequence\n :return: start position of the predicted CDS\n :return: end position of the predicted CDS\n :return: strand of the predicted CDS\n '
split_description = desc.split('#')
seq_id = split_description[0][:(- 1)]
origin_seq = '_'.join(seq_id.split('_')[:(- 1)])
if (seq_id.find('|') != (- 1)):
seq_id = ('cds_%s' % seq_id.split('_')[(- 1)])
start = int(split_description[1].replace(' ', ''))
end = int(split_description[2].replace(' ', ''))
strand = transform_strand(split_description[3].replace(' ', ''))
return (seq_id, origin_seq, start, end, strand) | Extract from description the seq id, the origin sequence, start, end and
strand from a predicted CDS
:param desc: description of a prediced CDS with Prodigal
:return: id of predicted CDS
:return: id of the origin sequence
:return: start position of the predicted CDS
:return: end position of the predicted CDS
:return: strand of the predicted CDS | pylprotpredictor/cds.py | extract_seq_desc | bebatut/PylProtPredictor | 0 | python | def extract_seq_desc(desc):
'Extract from description the seq id, the origin sequence, start, end and\n strand from a predicted CDS\n\n :param desc: description of a prediced CDS with Prodigal\n\n :return: id of predicted CDS\n :return: id of the origin sequence\n :return: start position of the predicted CDS\n :return: end position of the predicted CDS\n :return: strand of the predicted CDS\n '
split_description = desc.split('#')
seq_id = split_description[0][:(- 1)]
origin_seq = '_'.join(seq_id.split('_')[:(- 1)])
if (seq_id.find('|') != (- 1)):
seq_id = ('cds_%s' % seq_id.split('_')[(- 1)])
start = int(split_description[1].replace(' ', ))
end = int(split_description[2].replace(' ', ))
strand = transform_strand(split_description[3].replace(' ', ))
return (seq_id, origin_seq, start, end, strand) | def extract_seq_desc(desc):
'Extract from description the seq id, the origin sequence, start, end and\n strand from a predicted CDS\n\n :param desc: description of a prediced CDS with Prodigal\n\n :return: id of predicted CDS\n :return: id of the origin sequence\n :return: start position of the predicted CDS\n :return: end position of the predicted CDS\n :return: strand of the predicted CDS\n '
split_description = desc.split('#')
seq_id = split_description[0][:(- 1)]
origin_seq = '_'.join(seq_id.split('_')[:(- 1)])
if (seq_id.find('|') != (- 1)):
seq_id = ('cds_%s' % seq_id.split('_')[(- 1)])
start = int(split_description[1].replace(' ', ))
end = int(split_description[2].replace(' ', ))
strand = transform_strand(split_description[3].replace(' ', ))
return (seq_id, origin_seq, start, end, strand)<|docstring|>Extract from description the seq id, the origin sequence, start, end and
strand from a predicted CDS
:param desc: description of a prediced CDS with Prodigal
:return: id of predicted CDS
:return: id of the origin sequence
:return: start position of the predicted CDS
:return: end position of the predicted CDS
:return: strand of the predicted CDS<|endoftext|> |
d9f6e25de9c7c9912a8146c4741da290c457afb0dbc8d8c8ba04355ca49814a6 | def transform_strand(strand_id):
'Transform strand from numerical value to string value\n\n :param strand_id: numerical value to represent a strand (1 or -1)\n\n :return: string value (forward or reverse) for the strand\n '
if (strand_id == '-1'):
return 'reverse'
elif (strand_id == '1'):
return 'forward'
else:
raise ValueError('Wrong strand_id: {}'.format(strand_id)) | Transform strand from numerical value to string value
:param strand_id: numerical value to represent a strand (1 or -1)
:return: string value (forward or reverse) for the strand | pylprotpredictor/cds.py | transform_strand | bebatut/PylProtPredictor | 0 | python | def transform_strand(strand_id):
'Transform strand from numerical value to string value\n\n :param strand_id: numerical value to represent a strand (1 or -1)\n\n :return: string value (forward or reverse) for the strand\n '
if (strand_id == '-1'):
return 'reverse'
elif (strand_id == '1'):
return 'forward'
else:
raise ValueError('Wrong strand_id: {}'.format(strand_id)) | def transform_strand(strand_id):
'Transform strand from numerical value to string value\n\n :param strand_id: numerical value to represent a strand (1 or -1)\n\n :return: string value (forward or reverse) for the strand\n '
if (strand_id == '-1'):
return 'reverse'
elif (strand_id == '1'):
return 'forward'
else:
raise ValueError('Wrong strand_id: {}'.format(strand_id))<|docstring|>Transform strand from numerical value to string value
:param strand_id: numerical value to represent a strand (1 or -1)
:return: string value (forward or reverse) for the strand<|endoftext|> |
99bea37b441473045d74092e65d881b3fbb89d01d86eca530c0118954ff8f97f | def test_to_continue(end, origin_seq_size):
'Test if possible to extract next codon: position still in the genome\n\n :param end: int corresponding to the current end\n :param origin_seq_size: size of the origin sequence\n\n :return: boolean\n '
return ((end + 3) < origin_seq_size) | Test if possible to extract next codon: position still in the genome
:param end: int corresponding to the current end
:param origin_seq_size: size of the origin sequence
:return: boolean | pylprotpredictor/cds.py | test_to_continue | bebatut/PylProtPredictor | 0 | python | def test_to_continue(end, origin_seq_size):
'Test if possible to extract next codon: position still in the genome\n\n :param end: int corresponding to the current end\n :param origin_seq_size: size of the origin sequence\n\n :return: boolean\n '
return ((end + 3) < origin_seq_size) | def test_to_continue(end, origin_seq_size):
'Test if possible to extract next codon: position still in the genome\n\n :param end: int corresponding to the current end\n :param origin_seq_size: size of the origin sequence\n\n :return: boolean\n '
return ((end + 3) < origin_seq_size)<|docstring|>Test if possible to extract next codon: position still in the genome
:param end: int corresponding to the current end
:param origin_seq_size: size of the origin sequence
:return: boolean<|endoftext|> |
a8e537533d95d8bf92a342e1adeb7bca746b70896cecb8547d31da3b7fc9c261 | def find_stop_codon_pos_in_seq(seq):
'Find position of STOP codon inside a sequence (not the last position)\n\n :param seq: string sequence of amino acids\n\n :return: list of position for possible STOP codons in a sequence\n '
stop_codon_pos = []
for i in range((len(seq) - 1)):
if seq.startswith('*', i):
stop_codon_pos.append(i)
return stop_codon_pos | Find position of STOP codon inside a sequence (not the last position)
:param seq: string sequence of amino acids
:return: list of position for possible STOP codons in a sequence | pylprotpredictor/cds.py | find_stop_codon_pos_in_seq | bebatut/PylProtPredictor | 0 | python | def find_stop_codon_pos_in_seq(seq):
'Find position of STOP codon inside a sequence (not the last position)\n\n :param seq: string sequence of amino acids\n\n :return: list of position for possible STOP codons in a sequence\n '
stop_codon_pos = []
for i in range((len(seq) - 1)):
if seq.startswith('*', i):
stop_codon_pos.append(i)
return stop_codon_pos | def find_stop_codon_pos_in_seq(seq):
'Find position of STOP codon inside a sequence (not the last position)\n\n :param seq: string sequence of amino acids\n\n :return: list of position for possible STOP codons in a sequence\n '
stop_codon_pos = []
for i in range((len(seq) - 1)):
if seq.startswith('*', i):
stop_codon_pos.append(i)
return stop_codon_pos<|docstring|>Find position of STOP codon inside a sequence (not the last position)
:param seq: string sequence of amino acids
:return: list of position for possible STOP codons in a sequence<|endoftext|> |
7a540c46fc2390edbb688c20da994f2c76724a64b5343b7c1ce540c674c42204 | def translate(seq):
'Translate a sequence into amino acids while replacing any possible STOP\n codon encoded by TAG by a Pyl amino acid\n\n :param seq: a Seq object\n\n :return: string with the corresponding amino acid sequence with the TAG encoded STOP are replaced by Pyl amino acid\n '
translated_seq = seq.translate(66)
mutable_seq = translated_seq.tomutable()[:(- 1)]
translated_seq = mutable_seq.toseq()
return translated_seq | Translate a sequence into amino acids while replacing any possible STOP
codon encoded by TAG by a Pyl amino acid
:param seq: a Seq object
:return: string with the corresponding amino acid sequence with the TAG encoded STOP are replaced by Pyl amino acid | pylprotpredictor/cds.py | translate | bebatut/PylProtPredictor | 0 | python | def translate(seq):
'Translate a sequence into amino acids while replacing any possible STOP\n codon encoded by TAG by a Pyl amino acid\n\n :param seq: a Seq object\n\n :return: string with the corresponding amino acid sequence with the TAG encoded STOP are replaced by Pyl amino acid\n '
translated_seq = seq.translate(66)
mutable_seq = translated_seq.tomutable()[:(- 1)]
translated_seq = mutable_seq.toseq()
return translated_seq | def translate(seq):
'Translate a sequence into amino acids while replacing any possible STOP\n codon encoded by TAG by a Pyl amino acid\n\n :param seq: a Seq object\n\n :return: string with the corresponding amino acid sequence with the TAG encoded STOP are replaced by Pyl amino acid\n '
translated_seq = seq.translate(66)
mutable_seq = translated_seq.tomutable()[:(- 1)]
translated_seq = mutable_seq.toseq()
return translated_seq<|docstring|>Translate a sequence into amino acids while replacing any possible STOP
codon encoded by TAG by a Pyl amino acid
:param seq: a Seq object
:return: string with the corresponding amino acid sequence with the TAG encoded STOP are replaced by Pyl amino acid<|endoftext|> |
5e11cc9fefbeaef769e58373aed28bb14981e8c672038d9fc3796a0be7173e18 | def __init__(self, seq_id='', origin_seq=None, origin_seq_id='', start=(- 1), end=(- 1), strand='forward', seq=None, alternative_ends=[], alternative_cds=[], alignments=[], conserved_cds=None, rejected_cds=[], status=''):
'Initiate a CDS instance'
self.id = seq_id
self.origin_seq = origin_seq
self.origin_seq_id = origin_seq_id
self.start = start
self.end = end
self.strand = strand
self.seq = seq
self.alternative_ends = alternative_ends
self.alternative_cds = alternative_cds
self.alignments = alignments
self.conserved_cds = conserved_cds
self.rejected_cds = rejected_cds
self.status = status | Initiate a CDS instance | pylprotpredictor/cds.py | __init__ | bebatut/PylProtPredictor | 0 | python | def __init__(self, seq_id=, origin_seq=None, origin_seq_id=, start=(- 1), end=(- 1), strand='forward', seq=None, alternative_ends=[], alternative_cds=[], alignments=[], conserved_cds=None, rejected_cds=[], status=):
self.id = seq_id
self.origin_seq = origin_seq
self.origin_seq_id = origin_seq_id
self.start = start
self.end = end
self.strand = strand
self.seq = seq
self.alternative_ends = alternative_ends
self.alternative_cds = alternative_cds
self.alignments = alignments
self.conserved_cds = conserved_cds
self.rejected_cds = rejected_cds
self.status = status | def __init__(self, seq_id=, origin_seq=None, origin_seq_id=, start=(- 1), end=(- 1), strand='forward', seq=None, alternative_ends=[], alternative_cds=[], alignments=[], conserved_cds=None, rejected_cds=[], status=):
self.id = seq_id
self.origin_seq = origin_seq
self.origin_seq_id = origin_seq_id
self.start = start
self.end = end
self.strand = strand
self.seq = seq
self.alternative_ends = alternative_ends
self.alternative_cds = alternative_cds
self.alignments = alignments
self.conserved_cds = conserved_cds
self.rejected_cds = rejected_cds
self.status = status<|docstring|>Initiate a CDS instance<|endoftext|> |
3b20723416a0bfd8a30ef846581fa273f88810733f1f3abcb8a40e8f786a3ddf | def init_from_record(self, record):
'Initiate a CDS instance with a SeqRecord object\n\n :param record:\n '
(seq_id, origin_seq_id, start, end, strand) = extract_seq_desc(record.description)
self.set_id(seq_id)
self.set_origin_seq_id(origin_seq_id)
self.set_start(start)
self.set_end(end)
self.set_strand(strand)
self.set_seq(record.seq)
self.reset_alternative_cds()
self.reset_rejected_cds()
self.reset_alignments() | Initiate a CDS instance with a SeqRecord object
:param record: | pylprotpredictor/cds.py | init_from_record | bebatut/PylProtPredictor | 0 | python | def init_from_record(self, record):
'Initiate a CDS instance with a SeqRecord object\n\n :param record:\n '
(seq_id, origin_seq_id, start, end, strand) = extract_seq_desc(record.description)
self.set_id(seq_id)
self.set_origin_seq_id(origin_seq_id)
self.set_start(start)
self.set_end(end)
self.set_strand(strand)
self.set_seq(record.seq)
self.reset_alternative_cds()
self.reset_rejected_cds()
self.reset_alignments() | def init_from_record(self, record):
'Initiate a CDS instance with a SeqRecord object\n\n :param record:\n '
(seq_id, origin_seq_id, start, end, strand) = extract_seq_desc(record.description)
self.set_id(seq_id)
self.set_origin_seq_id(origin_seq_id)
self.set_start(start)
self.set_end(end)
self.set_strand(strand)
self.set_seq(record.seq)
self.reset_alternative_cds()
self.reset_rejected_cds()
self.reset_alignments()<|docstring|>Initiate a CDS instance with a SeqRecord object
:param record:<|endoftext|> |
e80c04635587be7b2a9fbd3c6d56235c8e1f0242c02adc2d124292ee7997583e | def init_from_dict(self, in_dict):
'Initiate a CDS instance with a dictionary\n\n :param in_dict: dictionary with attribute for a CDS object\n '
self.set_id(in_dict['id'])
self.set_status(in_dict['status'])
self.set_origin_seq_id(in_dict['origin_seq_id'])
self.set_start(in_dict['start'])
self.set_end(in_dict['end'])
self.set_strand(in_dict['strand'])
self.set_seq(Seq(in_dict['seq']))
self.set_alternative_ends(in_dict['alternative_ends'])
self.reset_alternative_cds()
self.reset_alignments()
self.reset_rejected_cds()
for cds_id in in_dict['alternative_cds']:
new_cds = CDS()
new_cds.init_from_dict(in_dict['alternative_cds'][cds_id])
self.add_alternative_cds(new_cds) | Initiate a CDS instance with a dictionary
:param in_dict: dictionary with attribute for a CDS object | pylprotpredictor/cds.py | init_from_dict | bebatut/PylProtPredictor | 0 | python | def init_from_dict(self, in_dict):
'Initiate a CDS instance with a dictionary\n\n :param in_dict: dictionary with attribute for a CDS object\n '
self.set_id(in_dict['id'])
self.set_status(in_dict['status'])
self.set_origin_seq_id(in_dict['origin_seq_id'])
self.set_start(in_dict['start'])
self.set_end(in_dict['end'])
self.set_strand(in_dict['strand'])
self.set_seq(Seq(in_dict['seq']))
self.set_alternative_ends(in_dict['alternative_ends'])
self.reset_alternative_cds()
self.reset_alignments()
self.reset_rejected_cds()
for cds_id in in_dict['alternative_cds']:
new_cds = CDS()
new_cds.init_from_dict(in_dict['alternative_cds'][cds_id])
self.add_alternative_cds(new_cds) | def init_from_dict(self, in_dict):
'Initiate a CDS instance with a dictionary\n\n :param in_dict: dictionary with attribute for a CDS object\n '
self.set_id(in_dict['id'])
self.set_status(in_dict['status'])
self.set_origin_seq_id(in_dict['origin_seq_id'])
self.set_start(in_dict['start'])
self.set_end(in_dict['end'])
self.set_strand(in_dict['strand'])
self.set_seq(Seq(in_dict['seq']))
self.set_alternative_ends(in_dict['alternative_ends'])
self.reset_alternative_cds()
self.reset_alignments()
self.reset_rejected_cds()
for cds_id in in_dict['alternative_cds']:
new_cds = CDS()
new_cds.init_from_dict(in_dict['alternative_cds'][cds_id])
self.add_alternative_cds(new_cds)<|docstring|>Initiate a CDS instance with a dictionary
:param in_dict: dictionary with attribute for a CDS object<|endoftext|> |
6a10ca9e2f12b0bb8342071280931fedea7f80810d80b5a0e81abfe3d11aa461 | def get_id(self):
'Return the id of the CDS\n\n :return: string corresponding to the id\n '
return self.id | Return the id of the CDS
:return: string corresponding to the id | pylprotpredictor/cds.py | get_id | bebatut/PylProtPredictor | 0 | python | def get_id(self):
'Return the id of the CDS\n\n :return: string corresponding to the id\n '
return self.id | def get_id(self):
'Return the id of the CDS\n\n :return: string corresponding to the id\n '
return self.id<|docstring|>Return the id of the CDS
:return: string corresponding to the id<|endoftext|> |
8b74d47448547cd3e0a72e090c77d140ed2d0f1adf23f87bfdf621d7fa7fb411 | def get_origin_seq_id(self):
'Return the id of origin seq of the CDS\n\n :return: string corresponding to the origin seq\n '
return self.origin_seq_id | Return the id of origin seq of the CDS
:return: string corresponding to the origin seq | pylprotpredictor/cds.py | get_origin_seq_id | bebatut/PylProtPredictor | 0 | python | def get_origin_seq_id(self):
'Return the id of origin seq of the CDS\n\n :return: string corresponding to the origin seq\n '
return self.origin_seq_id | def get_origin_seq_id(self):
'Return the id of origin seq of the CDS\n\n :return: string corresponding to the origin seq\n '
return self.origin_seq_id<|docstring|>Return the id of origin seq of the CDS
:return: string corresponding to the origin seq<|endoftext|> |
061bf1db5e38aad2e611c03876a7e4b25d874782a3e8853a6975bbb811a52fdc | def get_origin_seq(self):
'Return the SeqRecord object corresponding to the origin seq of the CDS\n\n :return: SeqRecord object\n '
return self.origin_seq | Return the SeqRecord object corresponding to the origin seq of the CDS
:return: SeqRecord object | pylprotpredictor/cds.py | get_origin_seq | bebatut/PylProtPredictor | 0 | python | def get_origin_seq(self):
'Return the SeqRecord object corresponding to the origin seq of the CDS\n\n :return: SeqRecord object\n '
return self.origin_seq | def get_origin_seq(self):
'Return the SeqRecord object corresponding to the origin seq of the CDS\n\n :return: SeqRecord object\n '
return self.origin_seq<|docstring|>Return the SeqRecord object corresponding to the origin seq of the CDS
:return: SeqRecord object<|endoftext|> |
07f86ba7ae462268ee2051eb4e131a97b577f4d05dc7b569b03d70d409babd18 | def get_start(self):
'Return the start position of the CDS on the origin sequence\n\n :return: int corresponding to the start position\n '
return self.start | Return the start position of the CDS on the origin sequence
:return: int corresponding to the start position | pylprotpredictor/cds.py | get_start | bebatut/PylProtPredictor | 0 | python | def get_start(self):
'Return the start position of the CDS on the origin sequence\n\n :return: int corresponding to the start position\n '
return self.start | def get_start(self):
'Return the start position of the CDS on the origin sequence\n\n :return: int corresponding to the start position\n '
return self.start<|docstring|>Return the start position of the CDS on the origin sequence
:return: int corresponding to the start position<|endoftext|> |
2bf518c61eeea22d0fefca2a0329437ee72a3fb9daff0a35539013ec149e8229 | def get_end(self):
'Return the end position of the CDS on the origin sequence\n\n :return: int corresponding to the end position\n '
return self.end | Return the end position of the CDS on the origin sequence
:return: int corresponding to the end position | pylprotpredictor/cds.py | get_end | bebatut/PylProtPredictor | 0 | python | def get_end(self):
'Return the end position of the CDS on the origin sequence\n\n :return: int corresponding to the end position\n '
return self.end | def get_end(self):
'Return the end position of the CDS on the origin sequence\n\n :return: int corresponding to the end position\n '
return self.end<|docstring|>Return the end position of the CDS on the origin sequence
:return: int corresponding to the end position<|endoftext|> |
e40c9a2331c787ac33e8faa1c1cc27d48dd437c589c8b74b681a0b598cae9b47 | def get_strand(self):
'Return the strand of the CDS on the origin sequence\n\n :return: string corresponding to the strand (forward or reverse)\n '
return self.strand | Return the strand of the CDS on the origin sequence
:return: string corresponding to the strand (forward or reverse) | pylprotpredictor/cds.py | get_strand | bebatut/PylProtPredictor | 0 | python | def get_strand(self):
'Return the strand of the CDS on the origin sequence\n\n :return: string corresponding to the strand (forward or reverse)\n '
return self.strand | def get_strand(self):
'Return the strand of the CDS on the origin sequence\n\n :return: string corresponding to the strand (forward or reverse)\n '
return self.strand<|docstring|>Return the strand of the CDS on the origin sequence
:return: string corresponding to the strand (forward or reverse)<|endoftext|> |
ed8f48b93f652bb97308b257bf744597227c17f66e8818c0d5dce20bf5a2a73f | def get_seq(self):
'Return the sequence of the CDS\n\n :return: string with the sequence\n '
return self.seq | Return the sequence of the CDS
:return: string with the sequence | pylprotpredictor/cds.py | get_seq | bebatut/PylProtPredictor | 0 | python | def get_seq(self):
'Return the sequence of the CDS\n\n :return: string with the sequence\n '
return self.seq | def get_seq(self):
'Return the sequence of the CDS\n\n :return: string with the sequence\n '
return self.seq<|docstring|>Return the sequence of the CDS
:return: string with the sequence<|endoftext|> |
5ad5a91219a7adbc0d8f61cdc4e9fc9debe599e99ffd1fa89c6e41dbba9bfb69 | def get_alternative_ends(self):
'Return the list of possible alternative ends if the CDS is ending with TAG STOP codon\n\n :return: list of int corresponding to the alternative ends\n '
return self.alternative_ends | Return the list of possible alternative ends if the CDS is ending with TAG STOP codon
:return: list of int corresponding to the alternative ends | pylprotpredictor/cds.py | get_alternative_ends | bebatut/PylProtPredictor | 0 | python | def get_alternative_ends(self):
'Return the list of possible alternative ends if the CDS is ending with TAG STOP codon\n\n :return: list of int corresponding to the alternative ends\n '
return self.alternative_ends | def get_alternative_ends(self):
'Return the list of possible alternative ends if the CDS is ending with TAG STOP codon\n\n :return: list of int corresponding to the alternative ends\n '
return self.alternative_ends<|docstring|>Return the list of possible alternative ends if the CDS is ending with TAG STOP codon
:return: list of int corresponding to the alternative ends<|endoftext|> |
e358d9acdf429de96cdb4dcc7a7ed06687afe00f1708beb0bb73f5e64527437a | def get_alternative_cds(self):
'Return the list of possible alternative CDS if the CDS is ending with TAG STOP codon\n\n :return: list of CDS object\n '
return self.alternative_cds | Return the list of possible alternative CDS if the CDS is ending with TAG STOP codon
:return: list of CDS object | pylprotpredictor/cds.py | get_alternative_cds | bebatut/PylProtPredictor | 0 | python | def get_alternative_cds(self):
'Return the list of possible alternative CDS if the CDS is ending with TAG STOP codon\n\n :return: list of CDS object\n '
return self.alternative_cds | def get_alternative_cds(self):
'Return the list of possible alternative CDS if the CDS is ending with TAG STOP codon\n\n :return: list of CDS object\n '
return self.alternative_cds<|docstring|>Return the list of possible alternative CDS if the CDS is ending with TAG STOP codon
:return: list of CDS object<|endoftext|> |
87a6ea12f131edd83bffc6a0cba40c9ddfbb97a0264e8331a4a71a313e8b9d19 | def get_alignments(self):
'Return the list of alignments\n\n :return: list of alignment object\n '
return self.alignments | Return the list of alignments
:return: list of alignment object | pylprotpredictor/cds.py | get_alignments | bebatut/PylProtPredictor | 0 | python | def get_alignments(self):
'Return the list of alignments\n\n :return: list of alignment object\n '
return self.alignments | def get_alignments(self):
'Return the list of alignments\n\n :return: list of alignment object\n '
return self.alignments<|docstring|>Return the list of alignments
:return: list of alignment object<|endoftext|> |
f973d988a6dc6ae59ebef149aee114d6bc0f733bab4087368f90acaa913b5414 | def get_conserved_cds(self):
'Return the CDS object of the conserved CDS as correct CDS (start, end, sequence)\n\n :return: CDS object of the conserved CDS\n '
return self.conserved_cds | Return the CDS object of the conserved CDS as correct CDS (start, end, sequence)
:return: CDS object of the conserved CDS | pylprotpredictor/cds.py | get_conserved_cds | bebatut/PylProtPredictor | 0 | python | def get_conserved_cds(self):
'Return the CDS object of the conserved CDS as correct CDS (start, end, sequence)\n\n :return: CDS object of the conserved CDS\n '
return self.conserved_cds | def get_conserved_cds(self):
'Return the CDS object of the conserved CDS as correct CDS (start, end, sequence)\n\n :return: CDS object of the conserved CDS\n '
return self.conserved_cds<|docstring|>Return the CDS object of the conserved CDS as correct CDS (start, end, sequence)
:return: CDS object of the conserved CDS<|endoftext|> |
14d5c6ff0803bdeaa89add7a5f31fa7939e2bbd8f619724a291d3ea7cc347bac | def get_rejected_cds(self):
'Return a list of the rejected CDS objects as correct CDS (start, end, sequence)\n\n :return: list of CDS objects\n '
return self.rejected_cds | Return a list of the rejected CDS objects as correct CDS (start, end, sequence)
:return: list of CDS objects | pylprotpredictor/cds.py | get_rejected_cds | bebatut/PylProtPredictor | 0 | python | def get_rejected_cds(self):
'Return a list of the rejected CDS objects as correct CDS (start, end, sequence)\n\n :return: list of CDS objects\n '
return self.rejected_cds | def get_rejected_cds(self):
'Return a list of the rejected CDS objects as correct CDS (start, end, sequence)\n\n :return: list of CDS objects\n '
return self.rejected_cds<|docstring|>Return a list of the rejected CDS objects as correct CDS (start, end, sequence)
:return: list of CDS objects<|endoftext|> |
cb813277df186ce87a5ab19a73085d841c2065893669db63088e0af02a59bba0 | def get_status(self):
'Return the status\n\n :return: string with the status of the CDS\n '
return self.status | Return the status
:return: string with the status of the CDS | pylprotpredictor/cds.py | get_status | bebatut/PylProtPredictor | 0 | python | def get_status(self):
'Return the status\n\n :return: string with the status of the CDS\n '
return self.status | def get_status(self):
'Return the status\n\n :return: string with the status of the CDS\n '
return self.status<|docstring|>Return the status
:return: string with the status of the CDS<|endoftext|> |
6af2f95a0202d376e7f645f7b60967ff15d5f0d16e4cb560e2b9da8fb2ec55ed | def get_stop_codon(self):
'Return the STOP codon of the CDS\n\n :return: the STOP codon\n '
return self.get_seq()[(- 3):] | Return the STOP codon of the CDS
:return: the STOP codon | pylprotpredictor/cds.py | get_stop_codon | bebatut/PylProtPredictor | 0 | python | def get_stop_codon(self):
'Return the STOP codon of the CDS\n\n :return: the STOP codon\n '
return self.get_seq()[(- 3):] | def get_stop_codon(self):
'Return the STOP codon of the CDS\n\n :return: the STOP codon\n '
return self.get_seq()[(- 3):]<|docstring|>Return the STOP codon of the CDS
:return: the STOP codon<|endoftext|> |
58890fbf9532757429fcac4e14d292ce0044bfcd5a68fc193591fa8d86388e0c | def get_origin_seq_size(self):
'Return the length of the origin sequence\n\n :return: int corresponding to the length of the origin sequence\n '
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
return len(self.get_origin_seq().seq) | Return the length of the origin sequence
:return: int corresponding to the length of the origin sequence | pylprotpredictor/cds.py | get_origin_seq_size | bebatut/PylProtPredictor | 0 | python | def get_origin_seq_size(self):
'Return the length of the origin sequence\n\n :return: int corresponding to the length of the origin sequence\n '
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
return len(self.get_origin_seq().seq) | def get_origin_seq_size(self):
'Return the length of the origin sequence\n\n :return: int corresponding to the length of the origin sequence\n '
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
return len(self.get_origin_seq().seq)<|docstring|>Return the length of the origin sequence
:return: int corresponding to the length of the origin sequence<|endoftext|> |
eeca608ca9f03302f4b2200d481fdaed00364cbf25bd1c18e2ad5307156e4f52 | def get_origin_seq_string(self):
'Return the string of the origin sequence\n\n :return: string corresponding to the origin sequence\n '
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
return str(self.get_origin_seq().seq) | Return the string of the origin sequence
:return: string corresponding to the origin sequence | pylprotpredictor/cds.py | get_origin_seq_string | bebatut/PylProtPredictor | 0 | python | def get_origin_seq_string(self):
'Return the string of the origin sequence\n\n :return: string corresponding to the origin sequence\n '
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
return str(self.get_origin_seq().seq) | def get_origin_seq_string(self):
'Return the string of the origin sequence\n\n :return: string corresponding to the origin sequence\n '
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
return str(self.get_origin_seq().seq)<|docstring|>Return the string of the origin sequence
:return: string corresponding to the origin sequence<|endoftext|> |
0ae11c6da0580d39cdb960d9a298f60e24eae37c0d559799b171fca1c32fafae | def get_alternative_start(self):
'Return the list of alternative CDS start\n\n :return: list of the start of the alternative CDS\n '
alt_starts = []
for alt_cds in self.get_alternative_cds():
alt_starts.append(alt_cds.get_start())
return alt_starts | Return the list of alternative CDS start
:return: list of the start of the alternative CDS | pylprotpredictor/cds.py | get_alternative_start | bebatut/PylProtPredictor | 0 | python | def get_alternative_start(self):
'Return the list of alternative CDS start\n\n :return: list of the start of the alternative CDS\n '
alt_starts = []
for alt_cds in self.get_alternative_cds():
alt_starts.append(alt_cds.get_start())
return alt_starts | def get_alternative_start(self):
'Return the list of alternative CDS start\n\n :return: list of the start of the alternative CDS\n '
alt_starts = []
for alt_cds in self.get_alternative_cds():
alt_starts.append(alt_cds.get_start())
return alt_starts<|docstring|>Return the list of alternative CDS start
:return: list of the start of the alternative CDS<|endoftext|> |
439ff1117dbdbbf96575ad2d61a38341080fb36c10c0e88a722aeabb0a7a6a5e | def get_alternative_end(self):
'Return the list of alternative CDS end\n\n :return: list of the end of the alternative CDS\n '
alt_ends = []
for alt_cds in self.get_alternative_cds():
alt_ends.append(alt_cds.get_end())
return alt_ends | Return the list of alternative CDS end
:return: list of the end of the alternative CDS | pylprotpredictor/cds.py | get_alternative_end | bebatut/PylProtPredictor | 0 | python | def get_alternative_end(self):
'Return the list of alternative CDS end\n\n :return: list of the end of the alternative CDS\n '
alt_ends = []
for alt_cds in self.get_alternative_cds():
alt_ends.append(alt_cds.get_end())
return alt_ends | def get_alternative_end(self):
'Return the list of alternative CDS end\n\n :return: list of the end of the alternative CDS\n '
alt_ends = []
for alt_cds in self.get_alternative_cds():
alt_ends.append(alt_cds.get_end())
return alt_ends<|docstring|>Return the list of alternative CDS end
:return: list of the end of the alternative CDS<|endoftext|> |
ac27fb91817c2f7f5033a4ea90ffbbcef6b460c3f2c00d8f77da480f3499a05e | def get_translated_seq(self):
'Return the translated sequence of the CDS\n\n :return: SeqRecord object corresponding to the translated sequence\n '
seq = SeqRecord(translate(self.get_seq()), id=self.get_id(), description=self.export_description())
return seq | Return the translated sequence of the CDS
:return: SeqRecord object corresponding to the translated sequence | pylprotpredictor/cds.py | get_translated_seq | bebatut/PylProtPredictor | 0 | python | def get_translated_seq(self):
'Return the translated sequence of the CDS\n\n :return: SeqRecord object corresponding to the translated sequence\n '
seq = SeqRecord(translate(self.get_seq()), id=self.get_id(), description=self.export_description())
return seq | def get_translated_seq(self):
'Return the translated sequence of the CDS\n\n :return: SeqRecord object corresponding to the translated sequence\n '
seq = SeqRecord(translate(self.get_seq()), id=self.get_id(), description=self.export_description())
return seq<|docstring|>Return the translated sequence of the CDS
:return: SeqRecord object corresponding to the translated sequence<|endoftext|> |
000e7bfa1dbda9480f3270642ec4d6a5071a7a0d470131762aede5a7a8fd41f8 | def get_translated_alternative_seq(self):
'Return a list of the translated sequences of the alternative sequences\n\n :return: list of SeqRecord objects\n '
transl_alt_seq = []
for alt_cds in self.get_alternative_cds():
transl_alt_seq.append(alt_cds.get_translated_seq())
return transl_alt_seq | Return a list of the translated sequences of the alternative sequences
:return: list of SeqRecord objects | pylprotpredictor/cds.py | get_translated_alternative_seq | bebatut/PylProtPredictor | 0 | python | def get_translated_alternative_seq(self):
'Return a list of the translated sequences of the alternative sequences\n\n :return: list of SeqRecord objects\n '
transl_alt_seq = []
for alt_cds in self.get_alternative_cds():
transl_alt_seq.append(alt_cds.get_translated_seq())
return transl_alt_seq | def get_translated_alternative_seq(self):
'Return a list of the translated sequences of the alternative sequences\n\n :return: list of SeqRecord objects\n '
transl_alt_seq = []
for alt_cds in self.get_alternative_cds():
transl_alt_seq.append(alt_cds.get_translated_seq())
return transl_alt_seq<|docstring|>Return a list of the translated sequences of the alternative sequences
:return: list of SeqRecord objects<|endoftext|> |
eb918bbc71d07eb3d5626dac4ccfd79891ebb7c049cc370792555ffb68997d36 | def get_seqrecord(self):
'Return a SeqRecord of the CDS\n\n :return: SeqRecord\n '
seq = SeqRecord(self.get_seq(), id=self.get_id(), description=self.export_description())
return seq | Return a SeqRecord of the CDS
:return: SeqRecord | pylprotpredictor/cds.py | get_seqrecord | bebatut/PylProtPredictor | 0 | python | def get_seqrecord(self):
'Return a SeqRecord of the CDS\n\n :return: SeqRecord\n '
seq = SeqRecord(self.get_seq(), id=self.get_id(), description=self.export_description())
return seq | def get_seqrecord(self):
'Return a SeqRecord of the CDS\n\n :return: SeqRecord\n '
seq = SeqRecord(self.get_seq(), id=self.get_id(), description=self.export_description())
return seq<|docstring|>Return a SeqRecord of the CDS
:return: SeqRecord<|endoftext|> |
d982f6bc6fe28ee0c692b5a070936009ca0df5ac87de5e472fad8f9e1b76021b | def get_lowest_evalue_alignment(self):
'Return the alignment with the lowest evalue\n\n :return: alignment\n '
lowest_evalue = 10
lowest_evalue_al = None
for al in self.get_alignments():
evalue = al.get_evalue()
if (evalue < lowest_evalue):
lowest_evalue = evalue
lowest_evalue_al = al
return lowest_evalue_al | Return the alignment with the lowest evalue
:return: alignment | pylprotpredictor/cds.py | get_lowest_evalue_alignment | bebatut/PylProtPredictor | 0 | python | def get_lowest_evalue_alignment(self):
'Return the alignment with the lowest evalue\n\n :return: alignment\n '
lowest_evalue = 10
lowest_evalue_al = None
for al in self.get_alignments():
evalue = al.get_evalue()
if (evalue < lowest_evalue):
lowest_evalue = evalue
lowest_evalue_al = al
return lowest_evalue_al | def get_lowest_evalue_alignment(self):
'Return the alignment with the lowest evalue\n\n :return: alignment\n '
lowest_evalue = 10
lowest_evalue_al = None
for al in self.get_alignments():
evalue = al.get_evalue()
if (evalue < lowest_evalue):
lowest_evalue = evalue
lowest_evalue_al = al
return lowest_evalue_al<|docstring|>Return the alignment with the lowest evalue
:return: alignment<|endoftext|> |
ddcddad64e99609c67c5062f1572ca560ab90327d046c4b6974149a8903ad4a9 | def get_highest_bitscore(self):
'Return the highest bitscore for all alignments\n\n :return: float\n '
highest_bitscore = 0
for al in self.get_alignments():
bitscore = al.get_bitscore()
if (bitscore > highest_bitscore):
highest_bitscore = bitscore
return highest_bitscore | Return the highest bitscore for all alignments
:return: float | pylprotpredictor/cds.py | get_highest_bitscore | bebatut/PylProtPredictor | 0 | python | def get_highest_bitscore(self):
'Return the highest bitscore for all alignments\n\n :return: float\n '
highest_bitscore = 0
for al in self.get_alignments():
bitscore = al.get_bitscore()
if (bitscore > highest_bitscore):
highest_bitscore = bitscore
return highest_bitscore | def get_highest_bitscore(self):
'Return the highest bitscore for all alignments\n\n :return: float\n '
highest_bitscore = 0
for al in self.get_alignments():
bitscore = al.get_bitscore()
if (bitscore > highest_bitscore):
highest_bitscore = bitscore
return highest_bitscore<|docstring|>Return the highest bitscore for all alignments
:return: float<|endoftext|> |
3b5efb69fcabc0e4661a8f2d106603e7d7f85ea46f6661db30804e21fa7ddfec | def set_id(self, seq_id):
'Change the id of the CDS\n\n :param seq_id: new seq id value\n '
self.id = seq_id | Change the id of the CDS
:param seq_id: new seq id value | pylprotpredictor/cds.py | set_id | bebatut/PylProtPredictor | 0 | python | def set_id(self, seq_id):
'Change the id of the CDS\n\n :param seq_id: new seq id value\n '
self.id = seq_id | def set_id(self, seq_id):
'Change the id of the CDS\n\n :param seq_id: new seq id value\n '
self.id = seq_id<|docstring|>Change the id of the CDS
:param seq_id: new seq id value<|endoftext|> |
ad401816d88c182e61f2dc1e12f273ae823411ed8c9900338c252669ce5f983a | def set_origin_seq_id(self, origin_seq_id):
'Change the id of the origin sequence of the CDS\n\n :param origin_seq_id: new origin seq id value\n '
self.origin_seq_id = origin_seq_id | Change the id of the origin sequence of the CDS
:param origin_seq_id: new origin seq id value | pylprotpredictor/cds.py | set_origin_seq_id | bebatut/PylProtPredictor | 0 | python | def set_origin_seq_id(self, origin_seq_id):
'Change the id of the origin sequence of the CDS\n\n :param origin_seq_id: new origin seq id value\n '
self.origin_seq_id = origin_seq_id | def set_origin_seq_id(self, origin_seq_id):
'Change the id of the origin sequence of the CDS\n\n :param origin_seq_id: new origin seq id value\n '
self.origin_seq_id = origin_seq_id<|docstring|>Change the id of the origin sequence of the CDS
:param origin_seq_id: new origin seq id value<|endoftext|> |
1f4c99f2ca102b3c84af11f0e9bbb1efb1f5822799b181e685b6038c804759b2 | def set_start(self, start):
'Change the start position of the CDS\n\n :param start: new start value (int)\n '
self.start = start | Change the start position of the CDS
:param start: new start value (int) | pylprotpredictor/cds.py | set_start | bebatut/PylProtPredictor | 0 | python | def set_start(self, start):
'Change the start position of the CDS\n\n :param start: new start value (int)\n '
self.start = start | def set_start(self, start):
'Change the start position of the CDS\n\n :param start: new start value (int)\n '
self.start = start<|docstring|>Change the start position of the CDS
:param start: new start value (int)<|endoftext|> |
463afd010cf7edec532b24da32a9d0369a6b25e07b688a97932f39f3cd237b65 | def set_end(self, end):
'Change the end position of the CDS\n\n :param end: new end value (int)\n '
self.end = end | Change the end position of the CDS
:param end: new end value (int) | pylprotpredictor/cds.py | set_end | bebatut/PylProtPredictor | 0 | python | def set_end(self, end):
'Change the end position of the CDS\n\n :param end: new end value (int)\n '
self.end = end | def set_end(self, end):
'Change the end position of the CDS\n\n :param end: new end value (int)\n '
self.end = end<|docstring|>Change the end position of the CDS
:param end: new end value (int)<|endoftext|> |
772b2a765ed9a7a3d5180eac5c53bac8000ffffdbc8770bcc1e056f0cd832d32 | def set_strand(self, strand):
'Change the strand value of the CDS\n\n :param end: new strand (forward or reverse)\n '
if ((strand != 'reverse') and (strand != 'forward')):
raise ValueError(('Incorrect strand value: %s' % strand))
self.strand = strand | Change the strand value of the CDS
:param end: new strand (forward or reverse) | pylprotpredictor/cds.py | set_strand | bebatut/PylProtPredictor | 0 | python | def set_strand(self, strand):
'Change the strand value of the CDS\n\n :param end: new strand (forward or reverse)\n '
if ((strand != 'reverse') and (strand != 'forward')):
raise ValueError(('Incorrect strand value: %s' % strand))
self.strand = strand | def set_strand(self, strand):
'Change the strand value of the CDS\n\n :param end: new strand (forward or reverse)\n '
if ((strand != 'reverse') and (strand != 'forward')):
raise ValueError(('Incorrect strand value: %s' % strand))
self.strand = strand<|docstring|>Change the strand value of the CDS
:param end: new strand (forward or reverse)<|endoftext|> |
659858366680a4df86c5b5c00a5cca2215ff5a7d4a53396b557707c94623707b | def set_seq(self, seq):
'Change the sequence object of the CDS\n\n :param seq: new Seq object with the sequence of the CDS\n '
self.seq = seq | Change the sequence object of the CDS
:param seq: new Seq object with the sequence of the CDS | pylprotpredictor/cds.py | set_seq | bebatut/PylProtPredictor | 0 | python | def set_seq(self, seq):
'Change the sequence object of the CDS\n\n :param seq: new Seq object with the sequence of the CDS\n '
self.seq = seq | def set_seq(self, seq):
'Change the sequence object of the CDS\n\n :param seq: new Seq object with the sequence of the CDS\n '
self.seq = seq<|docstring|>Change the sequence object of the CDS
:param seq: new Seq object with the sequence of the CDS<|endoftext|> |
3799c3bd472f95f80b245b051493846771f7c61d9d03f126f0ed1c3fbf82de62 | def set_origin_seq(self, origin_seq):
'Change the SeqRecord object corresponding to the origin seq of the CDS\n\n :param origin_seq: SeqRecord object\n '
if (self.get_strand() == 'reverse'):
self.origin_seq = origin_seq.reverse_complement()
self.origin_seq.description = origin_seq.description
self.origin_seq.id = origin_seq.id
self.origin_seq.name = origin_seq.name
else:
self.origin_seq = origin_seq | Change the SeqRecord object corresponding to the origin seq of the CDS
:param origin_seq: SeqRecord object | pylprotpredictor/cds.py | set_origin_seq | bebatut/PylProtPredictor | 0 | python | def set_origin_seq(self, origin_seq):
'Change the SeqRecord object corresponding to the origin seq of the CDS\n\n :param origin_seq: SeqRecord object\n '
if (self.get_strand() == 'reverse'):
self.origin_seq = origin_seq.reverse_complement()
self.origin_seq.description = origin_seq.description
self.origin_seq.id = origin_seq.id
self.origin_seq.name = origin_seq.name
else:
self.origin_seq = origin_seq | def set_origin_seq(self, origin_seq):
'Change the SeqRecord object corresponding to the origin seq of the CDS\n\n :param origin_seq: SeqRecord object\n '
if (self.get_strand() == 'reverse'):
self.origin_seq = origin_seq.reverse_complement()
self.origin_seq.description = origin_seq.description
self.origin_seq.id = origin_seq.id
self.origin_seq.name = origin_seq.name
else:
self.origin_seq = origin_seq<|docstring|>Change the SeqRecord object corresponding to the origin seq of the CDS
:param origin_seq: SeqRecord object<|endoftext|> |
25522fca4e5efdef6bc15246a573370ba020c6460e88ec4ce32b58ed0ce352d9 | def set_alternative_ends(self, alternative_ends):
'Change the list of alternative ends\n\n :param alternative_ends: list of int corresponding to the new alternative ends\n '
self.alternative_ends = alternative_ends | Change the list of alternative ends
:param alternative_ends: list of int corresponding to the new alternative ends | pylprotpredictor/cds.py | set_alternative_ends | bebatut/PylProtPredictor | 0 | python | def set_alternative_ends(self, alternative_ends):
'Change the list of alternative ends\n\n :param alternative_ends: list of int corresponding to the new alternative ends\n '
self.alternative_ends = alternative_ends | def set_alternative_ends(self, alternative_ends):
'Change the list of alternative ends\n\n :param alternative_ends: list of int corresponding to the new alternative ends\n '
self.alternative_ends = alternative_ends<|docstring|>Change the list of alternative ends
:param alternative_ends: list of int corresponding to the new alternative ends<|endoftext|> |
966b8be69c6bccf4478bd0c73a5217ae6f01c742d50241e2ca6096f4d656ac27 | def set_evalue(self, evalue):
'Change the evalue\n\n :param evalue: new evalue\n '
self.evalue = evalue | Change the evalue
:param evalue: new evalue | pylprotpredictor/cds.py | set_evalue | bebatut/PylProtPredictor | 0 | python | def set_evalue(self, evalue):
'Change the evalue\n\n :param evalue: new evalue\n '
self.evalue = evalue | def set_evalue(self, evalue):
'Change the evalue\n\n :param evalue: new evalue\n '
self.evalue = evalue<|docstring|>Change the evalue
:param evalue: new evalue<|endoftext|> |
fff2809879f292cca2ae90d5a3093d38521093aa0a31335f043c8792e6de3e0d | def set_status(self, status):
'Change the status\n\n :param status: new status\n '
self.status = status | Change the status
:param status: new status | pylprotpredictor/cds.py | set_status | bebatut/PylProtPredictor | 0 | python | def set_status(self, status):
'Change the status\n\n :param status: new status\n '
self.status = status | def set_status(self, status):
'Change the status\n\n :param status: new status\n '
self.status = status<|docstring|>Change the status
:param status: new status<|endoftext|> |
f6164014218d91523b81933f01d639c90c37119ec1bfaf673667054772585bf3 | def set_conserved_cds(self, conserved_cds):
'Change the conserved CDS\n\n :param conserved_cds: CDS object of the conserved CDS\n '
self.conserved_cds = conserved_cds | Change the conserved CDS
:param conserved_cds: CDS object of the conserved CDS | pylprotpredictor/cds.py | set_conserved_cds | bebatut/PylProtPredictor | 0 | python | def set_conserved_cds(self, conserved_cds):
'Change the conserved CDS\n\n :param conserved_cds: CDS object of the conserved CDS\n '
self.conserved_cds = conserved_cds | def set_conserved_cds(self, conserved_cds):
'Change the conserved CDS\n\n :param conserved_cds: CDS object of the conserved CDS\n '
self.conserved_cds = conserved_cds<|docstring|>Change the conserved CDS
:param conserved_cds: CDS object of the conserved CDS<|endoftext|> |
f27f42ec1e5328edb559b5338fc05d40cbd89aad876589126aa16c2d557be479 | def reset_alternative_cds(self):
'Reset the list of alternative cds'
self.alternative_cds = [] | Reset the list of alternative cds | pylprotpredictor/cds.py | reset_alternative_cds | bebatut/PylProtPredictor | 0 | python | def reset_alternative_cds(self):
self.alternative_cds = [] | def reset_alternative_cds(self):
self.alternative_cds = []<|docstring|>Reset the list of alternative cds<|endoftext|> |
c83c65cb499b50e340698dc9c623cc73e465cd290043078351c0ef2cbcfb80c9 | def add_alternative_cds(self, alternative_cds):
'Add an alternative CDS to the list of possible alternative CDS\n\n :param alternative_cds: a CDS object\n '
self.alternative_cds.append(alternative_cds) | Add an alternative CDS to the list of possible alternative CDS
:param alternative_cds: a CDS object | pylprotpredictor/cds.py | add_alternative_cds | bebatut/PylProtPredictor | 0 | python | def add_alternative_cds(self, alternative_cds):
'Add an alternative CDS to the list of possible alternative CDS\n\n :param alternative_cds: a CDS object\n '
self.alternative_cds.append(alternative_cds) | def add_alternative_cds(self, alternative_cds):
'Add an alternative CDS to the list of possible alternative CDS\n\n :param alternative_cds: a CDS object\n '
self.alternative_cds.append(alternative_cds)<|docstring|>Add an alternative CDS to the list of possible alternative CDS
:param alternative_cds: a CDS object<|endoftext|> |
b2a92971077e4e06ba26376b2e3c43ead4a95eed160cefe372ead168f0c2ca6f | def reset_alignments(self):
'Reset the list of alignments'
self.alignments = []
for alt_cds in self.get_alternative_cds():
alt_cds.reset_alignments() | Reset the list of alignments | pylprotpredictor/cds.py | reset_alignments | bebatut/PylProtPredictor | 0 | python | def reset_alignments(self):
self.alignments = []
for alt_cds in self.get_alternative_cds():
alt_cds.reset_alignments() | def reset_alignments(self):
self.alignments = []
for alt_cds in self.get_alternative_cds():
alt_cds.reset_alignments()<|docstring|>Reset the list of alignments<|endoftext|> |
bcc8cd3d35d8d1e3211854149f76b3b3facc7971f5fb89637790879c7f99fc20 | def add_alignment(self, alignment):
'Add an alignment object to the list of alignment\n\n :param alignment: an alignment object\n '
self.alignments.append(alignment) | Add an alignment object to the list of alignment
:param alignment: an alignment object | pylprotpredictor/cds.py | add_alignment | bebatut/PylProtPredictor | 0 | python | def add_alignment(self, alignment):
'Add an alignment object to the list of alignment\n\n :param alignment: an alignment object\n '
self.alignments.append(alignment) | def add_alignment(self, alignment):
'Add an alignment object to the list of alignment\n\n :param alignment: an alignment object\n '
self.alignments.append(alignment)<|docstring|>Add an alignment object to the list of alignment
:param alignment: an alignment object<|endoftext|> |
9febbaa464ffc3b661d6722aa44d60853b818c21d54dbe9d78928c0a6e97edf6 | def reset_rejected_cds(self):
'Reset the list of rejected cds'
self.rejected_cds = [] | Reset the list of rejected cds | pylprotpredictor/cds.py | reset_rejected_cds | bebatut/PylProtPredictor | 0 | python | def reset_rejected_cds(self):
self.rejected_cds = [] | def reset_rejected_cds(self):
self.rejected_cds = []<|docstring|>Reset the list of rejected cds<|endoftext|> |
09017c7e9e8ff4e61c4bdda8c7f90a04860375c1a662709887ad8eac34a84150 | def add_rejected_cds(self, rejected_cds):
'Add a rejected CDS to the list of rejected CDS\n\n :param rejected_cds: a CDS object\n '
self.rejected_cds.append(rejected_cds) | Add a rejected CDS to the list of rejected CDS
:param rejected_cds: a CDS object | pylprotpredictor/cds.py | add_rejected_cds | bebatut/PylProtPredictor | 0 | python | def add_rejected_cds(self, rejected_cds):
'Add a rejected CDS to the list of rejected CDS\n\n :param rejected_cds: a CDS object\n '
self.rejected_cds.append(rejected_cds) | def add_rejected_cds(self, rejected_cds):
'Add a rejected CDS to the list of rejected CDS\n\n :param rejected_cds: a CDS object\n '
self.rejected_cds.append(rejected_cds)<|docstring|>Add a rejected CDS to the list of rejected CDS
:param rejected_cds: a CDS object<|endoftext|> |
3721184b2443f91f799ee16e25be87bf7ff4e7a40e419f843d77255909c83b2a | def is_reverse_strand(self):
'Test if the strand is reverse\n\n :return: boolean\n '
return (self.get_strand() == 'reverse') | Test if the strand is reverse
:return: boolean | pylprotpredictor/cds.py | is_reverse_strand | bebatut/PylProtPredictor | 0 | python | def is_reverse_strand(self):
'Test if the strand is reverse\n\n :return: boolean\n '
return (self.get_strand() == 'reverse') | def is_reverse_strand(self):
'Test if the strand is reverse\n\n :return: boolean\n '
return (self.get_strand() == 'reverse')<|docstring|>Test if the strand is reverse
:return: boolean<|endoftext|> |
5e189aa750b88e58172bdb6265ad78d2981e396bf804ee7fd44f915c9186b265 | def is_tag_ending_seq(self):
'Test if the sequence is ending with TAG STOP codon\n\n :return: boolean\n '
return (self.get_stop_codon() == 'TAG') | Test if the sequence is ending with TAG STOP codon
:return: boolean | pylprotpredictor/cds.py | is_tag_ending_seq | bebatut/PylProtPredictor | 0 | python | def is_tag_ending_seq(self):
'Test if the sequence is ending with TAG STOP codon\n\n :return: boolean\n '
return (self.get_stop_codon() == 'TAG') | def is_tag_ending_seq(self):
'Test if the sequence is ending with TAG STOP codon\n\n :return: boolean\n '
return (self.get_stop_codon() == 'TAG')<|docstring|>Test if the sequence is ending with TAG STOP codon
:return: boolean<|endoftext|> |
a69dfaef32b123972140df590a1ca97606f9193acdcb5c39e5e285406375df71 | def is_potential_pyl(self):
'Test if the sequence has a status for potential pyl\n\n :return: boolean\n '
return (self.get_status() == 'potential pyl') | Test if the sequence has a status for potential pyl
:return: boolean | pylprotpredictor/cds.py | is_potential_pyl | bebatut/PylProtPredictor | 0 | python | def is_potential_pyl(self):
'Test if the sequence has a status for potential pyl\n\n :return: boolean\n '
return (self.get_status() == 'potential pyl') | def is_potential_pyl(self):
'Test if the sequence has a status for potential pyl\n\n :return: boolean\n '
return (self.get_status() == 'potential pyl')<|docstring|>Test if the sequence has a status for potential pyl
:return: boolean<|endoftext|> |
a1a3e6ffe563be4abca844d6d17109805c83f279761f28839932a800b82f969e | def is_tag_ending(self):
'Test if the sequence has a status for tag-ending\n\n :return: boolean\n '
return (self.get_status() == 'tag-ending') | Test if the sequence has a status for tag-ending
:return: boolean | pylprotpredictor/cds.py | is_tag_ending | bebatut/PylProtPredictor | 0 | python | def is_tag_ending(self):
'Test if the sequence has a status for tag-ending\n\n :return: boolean\n '
return (self.get_status() == 'tag-ending') | def is_tag_ending(self):
'Test if the sequence has a status for tag-ending\n\n :return: boolean\n '
return (self.get_status() == 'tag-ending')<|docstring|>Test if the sequence has a status for tag-ending
:return: boolean<|endoftext|> |
6da58edf8d05b70684aa6187ef344d909f4fd20099a055058f7916a9a4948c94 | def has_alternative_ends(self):
'Test if the list of alternative ends is not empty\n\n :return: boolean\n '
return (len(self.get_alternative_ends()) > 0) | Test if the list of alternative ends is not empty
:return: boolean | pylprotpredictor/cds.py | has_alternative_ends | bebatut/PylProtPredictor | 0 | python | def has_alternative_ends(self):
'Test if the list of alternative ends is not empty\n\n :return: boolean\n '
return (len(self.get_alternative_ends()) > 0) | def has_alternative_ends(self):
'Test if the list of alternative ends is not empty\n\n :return: boolean\n '
return (len(self.get_alternative_ends()) > 0)<|docstring|>Test if the list of alternative ends is not empty
:return: boolean<|endoftext|> |
bbc2fe6a590f976d89b864e9dc42cad3a6e65d6aa8f7db78eb5c88ede56d0740 | def has_alternative_cds(self):
'Test if the CDS has alternative cds\n\n :return: boolean\n '
return (len(self.get_alternative_cds()) > 0) | Test if the CDS has alternative cds
:return: boolean | pylprotpredictor/cds.py | has_alternative_cds | bebatut/PylProtPredictor | 0 | python | def has_alternative_cds(self):
'Test if the CDS has alternative cds\n\n :return: boolean\n '
return (len(self.get_alternative_cds()) > 0) | def has_alternative_cds(self):
'Test if the CDS has alternative cds\n\n :return: boolean\n '
return (len(self.get_alternative_cds()) > 0)<|docstring|>Test if the CDS has alternative cds
:return: boolean<|endoftext|> |
468603b8ec03ef05cb49d6703ba51df7d11fe751c21b60363e1a53d54e34f926 | def has_origin_seq(self):
'Test if the CDS has a origin seq\n\n :return: boolean\n '
return (self.get_origin_seq() is not None) | Test if the CDS has a origin seq
:return: boolean | pylprotpredictor/cds.py | has_origin_seq | bebatut/PylProtPredictor | 0 | python | def has_origin_seq(self):
'Test if the CDS has a origin seq\n\n :return: boolean\n '
return (self.get_origin_seq() is not None) | def has_origin_seq(self):
'Test if the CDS has a origin seq\n\n :return: boolean\n '
return (self.get_origin_seq() is not None)<|docstring|>Test if the CDS has a origin seq
:return: boolean<|endoftext|> |
360bc987b5ed0270e476d9235fa54b00b6d9fafcea5ff1bd782ac54df227fcbf | def find_alternative_ends(self):
'\n Find alternative ends (on the same ORF) for a CDS until the next found STOP\n codon on the genome (or its complement if the CDS is on the reverse strand)\n '
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
origin_seq = self.get_origin_seq_string()
origin_seq_size = self.get_origin_seq_size()
new_end = self.get_end()
if self.is_reverse_strand():
new_end = ((origin_seq_size - self.get_start()) + 1)
stop_codons = CodonTable.unambiguous_dna_by_id[1].stop_codons
to_continue = test_to_continue(new_end, origin_seq_size)
new_ends = []
while to_continue:
codon = origin_seq[new_end:(new_end + 3)]
new_end += 3
if (codon not in stop_codons):
to_continue = test_to_continue(new_end, origin_seq_size)
else:
new_ends.append(new_end)
if (codon != 'TAG'):
to_continue = False
else:
to_continue = test_to_continue(new_end, origin_seq_size)
self.set_alternative_ends(new_ends) | Find alternative ends (on the same ORF) for a CDS until the next found STOP
codon on the genome (or its complement if the CDS is on the reverse strand) | pylprotpredictor/cds.py | find_alternative_ends | bebatut/PylProtPredictor | 0 | python | def find_alternative_ends(self):
'\n Find alternative ends (on the same ORF) for a CDS until the next found STOP\n codon on the genome (or its complement if the CDS is on the reverse strand)\n '
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
origin_seq = self.get_origin_seq_string()
origin_seq_size = self.get_origin_seq_size()
new_end = self.get_end()
if self.is_reverse_strand():
new_end = ((origin_seq_size - self.get_start()) + 1)
stop_codons = CodonTable.unambiguous_dna_by_id[1].stop_codons
to_continue = test_to_continue(new_end, origin_seq_size)
new_ends = []
while to_continue:
codon = origin_seq[new_end:(new_end + 3)]
new_end += 3
if (codon not in stop_codons):
to_continue = test_to_continue(new_end, origin_seq_size)
else:
new_ends.append(new_end)
if (codon != 'TAG'):
to_continue = False
else:
to_continue = test_to_continue(new_end, origin_seq_size)
self.set_alternative_ends(new_ends) | def find_alternative_ends(self):
'\n Find alternative ends (on the same ORF) for a CDS until the next found STOP\n codon on the genome (or its complement if the CDS is on the reverse strand)\n '
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
origin_seq = self.get_origin_seq_string()
origin_seq_size = self.get_origin_seq_size()
new_end = self.get_end()
if self.is_reverse_strand():
new_end = ((origin_seq_size - self.get_start()) + 1)
stop_codons = CodonTable.unambiguous_dna_by_id[1].stop_codons
to_continue = test_to_continue(new_end, origin_seq_size)
new_ends = []
while to_continue:
codon = origin_seq[new_end:(new_end + 3)]
new_end += 3
if (codon not in stop_codons):
to_continue = test_to_continue(new_end, origin_seq_size)
else:
new_ends.append(new_end)
if (codon != 'TAG'):
to_continue = False
else:
to_continue = test_to_continue(new_end, origin_seq_size)
self.set_alternative_ends(new_ends)<|docstring|>Find alternative ends (on the same ORF) for a CDS until the next found STOP
codon on the genome (or its complement if the CDS is on the reverse strand)<|endoftext|> |
ca6b177841f3970ceb8ec4ae7c82a936b56477d0f5b2c814f34324bcd8b84fce | def extract_possible_alternative_seq(self):
'\n Extract the start, end and sequence of different possible sequences for a CDS identified as\n potential PYL CDS\n '
if (not self.has_alternative_ends()):
return
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
origin_seq = self.get_origin_seq_string()
origin_seq_size = self.get_origin_seq_size()
start = self.get_start()
end = self.get_end()
seq_id = self.get_id()
self.reset_alternative_cds()
count = 1
for alt_end in self.get_alternative_ends():
if self.is_reverse_strand():
new_start = ((origin_seq_size - alt_end) + 1)
new_end = end
rev_start = ((origin_seq_size - end) + 1)
new_seq = origin_seq[(rev_start - 1):alt_end]
else:
new_start = start
new_end = alt_end
new_seq = origin_seq[(start - 1):new_end]
new_cds = CDS(seq_id=('%s-%s' % (seq_id, count)), start=new_start, end=new_end, strand=self.get_strand(), origin_seq_id=self.get_origin_seq_id(), seq=Seq(new_seq))
count += 1
self.add_alternative_cds(new_cds) | Extract the start, end and sequence of different possible sequences for a CDS identified as
potential PYL CDS | pylprotpredictor/cds.py | extract_possible_alternative_seq | bebatut/PylProtPredictor | 0 | python | def extract_possible_alternative_seq(self):
'\n Extract the start, end and sequence of different possible sequences for a CDS identified as\n potential PYL CDS\n '
if (not self.has_alternative_ends()):
return
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
origin_seq = self.get_origin_seq_string()
origin_seq_size = self.get_origin_seq_size()
start = self.get_start()
end = self.get_end()
seq_id = self.get_id()
self.reset_alternative_cds()
count = 1
for alt_end in self.get_alternative_ends():
if self.is_reverse_strand():
new_start = ((origin_seq_size - alt_end) + 1)
new_end = end
rev_start = ((origin_seq_size - end) + 1)
new_seq = origin_seq[(rev_start - 1):alt_end]
else:
new_start = start
new_end = alt_end
new_seq = origin_seq[(start - 1):new_end]
new_cds = CDS(seq_id=('%s-%s' % (seq_id, count)), start=new_start, end=new_end, strand=self.get_strand(), origin_seq_id=self.get_origin_seq_id(), seq=Seq(new_seq))
count += 1
self.add_alternative_cds(new_cds) | def extract_possible_alternative_seq(self):
'\n Extract the start, end and sequence of different possible sequences for a CDS identified as\n potential PYL CDS\n '
if (not self.has_alternative_ends()):
return
if (not self.has_origin_seq()):
raise ValueError('No origin sequence provided')
origin_seq = self.get_origin_seq_string()
origin_seq_size = self.get_origin_seq_size()
start = self.get_start()
end = self.get_end()
seq_id = self.get_id()
self.reset_alternative_cds()
count = 1
for alt_end in self.get_alternative_ends():
if self.is_reverse_strand():
new_start = ((origin_seq_size - alt_end) + 1)
new_end = end
rev_start = ((origin_seq_size - end) + 1)
new_seq = origin_seq[(rev_start - 1):alt_end]
else:
new_start = start
new_end = alt_end
new_seq = origin_seq[(start - 1):new_end]
new_cds = CDS(seq_id=('%s-%s' % (seq_id, count)), start=new_start, end=new_end, strand=self.get_strand(), origin_seq_id=self.get_origin_seq_id(), seq=Seq(new_seq))
count += 1
self.add_alternative_cds(new_cds)<|docstring|>Extract the start, end and sequence of different possible sequences for a CDS identified as
potential PYL CDS<|endoftext|> |
f6ec79b38e2ef80dd5ce95d722da4e25dd5ea8bb72f234d9506a371889c8c2cc | def add_id_alignment(self, seq_id, alignment):
'Add alignment to the correct CDS object\n\n :param seq_id: id of the CDS\n :param alignment: alignment object to add\n '
assigned = False
if (seq_id == self.get_id()):
self.add_alignment(alignment)
assigned = True
else:
for alt_cds in self.get_alternative_cds():
if (alt_cds.get_id() == seq_id):
alt_cds.add_alignment(alignment)
assigned = True
if (not assigned):
raise ValueError(('Alignment for %s not assigned to %s' % (seq_id, self.get_id()))) | Add alignment to the correct CDS object
:param seq_id: id of the CDS
:param alignment: alignment object to add | pylprotpredictor/cds.py | add_id_alignment | bebatut/PylProtPredictor | 0 | python | def add_id_alignment(self, seq_id, alignment):
'Add alignment to the correct CDS object\n\n :param seq_id: id of the CDS\n :param alignment: alignment object to add\n '
assigned = False
if (seq_id == self.get_id()):
self.add_alignment(alignment)
assigned = True
else:
for alt_cds in self.get_alternative_cds():
if (alt_cds.get_id() == seq_id):
alt_cds.add_alignment(alignment)
assigned = True
if (not assigned):
raise ValueError(('Alignment for %s not assigned to %s' % (seq_id, self.get_id()))) | def add_id_alignment(self, seq_id, alignment):
'Add alignment to the correct CDS object\n\n :param seq_id: id of the CDS\n :param alignment: alignment object to add\n '
assigned = False
if (seq_id == self.get_id()):
self.add_alignment(alignment)
assigned = True
else:
for alt_cds in self.get_alternative_cds():
if (alt_cds.get_id() == seq_id):
alt_cds.add_alignment(alignment)
assigned = True
if (not assigned):
raise ValueError(('Alignment for %s not assigned to %s' % (seq_id, self.get_id())))<|docstring|>Add alignment to the correct CDS object
:param seq_id: id of the CDS
:param alignment: alignment object to add<|endoftext|> |
c5882832a2b2f3a2415aef60555d56f7fe43da6c8188d7ff4cbc0d772ba8095b | def identify_cons_rej_cds(self):
'Identify which alternative CDS to converse or reject based on the\n evalue and the alignment length: Keep the sequence with a lowest evalue\n and a longer alignment\n\n :return: better alignment\n '
self.reset_rejected_cds()
ref_al = self.get_lowest_evalue_alignment()
if (ref_al is None):
self.set_status('potential pyl - no homologous found')
self.set_conserved_cds(self)
return alignment.Alignment()
self.set_conserved_cds(self)
for alt_cds in self.get_alternative_cds():
alt_al = alt_cds.get_lowest_evalue_alignment()
if (alt_al is None):
continue
if ((alt_al.get_evalue() < ref_al.get_evalue()) and (alt_al.get_length() > ref_al.get_length())):
ref_al = alt_al
self.add_rejected_cds(self.get_conserved_cds())
self.set_conserved_cds(alt_cds)
else:
self.add_rejected_cds(alt_cds)
if (self.get_conserved_cds() == self):
self.set_status('not confirmed potential pyl')
else:
self.set_status('confirmed potential pyl')
return ref_al | Identify which alternative CDS to converse or reject based on the
evalue and the alignment length: Keep the sequence with a lowest evalue
and a longer alignment
:return: better alignment | pylprotpredictor/cds.py | identify_cons_rej_cds | bebatut/PylProtPredictor | 0 | python | def identify_cons_rej_cds(self):
'Identify which alternative CDS to converse or reject based on the\n evalue and the alignment length: Keep the sequence with a lowest evalue\n and a longer alignment\n\n :return: better alignment\n '
self.reset_rejected_cds()
ref_al = self.get_lowest_evalue_alignment()
if (ref_al is None):
self.set_status('potential pyl - no homologous found')
self.set_conserved_cds(self)
return alignment.Alignment()
self.set_conserved_cds(self)
for alt_cds in self.get_alternative_cds():
alt_al = alt_cds.get_lowest_evalue_alignment()
if (alt_al is None):
continue
if ((alt_al.get_evalue() < ref_al.get_evalue()) and (alt_al.get_length() > ref_al.get_length())):
ref_al = alt_al
self.add_rejected_cds(self.get_conserved_cds())
self.set_conserved_cds(alt_cds)
else:
self.add_rejected_cds(alt_cds)
if (self.get_conserved_cds() == self):
self.set_status('not confirmed potential pyl')
else:
self.set_status('confirmed potential pyl')
return ref_al | def identify_cons_rej_cds(self):
'Identify which alternative CDS to converse or reject based on the\n evalue and the alignment length: Keep the sequence with a lowest evalue\n and a longer alignment\n\n :return: better alignment\n '
self.reset_rejected_cds()
ref_al = self.get_lowest_evalue_alignment()
if (ref_al is None):
self.set_status('potential pyl - no homologous found')
self.set_conserved_cds(self)
return alignment.Alignment()
self.set_conserved_cds(self)
for alt_cds in self.get_alternative_cds():
alt_al = alt_cds.get_lowest_evalue_alignment()
if (alt_al is None):
continue
if ((alt_al.get_evalue() < ref_al.get_evalue()) and (alt_al.get_length() > ref_al.get_length())):
ref_al = alt_al
self.add_rejected_cds(self.get_conserved_cds())
self.set_conserved_cds(alt_cds)
else:
self.add_rejected_cds(alt_cds)
if (self.get_conserved_cds() == self):
self.set_status('not confirmed potential pyl')
else:
self.set_status('confirmed potential pyl')
return ref_al<|docstring|>Identify which alternative CDS to converse or reject based on the
evalue and the alignment length: Keep the sequence with a lowest evalue
and a longer alignment
:return: better alignment<|endoftext|> |
fbf84a9be7aac6ddc310b5535a760ff0dcf48c9279845fd114fae1576cdc9c16 | def export_description(self):
'Export the description of the CDS\n\n :return: string with the description\n '
desc = ('# origin_seq: %s # strand: %s # start: %s # end: %s' % (self.get_origin_seq_id(), self.get_strand(), self.get_start(), self.get_end()))
return desc | Export the description of the CDS
:return: string with the description | pylprotpredictor/cds.py | export_description | bebatut/PylProtPredictor | 0 | python | def export_description(self):
'Export the description of the CDS\n\n :return: string with the description\n '
desc = ('# origin_seq: %s # strand: %s # start: %s # end: %s' % (self.get_origin_seq_id(), self.get_strand(), self.get_start(), self.get_end()))
return desc | def export_description(self):
'Export the description of the CDS\n\n :return: string with the description\n '
desc = ('# origin_seq: %s # strand: %s # start: %s # end: %s' % (self.get_origin_seq_id(), self.get_strand(), self.get_start(), self.get_end()))
return desc<|docstring|>Export the description of the CDS
:return: string with the description<|endoftext|> |
9293ef230885a2f458a1c7628c1328d1ad66951a6e24d4004bb44abdb3573c2d | def export_to_dict(self):
'Export the object to CDS\n\n :return: dict corresponding to CDS object\n '
cds_id = self.get_id()
d = {cds_id: {'id': self.get_id(), 'status': self.get_status(), 'origin_seq_id': self.get_origin_seq_id(), 'start': self.get_start(), 'end': self.get_end(), 'strand': self.get_strand(), 'seq': str(self.get_seq()), 'alternative_ends': self.get_alternative_ends(), 'alternative_cds': {}}}
if self.has_alternative_ends():
for alt_cds in self.get_alternative_cds():
d[cds_id]['alternative_cds'].update(alt_cds.export_to_dict())
return d | Export the object to CDS
:return: dict corresponding to CDS object | pylprotpredictor/cds.py | export_to_dict | bebatut/PylProtPredictor | 0 | python | def export_to_dict(self):
'Export the object to CDS\n\n :return: dict corresponding to CDS object\n '
cds_id = self.get_id()
d = {cds_id: {'id': self.get_id(), 'status': self.get_status(), 'origin_seq_id': self.get_origin_seq_id(), 'start': self.get_start(), 'end': self.get_end(), 'strand': self.get_strand(), 'seq': str(self.get_seq()), 'alternative_ends': self.get_alternative_ends(), 'alternative_cds': {}}}
if self.has_alternative_ends():
for alt_cds in self.get_alternative_cds():
d[cds_id]['alternative_cds'].update(alt_cds.export_to_dict())
return d | def export_to_dict(self):
'Export the object to CDS\n\n :return: dict corresponding to CDS object\n '
cds_id = self.get_id()
d = {cds_id: {'id': self.get_id(), 'status': self.get_status(), 'origin_seq_id': self.get_origin_seq_id(), 'start': self.get_start(), 'end': self.get_end(), 'strand': self.get_strand(), 'seq': str(self.get_seq()), 'alternative_ends': self.get_alternative_ends(), 'alternative_cds': {}}}
if self.has_alternative_ends():
for alt_cds in self.get_alternative_cds():
d[cds_id]['alternative_cds'].update(alt_cds.export_to_dict())
return d<|docstring|>Export the object to CDS
:return: dict corresponding to CDS object<|endoftext|> |
ddd7654cc8b2cb2792c3fe8f2c5e425029be5e487a77a9c28b37a5a59fd87078 | def map(self, fn, *iterables, timeout=None, prefetch=None):
'Lazy apdaption of ThreadPoolExecutor.map.\n\n Unlike ThreadPoolExecutor.map:\n - iterables are prefetched lazily\n - if only a single iterable is specified, iter(iterables[0]) is used\n instead of zip(*iterables) to obtain a iterator over the arguments\n that are mapped to fn. This is to match the behavior of\n mxnet.gluon.Dataset.transform and gluonnlp.data.DataStream.transform\n which unpack argument tuples.\n\n '
if (timeout is not None):
end_time = (timeout + time.time())
if (prefetch is None):
prefetch = self._max_workers
if (prefetch < 0):
raise ValueError('prefetch count may not be negative')
if (len(iterables) > 1):
argsiter = zip(*iterables)
else:
argsiter = iter(iterables[0])
fs = collections.deque((self.submit(fn, *args) for args in itertools.islice(argsiter, (self._max_workers + prefetch))))
def _result_iterator():
nonlocal argsiter
try:
while fs:
res = (fs[0].result() if (timeout is None) else fs[0].result((end_time - time.time())))
del fs[0]
if argsiter:
try:
args = next(argsiter)
except StopIteration:
argsiter = None
else:
fs.append(self.submit(fn, *args))
(yield res)
finally:
for future in fs:
future.cancel()
return _result_iterator() | Lazy apdaption of ThreadPoolExecutor.map.
Unlike ThreadPoolExecutor.map:
- iterables are prefetched lazily
- if only a single iterable is specified, iter(iterables[0]) is used
instead of zip(*iterables) to obtain a iterator over the arguments
that are mapped to fn. This is to match the behavior of
mxnet.gluon.Dataset.transform and gluonnlp.data.DataStream.transform
which unpack argument tuples. | scripts/word_embeddings/executors.py | map | faramarzmunshi/gluon-nlp | 2 | python | def map(self, fn, *iterables, timeout=None, prefetch=None):
'Lazy apdaption of ThreadPoolExecutor.map.\n\n Unlike ThreadPoolExecutor.map:\n - iterables are prefetched lazily\n - if only a single iterable is specified, iter(iterables[0]) is used\n instead of zip(*iterables) to obtain a iterator over the arguments\n that are mapped to fn. This is to match the behavior of\n mxnet.gluon.Dataset.transform and gluonnlp.data.DataStream.transform\n which unpack argument tuples.\n\n '
if (timeout is not None):
end_time = (timeout + time.time())
if (prefetch is None):
prefetch = self._max_workers
if (prefetch < 0):
raise ValueError('prefetch count may not be negative')
if (len(iterables) > 1):
argsiter = zip(*iterables)
else:
argsiter = iter(iterables[0])
fs = collections.deque((self.submit(fn, *args) for args in itertools.islice(argsiter, (self._max_workers + prefetch))))
def _result_iterator():
nonlocal argsiter
try:
while fs:
res = (fs[0].result() if (timeout is None) else fs[0].result((end_time - time.time())))
del fs[0]
if argsiter:
try:
args = next(argsiter)
except StopIteration:
argsiter = None
else:
fs.append(self.submit(fn, *args))
(yield res)
finally:
for future in fs:
future.cancel()
return _result_iterator() | def map(self, fn, *iterables, timeout=None, prefetch=None):
'Lazy apdaption of ThreadPoolExecutor.map.\n\n Unlike ThreadPoolExecutor.map:\n - iterables are prefetched lazily\n - if only a single iterable is specified, iter(iterables[0]) is used\n instead of zip(*iterables) to obtain a iterator over the arguments\n that are mapped to fn. This is to match the behavior of\n mxnet.gluon.Dataset.transform and gluonnlp.data.DataStream.transform\n which unpack argument tuples.\n\n '
if (timeout is not None):
end_time = (timeout + time.time())
if (prefetch is None):
prefetch = self._max_workers
if (prefetch < 0):
raise ValueError('prefetch count may not be negative')
if (len(iterables) > 1):
argsiter = zip(*iterables)
else:
argsiter = iter(iterables[0])
fs = collections.deque((self.submit(fn, *args) for args in itertools.islice(argsiter, (self._max_workers + prefetch))))
def _result_iterator():
nonlocal argsiter
try:
while fs:
res = (fs[0].result() if (timeout is None) else fs[0].result((end_time - time.time())))
del fs[0]
if argsiter:
try:
args = next(argsiter)
except StopIteration:
argsiter = None
else:
fs.append(self.submit(fn, *args))
(yield res)
finally:
for future in fs:
future.cancel()
return _result_iterator()<|docstring|>Lazy apdaption of ThreadPoolExecutor.map.
Unlike ThreadPoolExecutor.map:
- iterables are prefetched lazily
- if only a single iterable is specified, iter(iterables[0]) is used
instead of zip(*iterables) to obtain a iterator over the arguments
that are mapped to fn. This is to match the behavior of
mxnet.gluon.Dataset.transform and gluonnlp.data.DataStream.transform
which unpack argument tuples.<|endoftext|> |
f21063e3e9c34f1f9b6c52c7d3c27e100bc91b25434c9f84170c677e4e360be0 | def XXX(self, str):
'\n :type str: str\n :rtype: int\n '
import math
s = str.strip()
if ((s == '') or (s[0] not in '-+0123456789')):
return 0
if ((s[0] in '+-') and ((len(s) == 1) or (not s[1].isdigit()))):
return 0
cont_str = ''
flag = ''
if (s[0] in '-+'):
flag = s[0]
s = s[1:]
for c in s:
if c.isdigit():
cont_str += c
else:
break
(INT_MIN, INT_MAX) = ((- 2147483648), 2147483647)
val = int(cont_str)
if (flag == '-'):
return ((- val) if ((- val) >= INT_MIN) else INT_MIN)
else:
return (val if (val <= (INT_MAX - 1)) else INT_MAX) | :type str: str
:rtype: int | Dataset/Leetcode/train/8/118.py | XXX | kkcookies99/UAST | 0 | python | def XXX(self, str):
'\n :type str: str\n :rtype: int\n '
import math
s = str.strip()
if ((s == ) or (s[0] not in '-+0123456789')):
return 0
if ((s[0] in '+-') and ((len(s) == 1) or (not s[1].isdigit()))):
return 0
cont_str =
flag =
if (s[0] in '-+'):
flag = s[0]
s = s[1:]
for c in s:
if c.isdigit():
cont_str += c
else:
break
(INT_MIN, INT_MAX) = ((- 2147483648), 2147483647)
val = int(cont_str)
if (flag == '-'):
return ((- val) if ((- val) >= INT_MIN) else INT_MIN)
else:
return (val if (val <= (INT_MAX - 1)) else INT_MAX) | def XXX(self, str):
'\n :type str: str\n :rtype: int\n '
import math
s = str.strip()
if ((s == ) or (s[0] not in '-+0123456789')):
return 0
if ((s[0] in '+-') and ((len(s) == 1) or (not s[1].isdigit()))):
return 0
cont_str =
flag =
if (s[0] in '-+'):
flag = s[0]
s = s[1:]
for c in s:
if c.isdigit():
cont_str += c
else:
break
(INT_MIN, INT_MAX) = ((- 2147483648), 2147483647)
val = int(cont_str)
if (flag == '-'):
return ((- val) if ((- val) >= INT_MIN) else INT_MIN)
else:
return (val if (val <= (INT_MAX - 1)) else INT_MAX)<|docstring|>:type str: str
:rtype: int<|endoftext|> |
d2b2781366753b06e2edc34612812e2fc7ac7f592a7fa7f872fcbe73d412afe2 | @abstractmethod
def convert(self, operator: OperatorBase, params: Optional[Union[(ParameterExpression, ParameterVector, List[ParameterExpression], Tuple[(ParameterExpression, ParameterExpression)], List[Tuple[(ParameterExpression, ParameterExpression)]])]]=None) -> OperatorBase:
'\n Args:\n operator: The operator we are taking the gradient of\n params: The parameters we are taking the gradient wrt: ω\n If a ParameterExpression, ParameterVector or List[ParameterExpression] is given,\n then the 1st order derivative of the operator is calculated.\n If a Tuple[ParameterExpression, ParameterExpression] or\n List[Tuple[ParameterExpression, ParameterExpression]]\n is given, then the 2nd order derivative of the operator is calculated.\n\n Returns:\n An operator whose evaluation yields the Gradient.\n\n Raises:\n ValueError: If ``params`` contains a parameter not present in ``operator``.\n '
raise NotImplementedError | Args:
operator: The operator we are taking the gradient of
params: The parameters we are taking the gradient wrt: ω
If a ParameterExpression, ParameterVector or List[ParameterExpression] is given,
then the 1st order derivative of the operator is calculated.
If a Tuple[ParameterExpression, ParameterExpression] or
List[Tuple[ParameterExpression, ParameterExpression]]
is given, then the 2nd order derivative of the operator is calculated.
Returns:
An operator whose evaluation yields the Gradient.
Raises:
ValueError: If ``params`` contains a parameter not present in ``operator``. | qiskit/opflow/gradients/circuit_gradients/circuit_gradient.py | convert | biblio-techers/Qiskit-Fall-Fest-2021 | 1,599 | python | @abstractmethod
def convert(self, operator: OperatorBase, params: Optional[Union[(ParameterExpression, ParameterVector, List[ParameterExpression], Tuple[(ParameterExpression, ParameterExpression)], List[Tuple[(ParameterExpression, ParameterExpression)]])]]=None) -> OperatorBase:
'\n Args:\n operator: The operator we are taking the gradient of\n params: The parameters we are taking the gradient wrt: ω\n If a ParameterExpression, ParameterVector or List[ParameterExpression] is given,\n then the 1st order derivative of the operator is calculated.\n If a Tuple[ParameterExpression, ParameterExpression] or\n List[Tuple[ParameterExpression, ParameterExpression]]\n is given, then the 2nd order derivative of the operator is calculated.\n\n Returns:\n An operator whose evaluation yields the Gradient.\n\n Raises:\n ValueError: If ``params`` contains a parameter not present in ``operator``.\n '
raise NotImplementedError | @abstractmethod
def convert(self, operator: OperatorBase, params: Optional[Union[(ParameterExpression, ParameterVector, List[ParameterExpression], Tuple[(ParameterExpression, ParameterExpression)], List[Tuple[(ParameterExpression, ParameterExpression)]])]]=None) -> OperatorBase:
'\n Args:\n operator: The operator we are taking the gradient of\n params: The parameters we are taking the gradient wrt: ω\n If a ParameterExpression, ParameterVector or List[ParameterExpression] is given,\n then the 1st order derivative of the operator is calculated.\n If a Tuple[ParameterExpression, ParameterExpression] or\n List[Tuple[ParameterExpression, ParameterExpression]]\n is given, then the 2nd order derivative of the operator is calculated.\n\n Returns:\n An operator whose evaluation yields the Gradient.\n\n Raises:\n ValueError: If ``params`` contains a parameter not present in ``operator``.\n '
raise NotImplementedError<|docstring|>Args:
operator: The operator we are taking the gradient of
params: The parameters we are taking the gradient wrt: ω
If a ParameterExpression, ParameterVector or List[ParameterExpression] is given,
then the 1st order derivative of the operator is calculated.
If a Tuple[ParameterExpression, ParameterExpression] or
List[Tuple[ParameterExpression, ParameterExpression]]
is given, then the 2nd order derivative of the operator is calculated.
Returns:
An operator whose evaluation yields the Gradient.
Raises:
ValueError: If ``params`` contains a parameter not present in ``operator``.<|endoftext|> |
39cab91789cd5d06dbcd249ce71dd6777150b9f2361c0bef87e0f0cc82dcd3db | @staticmethod
def _transpile_to_supported_operations(circuit: QuantumCircuit, supported_gates: Set[str]) -> QuantumCircuit:
'Transpile the given circuit into a gate set for which the gradients may be computed.\n\n Args:\n circuit: Quantum circuit to be transpiled into supported operations.\n supported_gates: Set of quantum operations supported by a gradient method intended to\n be used on the quantum circuit.\n\n Returns:\n Quantum circuit which is transpiled into supported operations.\n\n Raises:\n QiskitError: when circuit transpiling fails.\n\n '
unique_ops = set(circuit.count_ops())
if (not unique_ops.issubset(supported_gates)):
try:
circuit = transpile(circuit, basis_gates=list(supported_gates), optimization_level=0)
except Exception as exc:
raise QiskitError(f'Could not transpile the circuit provided {circuit} into supported gates {supported_gates}.') from exc
return circuit | Transpile the given circuit into a gate set for which the gradients may be computed.
Args:
circuit: Quantum circuit to be transpiled into supported operations.
supported_gates: Set of quantum operations supported by a gradient method intended to
be used on the quantum circuit.
Returns:
Quantum circuit which is transpiled into supported operations.
Raises:
QiskitError: when circuit transpiling fails. | qiskit/opflow/gradients/circuit_gradients/circuit_gradient.py | _transpile_to_supported_operations | biblio-techers/Qiskit-Fall-Fest-2021 | 1,599 | python | @staticmethod
def _transpile_to_supported_operations(circuit: QuantumCircuit, supported_gates: Set[str]) -> QuantumCircuit:
'Transpile the given circuit into a gate set for which the gradients may be computed.\n\n Args:\n circuit: Quantum circuit to be transpiled into supported operations.\n supported_gates: Set of quantum operations supported by a gradient method intended to\n be used on the quantum circuit.\n\n Returns:\n Quantum circuit which is transpiled into supported operations.\n\n Raises:\n QiskitError: when circuit transpiling fails.\n\n '
unique_ops = set(circuit.count_ops())
if (not unique_ops.issubset(supported_gates)):
try:
circuit = transpile(circuit, basis_gates=list(supported_gates), optimization_level=0)
except Exception as exc:
raise QiskitError(f'Could not transpile the circuit provided {circuit} into supported gates {supported_gates}.') from exc
return circuit | @staticmethod
def _transpile_to_supported_operations(circuit: QuantumCircuit, supported_gates: Set[str]) -> QuantumCircuit:
'Transpile the given circuit into a gate set for which the gradients may be computed.\n\n Args:\n circuit: Quantum circuit to be transpiled into supported operations.\n supported_gates: Set of quantum operations supported by a gradient method intended to\n be used on the quantum circuit.\n\n Returns:\n Quantum circuit which is transpiled into supported operations.\n\n Raises:\n QiskitError: when circuit transpiling fails.\n\n '
unique_ops = set(circuit.count_ops())
if (not unique_ops.issubset(supported_gates)):
try:
circuit = transpile(circuit, basis_gates=list(supported_gates), optimization_level=0)
except Exception as exc:
raise QiskitError(f'Could not transpile the circuit provided {circuit} into supported gates {supported_gates}.') from exc
return circuit<|docstring|>Transpile the given circuit into a gate set for which the gradients may be computed.
Args:
circuit: Quantum circuit to be transpiled into supported operations.
supported_gates: Set of quantum operations supported by a gradient method intended to
be used on the quantum circuit.
Returns:
Quantum circuit which is transpiled into supported operations.
Raises:
QiskitError: when circuit transpiling fails.<|endoftext|> |
b01711192bc1ce09a8b9c1d7521bc97b47ed75abeb72894b83b96c88744db172 | def file_stats(filename):
'Prints number of bytes, lines, words and length of the longest line in a file'
with open(filename, 'br') as f:
file_bytes = f.read()
with open(filename, 'r', encoding='utf8') as f:
file_lines = f.readlines()
byte_amount = len(file_bytes)
word_amount = sum([len(line.split()) for line in file_lines])
line_amount = len(file_lines)
longest_line = max([len(line) for line in file_lines])
print(f'Bytes: {byte_amount}')
print(f'Lines: {line_amount}')
print(f'Words: {word_amount}')
print(f'Longest line: {longest_line}') | Prints number of bytes, lines, words and length of the longest line in a file | Lista2/wordcount.py | file_stats | pi-kolo/python | 0 | python | def file_stats(filename):
with open(filename, 'br') as f:
file_bytes = f.read()
with open(filename, 'r', encoding='utf8') as f:
file_lines = f.readlines()
byte_amount = len(file_bytes)
word_amount = sum([len(line.split()) for line in file_lines])
line_amount = len(file_lines)
longest_line = max([len(line) for line in file_lines])
print(f'Bytes: {byte_amount}')
print(f'Lines: {line_amount}')
print(f'Words: {word_amount}')
print(f'Longest line: {longest_line}') | def file_stats(filename):
with open(filename, 'br') as f:
file_bytes = f.read()
with open(filename, 'r', encoding='utf8') as f:
file_lines = f.readlines()
byte_amount = len(file_bytes)
word_amount = sum([len(line.split()) for line in file_lines])
line_amount = len(file_lines)
longest_line = max([len(line) for line in file_lines])
print(f'Bytes: {byte_amount}')
print(f'Lines: {line_amount}')
print(f'Words: {word_amount}')
print(f'Longest line: {longest_line}')<|docstring|>Prints number of bytes, lines, words and length of the longest line in a file<|endoftext|> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.