#NEWLINE# def posmap( args ) : #NEWLINE# #INDENT# '\n    %prog posmap frgscf.sorted scf.fasta scfID\n\n    Perform QC on the selected scfID, generate multiple BED files for plotting.\n    ' #NEWLINE# p = OptionParser ( posmap . __doc__ ) #NEWLINE# ( opts , args ) = p . parse_args ( args ) #NEWLINE# if ( len ( args ) != 3 ) : #NEWLINE# #INDENT# sys . exit ( p . print_help ( ) ) #NEWLINE# #UNINDENT# ( frgscffile , fastafile , scf ) = args #NEWLINE# cmd = 'faOneRecord {0} {1}' . format ( fastafile , scf ) #NEWLINE# scffastafile = ( scf + '.fasta' ) #NEWLINE# if ( not op . exists ( scffastafile ) ) : #NEWLINE# #INDENT# sh ( cmd , outfile = scffastafile ) #NEWLINE# #UNINDENT# sizesfile = ( scffastafile + '.sizes' ) #NEWLINE# sizes = Sizes ( scffastafile ) . mapping #NEWLINE# scfsize = sizes [ scf ] #NEWLINE# logging . debug ( '`{0}` has length of {1}.' . format ( scf , scfsize ) ) #NEWLINE# gapsbedfile = ( scf + '.gaps.bed' ) #NEWLINE# if ( not op . exists ( gapsbedfile ) ) : #NEWLINE# #INDENT# args = [ scffastafile , '--bed' , '--mingap=100' ] #NEWLINE# gaps ( args ) #NEWLINE# #UNINDENT# posmapfile = ( scf + '.posmap' ) #NEWLINE# if ( not op . exists ( posmapfile ) ) : #NEWLINE# #INDENT# args = [ frgscffile , scf ] #NEWLINE# query ( args ) #NEWLINE# #UNINDENT# bedfile = ( scf + '.bed' ) #NEWLINE# if ( not op . exists ( bedfile ) ) : #NEWLINE# #INDENT# args = [ posmapfile ] #NEWLINE# bed ( args ) #NEWLINE# #UNINDENT# bedpefile = ( scf + '.bedpe' ) #NEWLINE# pairsbedfile = ( scf + '.pairs.bed' ) #NEWLINE# if ( not ( op . exists ( bedpefile ) and op . exists ( pairsbedfile ) ) ) : #NEWLINE# #INDENT# bed_to_bedpe ( bedfile , bedpefile , pairsbedfile = pairsbedfile , ca = True ) #NEWLINE# #UNINDENT# Coverage ( bedfile , sizesfile ) #NEWLINE# Coverage ( pairsbedfile , sizesfile )