ó
ÈÅ…Nc @ su d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d Z d Z d Z
d Z d Z d Z
d „ Z d „ Z d
„ Z d „ Z d d „ Z d
„ Z d d d d d g e d „ Z d „ Z d d „ Z d d d „ Z g d d d d „ Z g d d e d „ Z d d d g d g d „ Z g d g d „ Z d e i d d d d „ Z d S( iÿÿÿÿNs
t plinkt Rs
smartpca.perlc C s t j d t j t j ƒ ƒ ƒ S( s$ return current time as a string
s %d/%m/%Y %H:%M:%S( t timet strftimet localtime( ( ( s5 /Users/xuebing/galaxy-dist/tools/rgenetics/rgutils.pyt timenow s c C s t j j ƒ j d ƒ S( Ns %Y%m%d%H%M%S( t datetimet nowR ( ( ( s5 /Users/xuebing/galaxy-dist/tools/rgenetics/rgutils.pyt timestamp" s c C s t j | IJd S( Niÿÿÿÿ( t syst stderr( t message( ( s5 /Users/xuebing/galaxy-dist/tools/rgenetics/rgutils.pyt fail% s
c C sƒ x| t j j d d ƒ j d ƒ D]\ } t j j t j j | | ƒ ƒ r t j j t j j | | ƒ ƒ r t j j | | ƒ Sq Wd S( Nt PATHt t :( t ost environt gett splitt patht existst joint isdirt None( t programR ( ( s5 /Users/xuebing/galaxy-dist/tools/rgenetics/rgutils.pyt whereis) s
%!"c s\ d d „ ‰ d „ ‰ d d ‡ ‡ f d † } t j d d ƒ \ } } | d | d | ƒ | S( sf
Picard tools requiring targets want
a sam style header which incidentally, MUST be sorted in natural order - not lexicographic order:
@SQ SN:chrM LN:16571
@SQ SN:chr1 LN:247249719
@SQ SN:chr2 LN:242951149
@SQ SN:chr3 LN:199501827
@SQ SN:chr4 LN:191273063
added to the start of what looks like a bed style file
chr1 67052400 67052451 - CCDS635.1_cds_0_0_chr1_67052401_r
chr1 67060631 67060788 - CCDS635.1_cds_1_0_chr1_67060632_r
chr1 67065090 67065317 - CCDS635.1_cds_2_0_chr1_67065091_r
chr1 67066082 67066181 - CCDS635.1_cds_3_0_chr1_67066083_r
see http://genome.ucsc.edu/FAQ/FAQtracks.html#tracks1
we need to add 1 to start coordinates on the way through - but length calculations are easier
c
S s i } y t | d ƒ } Wn d | GHt j d ƒ n XxI t | ƒ D]; \ } } | d d k rF d | | f GHt j d ƒ qF qF W| j ƒ } t | ƒ d k r | j d ƒ } | d } | d } | d } t | ƒ t | ƒ } | j | d ƒ | | c | 7