Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix DNA valid check and output path #1

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions correct_primer_positions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
import os.path

def verify(sequence):
'''This code verifies if a sequence is a DNA'''
'''This code verifies if a sequence is a DNA or contains ambiguous bases according to the IUPAC code.'''

# set the input sequence
seq = set(sequence)

# confirm if its elements is equal to the set of valid DNA bases
# Use a union method to ensure the sequence is verified if does not
# contain all the bases
if seq == {"A", "T", "C", "G"}.union(seq):
# Set of valid DNA bases including IUPAC ambiguity codes
valid_bases = {"A", "T", "C", "G", "Y", "R", "S", "W", "K", "M", "B", "D", "H", "V", "N"}

# confirm if its elements are only from the set of valid DNA bases
if seq.issubset(valid_bases):
return "DNA"
else:
return "Invalid DNA sequence"
Expand Down Expand Up @@ -130,8 +131,8 @@ def main(argv):
primer_bed_df.iloc[:,1] = s_pos
primer_bed_df.iloc[:,2] = e_pos

primer_bed_df.to_csv(os.path.dirname(argv[3])+'/'+os.path.basename(argv[3])+'.position.corrected.bed', index=False, sep='\t', header=False)
print("Primer.bed file has been updated. See: \n"+os.path.dirname(argv[3])+'/'+os.path.basename(argv[3])+'.position.corrected.bed')
primer_bed_df.to_csv('./'+os.path.dirname(argv[3])+'/'+os.path.basename(argv[3])+'.position.corrected.bed', index=False, sep='\t', header=False)
print("Primer.bed file has been updated. See: \n./"+os.path.dirname(argv[3])+'/'+os.path.basename(argv[3])+'.position.corrected.bed')
except Exception as e: # pragma: nocover
return "An error has occured: " + str(e)
if __name__ == "__main__": # pragma: nocover
Expand Down