Example #1
0
    def get_sequence(self, transcripts):

        sequences = []
        for transcript in transcripts:

            # get DNA sequence
            seq = self._seq_handle.fetch(transcript.chromosome, transcript.start, transcript.stop).upper()

            # get DNA sequence of transcript
            # reverse complement, if necessary
            if transcript.strand=="-":
                seq = seq[::-1]
                seq = ''.join(np.array(list(seq))[transcript.mask].tolist())
                seq = utils.make_complement(seq)
            else:
                seq = ''.join(np.array(list(seq))[transcript.mask].tolist())

            # get RNA sequence
            seq = ''.join(['U' if s=='T' else s for s in seq])
            sequences.append(seq)
            
        return sequences
Example #2
0
    def get_sequence(self, transcripts):

        sequences = []
        for transcript in transcripts:

            # get DNA sequence
            seq = self._seq_handle.fetch(transcript.chromosome,
                                         transcript.start,
                                         transcript.stop).upper()

            # get DNA sequence of transcript
            # reverse complement, if necessary
            if transcript.strand == "-":
                seq = seq[::-1]
                seq = ''.join(np.array(list(seq))[transcript.mask].tolist())
                seq = utils.make_complement(seq)
            else:
                seq = ''.join(np.array(list(seq))[transcript.mask].tolist())

            # get RNA sequence
            seq = ''.join(['U' if s == 'T' else s for s in seq])
            sequences.append(seq)

        return sequences
        positions = transcript.start + np.where(transcript.mask)[0]
        reads = [
            seq[i:i + options.footprint_length]
            for i in xrange(L - options.footprint_length + 1)
        ]

        # write synthetic reads
        fastq_handle.write(''.join(["@%s:%d:%s\n%s\n+\n%s\n"%(transcript.chromosome, \
            position,transcript.strand,read,qual) \
            for position,read in zip(positions,reads)]))

        # get reverse strand reads
        transcript.mask = transcript.mask[::-1]
        transcript.strand = "-"
        seq = seq[::-1]
        seq = ''.join(utils.make_complement(seq))
        positions = transcript.start + transcript.mask.size - np.where(
            transcript.mask)[0]
        reads = [
            seq[i:i + options.footprint_length]
            for i in xrange(L - options.footprint_length + 1)
        ]

        # write synthetic reads
        fastq_handle.write(''.join(["@%s:%d:%s\n%s\n+\n%s\n"%(transcript.chromosome, \
            position,transcript.strand,read,qual) \
            for position,read in zip(positions,reads)]))

    seq_handle.close()
    fastq_handle.close()
            transcript.mask = transcript.mask[::-1]
            transcript.strand = "+"

        seq = ''.join(np.array(list(sequence))[transcript.mask].tolist())
        L = len(seq)
        positions = transcript.start + np.where(transcript.mask)[0]
        reads = [seq[i:i+options.footprint_length] 
                 for i in xrange(L-options.footprint_length+1)]
    
        # write synthetic reads
        fastq_handle.write(''.join(["@%s:%d:%s\n%s\n+\n%s\n"%(transcript.chromosome, \
            position,transcript.strand,read,qual) \
            for position,read in zip(positions,reads)]))

        # get reverse strand reads
        transcript.mask = transcript.mask[::-1]
        transcript.strand = "-"
        seq = seq[::-1]
        seq = ''.join(utils.make_complement(seq))
        positions = transcript.start + transcript.mask.size - np.where(transcript.mask)[0]
        reads = [seq[i:i+options.footprint_length] 
                 for i in xrange(L-options.footprint_length+1)]

        # write synthetic reads
        fastq_handle.write(''.join(["@%s:%d:%s\n%s\n+\n%s\n"%(transcript.chromosome, \
            position,transcript.strand,read,qual) \
            for position,read in zip(positions,reads)]))

    seq_handle.close()
    fastq_handle.close()