"""A Chain header as in http://genome.ucsc.edu/goldenPath/help/chain.html
chain coordinates are with respect to the strand, so for example tStart on the + strand is the
- distance from the 0th position from the left; tStart on the - strand is the distance from
- the last position from the right."""
+ distance from the leftmost position; tStart on the - strand is the distance from the rightmost position."""
:param fname: name of the file"""
+ #you asked for the pickled file. I'll give it to you
log.debug("loading pickled file %s ..." % fname)
return cPickle.load( open(fname) )
elif os.path.isfile("%s.pkl" % fname):
+ #there is a cached version I can give to you
log.info("loading pickled file %s.pkl ..." % fname)
if os.stat(fname).st_mtime > os.stat("%s.pkl" % fname).st_mtime:
log.critical("*** pickled file %s.pkl is not up to date ***" % (fname))
return d[1:] #clip the (thr, thr) entry
"""Map features from the target species to the query species of a chain alignment file.
This is intended for mapping relatively short features such as Chip-Seq
peaks on TF binding events. Features that get mapped on different chromosomes
-or that span multiple chains are silently filtered out."""
+or that span multiple chains are silently filtered out. TODO:
+(1)for narrowPeak input, map the predicted peak position.
import sys, os, logging, pdb
def transform_file(ELEMS, ofname, EPO, TREE, opt):
"transform/map the elements of this file and dump the output on 'ofname'"
+ BED4_FRM = "%s\t%d\t%d\t%s\n"
log.info("%s (%d) elements ..." % (opt.screen and "screening" or "transforming", ELEMS.shape))
with open(ofname, 'w') as out_fd: