pairwise identity table

Hi Andrew ! I've cc'ed the list for posterity...

I had a request from a user, they want to show/print a pairwise identity table for a multiple alignment. Is this possible with the latest Jalview? If not, should I create a feature request?

There's actually one in the issue database already, and I was all set to work on it for the last release, but got delayed by some other stuff (no surprise there :frowning: ). With any luck I'll add an export matrix option for 2.9...

Until then - the groovy script below will compute a PID similarity matrix for the alignment. Your user can open the groovy console and paste this in, then hit 'CTRL-R' to run it... by default it works on the first alignment (see Jalview.getAlignframes()[0] statement) - let me know if you want the tweaked version to work through all alignments...

it must be Friday - enjoy ! :smiley:
j.

// prints a sequence similarity matrix in PHYLIP format
boolean selview=false // use current selection or whole alignment
boolean includeids=true // false to report in strict PHYLIP where no OTUs are given

jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();

jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview);
if (!selview) {
   start = 0;
   end = av.getAlignment().getWidth();
   seqs = av.getAlignment().getSequencesArray();
} else {
   start = av.getSelectionGroup().getStartRes();
   end = av.getSelectionGroup().getEndRes() + 1;
   seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}

distance = new jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);

print distance.length+" "+distance.length+"\n"
p = 0;
for (v in distance) { if (includeids) { print seqs[p++].getDisplayId(false)+" "; }
for (r in v) { print r+" "; }; print "\n"; }

//

···

On 06/02/2015 12:48, Andrew Mark Waterhouse wrote:

--
-------------------------------------------------------------------
Dr JB Procter, Jalview Coordinator, The Barton Group
Division of Computational Biology, College of Life Sciences
University of Dundee, Dundee DD1 5EH, UK.
+44 1382 388734 | www.jalview.org | www.compbio.dundee.ac.uk
The University of Dundee is registered Scottish charity: No.SC015096

Thanks a lot Jim, that should do the trick.

···

-----Original Message-----
From: Jim Procter [mailto:foreveremain@gmail.com] On Behalf Of Jim Procter
Sent: 06 February 2015 18:11
To: Andrew Mark Waterhouse
Cc: Jalview-discuss@jalview.org
Subject: Re: pairwise identity table

Hi Andrew ! I've cc'ed the list for posterity...

On 06/02/2015 12:48, Andrew Mark Waterhouse wrote:

I had a request from a user, they want to show/print a pairwise identity table for a multiple alignment. Is this possible with the latest Jalview? If not, should I create a feature request?

There's actually one in the issue database already, and I was all set to work on it for the last release, but got delayed by some other stuff (no surprise there :frowning: ). With any luck I'll add an export matrix option for 2.9...

Until then - the groovy script below will compute a PID similarity matrix for the alignment. Your user can open the groovy console and paste this in, then hit 'CTRL-R' to run it... by default it works on the first alignment (see Jalview.getAlignframes()[0] statement) - let me know if you want the tweaked version to work through all alignments...

it must be Friday - enjoy ! :smiley:
j.

// prints a sequence similarity matrix in PHYLIP format boolean selview=false // use current selection or whole alignment boolean includeids=true // false to report in strict PHYLIP where no OTUs are given

jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();

jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview); if (!selview) {
   start = 0;
   end = av.getAlignment().getWidth();
   seqs = av.getAlignment().getSequencesArray();
} else {
   start = av.getSelectionGroup().getStartRes();
   end = av.getSelectionGroup().getEndRes() + 1;
   seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}

distance = new
jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);

print distance.length+" "+distance.length+"\n"
p = 0;
for (v in distance) { if (includeids) { print seqs[p++].getDisplayId(false)+" "; } for (r in v) { print r+" "; }; print "\n"; }

//

--
-------------------------------------------------------------------
Dr JB Procter, Jalview Coordinator, The Barton Group Division of Computational Biology, College of Life Sciences University of Dundee, Dundee DD1 5EH, UK.
+44 1382 388734 | www.jalview.org | www.compbio.dundee.ac.uk
The University of Dundee is registered Scottish charity: No.SC015096

Hi Jim,

Sorry to report the script threw an exception:

// prints a sequence similarity matrix in PHYLIP format
boolean selview=false // use current selection or whole alignment
boolean includeids=true // false to report in strict PHYLIP where no
OTUs are given
jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();
jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview);
if (!selview) {
   start = 0;
   end = av.getAlignment().getWidth();
   seqs = av.getAlignment().getSequencesArray();
} else {
   start = av.getSelectionGroup().getStartRes();
   end = av.getSelectionGroup().getEndRes() + 1;
   seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
distance = new
jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);
print distance.length+" "+distance.length+"\n"
p = 0;
for (v in distance) { if (includeids) { print
seqs[p++].getDisplayId(false)+" "; }
for (r in v) { print r+" "; }; print "\n"; }
//

Exception thrown

groovy.lang.MissingPropertyException: No such property: are for class: matrix

     at matrix.run(matrix.groovy:4)

···

-----Original Message-----
From: Jim Procter [mailto:foreveremain@gmail.com] On Behalf Of Jim Procter
Sent: 06 February 2015 18:11
To: Andrew Mark Waterhouse
Cc: Jalview-discuss@jalview.org
Subject: Re: pairwise identity table

Hi Andrew ! I've cc'ed the list for posterity...

On 06/02/2015 12:48, Andrew Mark Waterhouse wrote:

I had a request from a user, they want to show/print a pairwise identity table for a multiple alignment. Is this possible with the latest Jalview? If not, should I create a feature request?

There's actually one in the issue database already, and I was all set to work on it for the last release, but got delayed by some other stuff (no surprise there :frowning: ). With any luck I'll add an export matrix option for 2.9...

Until then - the groovy script below will compute a PID similarity matrix for the alignment. Your user can open the groovy console and paste this in, then hit 'CTRL-R' to run it... by default it works on the first alignment (see Jalview.getAlignframes()[0] statement) - let me know if you want the tweaked version to work through all alignments...

it must be Friday - enjoy ! :smiley:
j.

// prints a sequence similarity matrix in PHYLIP format boolean selview=false // use current selection or whole alignment boolean includeids=true // false to report in strict PHYLIP where no OTUs are given

jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();

jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview); if (!selview) {
   start = 0;
   end = av.getAlignment().getWidth();
   seqs = av.getAlignment().getSequencesArray();
} else {
   start = av.getSelectionGroup().getStartRes();
   end = av.getSelectionGroup().getEndRes() + 1;
   seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}

distance = new
jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);

print distance.length+" "+distance.length+"\n"
p = 0;
for (v in distance) { if (includeids) { print seqs[p++].getDisplayId(false)+" "; } for (r in v) { print r+" "; }; print "\n"; }

//

--
-------------------------------------------------------------------
Dr JB Procter, Jalview Coordinator, The Barton Group Division of Computational Biology, College of Life Sciences University of Dundee, Dundee DD1 5EH, UK.
+44 1382 388734 | www.jalview.org | www.compbio.dundee.ac.uk
The University of Dundee is registered Scottish charity: No.SC015096

Hello Andrew,

That looks like a line wrapping thing. It should start:

// prints a sequence similarity matrix in PHYLIP format
boolean selview=false // use current selection or whole alignment
boolean includeids=true // false to report in strict PHYLIP where no OTUs are given

...etc...

I also found I had to insert a semi-colon before "for (r in v)" thus:

....; }; for (r in v)

then it ran ok for me.

Regards,

Mungo

Mungo Carstairs
Jalview Computational Scientist
The Barton Group
Division of Computational Biology
College of Life Sciences
University of Dundee, Dundee, Scotland, UK.
www.jalview.org
www.compbio.dundee.ac.uk

···

________________________________________
From: jalview-discuss-bounces@jalview.org <jalview-discuss-bounces@jalview.org> on behalf of Andrew Mark Waterhouse <andrew.waterhouse@unibas.ch>
Sent: 09 February 2015 10:19
To: Jim Procter
Cc: Jalview-discuss@jalview.org
Subject: Re: [Jalview-discuss] pairwise identity table

Hi Jim,

Sorry to report the script threw an exception:

// prints a sequence similarity matrix in PHYLIP format
boolean selview=false // use current selection or whole alignment
boolean includeids=true // false to report in strict PHYLIP where no
OTUs are given
jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();
jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview);
if (!selview) {
   start = 0;
   end = av.getAlignment().getWidth();
   seqs = av.getAlignment().getSequencesArray();
} else {
   start = av.getSelectionGroup().getStartRes();
   end = av.getSelectionGroup().getEndRes() + 1;
   seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
distance = new
jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);
print distance.length+" "+distance.length+"\n"
p = 0;
for (v in distance) { if (includeids) { print
seqs[p++].getDisplayId(false)+" "; }
for (r in v) { print r+" "; }; print "\n"; }
//

Exception thrown

groovy.lang.MissingPropertyException: No such property: are for class: matrix

     at matrix.run(matrix.groovy:4)

-----Original Message-----
From: Jim Procter [mailto:foreveremain@gmail.com] On Behalf Of Jim Procter
Sent: 06 February 2015 18:11
To: Andrew Mark Waterhouse
Cc: Jalview-discuss@jalview.org
Subject: Re: pairwise identity table

Hi Andrew ! I've cc'ed the list for posterity...

On 06/02/2015 12:48, Andrew Mark Waterhouse wrote:

I had a request from a user, they want to show/print a pairwise identity table for a multiple alignment. Is this possible with the latest Jalview? If not, should I create a feature request?

There's actually one in the issue database already, and I was all set to work on it for the last release, but got delayed by some other stuff (no surprise there :frowning: ). With any luck I'll add an export matrix option for 2.9...

Until then - the groovy script below will compute a PID similarity matrix for the alignment. Your user can open the groovy console and paste this in, then hit 'CTRL-R' to run it... by default it works on the first alignment (see Jalview.getAlignframes()[0] statement) - let me know if you want the tweaked version to work through all alignments...

it must be Friday - enjoy ! :smiley:
j.

// prints a sequence similarity matrix in PHYLIP format boolean selview=false // use current selection or whole alignment boolean includeids=true // false to report in strict PHYLIP where no OTUs are given

jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();

jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview); if (!selview) {
   start = 0;
   end = av.getAlignment().getWidth();
   seqs = av.getAlignment().getSequencesArray();
} else {
   start = av.getSelectionGroup().getStartRes();
   end = av.getSelectionGroup().getEndRes() + 1;
   seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}

distance = new
jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);

print distance.length+" "+distance.length+"\n"
p = 0;
for (v in distance) { if (includeids) { print seqs[p++].getDisplayId(false)+" "; } for (r in v) { print r+" "; }; print "\n"; }

//

--
-------------------------------------------------------------------
Dr JB Procter, Jalview Coordinator, The Barton Group Division of Computational Biology, College of Life Sciences University of Dundee, Dundee DD1 5EH, UK.
+44 1382 388734 | www.jalview.org | www.compbio.dundee.ac.uk
The University of Dundee is registered Scottish charity: No.SC015096

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

The University of Dundee is a registered Scottish Charity, No: SC015096

Hello Mungo,

Ok, that could explain it, theres a fair amount of copy/paste between different email clients taking place here, thanks for your reply, I'll pass on the information.

Andrew

···

-----Original Message-----
From: Mungo Carstairs (Staff) [mailto:g.m.carstairs@dundee.ac.uk]
Sent: 09 February 2015 11:30
To: Andrew Mark Waterhouse; Jim Procter
Cc: Jalview-discuss@jalview.org
Subject: Re: pairwise identity table

Hello Andrew,

That looks like a line wrapping thing. It should start:

// prints a sequence similarity matrix in PHYLIP format
boolean selview=false // use current selection or whole alignment
boolean includeids=true // false to report in strict PHYLIP where no OTUs are given

...etc...

I also found I had to insert a semi-colon before "for (r in v)" thus:

....; }; for (r in v)

then it ran ok for me.

Regards,

Mungo

Mungo Carstairs
Jalview Computational Scientist
The Barton Group
Division of Computational Biology
College of Life Sciences
University of Dundee, Dundee, Scotland, UK.
www.jalview.org
www.compbio.dundee.ac.uk

________________________________________
From: jalview-discuss-bounces@jalview.org <jalview-discuss-bounces@jalview.org> on behalf of Andrew Mark Waterhouse <andrew.waterhouse@unibas.ch>
Sent: 09 February 2015 10:19
To: Jim Procter
Cc: Jalview-discuss@jalview.org
Subject: Re: [Jalview-discuss] pairwise identity table

Hi Jim,

Sorry to report the script threw an exception:

// prints a sequence similarity matrix in PHYLIP format
boolean selview=false // use current selection or whole alignment
boolean includeids=true // false to report in strict PHYLIP where no
OTUs are given
jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();
jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview);
if (!selview) {
   start = 0;
   end = av.getAlignment().getWidth();
   seqs = av.getAlignment().getSequencesArray();
} else {
   start = av.getSelectionGroup().getStartRes();
   end = av.getSelectionGroup().getEndRes() + 1;
   seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
distance = new
jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);
print distance.length+" "+distance.length+"\n"
p = 0;
for (v in distance) { if (includeids) { print
seqs[p++].getDisplayId(false)+" "; }
for (r in v) { print r+" "; }; print "\n"; }
//

Exception thrown

groovy.lang.MissingPropertyException: No such property: are for class: matrix

     at matrix.run(matrix.groovy:4)

-----Original Message-----
From: Jim Procter [mailto:foreveremain@gmail.com] On Behalf Of Jim Procter
Sent: 06 February 2015 18:11
To: Andrew Mark Waterhouse
Cc: Jalview-discuss@jalview.org
Subject: Re: pairwise identity table

Hi Andrew ! I've cc'ed the list for posterity...

On 06/02/2015 12:48, Andrew Mark Waterhouse wrote:

I had a request from a user, they want to show/print a pairwise identity table for a multiple alignment. Is this possible with the latest Jalview? If not, should I create a feature request?

There's actually one in the issue database already, and I was all set to work on it for the last release, but got delayed by some other stuff (no surprise there :frowning: ). With any luck I'll add an export matrix option for 2.9...

Until then - the groovy script below will compute a PID similarity matrix for the alignment. Your user can open the groovy console and paste this in, then hit 'CTRL-R' to run it... by default it works on the first alignment (see Jalview.getAlignframes()[0] statement) - let me know if you want the tweaked version to work through all alignments...

it must be Friday - enjoy ! :smiley:
j.

// prints a sequence similarity matrix in PHYLIP format boolean selview=false // use current selection or whole alignment boolean includeids=true // false to report in strict PHYLIP where no OTUs are given

jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();

jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview); if (!selview) {
   start = 0;
   end = av.getAlignment().getWidth();
   seqs = av.getAlignment().getSequencesArray();
} else {
   start = av.getSelectionGroup().getStartRes();
   end = av.getSelectionGroup().getEndRes() + 1;
   seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}

distance = new
jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);

print distance.length+" "+distance.length+"\n"
p = 0;
for (v in distance) { if (includeids) { print seqs[p++].getDisplayId(false)+" "; } for (r in v) { print r+" "; }; print "\n"; }

//

--
-------------------------------------------------------------------
Dr JB Procter, Jalview Coordinator, The Barton Group Division of Computational Biology, College of Life Sciences University of Dundee, Dundee DD1 5EH, UK.
+44 1382 388734 | www.jalview.org | www.compbio.dundee.ac.uk
The University of Dundee is registered Scottish charity: No.SC015096

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

The University of Dundee is a registered Scottish Charity, No: SC015096

Thanks for catching that Mungo… That wasn’t the first time line wrapping has broken scripts. We should probably set up a Jalview groovy script repository and/or post gists to the list… Does that sound a good idea ?

Jim.

···

On 9 Feb 2015 10:33, “Andrew Mark Waterhouse” <andrew.waterhouse@unibas.ch> wrote:

Hello Mungo,

Ok, that could explain it, theres a fair amount of copy/paste between different email clients taking place here, thanks for your reply, I’ll pass on the information.

Andrew

-----Original Message-----
From: Mungo Carstairs (Staff) [mailto:g.m.carstairs@dundee.ac.uk]
Sent: 09 February 2015 11:30
To: Andrew Mark Waterhouse; Jim Procter
Cc: Jalview-discuss@jalview.org
Subject: Re: pairwise identity table

Hello Andrew,

That looks like a line wrapping thing. It should start:

// prints a sequence similarity matrix in PHYLIP format
boolean selview=false // use current selection or whole alignment
boolean includeids=true // false to report in strict PHYLIP where no OTUs are given

…etc…

I also found I had to insert a semi-colon before “for (r in v)” thus:

…; }; for (r in v)

then it ran ok for me.

Regards,

Mungo

Mungo Carstairs
Jalview Computational Scientist
The Barton Group
Division of Computational Biology
College of Life Sciences
University of Dundee, Dundee, Scotland, UK.
www.jalview.org
www.compbio.dundee.ac.uk


From: jalview-discuss-bounces@jalview.org <jalview-discuss-bounces@jalview.org> on behalf of Andrew Mark Waterhouse <andrew.waterhouse@unibas.ch>
Sent: 09 February 2015 10:19
To: Jim Procter
Cc: Jalview-discuss@jalview.org
Subject: Re: [Jalview-discuss] pairwise identity table

Hi Jim,

Sorry to report the script threw an exception:

// prints a sequence similarity matrix in PHYLIP format
boolean selview=false // use current selection or whole alignment
boolean includeids=true // false to report in strict PHYLIP where no
OTUs are given
jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();
jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview);
if (!selview) {
start = 0;
end = av.getAlignment().getWidth();
seqs = av.getAlignment().getSequencesArray();
} else {
start = av.getSelectionGroup().getStartRes();
end = av.getSelectionGroup().getEndRes() + 1;
seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}
distance = new
jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);
print distance.length+" “+distance.length+”\n"
p = 0;
for (v in distance) { if (includeids) { print
seqs[p++].getDisplayId(false)+" “; }
for (r in v) { print r+” "; }; print “\n”; }
//

Exception thrown

groovy.lang.MissingPropertyException: No such property: are for class: matrix

at matrix.run(matrix.groovy:4)

-----Original Message-----
From: Jim Procter [mailto:foreveremain@gmail.com] On Behalf Of Jim Procter
Sent: 06 February 2015 18:11
To: Andrew Mark Waterhouse
Cc: Jalview-discuss@jalview.org
Subject: Re: pairwise identity table

Hi Andrew ! I’ve cc’ed the list for posterity…

On 06/02/2015 12:48, Andrew Mark Waterhouse wrote:

I had a request from a user, they want to show/print a pairwise identity table for a multiple alignment. Is this possible with the latest Jalview? If not, should I create a feature request?
There’s actually one in the issue database already, and I was all set to work on it for the last release, but got delayed by some other stuff (no surprise there :frowning: ). With any luck I’ll add an export matrix option for 2.9…

Until then - the groovy script below will compute a PID similarity matrix for the alignment. Your user can open the groovy console and paste this in, then hit ‘CTRL-R’ to run it… by default it works on the first alignment (see Jalview.getAlignframes()[0] statement) - let me know if you want the tweaked version to work through all alignments…

it must be Friday - enjoy ! :smiley:
j.

// prints a sequence similarity matrix in PHYLIP format boolean selview=false // use current selection or whole alignment boolean includeids=true // false to report in strict PHYLIP where no OTUs are given

jalview.gui.AlignViewport av = Jalview.getAlignframes()[0].getViewport();

jalview.datamodel.AlignmentView seqStrings = av.getAlignmentView(selview); if (!selview) {
start = 0;
end = av.getAlignment().getWidth();
seqs = av.getAlignment().getSequencesArray();
} else {
start = av.getSelectionGroup().getStartRes();
end = av.getSelectionGroup().getEndRes() + 1;
seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
}

distance = new
jalview.analysis.scoremodels.PIDScoreModel().findDistances(seqStrings);

print distance.length+" “+distance.length+”\n"
p = 0;
for (v in distance) { if (includeids) { print seqs[p++].getDisplayId(false)+" “; } for (r in v) { print r+” "; }; print “\n”; }

//

Dr JB Procter, Jalview Coordinator, The Barton Group Division of Computational Biology, College of Life Sciences University of Dundee, Dundee DD1 5EH, UK.
+44 1382 388734 | www.jalview.org | www.compbio.dundee.ac.uk
The University of Dundee is registered Scottish charity: No.SC015096


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

The University of Dundee is a registered Scottish Charity, No: SC015096


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