This file contains hidden or 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
def pattern_check(pattern): | |
answer = pattern.upper() | |
if (len(answer) < 4 or len(answer) > 8) or re.search('[^AGCT]', answer): | |
raise argparse.ArgumentTypeError('A valid restriction enzyme must be entered: \n' | |
'1. Between 4-8 bases long \n2. Comprise of the nucleotides A, G, C and T') | |
return answer |
This file contains hidden or 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
arg_parse.py -p AAGGCGC AGAGGGAT -i E.coli_genome.fasta -c -2 | |
arg_parse.py -i E.coli_genome.fasta -c -2 -p AAGGCGC AGAGGGAT | |
arg_parse.py --pattern AAGGCGC AGAGGGAT -i E.coli_genome.fasta --count_no 50 | |
arg_parse.py --input_filename E.coli_genome.fasta -c 50 -p AAGGCGC AGAGGGAT |
This file contains hidden or 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
result = [] | |
for seq in args.pattern: | |
for x in re.findall(seq, DNA): | |
result.append(x) | |
restriction_enzyme = collections.Counter(result) |
This file contains hidden or 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
import re | |
import collections | |
import argparse | |
parser = argparse.ArgumentParser(description='Finding restriction sites in DNA sequences') | |
def count_valid(count_no): | |
num = int(count_no) | |
if num < 1: |
This file contains hidden or 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
parser.add_argument('-p', | |
'--pattern', | |
help='Enter the pattern of the restriction enzyme', | |
type=pattern_check, | |
nargs='*') |
This file contains hidden or 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
def count_valid(count_no): | |
num = int(count_no) | |
if num < 1: | |
raise argparse.ArgumentTypeError('The count has to be an integer above 0') | |
return num |
This file contains hidden or 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
parser.add_argument('-c', | |
'--count_no', | |
help='count number to be specified', | |
type=count_valid, | |
default=0) |
This file contains hidden or 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
import re | |
import collections | |
import argparse | |
parser = argparse.ArgumentParser(description='Finding restriction sites in DNA sequences') | |
def count_valid(count_no): | |
num = int(count_no) | |
if num < 1: |
This file contains hidden or 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
import pandas as pd |
This file contains hidden or 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
Blast = pd.read_csv('SPECIES_BLAST_DATA.CSV') | |
print(Blast.head()) | |
print(Blast.columns) | |
print(Blast.shape) |