/** * A CDS sequence if negative stranded needs to be reverse complement * to represent the actual coding sequence. When getting a ProteinSequence * from a TranscriptSequence this method is callled for each CDSSequence * {@link http://www.sequenceontology.org/gff3.shtml} * {@link http://biowiki.org/~yam/bioe131/GFF.ppt} * @return coding sequence */ public String getCodingSequence() { String sequence = this.getSequenceAsString(getBioBegin(), getBioEnd(), getStrand()); if (getStrand() == Strand.NEGATIVE) { //need to take complement of sequence because it is negative and we are returning a coding sequence StringBuilder b = new StringBuilder(getLength()); CompoundSet<NucleotideCompound> compoundSet = this.getCompoundSet(); for (int i = 0; i < sequence.length(); i++) { String nucleotide = String.valueOf(sequence.charAt(i)); NucleotideCompound nucleotideCompound = compoundSet.getCompoundForString(nucleotide); b.append(nucleotideCompound.getComplement().getShortName()); } sequence = b.toString(); } // sequence = sequence.substring(phase); return sequence; } }
/** * A CDS sequence if negative stranded needs to be reverse complement * to represent the actual coding sequence. When getting a ProteinSequence * from a TranscriptSequence this method is callled for each CDSSequence * {@link http://www.sequenceontology.org/gff3.shtml} * {@link http://biowiki.org/~yam/bioe131/GFF.ppt} * @return coding sequence */ public String getCodingSequence() { String sequence = this.getSequenceAsString(getBioBegin(), getBioEnd(), getStrand()); if (getStrand() == Strand.NEGATIVE) { //need to take complement of sequence because it is negative and we are returning a coding sequence StringBuilder b = new StringBuilder(getLength()); CompoundSet<NucleotideCompound> compoundSet = this.getCompoundSet(); for (int i = 0; i < sequence.length(); i++) { String nucleotide = String.valueOf(sequence.charAt(i)); NucleotideCompound nucleotideCompound = compoundSet.getCompoundForString(nucleotide); b.append(nucleotideCompound.getComplement().getShortName()); } sequence = b.toString(); } // sequence = sequence.substring(phase); return sequence; } }
/** * Try to give method clarity where you want a DNASequence coding in the 5' to 3' direction * Returns the DNASequence representative of the 5' and 3' reading based on strand * @return dna sequence */ public DNASequence getSequence5PrimeTo3Prime() { String sequence = getSequenceAsString(this.getBioBegin(), this.getBioEnd(), this.getStrand()); if (getStrand() == Strand.NEGATIVE) { //need to take complement of sequence because it is negative and we are returning the gene sequence from the opposite strand StringBuilder b = new StringBuilder(getLength()); CompoundSet<NucleotideCompound> compoundSet = this.getCompoundSet(); for (int i = 0; i < sequence.length(); i++) { String nucleotide = String.valueOf(sequence.charAt(i)); NucleotideCompound nucleotideCompound = compoundSet.getCompoundForString(nucleotide); b.append(nucleotideCompound.getComplement().getShortName()); } sequence = b.toString(); } DNASequence dnaSequence = null; try { dnaSequence = new DNASequence(sequence.toUpperCase()); } catch (CompoundNotFoundException e) { // this should not happen, the sequence is DNA originally, if it does, there's a bug somewhere logger.error("Could not create new DNA sequence in getSequence5PrimeTo3Prime(). Error: {}",e.getMessage()); } dnaSequence.setAccession(new AccessionID(this.getAccession().getID())); return dnaSequence; } }
/** * Try to give method clarity where you want a DNASequence coding in the 5' to 3' direction * Returns the DNASequence representative of the 5' and 3' reading based on strand * @return dna sequence */ public DNASequence getSequence5PrimeTo3Prime() { String sequence = getSequenceAsString(this.getBioBegin(), this.getBioEnd(), this.getStrand()); if (getStrand() == Strand.NEGATIVE) { //need to take complement of sequence because it is negative and we are returning the gene sequence from the opposite strand StringBuilder b = new StringBuilder(getLength()); CompoundSet<NucleotideCompound> compoundSet = this.getCompoundSet(); for (int i = 0; i < sequence.length(); i++) { String nucleotide = String.valueOf(sequence.charAt(i)); NucleotideCompound nucleotideCompound = compoundSet.getCompoundForString(nucleotide); b.append(nucleotideCompound.getComplement().getShortName()); } sequence = b.toString(); } DNASequence dnaSequence = null; try { dnaSequence = new DNASequence(sequence.toUpperCase()); } catch (CompoundNotFoundException e) { // this should not happen, the sequence is DNA originally, if it does, there's a bug somewhere logger.error("Could not create new DNA sequence in getSequence5PrimeTo3Prime(). Error: {}",e.getMessage()); } dnaSequence.setAccession(new AccessionID(this.getAccession().getID())); return dnaSequence; } }