Exemplo n.º 1
0
gsnapAnnotation = param['gsnapAnnotation']
#========  (0) enter the directory ================
os.chdir(file_path)
Message(startMessage,email)
#========  (1) read files  ================================
fastqFiles = list_files(file_path)
if trim == 'True':
    fastqFiles = Trimmomatic(trimmomatic,fastqFiles,phred)
print 'list file succeed'
print 'fastqFiles is: ',fastqFiles
#========  (2) align fastq files to host ================================
try:
    if aligner == 'gsnap':
        # check index
        if os.listdir(alignerDb) == []:
            gsnap_Db(ref_fa,alignerDb,gsnapDbName,gsnapAnnotation)
        map_files = gsnap(fastqFiles,alignerDb,gsnapDbName,gsnapAnnotation,thread) # [file.sam]
    else:
        map_files = STAR(fastqFiles,alignerDb,thread)
    print 'align succeed'
    print 'map_files is: ',map_files
except:
    print 'align failed'
    Message('host align failed',email)
    raise
#========  (3) sam to bam and sort  ================================
try:
    sorted_bams = sam2bam_sort(map_files,thread)  # [file.sort.bam]
    print 'bam sorted succeed'
    print 'sorted_bam is: ',sorted_bams
except:
Exemplo n.º 2
0
    remove(unmap2host_bams)
except:
    print 'unmap2host_fq_gzs failed'
    Message('unmap2host_fq_gzs failed',email)
    raise
"""
unmap2host_fq_gzs = [['sub1.fq.gz']]
#===========================================================================
#                 2. Map to virus reference genome
#===========================================================================
#========  (1) align unmap2host_fq to virus  =========================
try:
    if aligner == 'gsnap':
        # check index
        if os.listdir(virus_alignerDb) == []:
            gsnap_Db(virus_ref_fa,virus_alignerDb,virus_gsnapDbName,virus_gsnapAnnotation)
        # align the reads
        map_files = gsnap(unmap2host_fq_gzs,virus_alignerDb, virus_gsnapDbName,virus_gsnapAnnotation,thread)
    else:
        map_files = STAR(unmap2host_fq_gzs,virus_alignerDb,thread,'',['--outSAMunmapped Within'])  # [file.sam] 
        new_map_files = [f[:-3]+'sort.unmap2host.sam' for f in map_files]
        for f1,f2 in zip(map_files,new_map_files):
            os.rename(f1,f2)                                        # [file.sort.unmap2host.sam]
    print 'virus align succeed'
    print 'map_files is: ',new_map_files
#     remove(unmap2host_fq_gzs)
except:
    print 'virus align failed'
    Message('virus align failed',email)
    raise
#========  (2) sam to bam and sort  ================================
Exemplo n.º 3
0
gsnapAnnotation = param['gsnapAnnotation']
#========  (0) enter the directory ================
os.chdir(file_path)
Message(startMessage, email)
#========  (1) read files  ================================
fastqFiles = list_files(file_path)
if trim == 'True':
    fastqFiles = Trimmomatic(trimmomatic, fastqFiles, phred)
print 'list file succeed'
print 'fastqFiles is: ', fastqFiles
#========  (2) align fastq files to host ================================
try:
    if aligner == 'gsnap':
        # check index
        if os.listdir(alignerDb) == []:
            gsnap_Db(ref_fa, alignerDb, gsnapDbName, gsnapAnnotation)
        map_files = gsnap(fastqFiles, alignerDb, gsnapDbName, gsnapAnnotation,
                          thread)  # [file.sam]
    else:
        map_files = STAR(fastqFiles, alignerDb, thread)
    print 'align succeed'
    print 'map_files is: ', map_files
except:
    print 'align failed'
    Message('host align failed', email)
    raise
#========  (3) sam to bam and sort  ================================
try:
    sorted_bams = sam2bam_sort(map_files, thread)  # [file.sort.bam]
    print 'bam sorted succeed'
    print 'sorted_bam is: ', sorted_bams