def updateContext(oFN, wigDir, chrom, strand, rn = None, tn = None): oNX = cgNexusFlat.Nexus(oFN, degPeak.degPeak) oNX.load(['context', 'tcc'], [rn, tn]) print 'loading wig' coord_contexts = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'context') print 'done loading' ds = bioLibCG.dominantSpotter(['C_EXON', 'C_3UTR', 'C_5UTR', 'NC_EXON', 'NC_3UTR', 'NC_5UTR', 'C_INTRON', 'NC_INTRON', 'INTER']) for oID in oNX.tcc: oChrom, oStrand, start, end = bioLibCG.tccSplit(oNX.tcc[oID]) #deg wigs is AS to actual clipping site if oStrand == '1': oStrand = '-1' else: oStrand = '1' if oChrom == chrom and oStrand == strand: contexts = coord_contexts.get(start, 'INTER').split(',') oNX.context[oID] = ds.spotItem(contexts) oNX.save()
def updateContext(oFN, wigDir, chrom, strand, switchStrand = False): oNX = cgNexusFlat.Nexus(oFN, cgDegPeak.Peak) oNX.load(['tcc', 'context']) if switchStrand: strand = str(-int(strand)) else: strand = str(strand) print 'loading wig' coord_contexts = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'context') print 'done loading' ds = bioLibCG.dominantSpotter(['C_EXON', 'C_3UTR', 'C_5UTR', 'NC_EXON', 'NC_3UTR', 'NC_5UTR', 'C_INTRON', 'NC_INTRON', 'INTER']) for oID in oNX.tcc: oChrom, oStrand, start, end = bioLibCG.tccSplit(oNX.tcc[oID]) #deg wigs is AS to actual clipping site if switchStrand: oStrand = str(-int(strand)) else: oStrand = str(oStrand) if oChrom == chrom and oStrand == strand: contexts = coord_contexts.get(start, 'INTER').split(',') oNX.context[oID] = ds.spotItem(contexts) oNX.save()
def updateContext(fN, fF, wigDir, chrom, strand, switchStrand = False): NX = Nexus(fN, fF) NX.load(['tcc', 'context']) if switchStrand: strand = str(-int(strand)) else: strand = str(strand) print 'loading wig' coord_contexts = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'context') print 'done loading' ds = bioLibCG.dominantSpotter(['C_EXON', 'C_3UTR', 'C_5UTR', 'NC_EXON', 'NC_3UTR', 'NC_5UTR', 'C_INTRON', 'NC_INTRON', 'INTER']) while NX.nextID(): oChrom, oStrand, start, end = bioLibCG.tccSplit(NX.tcc) #deg wigs is AS to actual clipping site if switchStrand: oStrand = str(-int(strand)) else: oStrand = str(oStrand) if oChrom == chrom and oStrand == strand: contexts = coord_contexts.get(start, 'INTER').split(',') NX.context = ds.spotItem(contexts) NX.save()
def updateContext(oFN, wigDir, chrom, strand, rn=None, tn=None): oNX = cgNexusFlat.Nexus(oFN, degPeak.degPeak) oNX.load(['context', 'tcc'], [rn, tn]) print 'loading wig' coord_contexts = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'context') print 'done loading' ds = bioLibCG.dominantSpotter([ 'C_EXON', 'C_3UTR', 'C_5UTR', 'NC_EXON', 'NC_3UTR', 'NC_5UTR', 'C_INTRON', 'NC_INTRON', 'INTER' ]) for oID in oNX.tcc: oChrom, oStrand, start, end = bioLibCG.tccSplit(oNX.tcc[oID]) #deg wigs is AS to actual clipping site if oStrand == '1': oStrand = '-1' else: oStrand = '1' if oChrom == chrom and oStrand == strand: contexts = coord_contexts.get(start, 'INTER').split(',') oNX.context[oID] = ds.spotItem(contexts) oNX.save()
def updateTypeAlignment(oFN, wigDir, chrom, strand, rn = None, tn = None): '''This is for ALIGNMENTS...NOT DEG PEAKS!''' oNX = cgNexusFlat.Nexus(oFN, cgAlignmentFlat.cgAlignment) oNX.load(['tTcc', 'type'], [rn, tn]) if strand == '1': strand = '-1' else: strand = '1' print 'loading wig' coord_types = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'tType') print 'done loading' domOrder = ['microRNA_noncoding', 'lincRNA_noncoding', 'longNC_noncoding', 'miRNA_pseudogene_noncoding', 'Mt_rRNA_noncoding', 'Mt_tRNA_noncoding', 'Mt_tRNA_pseudogene_noncoding', 'rRNA_noncoding', 'rRNA_pseudogene_noncoding', 'scRNA_pseudogene_noncoding', 'snoRNA_noncoding', 'snoRNA_pseudogene_noncoding', 'snRNA_noncoding', 'snRNA_pseudogene_noncoding', 'tRNA_pseudogene_noncoding', 'pseudogene_noncoding', 'protein_coding', 'None'] ds = bioLibCG.dominantSpotter(domOrder) for oID in oNX.tTcc: oChrom, oStrand, start, end = bioLibCG.tccSplit(oNX.tTcc[oID]) #deg wigs is AS to actual clipping site if oStrand == '1': oStrand = '-1' else: oStrand = '1' if oChrom == chrom and oStrand == strand: tranTypes = coord_types.get(start, 'None').split(',') types = [x.split(':')[1] if x != 'None' else 'None' for x in tranTypes] types = list(set(types)) oNX.type[oID] = ds.spotItem(types) oNX.save()
def updateType(oFN, wigDir, chrom, strand, rn = None, tn = None): oNX = cgNexusFlat.Nexus(oFN, cgOriginRNAFlat.OriginRNA) oNX.load(['tcc', 'transcriptType', 'transcriptTypes'], [rn, tn]) print 'loading wig' coord_types = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'tType') print 'done loading' domOrder = ['microRNA_noncoding', 'lincRNA_noncoding', 'longNC_noncoding', 'miRNA_pseudogene_noncoding', 'Mt_rRNA_noncoding', 'Mt_tRNA_noncoding', 'Mt_tRNA_pseudogene_noncoding', 'rRNA_noncoding', 'rRNA_pseudogene_noncoding', 'scRNA_pseudogene_noncoding', 'snoRNA_noncoding', 'snoRNA_pseudogene_noncoding', 'snRNA_noncoding', 'snRNA_pseudogene_noncoding', 'tRNA_pseudogene_noncoding', 'pseudogene_noncoding', 'protein_coding', 'None'] ds = cg.dominantSpotter(domOrder) for oID in oNX.tcc: oChrom, oStrand, start, end = cg.tccSplit(oNX.tcc[oID]) if oChrom == chrom and oStrand == strand: tranTypes = coord_types.get(start, 'None').split(',') types = [x.split(':')[1] if x != 'None' else 'None' for x in tranTypes] types = list(set(types)) oNX.transcriptTypes[oID] = types oNX.transcriptType[oID] = ds.spotItem(types) oNX.save()
def updateType(oFN, wigDir, chrom, strand, rn=None, tn=None): oNX = cgNexusFlat.Nexus(oFN, cgDegPeak.Peak) oNX.load(['tcc', 'type'], [rn, tn]) if strand == '1': strand = '-1' else: strand = '1' print 'loading wig' coord_types = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'tType') print 'done loading' domOrder = [ 'protein_coding', 'miRNA', 'rRNA', 'snoRNA', 'snRNA', 'lincRNA', 'longNC', 'misc_RNA', 'Mt_rRNA', 'Mt_tRNA', 'misc_RNA_pseudogene', 'Mt_tRNA_pseudogene', 'polymorphic_pseudogene', 'processed_transcript', 'miRNA_pseudogene', 'rRNA_pseudogene', 'scRNA_pseudogene', 'snoRNA_pseudogene', 'snRNA_pseudogene', 'tRNA_pseudogene', 'pseudogene', 'TR_C_gene', 'TR_J_gene', 'TR_V_gene', 'TR_V_pseudogene', 'IG_C_gene', 'IG_C_pseudogene', 'IG_D_gene', 'IG_J_gene', 'IG_J_pseudogene', 'IG_V_gene', 'IG_V_pseudogene', 'unknown', 'None' ] ds = bioLibCG.dominantSpotter(domOrder) for oID in oNX.tcc: oChrom, oStrand, start, end = bioLibCG.tccSplit(oNX.tcc[oID]) #deg wigs is AS to actual clipping site if oStrand == '1': oStrand = '-1' else: oStrand = '1' if oChrom == chrom and oStrand == strand: tranTypes = coord_types.get(start, 'None').split(',') print tranTypes types = [ x.split(':')[1] if x != 'None' else ['None'] for x in tranTypes ] oNX.type = oNX.transcriptType = ds.spotItem(types) oNX.save()
def updateTypeAlignment(oFN, wigDir, chrom, strand, rn=None, tn=None): '''This is for ALIGNMENTS...NOT DEG PEAKS!''' oNX = cgNexusFlat.Nexus(oFN, cgAlignmentFlat.cgAlignment) oNX.load(['tTcc', 'type'], [rn, tn]) if strand == '1': strand = '-1' else: strand = '1' print 'loading wig' coord_types = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'tType') print 'done loading' domOrder = [ 'microRNA_noncoding', 'lincRNA_noncoding', 'longNC_noncoding', 'miRNA_pseudogene_noncoding', 'Mt_rRNA_noncoding', 'Mt_tRNA_noncoding', 'Mt_tRNA_pseudogene_noncoding', 'rRNA_noncoding', 'rRNA_pseudogene_noncoding', 'scRNA_pseudogene_noncoding', 'snoRNA_noncoding', 'snoRNA_pseudogene_noncoding', 'snRNA_noncoding', 'snRNA_pseudogene_noncoding', 'tRNA_pseudogene_noncoding', 'pseudogene_noncoding', 'protein_coding', 'None' ] ds = bioLibCG.dominantSpotter(domOrder) for oID in oNX.tTcc: oChrom, oStrand, start, end = bioLibCG.tccSplit(oNX.tTcc[oID]) #deg wigs is AS to actual clipping site if oStrand == '1': oStrand = '-1' else: oStrand = '1' if oChrom == chrom and oStrand == strand: tranTypes = coord_types.get(start, 'None').split(',') types = [ x.split(':')[1] if x != 'None' else 'None' for x in tranTypes ] types = list(set(types)) oNX.type[oID] = ds.spotItem(types) oNX.save()
def updateType(oFN, wigDir, chrom, strand, rn = None, tn = None): oNX = cgNexusFlat.Nexus(oFN, cgDegPeak.Peak) oNX.load(['tcc', 'type'], [rn, tn]) if strand == '1': strand = '-1' else: strand = '1' print 'loading wig' coord_types = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'tType') print 'done loading' domOrder = ['protein_coding', 'miRNA', 'rRNA', 'snoRNA', 'snRNA', 'lincRNA', 'longNC', 'misc_RNA', 'Mt_rRNA', 'Mt_tRNA', 'misc_RNA_pseudogene', 'Mt_tRNA_pseudogene', 'polymorphic_pseudogene', 'processed_transcript', 'miRNA_pseudogene', 'rRNA_pseudogene', 'scRNA_pseudogene', 'snoRNA_pseudogene', 'snRNA_pseudogene', 'tRNA_pseudogene', 'pseudogene', 'TR_C_gene', 'TR_J_gene', 'TR_V_gene', 'TR_V_pseudogene', 'IG_C_gene', 'IG_C_pseudogene', 'IG_D_gene', 'IG_J_gene', 'IG_J_pseudogene', 'IG_V_gene', 'IG_V_pseudogene', 'unknown', 'None'] ds = bioLibCG.dominantSpotter(domOrder) for oID in oNX.tcc: oChrom, oStrand, start, end = bioLibCG.tccSplit(oNX.tcc[oID]) #deg wigs is AS to actual clipping site if oStrand == '1': oStrand = '-1' else: oStrand = '1' if oChrom == chrom and oStrand == strand: tranTypes = coord_types.get(start, 'None').split(',') print tranTypes types = [x.split(':')[1] if x != 'None' else ['None'] for x in tranTypes] oNX.type = oNX.transcriptType = ds.spotItem(types) oNX.save()
def updateContext(oFN, wigDir, chrom, strand, rn = None, tn = None): oNX = cgNexusFlat.Nexus(oFN, cgOriginRNAFlat.OriginRNA) oNX.load(['tcc', 'context'], [rn, tn]) print 'loading wig' coord_contexts = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'context') print 'done loading' ds = cg.dominantSpotter(['C_EXON', 'C_3UTR', 'C_5UTR', 'NC_EXON', 'NC_3UTR', 'NC_5UTR', 'C_INTRON', 'NC_INTRON', 'INTER']) for oID in oNX.tcc: oChrom, oStrand, start, end = cg.tccSplit(oNX.tcc[oID]) if oChrom == chrom and oStrand == strand: contexts = coord_contexts.get(start, 'INTER').split(',') oNX.context[oID] = ds.spotItem(contexts) oNX.save()
def updateContext(oFN, wigDir, chrom, strand, switchStrand=False): oNX = cgNexusFlat.Nexus(oFN, cgDegPeak.Peak) oNX.load(['tcc', 'context']) if switchStrand: strand = str(-int(strand)) else: strand = str(strand) print 'loading wig' coord_contexts = cgWig.loadSingleWigContext(wigDir, chrom, strand, 'context') print 'done loading' ds = bioLibCG.dominantSpotter([ 'C_EXON', 'C_3UTR', 'C_5UTR', 'NC_EXON', 'NC_3UTR', 'NC_5UTR', 'C_INTRON', 'NC_INTRON', 'INTER' ]) for oID in oNX.tcc: oChrom, oStrand, start, end = bioLibCG.tccSplit(oNX.tcc[oID]) #deg wigs is AS to actual clipping site if switchStrand: oStrand = str(-int(strand)) else: oStrand = str(oStrand) if oChrom == chrom and oStrand == strand: contexts = coord_contexts.get(start, 'INTER').split(',') oNX.context[oID] = ds.spotItem(contexts) oNX.save()
def updateContext(oDir, geneSetFN): print 'loading oRNA' oDC = cgDB.dataController(oDir, cgOriginRNA.OriginRNA) id_oRNA = oDC.load() print 'loading gene set' geneSet = cgGenes3.createGeneSetEditing(geneSetFN) #Get in terms of tccs print 'Joining' oTcc_oRNA = oneToOne(id_oRNA.values(), 'tcc') tTcc_transcripts = oneToMany(geneSet.transcripts, 'tcc') #Overlap tccs print 'overlapping' oTcc_tTccs = compareData.getIndividualOverlaps(oTcc_oRNA.keys(), tTcc_transcripts.keys(), 1) #create final dictionary containing {oRNA : [transcript, ..]} oRNA_transcripts = {} for oTcc in oTcc_tTccs: oRNA = oTcc_oRNA[oTcc] oRNA_transcripts[oRNA] = [] for tTcc in oTcc_tTccs[oTcc]: oRNA_transcripts[oRNA].extend(tTcc_transcripts[tTcc]) print 'get context info' #Go through each site and find out what it overlaps, and if it is in a coding region... ds = bioLibCG.dominantSpotter(['EXON_INTRON', '3UTR', '5UTR', 'EXON', 'INTRON']) for oRNA in oRNA_transcripts: oRNA.transcriptIDs = [] oRNA.transcriptContexts = [] oRNA.transcriptTypes = [] oRNA.transcriptCodingTypes = [] if len(oRNA_transcripts[oRNA]) == 0: continue for transcript in oRNA_transcripts[oRNA]: codingTranscript = '_coding' in transcript.tType tType = None codingFlag = None tTypes = [x[1] for x in transcript.getOverlappingElements(oRNA.tcc)] #categorize border types tType = ds.spotItem(tTypes) if tType == 'EXON' or 'EXON_INTRON': if codingTranscript: codingFlag = 'C' else: codingFlag = 'NC' else: codingFlag = 'NC' oRNA.transcriptIDs.append(transcript.id) oRNA.transcriptContexts.append(tType) oRNA.transcriptTypes.append(transcript.tType) oRNA.transcriptCodingTypes.append(codingFlag) oDC.commit(id_oRNA)