예제 #1
0
def pair(args):
    ''' pairs two same files '''

    # validate parameters.
    assert os.path.isdir(args.base_dir), 'base_dir'
    assert os.path.isfile(args.tmp1_sam), 'tmp1_sam'
    assert os.path.isfile(args.tmp2_sam), 'tmp2_sam'

    # relavent files.
    base_dir = os.path.abspath(args.base_dir)
    tmp1_sam = os.path.abspath(args.tmp1_sam)
    tmp2_sam = os.path.abspath(args.tmp2_sam)
    read1_sam = os.path.abspath('%s/read1.sam' % base_dir)
    read2_sam = os.path.abspath('%s/read2.sam' % base_dir)

    # pair the alignment.
    pair_sam2(tmp1_sam, tmp2_sam, read1_sam, read2_sam, args.key_size)
예제 #2
0
def align(args):
    ''' aligns reads against reference '''

    # validate parameters.
    assert os.path.isdir(args.base_dir), 'base_dir'
    assert os.path.isfile(args.ctg_fasta), 'ctg_fasta'
    assert os.path.isfile(args.read1_fastq), 'read1_fastq'
    assert os.path.isfile(args.read2_fastq), 'read2_fastq'
    assert os.path.isfile(args.size_file), 'size_file'

    # relavent files.
    base_dir = os.path.abspath(args.base_dir)

    size_file = os.path.abspath(args.size_file)
    ctg_fasta = os.path.abspath(args.ctg_fasta)
    read1_fastq = os.path.abspath(args.read1_fastq)
    read2_fastq = os.path.abspath(args.read2_fastq)

    tmp1_sam = os.path.abspath('%s/tmp1.sam' % base_dir)
    tmp2_sam = os.path.abspath('%s/tmp2.sam' % base_dir)

    read1_sam = os.path.abspath('%s/read1.sam' % base_dir)
    read2_sam = os.path.abspath('%s/read2.sam' % base_dir)

    ant_dir = '%s/ant' % base_dir
    idx_dir = '%s/index' % base_dir
    idx_file = '%s/index' % idx_dir

    # build index if not present.
    if os.path.isdir(idx_dir) == False:
        subprocess.call(["mkdir", "-p", idx_dir])
        create_idx(ctg_fasta, idx_file)

    # remove annotation dir if present.
    if os.path.isdir(ant_dir) == True:
        subprocess.call(["rm", "-rf", ant_dir])
    subprocess.call(["mkdir", "-p", ant_dir])

    # perform alignment.
    create_aln(size_file, idx_file, read1_fastq, tmp1_sam, ant_dir, args.num_cpu)
    create_aln(size_file, idx_file, read2_fastq, tmp2_sam, ant_dir, args.num_cpu)

    # pair the alignment.
    pair_sam2(tmp1_sam, tmp2_sam, read1_sam, read2_sam, args.key_size)