Skip to content

Commit

Permalink
[add] complementary strand method
Browse files Browse the repository at this point in the history
全ての塩基を相補的な塩基に変換した配列を生成するメソッド.
  • Loading branch information
rrbox committed Sep 4, 2022
1 parent 59632a3 commit 2775299
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Sources/Nucleotide/Sequence/Analyze/Standard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public extension BaseSequence {
}).reversed())
}

/// 全ての塩基を相補的な塩基に変換した配列を生成します.
/// - Returns: 現在の配列の相補鎖を逆向きにした配列に相当するデータ.
func complementaryStrand() -> BaseSequence<T> {
return BaseSequence<T>(sequence: self.sequence.map({ n in
bitRotateLeft(n, n: 4)
}))
}

/// 相補的な逆向き配列を算出します.
/// - Parameter type: 塩基の型を選択することができます.
/// - Returns: 現在の配列の相補鎖に相当する配列. type で指定した塩基が適用されます.
Expand All @@ -63,6 +71,14 @@ public extension BaseSequence {
}).reversed())
}

/// 全ての塩基を相補的な塩基に変換した配列を生成します.
/// - Returns: 現在の配列の相補鎖を逆向きにした配列に相当するデータ. type で指定した塩基が適用されます.
func complementaryStrand<U: BaseType>(typeOf type: U.Type) -> BaseSequence<U> {
return BaseSequence<U>(sequence: self.sequence.map({ n in
bitRotateLeft(n, n: 4)
}))
}

/// 逆向き配列を出力します.
func reversed() -> BaseSequence<T> {
return BaseSequence<T>(sequence: self.sequence.reversed())
Expand Down

0 comments on commit 2775299

Please sign in to comment.