Commits

Hanfei Sun  committed d38db15

Add support for peak file
Fix a display error for help info

  • Participants
  • Parent commits 20c756d

Comments (0)

Files changed (2)

File MPIPE/bed2fasta.py

 #! /usr/bin/env python
-# Time-stamp: <2011-11-28 07:02:40 hanfei>
+# Time-stamp: <2011-12-03 10:37:13 sunhf>
 """Module Description: Main executable for converting summits bed to fasta files
 
 Copyright (c) 2011 Hanfei Sun <hfsun.tju@gmail.com>
     if bf_prefix==None:
         bf_prefix=_get_prefix(bf_summit)
     bf_tag=lambda tag:bf_prefix+'_'+tag+'.bed'
-
-    one_chr = lambda chrom,chrom_leng:r"(/^("+chrom+r"\t)/ && $2-%d>0 && $3+%d<"%(shiftsize*3,shiftsize*3)+str(chrom_leng-300)+r")"
+    one_chr = lambda chrom,chrom_leng:r"(/^("+chrom+r"\t)/ && $2-%d>0 && $3+%d<"%(shiftsize*3,shiftsize*3)+str(chrom_leng)+" && $2*2-$3>0 && $3*2-$2<"+str(chrom_leng)+r")"
     # summit +/-300 is the edge as 200bp is the width
     awk_pattern = "'" + " || ".join(one_chr(i,_chrom_len[species][i]) for i in _chrom_len[species] ) + "'"
     cmd="awk %s %s > %s"%(awk_pattern, bf_summit, bf_tag("summits_filtered"))
         info("Every line in %s were in legal range of chromesome"%bf_summit)
 
 
-    cmd="awk -v OFS='\t' '$2=$2-%d,$3=$3+%d' %s > %s"%(shiftsize,shiftsize-1,bf_tag("summits_filtered"),bf_tag("middle"))
+    cmd="awk -v OFS='\t' '{if ($3-$2==1) print $1,$2-%d,$3+%d,$4,$5; else print $1,$2,$3,$4,$5}' %s > %s"%(shiftsize,shiftsize-1,bf_tag("summits_filtered"),bf_tag("middle"))
     run(cmd)
-    cmd="awk -v OFS='\t' '$2=$2-%d,$3=$3-%d' %s > %s"%(shiftsize*3,shiftsize+1,bf_tag("summits_filtered"),bf_tag("left"))
+    cmd="awk -v OFS='\t' '{if ($3-$2==1) print $1,$2-%d,$3-%d,$4,$5; else print $1,$2*2-$3,$2,$4,$5}' %s > %s"%(shiftsize*3,shiftsize+1,bf_tag("summits_filtered"),bf_tag("left"))
     run(cmd)
-    cmd="awk -v OFS='\t' '$2=$2+%d,$3=$3+%d' %s > %s"%(shiftsize,shiftsize*3-1,bf_tag("summits_filtered"),bf_tag("right"))
+    cmd="awk -v OFS='\t' '{if ($3-$2==1) print $1,$2+%d,$3+%d,$4,$5; else print $1,$3,$3*2-$2,$4,$5}' %s > %s"%(shiftsize,shiftsize*3-1,bf_tag("summits_filtered"),bf_tag("right"))
     run(cmd)
     cmd="rm %s"%bf_tag("summits_filtered")
     run(cmd)

File bin/Mpipe.py

 #! /usr/bin/env python
-# Time-stamp: <2011-12-02 05:16:13 hanfei>
+# Time-stamp: <2011-12-05 11:11:14 sunhf>
 
 """Description: Main executable for a whole pipeline for motif scaning and comparing
 
     optparser.add_option("-p","--percent",type="int",dest="n_top_percent",help="The percent of Top peak summits used to generate results. For example, input 1 for top 1% peaks")    
     optparser.add_option("-m","--motif",type="str",dest="motif_xml",help="The xml file of motif database.")
     optparser.add_option("-o","--name",type="str",dest="prefix_name",help="The name for this run, a directory will be created in this name in the current working directory, and the output file will all have a prefix of this name.")
-    optparser.add_option("-c","--cutoff",dest = "cutoff",type = "int",help = "The cutoff of the quotient of two likelyhood to throw some bad motif scores. default=1000",default=500) 
+    optparser.add_option("-c","--cutoff",dest = "cutoff",type = "int",help = "The cutoff of the quotient of two likelyhood to throw some bad motif scores. default=500",default=500) 
     optparser.add_option("-s","--shiftsize",dest = "shiftsize",type = "int",help = "Half of the region's length that you want to find the motif in. default=100",default=100)
     optparser.add_option("-k","--genomeversion",dest = "kind",type = "str",help = "What kind of Genome version to use. 'hg19' and 'mm9' available now. default=hg19",default="hg19")
     optparser.add_option("--debug",dest = "debug",action="store_true",help = "For debug only",default=False)