Example #1
0
    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  ================================
try:
    sorted_bams = sam2bam_sort(new_map_files,thread)    # [file.sort.bam] [file.sort.unmap2host.sort.bam]
Example #2
0
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(host_alignerDb) == []:
            gsnap_Db(host_fa,host_alignerDb,host_gsnapDbName,host_gsnapAnnotation)
        map_files = gsnap(fastqFiles,host_alignerDb, host_gsnapDbName,host_gsnapAnnotation,thread) # [file.sam]
    else:
        map_files = STAR(fastqFiles,host_alignerDb,thread)
    print 'host align succeed'
    print 'map_files is: ',map_files
except:
    print 'host 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 'host sorted succeed'
    print 'sorted_bam is: ',sorted_bams
except:
    print 'host sorted failed'
Example #3
0
output_path = param['htseqOutPath']
db_name = param['gsnapDbName']
gsnap_annotation = param['gsnapAnnotation']

Dict = param['symbolIDFile']
inputpath = file_path

#=========== (0) enter the directory ================
Message(startMessage, email)
os.chdir(file_path)
#=========== (1) reads files and trim ===============
fastqFiles = list_files(file_path)
if trim == 'True':
    fastqFiles = Trimmomatic(trimmomatic, fastqFiles, phred, trimmoAdapter)
print 'list file succeed'
#=========== (2) run gsnap to do the mapping ========
if aligner == 'gsnap':
    map_files = gsnap(fastqFiles, db_path, db_name, gsnap_annotation, thread)
else:
    map_files = STAR(fastqFiles, db_path, thread)
print 'align succeed'
#=========== (3) samtools to sort the file ==========
sorted_bam = sam2bam_sort(map_files, thread)
print 'sorted succeed'
#=========== (4) htseq_count ========================
htseq_count(sorted_bam, annotation, file_path)
print 'htseq count succeed'
#=========== (5) htseq symbol to id =================
ID_Convert(Dict, output_path, inputpath)
print 'id convert succeed'
Message(endMessage, email)
#========  (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:
    print 'bam sorted failed'
#========  (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:
    print 'bam sorted failed'
Example #6
0
output_path = param['htseqOutPath']
db_name = param['gsnapDbName']
gsnap_annotation = param['gsnapAnnotation']

Dict = param['symbolIDFile']
inputpath = file_path

#=========== (0) enter the directory ================
Message(startMessage,email)
os.chdir(file_path)
#=========== (1) reads files and trim ===============
fastqFiles = list_files(file_path)
if trim == 'True':
    fastqFiles = Trimmomatic(trimmomatic,fastqFiles,phred,trimmoAdapter)
print 'list file succeed'
#=========== (2) run gsnap to do the mapping ========
if aligner == 'gsnap':
    map_files = gsnap(fastqFiles,db_path, db_name,gsnap_annotation,thread)
else:
    map_files = STAR(fastqFiles,db_path,thread)
print 'align succeed'
#=========== (3) samtools to sort the file ==========
sorted_bam = sam2bam_sort(map_files,thread)
print 'sorted succeed'
#=========== (4) htseq_count ========================
htseq_count(sorted_bam,annotation,file_path)
print 'htseq count succeed'
#=========== (5) htseq symbol to id =================
ID_Convert(Dict,output_path,inputpath)
print 'id convert succeed'
Message(endMessage,email)