#!/bin/bash


# Sort all helicos tagAlign files and append them together
#for F in helicos_*.tagAlign.bed
#do
#  echo doign $F
#  (sort -k1,1 -k2,2n -o $F $F ) &
#done
#wait 
sort -m helicos_*.tagAlign.bed > helicos.all.sorted.tagAlign.bed 
# remove the strand because this is unreliable
sed 's/[+-]/./' helicos.all.sorted.tagAlign.bed > wgEncodeHelicosRnaSeqAlignmentsK562CytosolLongpolya.bed

# zip the tagAlign to the goldenPath download dir
#gzip -c wgEncodeHelicosRnaSeqAlignmentsK562CytosolLongpolya.bed >/usr/local/apache/htdocs/goldenPath/hg18/wgEncodeHelicosRnaSeq/wgEncodeHelicosRnaSeqAlignmentsK562CytosolLongpolya.tagAlign.gz

# load tagAlign as bigBed
#/cluster/home/mikep/bin/x86_64/bedToBigBed -sorted -as=$HOME/kent/src/hg/lib/encode/tagAlign.as wgEncodeHelicosRnaSeqAlignmentsK562CytosolLongpolya.bed $HOME/kent/src/hg/encode/validateFiles/hg18_chromInfo.txt wgEncodeHelicosRnaSeqAlignmentsK562CytosolLongpolya.bb
#ln -s wgEncodeHelicosRnaSeqAlignmentsK562CytosolLongpolya.bb /gbdb/hg18/bbi/
#hgBbiDbLink hg18 wgEncodeHelicosRnaSeqAlignmentsK562CytosolLongpolya /gbdb/hg18/bbi/wgEncodeHelicosRnaSeqAlignmentsK562CytosolLongpolya.bb


# Make wig/wib for helicos
## output: Converted stdin, upper limit 65535.00, lower limit 1.00

RawSig=wgEncodeHelicosRnaSeqRawSignalK562CytosolLongpolya
#cat wgEncodeHelicosRnaSeqAlignmentsK562CytosolLongpolya.bed |bedItemOverlapCount hg18 stdin |wigEncode stdin $RawSig.wig $RawSig.wib
#ln -s $RawSig.wib /gbdb/hg18/wib/
#hgLoadWiggle  hg18 $RawSig $RawSig.wig

# zip the wig to the goldenPath download dir
#gzip -c wgEncodeHelicosRnaSeqRawSignalK562CytosolLongpolya.wig >/usr/local/apache/htdocs/goldenPath/hg18/wgEncodeHelicosRnaSeq/wgEncodeHelicosRnaSeqRawSignalK562CytosolLongpolya.wig.gz

