Skip to content

Commit 783c768

Browse files
author
RJain12
committed
renaming & hfc
1 parent f99d5be commit 783c768

4 files changed

Lines changed: 8 additions & 17 deletions

File tree

tool/optimizers/BFC_optimizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Output dir to store optimized seqs:
4040
# hardcoded path
41-
out_dir = os.path.join(os.getcwd(), 'benchmark_sequences', 'naive')
41+
out_dir = os.path.join(os.getcwd(), 'benchmark_sequences', 'BFC')
4242

4343

4444
# Normalize probabilities for frequency if sum is not exactly 1.
@@ -49,7 +49,7 @@ def fix_p(p):
4949

5050

5151
for entry in os.scandir(aa_dir):
52-
name = entry.replace("_aa.fasta", "_dna")
52+
name = entry.name.replace("_aa.fasta", "_dna")
5353

5454
# Replace ambiguities with amino acids from IUPAC guidelines: https://www.bioinformatics.org/sms/iupac.html
5555
record = SeqIO.read(entry, "fasta")

tool/optimizers/ERC_optimizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Set input AA sequence directory and output for writing brute sequences
1616
aa_dir = os.path.join(os.getcwd(), 'benchmark_sequences', 'aa')
17-
out_dir = os.path.join(os.getcwd(), 'benchmark_sequences', 'brute')
17+
out_dir = os.path.join(os.getcwd(), 'benchmark_sequences', 'ERC')
1818

1919
# Define weights for each codon
2020
weights = [0, 1, 0.647058823500000, 0.500000000000000, 0.794117647100000, 0.0789473684200000, 0.131578947400000, 0.263157894700000, 0.184210526300000, 0.973684210500000, 1, 0.851851851900000, 1, 1, 0.587301587300000, 0.818181818200000, 1, 0.483870967700000, 0.129032258100000, 1, 1, 0.515151515200000, 0.470588235300000, 1, 0.384615384600000, 0.307692307700000, 0.871794871800000, 1, 1, 0.754385964900000, 0.180000000000000, 1, 0.820000000000000,
@@ -129,7 +129,7 @@ def aa2codons(seq: str) -> list:
129129
# Converts an amino acid to a random corresponding codon:
130130
for entry in os.scandir(aa_dir):
131131
# Read in the amino acid sequence:
132-
name = entry.replace("_aa.fasta", "_dna")
132+
name = entry.name.replace("_aa.fasta", "_dna")
133133
record = SeqIO.read(entry, 'fasta')
134134

135135
masterlist = []

tool/optimizers/HFC_optimizer.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,10 @@
3838

3939
# Output dir to store optimized seqs:
4040
# hardcoded path
41-
out_dir = os.path.join(os.getcwd(), 'benchmark_sequences', 'naive')
42-
43-
44-
# Normalize probabilities for frequency if sum is not exactly 1.
45-
def fix_p(p):
46-
if p.sum() != 1.0:
47-
p = p*(1./p.sum())
48-
return p
49-
41+
out_dir = os.path.join(os.getcwd(), 'benchmark_sequences', 'HFC')
5042

5143
for entry in os.scandir(aa_dir):
52-
name = entry.replace("_aa.fasta", "_dna")
44+
name = entry.name.replace("_aa.fasta", "_dna")
5345

5446
# Replace ambiguities with amino acids from IUPAC guidelines: https://www.bioinformatics.org/sms/iupac.html
5547
record = SeqIO.read(entry, "fasta")
@@ -58,8 +50,7 @@ def fix_p(p):
5850
seq_arr = []
5951
for aa in seq:
6052
# append to the array a random choice of codon using the probabilities given (p)
61-
seq_arr.append(np.random.choice(
62-
frequency[aa][0], p=fix_p(np.asarray(frequency[aa][1]))))
53+
seq_arr.append(frequency[aa][0][np.argmax(frequency[aa][1])])
6354

6455
record.seq = Seq(re.sub('[^GATC]', "", str("".join(seq_arr)).upper()))
6556
complete_name = os.path.join(out_dir, name)

tool/optimizers/URC_optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
# Output dir to store optimized seqs:
15-
out_dir = os.path.join(os.getcwd(), 'benchmark_sequences', 'super_naive')
15+
out_dir = os.path.join(os.getcwd(), 'benchmark_sequences', 'URC')
1616

1717
# Amino acid to codon table, outputs arr of codons:
1818

0 commit comments

Comments
 (0)