programmaticaly colour selected columns in JalView

Hello everyone,

Is there a way to programmaticaly colour the selected column in jalview? I have a ColumnSelection and want to show it in a different colour.
Any suggestion/help would be great.
Thanks.

Regards,
Nicee.

Hello everyone,

Is there a way to programmaticaly colour the selected column in jalview? I have a ColumnSelection and want to show it in a different colour.
Any suggestion/help would be great.
Thanks.

Regards,
Nicee.

Not sure where you have got the column selection from without seeing how you have integrated jalview… since there isn’t a clear api for doing this yet. Can you send me a code sample so i can help you out?

Jim.

Ps. I realize this is unreleased code. But one of the great things about open source is you get help for free if you develop your code in the open too :slight_smile:

···

On Jul 11, 2012 3:37 PM, “Nicee Srivastava” <nsrivast@unil.ch> wrote:

Hello everyone,

Is there a way to programmaticaly colour the selected column in jalview? I have a ColumnSelection and want to show it in a different colour.
Any suggestion/help would be great.
Thanks.

Regards,
Nicee.


Jalview-discuss mailing list
Jalview-discuss@jalview.org
http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-discuss

Hey Jim,

Thanks for your reply.

I have one main alignment, on this alignment i apply some sequence filter after which some sequences and some columns form the alignment are deleted. In my viewer i want to show the main full alignmnet with deleted sequences and columns highlighted/selected/coloured, so that user can see what changes have been made and then decide the next step.

for the alignment view, this is what i have done:

SequenceI[] seqs = new SequenceI[ado.getAlignment().size()]; // ado=alignmnet data object
for (int i = 0; i < seqs.length; i++) {
seqs[i] = new Sequence(ado.getAlignment().get(i).getHeader(), ado.getAlignment().get(i).getOriginalSequence());
// String name , and sequence
}
Alignment alignment = new Alignment(seqs);

AlignFrame af = new AlignFrame(alignment, null, null, false);
af.setVisible(false);
af.setEnabled(false);

AlignViewport avw = new AlignViewport(alignment, null);
avw.setGlobalColourScheme(new ZappoColourScheme());

AlignmentPanel apl = new AlignmentPanel(af, avw);
apl.setAnnotationVisible(false);

this.jScrollPane1.setViewportView(apl);

and so i get the jalview alignmnet viewer in my jScrollPane.

i am able to show the deleted sequences as coloured sequence in the full alignment by:

SequenceI[] alteredSeqs = new SequenceI[altseq.size()]; // altseq is an ArrayList of sequences left the filter.
for (int i = 0; i < alteredSeqs.length; i++) {
alteredSeqs[i] = new Sequence(name.get(i), altseq.get(i));
}
Alignment alteredAlignment = new Alignment(alteredSeqs);

AlignFrame af = new AlignFrame(alignment, null, null, false);
af.setVisible(false);
af.setEnabled(false);

AlignViewport avw = new AlignViewport(alignment, null);
for (int i = 0; i < seqs.length; i++) { // seq is full alignment.
SequenceI s = alteredAlignment.findName(seqs[i].getName());
if (s == null) {
avw.setSequenceColour(alignment.getSequenceAt(alignment.findIndex(seqs[i])), Color.red);
}
}

AlignmentPanel apl = new AlignmentPanel(af, avw);
apl.setAnnotationVisible(false);
this.jScrollPane1.setViewportView(apl);

My alignment filter class, gves me an option to store a conserved string. This string has “x” at the conserved positions,i.e, the positions which are retained in the alignment after the filter and “-” for position which have been deleted. So form this string i make a column selection as below:

ArrayList conPos2origPos = new ArrayList();
for (int i = 0; i < constr.length(); i++) { // constr is the conserved string
if (constr.charAt(i) == ‘-’) {
conPos2origPos.add(i);
}
}
ColumnSelection col = new ColumnSelection();
for (int j = 0; j < conPos2origPos.size(); j++) {
col.addElement(conPos2origPos.get(j));
}

Now i am able to highlight/colour these columns in the full alignment.
Hope the explanation is not very confusing.
Suggestions/help is welcome.

Regards,
Nicee.

···

On Thu, Jul 12, 2012 at 5:56 PM, Jim Procter <foreveremain@gmail.com> wrote:

Not sure where you have got the column selection from without seeing how you have integrated jalview… since there isn’t a clear api for doing this yet. Can you send me a code sample so i can help you out?

Jim.

Ps. I realize this is unreleased code. But one of the great things about open source is you get help for free if you develop your code in the open too :slight_smile:

On Jul 11, 2012 3:37 PM, “Nicee Srivastava” <nsrivast@unil.ch> wrote:

Hello everyone,

Is there a way to programmaticaly colour the selected column in jalview? I have a ColumnSelection and want to show it in a different colour.
Any suggestion/help would be great.
Thanks.

Regards,
Nicee.


Jalview-discuss mailing list
Jalview-discuss@jalview.org
http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-discuss


Regards,
Nicee Srivastava
Phd Student,
Group of Prof. Dr. Dirk Fasshauer,
Faculty of Biology and Medicine,
Department of Biology and Cellular Morphology,
Quartier UNIL-CHUV,
Rue du Bugnon 9,
CH-1005 Lausanne .

any suggestions as how to highlight/colour the columns.

···

---------- Forwarded message ----------
From: Nicee Srivastava <nsrivast@unil.ch>

Date: Tue, Jul 17, 2012 at 4:11 PM
Subject: Re: [Jalview-discuss] programmaticaly colour selected columns in JalView
To: Jim Procter <foreveremain@gmail.com>, Jalview-discuss@jalview.org

Hey Jim,

Thanks for your reply.

I have one main alignment, on this alignment i apply some sequence filter after which some sequences and some columns form the alignment are deleted. In my viewer i want to show the main full alignmnet with deleted sequences and columns highlighted/selected/coloured, so that user can see what changes have been made and then decide the next step.

for the alignment view, this is what i have done:

SequenceI[] seqs = new SequenceI[ado.getAlignment().size()]; // ado=alignmnet data object
for (int i = 0; i < seqs.length; i++) {
seqs[i] = new Sequence(ado.getAlignment().get(i).getHeader(), ado.getAlignment().get(i).getOriginalSequence());
// String name , and sequence
}
Alignment alignment = new Alignment(seqs);

AlignFrame af = new AlignFrame(alignment, null, null, false);
af.setVisible(false);
af.setEnabled(false);

AlignViewport avw = new AlignViewport(alignment, null);
avw.setGlobalColourScheme(new ZappoColourScheme());

AlignmentPanel apl = new AlignmentPanel(af, avw);
apl.setAnnotationVisible(false);

this.jScrollPane1.setViewportView(apl);

and so i get the jalview alignmnet viewer in my jScrollPane.

i am able to show the deleted sequences as coloured sequence in the full alignment by:

SequenceI[] alteredSeqs = new SequenceI[altseq.size()]; // altseq is an ArrayList of sequences left the filter.
for (int i = 0; i < alteredSeqs.length; i++) {
alteredSeqs[i] = new Sequence(name.get(i), altseq.get(i));
}
Alignment alteredAlignment = new Alignment(alteredSeqs);

AlignFrame af = new AlignFrame(alignment, null, null, false);
af.setVisible(false);
af.setEnabled(false);

AlignViewport avw = new AlignViewport(alignment, null);
for (int i = 0; i < seqs.length; i++) { // seq is full alignment.
SequenceI s = alteredAlignment.findName(seqs[i].getName());
if (s == null) {
avw.setSequenceColour(alignment.getSequenceAt(alignment.findIndex(seqs[i])), Color.red);
}
}

AlignmentPanel apl = new AlignmentPanel(af, avw);
apl.setAnnotationVisible(false);
this.jScrollPane1.setViewportView(apl);

My alignment filter class, gves me an option to store a conserved string. This string has “x” at the conserved positions,i.e, the positions which are retained in the alignment after the filter and “-” for position which have been deleted. So form this string i make a column selection as below:

ArrayList conPos2origPos = new ArrayList();
for (int i = 0; i < constr.length(); i++) { // constr is the conserved string
if (constr.charAt(i) == ‘-’) {
conPos2origPos.add(i);
}
}
ColumnSelection col = new ColumnSelection();
for (int j = 0; j < conPos2origPos.size(); j++) {
col.addElement(conPos2origPos.get(j));
}

Now i am unable to highlight/colour these columns in the full alignment.
Hope the explanation is fine.
Suggestions/help is welcome.

Regards,
Nicee.

On Thu, Jul 12, 2012 at 5:56 PM, Jim Procter <foreveremain@gmail.com> wrote:

Not sure where you have got the column selection from without seeing how you have integrated jalview… since there isn’t a clear api for doing this yet. Can you send me a code sample so i can help you out?

Jim.

Ps. I realize this is unreleased code. But one of the great things about open source is you get help for free if you develop your code in the open too :slight_smile:

On Jul 11, 2012 3:37 PM, “Nicee Srivastava” <nsrivast@unil.ch> wrote:

Hello everyone,

Is there a way to programmaticaly colour the selected column in jalview? I have a ColumnSelection and want to show it in a different colour.
Any suggestion/help would be great.
Thanks.

Regards,
Nicee.


Jalview-discuss mailing list
Jalview-discuss@jalview.org
http://www.compbio.dundee.ac.uk/mailman/listinfo/jalview-discuss


Regards,
Nicee Srivastava
Phd Student,
Group of Prof. Dr. Dirk Fasshauer,
Faculty of Biology and Medicine,
Department of Biology and Cellular Morphology,
Quartier UNIL-CHUV,
Rue du Bugnon 9,
CH-1005 Lausanne .

sorry for not answering your quetion 'in turn' - I was travelling at the time, didn't have time to properly think about your code.

Generally, to colour parts of the alignment, you'd create a sequence group (jalview.datamodel.SequenceGroup), which holds a set of references to SequenceI objects in the alignment, a start/end column range, and has its own colourscheme and other display attributes. Then, simply add the sequence group to the AlignmentI (there's a method for this). if you're doing this on a panel that's already displayed, then you can call repaint(true) to tell the AlignPanel that the view has changed.

If you want to colour whole columns of the alignment, rather than create a column selection, you could add a series of groups containing all sequences, and where the start/end are contiguous columns that you want to highlight. Set the cs field with a colourscheme to control colour of each group (you can create new colourschemes where every residue gets the same colour with jalview.schemes.ColourSchemeProperty.getColour(AlignmentI alignment,"<red/green/etc colour name>") (note - this is the method signature for version 2.8 - the v2.7 code method doesn't need the alignment reference, IIRC).

Jim.

···

On Wed Jul 18 02:16:12 2012, Nicee Srivastava wrote:

any suggestions as how to highlight/colour the columns.