<s> """<STR_LIT>""" <EOL> import sys <EOL> from jcvi . apps . base import OptionParser , ActionDispatcher , sh , need_update <EOL> def main ( ) : <EOL> actions = ( <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ) <EOL> p = ActionDispatcher ( actions ) <EOL> p . dispatch ( globals ( ) ) <EOL> def scaffold ( args ) : <EOL> """<STR_LIT>""" <EOL> from jcvi . formats . base import FileMerger <EOL> from jcvi . formats . bed import mates <EOL> from jcvi . formats . contig import frombed <EOL> from jcvi . formats . fasta import join <EOL> from jcvi . utils . iter import grouper <EOL> p = OptionParser ( scaffold . __doc__ ) <EOL> p . set_rclip ( rclip = <NUM_LIT:1> ) <EOL> p . add_option ( "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> p . add_option ( "<STR_LIT>" , default = False , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> opts , args = p . parse_args ( args ) <EOL> nargs = len ( args ) <EOL> if nargs < <NUM_LIT:3> or nargs % <NUM_LIT:2> != <NUM_LIT:1> : <EOL> sys . exit ( not p . print_help ( ) ) <EOL> rclip = opts . rclip <EOL> ctgfasta = args [ <NUM_LIT:0> ] <EOL> duos = list ( grouper ( args [ <NUM_LIT:1> : ] , <NUM_LIT:2> ) ) <EOL> trios = [ ] <EOL> for fastafile , bedfile in duos : <EOL> prefix = bedfile . rsplit ( "<STR_LIT:.>" , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> matefile = prefix + "<STR_LIT>" <EOL> matebedfile = matefile + "<STR_LIT>" <EOL> if need_update ( bedfile , [ matefile , matebedfile ] ) : <EOL> matesopt = [ bedfile , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" . format ( rclip ) , <EOL> "<STR_LIT>" . format ( opts . cutoff ) ] <EOL> if opts . prefix : <EOL> matesopt += [ "<STR_LIT>" ] <EOL> matefile , matebedfile = mates ( matesopt ) <EOL> trios . append ( ( fastafile , matebedfile , matefile ) ) <EOL> bbfasta , bbbed , bbmate = "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" <EOL> for files , outfile in zip ( zip ( * trios ) , ( bbfasta , bbbed , bbmate ) ) : <EOL> FileMerger ( files , outfile = outfile ) . merge ( checkexists = True ) <EOL> ctgfile = "<STR_LIT>" <EOL> idsfile = "<STR_LIT>" <EOL> frombedInputs = [ bbbed , ctgfasta , bbfasta ] <EOL> if need_update ( frombedInputs , ctgfile ) : <EOL> frombed ( frombedInputs ) <EOL> inputfasta = "<STR_LIT>" <EOL> singletonfasta = "<STR_LIT>" <EOL> cmd = "<STR_LIT>" . format ( ctgfasta , idsfile ) <EOL> sh ( cmd + inputfasta ) <EOL> sh ( cmd + singletonfasta + "<STR_LIT>" ) <EOL> prefix = "<STR_LIT>" <EOL> cmd = "<STR_LIT>" . format ( ctgfile , bbmate , prefix ) <EOL> if opts . conf : <EOL> cmd += "<STR_LIT>" . format ( opts . conf ) <EOL> sh ( cmd ) <EOL> cmd = "<STR_LIT>" . format ( prefix ) <EOL> sh ( cmd ) <EOL> final = "<STR_LIT>" <EOL> cmd = "<STR_LIT>" "<STR_LIT>" . format ( prefix , final ) <EOL> sh ( cmd ) <EOL> oofile = final + "<STR_LIT>" <EOL> join ( [ inputfasta , "<STR_LIT>" . format ( oofile ) ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
