diff options
author | Mark Sims <mark@nanorex.com> | 2008-12-19 16:04:17 +0000 |
---|---|---|
committer | Mark Sims <mark@nanorex.com> | 2008-12-19 16:04:17 +0000 |
commit | a4f5a63aa18ffec8c2535d3d24bdf3bac4585981 (patch) | |
tree | a9e08cc80451510c4b113e7c2c6479e09e32ec5a | |
parent | 6a2bf235753a9fa62c20da1c3c025eb1b295e6be (diff) | |
download | nanoengineer-a4f5a63aa18ffec8c2535d3d24bdf3bac4585981.tar.gz nanoengineer-a4f5a63aa18ffec8c2535d3d24bdf3bac4585981.zip |
Color extra sequence characters gray to indicate they are not part of the sequence string that will be applied. Also disabled the "3' to 5'" option in the DNA Sequence Editor due to bugs (see bug 2956 for details).
-rw-r--r-- | cad/src/dna/DnaSequenceEditor/DnaSequenceEditor.py | 44 | ||||
-rw-r--r-- | cad/src/dna/DnaSequenceEditor/Ui_DnaSequenceEditor.py | 12 |
2 files changed, 47 insertions, 9 deletions
diff --git a/cad/src/dna/DnaSequenceEditor/DnaSequenceEditor.py b/cad/src/dna/DnaSequenceEditor/DnaSequenceEditor.py index 163912ec2..d702a568e 100644 --- a/cad/src/dna/DnaSequenceEditor/DnaSequenceEditor.py +++ b/cad/src/dna/DnaSequenceEditor/DnaSequenceEditor.py @@ -22,6 +22,14 @@ TODO: Ninad 2007-11-28 (reviewed and updated by Mark 2008-12-17) and then called here? - Implement synchronizeLengths(). It doesn't do anything for now. - Create superclass that both the DNA and Protein sequence editors can use. + +BUGS: + +Bug 2956: Problems related to changing strand direction to "3' to 5'" direction: + - Complement sequence field is offset from the sequence field when typing + overhang characters. + - The sequence field overhang coloring is not correct. + Implementation Notes as of 2007-11-20 (reviewed and updated by Mark 2008-12-17): The Sequence Editor is shown when you edit a DnaStrand (if visible, the @@ -462,7 +470,8 @@ class DnaSequenceEditor(Ui_DnaSequenceEditor): #Find out complement sequence complementSequence = self._determine_complementSequence(inSequence) - inSequence = self._fixedPitchSequence(inSequence) + htmlSequence = self._colorExtraSequenceCharacters(inSequence) + htmlSequence = self._fixedPitchSequence(htmlSequence) complementSequence = self._fixedPitchSequence(complementSequence) # Get current cursor position before inserting inSequence. @@ -473,7 +482,7 @@ class DnaSequenceEditor(Ui_DnaSequenceEditor): # Specify that theSequence is definitely HTML format, because # Qt can get confused between HTML and Plain Text. - self.sequenceTextEdit.insertHtml( inSequence ) #@@@ Generates signal??? + self.sequenceTextEdit.insertHtml( htmlSequence ) #@@@ Generates signal??? self.sequenceTextEdit_mate.insertHtml(complementSequence) self.setCursorPosition(cursorPos = cursorPos) @@ -661,19 +670,39 @@ class DnaSequenceEditor(Ui_DnaSequenceEditor): #stylize the sequence .-- Ninad 2008-01-22 ##inSequence = self.stylizeSequence( inSequence ) - #Instead only make the sequence 'Fixed pitch' (while bug 2604 - #is still open - inSequence = self._fixedPitchSequence(inSequence) + # Color any overhang sequence characters gray. + htmlSequence = self._colorExtraSequenceCharacters(inSequence) + + #Make the sequence 'Fixed pitch'. + htmlSequence = self._fixedPitchSequence(htmlSequence) # Specify that theSequence is definitely HTML format, because # Qt can get confused between HTML and Plain Text. self._suppress_textChanged_signal = True - self.sequenceTextEdit.insertHtml( inSequence ) + self.sequenceTextEdit.insertHtml( htmlSequence ) self._suppress_textChanged_signal = False self.setCursorPosition(0) return + def _colorExtraSequenceCharacters(self, inSequence): + """ + Returns I{inSequence} with html tags that color any extra overhang + characters gray. + @param inSequence: The sequence. + @type inSequence: QString + @return: inSequence with the html tags to color any overhang characters. + @rtype: string + """ + strandLength = self.current_strand.getNumberOfBases() + if len(inSequence) <= strandLength: + return inSequence + + sequence = inSequence[:strandLength] + overhang = inSequence[strandLength:] + + return sequence + "<font color=gray>" + overhang + "</font>" + def _fixedPitchSequence(self, sequence): """ Make the sequence 'fixed-pitched' i.e. width of all characters @@ -992,8 +1021,7 @@ class DnaSequenceEditor(Ui_DnaSequenceEditor): newCursorStartPosition = 0 cursor.setPosition( newCursorStartPosition, - QTextCursor.MoveAnchor) - print "_findNextOrPrevious(): setting cursor pos:" + QTextCursor.MoveAnchor) self.sequenceTextEdit.setTextCursor(cursor) found = self.sequenceTextEdit.find(searchString, findFlags) diff --git a/cad/src/dna/DnaSequenceEditor/Ui_DnaSequenceEditor.py b/cad/src/dna/DnaSequenceEditor/Ui_DnaSequenceEditor.py index 40fcc6287..425ad8e68 100644 --- a/cad/src/dna/DnaSequenceEditor/Ui_DnaSequenceEditor.py +++ b/cad/src/dna/DnaSequenceEditor/Ui_DnaSequenceEditor.py @@ -15,6 +15,14 @@ TODO: - NFR: Support both "Insert" and "Overtype" modes in sequence field. - Split out find and replace widgets to their own class (low priority) - Create superclass that both the DNA and Protein sequence editors can use. + +BUGS: + +Bug 2956: Problems related to changing strand direction to "3' to 5'" direction: + - Complement sequence field is offset from the sequence field when typing + overhang characters. + - The sequence field overhang coloring is not correct. + """ from PyQt4.Qt import QToolButton @@ -141,7 +149,9 @@ class Ui_DnaSequenceEditor(PM_DockWidget): self.loadSequenceButton.setAutoRaise(True) self.saveSequenceButton.setAutoRaise(True) - editDirectionChoices = ["5' to 3'", "3' to 5'"] + # Only supporting 5' to 3' direction until bug 2956 is fixed. + # Mark 2008-12-19 + editDirectionChoices = ["5' to 3'"] # , "3' to 5'"] self.baseDirectionChoiceComboBox = \ PM_ComboBox( self, choices = editDirectionChoices, |