Skip to content

Commit

Permalink
Fix up sandbox scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
camillescott committed Sep 2, 2017
1 parent ee19b04 commit 3664a9f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
3 changes: 2 additions & 1 deletion sandbox/correct-reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import screed
import khmer

from khmer import Countgraph
from khmer.khmer_args import (build_counting_args, info, add_loadgraph_args,
report_on_config, sanitize_help,
calculate_graphsize, create_countgraph)
Expand Down Expand Up @@ -171,7 +172,7 @@ def main():

if args.loadgraph:
print('loading k-mer countgraph from', args.loadgraph, file=sys.stderr)
ct = khmer.load_countgraph(args.loadgraph)
ct = Countgraph.load(args.loadgraph)
else:
print('making k-mer countgraph', file=sys.stderr)
ct = create_countgraph(args, multiplier=8 / (9. + 0.3))
Expand Down
4 changes: 2 additions & 2 deletions sandbox/count-kmers-single.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def main():

kmer_size = countgraph.ksize()
hashsizes = countgraph.hashsizes()
tracking = khmer._Nodegraph( # pylint: disable=protected-access
kmer_size, hashsizes)
tracking = khmer.Nodegraph( # pylint: disable=protected-access
kmer_size, 1, 1, primes=hashsizes)

print ('kmer_size: %s' % countgraph.ksize(), file=sys.stderr)
print ('k-mer countgraph sizes: %s' % (countgraph.hashsizes(),),
Expand Down
7 changes: 4 additions & 3 deletions sandbox/count-kmers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import argparse
import screed
import csv
from khmer import Countgraph
from khmer.khmer_args import info


Expand Down Expand Up @@ -76,13 +77,13 @@ def main():

print ('hashtable from', args.input_count_graph_filename,
file=sys.stderr)
countgraph = khmer.load_countgraph(
countgraph = Countgraph.load(
args.input_count_graph_filename)

kmer_size = countgraph.ksize()
hashsizes = countgraph.hashsizes()
tracking = khmer._Nodegraph( # pylint: disable=protected-access
kmer_size, hashsizes)
tracking = khmer.Nodegraph( # pylint: disable=protected-access
kmer_size, 1, 1, primes=hashsizes)

if args.output_file is None:
args.output_file = sys.stdout
Expand Down
3 changes: 2 additions & 1 deletion sandbox/error-correct-pass2.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import os
import screed
import khmer
from khmer import Countgraph
from khmer import khmer_args
from khmer.khmer_args import FileType as khFileType

Expand Down Expand Up @@ -87,7 +88,7 @@ def main():
args = parser.parse_args()

print('loading counts')
ht = khmer.load_countgraph(args.counts_table)
ht = Countgraph.load(args.counts_table)

aligner = khmer.ReadAligner(ht,
args.trusted_cov,
Expand Down
3 changes: 2 additions & 1 deletion sandbox/extract-compact-dbg.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def add_adjacency(self, node_id, adj):

def traverse_and_mark_linear_paths(graph, nk, stop_bf, pathy, degree_nodes):
size, conns, visited = graph.traverse_linear_path(nk, degree_nodes,
stop_bf)
stop_filter=stop_bf)
if not size:
return

Expand Down Expand Up @@ -86,6 +86,7 @@ def main():
# if memory is a problem.

graph = khmer.Nodegraph(args.ksize, args.tablesize, 2)
print(graph.ksize(), graph.hashsizes())
stop_bf = khmer.Nodegraph(args.ksize, args.tablesize, 2)
stop_bf2 = khmer.Nodegraph(args.ksize, args.tablesize, 2)
n = 0
Expand Down
12 changes: 7 additions & 5 deletions sandbox/sweep-reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import os
import time
import khmer
from khmer import GraphLabels
from khmer.khmer_args import (build_nodegraph_args, report_on_config, info,
sanitize_help)
from khmer.kfile import (check_input_files, check_valid_file_exists,
Expand All @@ -78,7 +79,7 @@
DEFAULT_MAX_READS = 1000000
DEFAULT_BUFFER_SIZE = 10
DEFAULT_OUT_PREF = 'reads'
DEFAULT_RANGE = -1
DEFAULT_RANGE = None

MAX_HSIZE = 4e7
MIN_KSIZE = 21
Expand Down Expand Up @@ -283,7 +284,7 @@ def main():
max_buffers, max_reads, buf_size, output_pref, outdir, extension)

# consume the partitioned fasta with which to label the graph
ht = khmer.GraphLabels(K, HT_SIZE, N_HT)
ht = GraphLabels.NodeGraphLabels(K, HT_SIZE, N_HT)
try:
print('consuming input sequences...', file=sys.stderr)
if args.label_by_pid:
Expand Down Expand Up @@ -331,8 +332,8 @@ def main():

print('done consuming input sequence. \
added {t} tags and {l} \
labels...'.format(t=ht.graph.n_tags(),
l=ht.n_labels()))
labels...'.format(t=ht.graph.n_tags,
l=ht.n_labels))

label_dict = defaultdict(int)
label_number_dist = []
Expand Down Expand Up @@ -369,7 +370,8 @@ def main():
seq = record.sequence
name = record.name
try:
labels = ht.sweep_label_neighborhood(seq, traversal_range)
labels = list(ht.sweep_label_neighborhood(seq,
traversal_range))
except ValueError as e:
pass
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sandbox_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def test_multirename_fasta():
def test_extract_compact_dbg_1():
infile = utils.get_test_data('simple-genome.fa')
outfile = utils.get_temp_filename('out.gml')
args = ['-x', '1e4', '-o', outfile, infile]
args = ['-x', '1e5', '-o', outfile, infile]
_, out, err = utils.runscript('extract-compact-dbg.py', args, sandbox=True)

print(out)
Expand Down

0 comments on commit 3664a9f

Please sign in to comment.