Pycharm keeps asking for command line args although argparse is commented out

I wish Japanese companies would build IDEs and I probably would not be having this conversation.

This is so clunky.  The argparse stuff is clearly commented out so why is it telling me I am missing arguments when I try to run it?

I invalidated caches, etc. 

```

"""
Run KMP on sequence, find the upstream TTGACA using KMP then find TATAAT starting from the 16 to 21st position
after the "A" in TTGACA. Since TATAAT is 6 chars, that means +16 to +22 ~ +22 to +28th pos must be
TATAAT. Restart search for upstream TTGACA at the next pos.
"""

import argparse
import Bio
from Bio.Seq import Seq
from Bio import SeqIO
from Bio.SeqUtils.ProtParam import ProteinAnalysis
from asn1e2 import read_file

'''
parser = argparse.ArgumentParser(description='import seq file to parse for protein seq')
parser.add_argument('--input', help='input dir', required=False)
parser.add_argument('--filetype', help='file type', required=False, default="fasta")
parser.add_argument('--output', help='output dir', required=False)


args = parser.parse_args()
'''
# Python program for KMP Algorithm
def KMPSearch(pat, txt):
M = len(pat)
N = len(txt)

# create lps[] that will hold the longest prefix suffix
# values for pattern
lps = [0]*M
j = 0 # index for pat[]

# Preprocess the pattern (calculate lps[] array)
computeLPSArray(pat, M, lps)

i = 0 # index for txt[]
while i < N:
if pat[j] == txt[i]:
i += 1
j += 1

if j == M:
print(f'i:{i}, j:{j}')
print("Found pattern at index " + str(i-j))
j = lps[j-1]

# mismatch after j matches
elif i < N and pat[j] != txt[i]:
# Do not match lps[0..lps[j-1]] characters,
# they will match anyway,
if j != 0:
j = lps[j-1]
else:
i += 1

def computeLPSArray(pat, M, lps):
len = 0 # length of the previous longest prefix suffix

lps[0] # lps[0] is always 0
i = 1

# the loop calculates lps[i] for i = 1 to M-1
while i < M:
if pat[i]== pat[len]:
len += 1
lps[i] = len
i += 1
else:
# This is tricky. Consider the example.
# AAACAAAA and i = 7. The idea is similar
# to search step.
if len != 0:
len = lps[len-1]

# Also, note that we do not increment i here
else:
lps[i] = 0
i += 1


def main():
# pattern 1
upstream_seq = input("Enter the upstream seq: ")
# pattern 2
following_seq = input("Enter the following seq: ")

num_in_btwn_low = int(input("Enter the minimum num of nucleotides btwn them: "))
num_in_btwn_hi = int(input("Enter the max num nucleotides btwn them: "))
# get text:
#arr of dicts for each record in fasta file
records_dict_arr = read_file()
# get the sequences as string
seq_str_arr = []
for seq_record in records_dict_arr:
curr_seq = seq_record.seq
curr_seq_str = str(curr_seq)
seq_str_arr.append(curr_seq_str) #probably only has one

# call KMP
pass


txt = "ABABDABACDABABCABAB"
pat = "ABABCABAB"

txt2 = "aaabaadaabaaa"
print(len(txt2))
pat2 = "aabaaa"
print(len(pat2))
KMPSearch(pat2, txt2)
print("promoter seq search")



# This code is contributed by Bhavya Jain
3 comments
Comment actions Permalink

usage: kmp.py [-h] [--input INPUT] [--filetype FILETYPE] [--output OUTPUT] --rframe RFRAME
kmp.py: error: the following arguments are required: --rframe

0
Comment actions Permalink

Really would love it if you let users choose configurations from basic/streamlined version that ensures bug-free performance on limited feature set or mid-level with a a few more bugs and fancy bells and whistles with use-at-your-own-risk warnings. 

0
Comment actions Permalink

Hi. To check if the issue is IDE-related, I suggest the following:

1. Open the file in some external editor to make sure the changes made in PyCharm has been saved.

2. Run the code using the same interpreter from command line outside of IDE.

Do you get the same result?

0

Please sign in to leave a comment.