forked from kyclark/biofx_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
""" Locating Restriction Sites """ | ||
|
||
import argparse | ||
import operator | ||
import sys | ||
from typing import NamedTuple, TextIO | ||
from Bio import SeqIO, Seq | ||
from common import find_kmers | ||
|
||
|
||
class Args(NamedTuple): | ||
""" Command-line arguments """ | ||
file: TextIO | ||
|
||
|
||
# -------------------------------------------------- | ||
def get_args() -> Args: | ||
""" Get command-line arguments """ | ||
|
||
parser = argparse.ArgumentParser( | ||
description='Locating Restriction Sites', | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
|
||
parser.add_argument('file', | ||
help='Input FASTA file', | ||
metavar='FILE', | ||
type=argparse.FileType('rt')) | ||
|
||
args = parser.parse_args() | ||
|
||
return Args(args.file) | ||
|
||
|
||
# -------------------------------------------------- | ||
def main() -> None: | ||
""" Make a jazz noise here """ | ||
|
||
args = get_args() | ||
if seqs := [str(rec.seq) for rec in SeqIO.parse(args.file, 'fasta')]: | ||
seq = seqs[0] | ||
|
||
for k in range(4, 13): | ||
kmers = find_kmers(seq, k) | ||
revc = list(map(Seq.reverse_complement, kmers)) | ||
|
||
for pos, pair in enumerate(zip(kmers, revc)): | ||
if operator.eq(*pair): | ||
print(pos + 1, k) | ||
else: | ||
sys.exit(f'"{args.file.name}" contains no sequences.') | ||
|
||
|
||
# -------------------------------------------------- | ||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters