Mercurial > repos > cafletezbrant > kmersvm
diff kmersvm/scripts/nullseq_generate.py @ 7:fd740d515502 draft default tip
Uploaded revised kmer-SVM to include modules from kmer-visual.
author | cafletezbrant |
---|---|
date | Sun, 16 Jun 2013 18:06:14 -0400 |
parents | 7fe1103032f7 |
children |
line wrap: on
line diff
--- a/kmersvm/scripts/nullseq_generate.py Mon Aug 20 21:42:29 2012 -0400 +++ b/kmersvm/scripts/nullseq_generate.py Sun Jun 16 18:06:14 2013 -0400 @@ -71,8 +71,7 @@ def sample_sequences(positions, buildname, basedir, options): """ """ - rpt_err = options.rpt_err - gc_err = options.gc_err + max_fails = 20 max_trys = options.max_trys norpt = options.norpt nogc = options.nogc @@ -121,6 +120,12 @@ else: count = options.count + #initialize paramter + #added by dlee 2/17/13 + ncfails = 0 + rpt_err = options.rpt_err + gc_err = options.gc_err + sampled_positions = [] while len(sampled_positions) < count: sampled_prof = random.choice(profiles) @@ -128,6 +133,15 @@ sampled_gc = sampled_prof[2] sampled_rpt = sampled_prof[3] + #relax rpt_err and gc_err if it keep fail to sample a region + #added by dlee 2/17/13 + if ncfails >= max_fails: + if options.quiet == False: + sys.stderr.write("reached max_fail. relax gc and rpt err criteria\n") + ncfails = 0 + rpt_err += 0.01 + gc_err += 0.01 + rpt_err_allowed = int(rpt_err*sampled_len) gc_err_allowed = int(gc_err*sampled_len) trys = 0 @@ -156,9 +170,17 @@ sampled_positions.append((chrom, pos, pos_e)) + #reset the counter of consecutive fails + #added by dlee 2/17/13 + ncfails = 0 + #print trys, chrom, pos, pos_e, sampled_len, pos_rpt, sampled_rpt, pos_gc, sampled_gc break else: + #increase the counter of consecutive fails + #added by dlee 2/17/13 + ncfails += 1 + if options.quiet == False: sys.stderr.write(' '.join(["fail to sample from", \ "len=", str(sampled_len), \