def fastq(args):
    """
    %prog fastq fastqfile

    Convert reads formatted as FASTQ file, and convert to CA frg file.
    """
    from jcvi.formats.fastq import guessoffset

    p = OptionParser(fastq.__doc__)
    p.add_option("--outtie", dest="outtie", default=False, action="store_true",
            help="Are these outie reads? [default: %default]")
    p.set_phred()
    p.set_size()

    opts, args = p.parse_args(args)

    if len(args) < 1:
        sys.exit(p.print_help())

    fastqfiles = [get_abs_path(x) for x in args]
    size = opts.size
    outtie = opts.outtie
    if size > 1000 and (not outtie):
        logging.debug("[warn] long insert size {0} but not outtie".format(size))

    mated = (size != 0)
    libname = op.basename(args[0]).split(".")[0]
    libname = libname.replace("_1_sequence", "")

    frgfile = libname + ".frg"
    mean, sv = get_mean_sv(opts.size)

    cmd = "fastqToCA"
    cmd += " -libraryname {0} ".format(libname)
    fastqs = " ".join("-reads {0}".format(x) for x in fastqfiles)
    if mated:
        assert len(args) in (1, 2), "you need one or two fastq files for mated library"
        fastqs = "-mates {0}".format(",".join(fastqfiles))
        cmd += "-insertsize {0} {1} ".format(mean, sv)
    cmd += fastqs

    offset = int(opts.phred) if opts.phred else guessoffset([fastqfiles[0]])
    illumina = (offset == 64)
    if illumina:
        cmd += " -type illumina"
    if outtie:
        cmd += " -outtie"

    sh(cmd, outfile=frgfile)
def fastq ( args ) : from jcvi . formats . fastq import guessoffset p = OptionParser ( fastq . __doc__ ) p . add_option ( "--outtie" , dest = "outtie" , default = False , action = "store_true" , help = "Are these outie reads? [default: %default]" ) p . set_phred ( ) p . set_size ( ) opts , args = p . parse_args ( args ) if len ( args ) < 1 : sys . exit ( p . print_help ( ) ) fastqfiles = [ get_abs_path ( x ) for x in args ] size = opts . size outtie = opts . outtie if size > 1000 and ( not outtie ) : logging . debug ( "[warn] long insert size {0} but not outtie" . format ( size ) ) mated = ( size != 0 ) libname = op . basename ( args [ 0 ] ) . split ( "." ) [ 0 ] libname = libname . replace ( "_1_sequence" , "" ) frgfile = libname + ".frg" mean , sv = get_mean_sv ( opts . size ) cmd = "fastqToCA" cmd += " -libraryname {0} " . format ( libname ) fastqs = " " . join ( "-reads {0}" . format ( x ) for x in fastqfiles ) if mated : assert len ( args ) in ( 1 , 2 ) , "you need one or two fastq files for mated library" fastqs = "-mates {0}" . format ( "," . join ( fastqfiles ) ) cmd += "-insertsize {0} {1} " . format ( mean , sv ) cmd += fastqs offset = int ( opts . phred ) if opts . phred else guessoffset ( [ fastqfiles [ 0 ] ] ) illumina = ( offset == 64 ) if illumina : cmd += " -type illumina" if outtie : cmd += " -outtie" sh ( cmd , outfile = frgfile )
%prog fastq fastqfile

    Convert reads formatted as FASTQ file, and convert to CA frg file.