Beispiel #1
0
    def scan_file(self):
        d = ScanDialog(self.master)
        if d.scan_ok:
            min_spacer = d.min_spacer
            max_spacer = d.max_spacer
            nreport = d.nreport
            cutoffs = []
            if d.defaults:
                cutoffs = DEFAULT_CUTOFFS
            elif d.cutoff:
                cutoffs = (max_spacer - min_spacer + 1) * [d.cutoff]

            d.destroy()

            self.status.set("Scanning %s for p53 binding sites" %
                            self.loaded_file)
            self.mlb.delete(0, self.mlb.size() - 1)
            count = 0
            for (id, seq) in self.f.items():
                result = scan(seq.upper(), PWM_LEFT, PWM_RIGHT, min_spacer,
                              max_spacer, cutoffs, nreport)
                for (score, pos, spacer, strand) in result:
                    count += 1
                    self.mlb.insert(
                        END,
                        (id, pos, pos + len(PWM_LEFT) + spacer +
                         len(PWM_RIGHT), score, seq[pos:pos + len(PWM_LEFT)],
                         seq[pos + len(PWM_LEFT):pos + len(PWM_LEFT) + spacer],
                         seq[pos + len(PWM_LEFT) + spacer:pos + len(PWM_LEFT) +
                             spacer + len(PWM_RIGHT)]))
            self.status.set("Done scanning %s. Found %s binding sites." %
                            (self.loaded_file, count))
            self.filemenu.entryconfig(1, state=NORMAL)
Beispiel #2
0
	def scan_file(self):
		d = ScanDialog(self.master)
		if d.scan_ok:
			min_spacer = d.min_spacer
			max_spacer = d.max_spacer
			nreport = d.nreport
			cutoffs = []
			if d.defaults:
				cutoffs = DEFAULT_CUTOFFS
			elif d.cutoff:
				cutoffs = (max_spacer - min_spacer + 1) * [d.cutoff]
			
			d.destroy()

			self.status.set("Scanning %s for p63 binding sites" % self.loaded_file)
			self.mlb.delete(0, self.mlb.size() - 1)
			count = 0
			for (id,seq) in self.f.items():
				result = scan(seq.upper(), PWM_LEFT, PWM_RIGHT, min_spacer, max_spacer, cutoffs, nreport)
				for (score, pos, spacer, strand) in result:
					count += 1
					self.mlb.insert(END,(id, pos, pos + len(PWM_LEFT) + spacer + len(PWM_RIGHT), score,
						seq[pos: pos + len(PWM_LEFT)],
						seq[pos + len(PWM_LEFT): pos + len(PWM_LEFT) + spacer],
						seq[pos + len(PWM_LEFT) + spacer: pos + len(PWM_LEFT) + spacer + len(PWM_RIGHT)]
					))
			self.status.set("Done scanning %s. Found %s binding sites." % (self.loaded_file, count))
			self.filemenu.entryconfig(1, state=NORMAL)
Beispiel #3
0
        s_max = max_score(pwm_left) + max_score(pwm_right)
        s_min = min_score(pwm_left) + min_score(pwm_right)
        sys.stderr.write(
            "No cutoffs specified, using %s as a cutoff (%s of maxscore)\n" %
            (SCORE_FRACTION * (s_max - s_min) + s_min, SCORE_FRACTION))
        cutoffs = [
            SCORE_FRACTION * (s_max - s_min) + s_min
            for i in range(max_spacer - min_spacer + 1)
        ]

bed = options.bed
f = Fasta(inputfile)

for (id, seq) in f.items():
    result = scan(seq.upper(), pwm_left, pwm_right, min_spacer, max_spacer,
                  cutoffs, nreport)
    for (score, pos, spacer, strand) in result:
        if bed:
            first = id.split(" ")[0]
            (chr, loc) = first.split(":")
            if loc:
                (start, end) = map(int, loc.split("-"))
                print "%s\t%s\t%s\t%s" % (chr, start + pos,
                                          start + pos + len(pwm_left) +
                                          spacer + len(pwm_right), score)
            else:
                print "%s\t%s\t%s\t%s" % (id, pos, pos + len(pwm_left) +
                                          spacer + len(pwm_right), score)
        else:
            print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s %s %s" % (
                id, "p53scan", "misc_feature", pos,
Beispiel #4
0
if options.pwmfile:
	id, pwm_left,pwm_right = read_pwm_with_spacer(options.pwmfile) 
	sys.stderr.write("PWM-file supplied, left halfsite: %s, right halfsite: %s\n" % (len(pwm_left), len(pwm_right)))
	if not options.cutoff:
		
		s_max = max_score(pwm_left) + max_score(pwm_right) 
		s_min = min_score(pwm_left) + min_score(pwm_right)
		sys.stderr.write("No cutoffs specified, using %s as a cutoff (%s of maxscore)\n" % (SCORE_FRACTION * (s_max - s_min) + s_min, SCORE_FRACTION))
		cutoffs = [SCORE_FRACTION * (s_max - s_min) + s_min for i in range(max_spacer - min_spacer + 1)]
	
bed = options.bed
f = Fasta(inputfile)

for (id,seq) in f.items():
	result = scan(seq.upper(), pwm_left, pwm_right, min_spacer, max_spacer, cutoffs, nreport)
	for (score, pos, spacer, strand) in result:
		if bed:
			first = id.split(" ")[0]	
			(chr,loc) = first.split(":")
			if loc:
				(start, end) = map(int, loc.split("-"))
				print "%s\t%s\t%s\t%s" % (chr, start + pos, start + pos + len(pwm_left) + spacer + len(pwm_right), score)
			else:
				print "%s\t%s\t%s\t%s" % (id, pos, pos +  len(pwm_left) + spacer + len(pwm_right), score)
		else:
			print "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s %s %s" % (
			id, 
			"p53scan", 
			"misc_feature", 
			pos, pos + len(pwm_left) + spacer + len(pwm_right),