Skip to content

Commit 83b92bf

Browse files
author
Julius Booth
committed
fixed hard coded 24 region bug
1 parent a764c87 commit 83b92bf

5 files changed

Lines changed: 14 additions & 36 deletions

File tree

bin/prince

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ from prince import __version__
1313

1414
DEFAULT_K = 25
1515
DEFAULT_BOOST_OUTPUT = resource_filename('prince.resources', 'training_data_w_extensions.txt')
16+
DEFAULT_PRIMERS = resource_filename('prince.resources', 'TB_primers_extended.json')
17+
DEFAULT_TEMPLATES = resource_filename('prince.resources', 'templates.fasta')
1618

1719
def main():
1820
parser = argparse.ArgumentParser(description='Prince Options.')
@@ -21,7 +23,7 @@ def main():
2123
help="output file for training data / training data used to predict copy numbers for queries")
2224
parser.add_argument('-to', '--target_output', default="results/predictions.csv",
2325
help="output file for query copy number predictions")
24-
parser.add_argument('-tmp','--templates', default="templates.fasta",
26+
parser.add_argument('-tmp','--templates', default=DEFAULT_TEMPLATES,
2527
help="VNTR templates. Default is for M.TB")
2628
parser.add_argument('-tf', '--target_file', default=None,
2729
help="target genome names in a text file")
@@ -31,7 +33,7 @@ def main():
3133
help="Kmer size used during read recruitment.")
3234
parser.add_argument('-cn', '--copynumber', default=1,type=int,
3335
help="Copy number for training genome.")
34-
parser.add_argument('-p', '--primers', default="TB_primers_extended.json",
36+
parser.add_argument('-p', '--primers', default=DEFAULT_PRIMERS,
3537
help="Flanking sequences used in coverage adjustments")
3638
parser.add_argument('-np', '--num_procs', default=1,type=int,
3739
help="Number of cores for parallel processing.")
@@ -44,12 +46,12 @@ def main():
4446
if prince_options.k != DEFAULT_K and prince_options.boost_output == DEFAULT_BOOST_OUTPUT:
4547
warnings.warn("Warning: Target kmer size does not equal training settings. May lead to inaccurate predictions.")
4648

47-
with open(resource_filename('prince.resources', prince_options.primers)) as primers:
49+
with open(prince_options.primers) as primers:
4850
primers=json.load(primers)
4951

5052
#Template data initialized
5153

52-
templates = list(SeqIO.parse(resource_filename('prince.resources', prince_options.templates), "fasta"))
54+
templates = list(SeqIO.parse(prince_options.templates, "fasta"))
5355
templateNames = [t.id for t in templates]
5456
templates = [str(t.seq) for t in templates]
5557

prince/match_score.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ def compute_match_score(query, template_obj, kmerLength, primers):
146146

147147
#Run reads through Fine Filtering to get score for each template
148148
matchScore, flanking_coverage = fine_filtering(template_obj, recruitedReads, kmerLength, primers)
149-
print(matchScore)
150-
print(flanking_coverage)
149+
print("VNTR Coverage: ", matchScore)
150+
print("Flanking Coverage: ", flanking_coverage)
151151
matchScore = [score/float(1+flanking_coverage[i]) for i,score in enumerate(matchScore)]
152-
print(matchScore)
152+
print("Adjusted Coverage: ", matchScore)
153153
print("\n")
154154
return matchScore, filename
155155

prince/predict.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def get_X_and_Y(data,template):
1414
Y.append(cn)
1515
return(X,Y)
1616

17-
def get_equations(data):
17+
def get_equations(data, number_of_equations):
1818
equations = []
19-
for t in range(24):
19+
for t in range(number_of_equations):
2020
X,Y = get_X_and_Y(data,t)
2121
X = np.array(X, dtype=np.float64)
2222
Y = np.array(Y, dtype=np.float64)

prince/query_sample.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import multiprocessing as mp
77

88
def test_target(opts, template_obj, primers):
9+
NUM_LOCI = len(primers)
10+
911
# Get the query paths
1012
with open(opts.target_file) as file:
1113
queries = [line.rstrip("\n") for line in file]
@@ -18,7 +20,7 @@ def test_target(opts, template_obj, primers):
1820

1921
# Write results
2022
data = get_data(opts.boost_output)
21-
equations = get_equations(data)
23+
equations = get_equations(data, NUM_LOCI)
2224
with open(opts.target_output,'a+') as file:
2325
if os.path.getsize(opts.target_output) == 0:
2426
file.write("Templates,")

prince/resources/TB_primers.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)