[Biojava-l] Biojava-l Digest, Vol 100, Issue 4
Andreas Prlic
andreas at sdsc.edu
Thu May 12 03:09:35 UTC 2011
Hi Muhammad,
I am not sure how to convert a profile from the alignment module into a
sequence alignment that can be used in the phylo module. Perhaps Andy,
Scooter, or Mark have a suggestion on that? It would be good if there was a
convenience method for that.
Looking at your code it seems you are doing a profile.toString() when
creating the ProteinSequence. This seems wrong, since you would dump the
whole alignment representation into a single sequence object. I suspect a
better approach would be to get an aligned sequence from the profile and use
that instead, however I have never tried that myself...
Perhaps one of the over developers has a better suggestion here?
Andreas
On Tue, May 10, 2011 at 11:00 PM, Muhammad Tariq Pervez <
tariq_cp at hotmail.com> wrote:
>
>
>
> Dear Andreas, now I took code from BioJavaCookbook as it is and tried again
> to create the tree but in vain. Problem is not with
> http://biojava.org/wiki/BioJava:CookBook3:MSA and
> http://biojava.org/wiki/BioJava:CookBook:Core:FastaReadWrite. Files are
> read and MSA is performed successfully but problem is faced when the code to
> build the tree is reached.
>
> Problem is how to get MultipleSequenceAlignment object to be used in the
> phylo module from the Profile object used in the alignment module.
>
>
>
>
>
>
> Kindly help me.
>
> The following exception is thrown and code is given below of this
> exception.
>
> Best Regards.
>
>
> Exception in thread "AWT-EventQueue-0"
> org.biojava3.core.exceptions.CompoundNotFoundError: Compound not found
> for: Cannot find compound for:
>
> at
> org.biojava3.core.sequence.storage.ArrayListSequenceReader.setContents(ArrayListSequenceReader.java:196)
> at
> org.biojava3.core.sequence.template.AbstractSequence.<init>(AbstractSequence.java:88)
>
>
>
>
> at
> org.biojava3.core.sequence.ProteinSequence.<init>(ProteinSequence.java:52)
> at biojavademo.MSA.multipleSequenceAlignment(MSA.java:41)
> at biojavademo.MSAJFrame.jButton2ActionPerformed(MSAJFrame.java:160)
>
>
>
>
> at biojavademo.MSAJFrame.access$100(MSAJFrame.java:27)
> at biojavademo.MSAJFrame$2.actionPerformed(MSAJFrame.java:72)
> at
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
>
>
>
>
> at
> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
> at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
> at
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
>
>
>
>
> at
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
> at java.awt.Component.processMouseEvent(Component.java:6038)
> at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
>
>
>
>
> at java.awt.Component.processEvent(Component.java:5803)
> at java.awt.Container.processEvent(Container.java:2058)
> at java.awt.Component.dispatchEventImpl(Component.java:4410)
> at java.awt.Container.dispatchEventImpl(Container.java:2116)
>
>
>
>
> at java.awt.Component.dispatchEvent(Component.java:4240)
> at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
> at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
>
>
>
>
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
> at java.awt.Container.dispatchEventImpl(Container.java:2102)
> at java.awt.Window.dispatchEventImpl(Window.java:2429)
> at java.awt.Component.dispatchEvent(Component.java:4240)
>
>
>
>
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
> at
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
> at
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
>
>
>
>
> at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
>
>
>
>
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
>
>
> package biojavademo;
>
>
> import java.net.URL;
> import java.util.ArrayList;
> import java.util.List;
>
>
> import org.biojava3.alignment.template.Profile;
> import org.biojava3.alignment.Alignments;
> import org.biojava3.core.sequence.MultipleSequenceAlignment;
> import org.biojava3.core.sequence.ProteinSequence;
>
>
>
> import org.biojava3.core.sequence.compound.AminoAcidCompound;
> import org.biojava3.core.sequence.io.FastaReaderHelper;
> import org.biojava3.core.util.ConcurrencyTools;
> import org.biojava3.phylo.ProgessListenerStub;
>
>
>
> import org.biojava3.phylo.TreeConstructionAlgorithm;
> import org.biojava3.phylo.TreeConstructor;
> import org.biojava3.phylo.TreeType;
>
> public class MSA {
>
>
> MSA(){
> multipleSequenceAlignment = new MultipleSequenceAlignment
> <ProteinSequence, AminoAcidCompound>();
>
>
>
> }
> public void multipleSequenceAlignment() throws Exception {
> String[] ids = new String[] {"Q21691", "Q21495", "O48771"};
> try {
> multipleSequenceAlignment(ids);
>
>
>
> } catch (Exception e){
> e.printStackTrace();
> }
> }
>
> private void multipleSequenceAlignment(String[] ids) throws Exception {
> List<ProteinSequence> lst = new ArrayList<ProteinSequence>();
>
>
>
> for (String id : ids) {
> lst.add(getSequenceForId(id));
> }
> Profile<ProteinSequence, AminoAcidCompound> profile =
> Alignments.getMultipleSequenceAlignment(lst);
> System.out.printf("Clustalw:%n%s%n", profile);
>
>
>
>
> ProteinSequence seq=new ProteinSequence(profile.toString());
> multipleSequenceAlignment.addAlignedSequence(seq);
>
> TreeConstructor<ProteinSequence, AminoAcidCompound>
> treeConstructor = new TreeConstructor<ProteinSequence,
> AminoAcidCompound>(multipleSequenceAlignment, TreeType.NJ,
> TreeConstructionAlgorithm.PID, new ProgessListenerStub());
>
>
>
> treeConstructor.process();
> String newick = treeConstructor.getNewickString(true, true);
> ConcurrencyTools.shutdown();
> }
>
> private static ProteinSequence getSequenceForId(String uniProtId) throws
> Exception {
>
>
>
> URL uniprotFasta = new URL(String.format("
> http://www.uniprot.org/uniprot/%s.fasta", uniProtId));
> ProteinSequence seq =
> FastaReaderHelper.readFastaProteinSequence(uniprotFasta.openStream()).get(uniProtId);
>
>
>
> System.out.printf("id : %s %s%n%s%n", uniProtId, seq,
> seq.getOriginalHeader());
> return seq;
> }
>
> Muhammad Tariq Pervez
>
> Ph.D (Scholar) - Bioinformatics,
> University of Veterinary and Animal Science, Lahore, Pakistan
>
>
>
>
> > From: biojava-l-request at lists.open-bio.org
> > Subject: Biojava-l Digest, Vol 100, Issue 4
> > To: biojava-l at lists.open-bio.org
> > Date: Tue, 10 May 2011 12:00:04 -0400
> >
> > Send Biojava-l mailing list submissions to
> > biojava-l at lists.open-bio.org
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > http://lists.open-bio.org/mailman/listinfo/biojava-l
> > or, via email, send a message with subject or body 'help' to
> > biojava-l-request at lists.open-bio.org
> >
> > You can reach the person managing the list at
> > biojava-l-owner at lists.open-bio.org
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of Biojava-l digest..."
> >
> >
> > Today's Topics:
> >
> > 1. Re: An exception is being thrown while using the code related
> > to phylogeny from BioJava cookbook (Andreas Prlic)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Mon, 9 May 2011 17:13:01 -0700
> > From: Andreas Prlic <andreas at sdsc.edu>
> > Subject: Re: [Biojava-l] An exception is being thrown while using the
> > code related to phylogeny from BioJava cookbook
> > To: Muhammad Tariq Pervez <tariq_cp at hotmail.com>
> > Cc: biojava-l at lists.open-bio.org
> > Message-ID: <BANLkTi=_JXsoDOyBEtaPYPUsg_Gry+Vadw at mail.gmail.com>
> > Content-Type: text/plain; charset=ISO-8859-1
> >
> > Hi Muhammad,
> >
> > did you see the Cookbook pages?
> >
> > Best to start with a simple example like
> > http://biojava.org/wiki/BioJava:CookBook3:MSA
> >
> > I suspect there is something going wrong with your input file. Try to
> get
> > the file parsing right first. E.g.:
> > http://biojava.org/wiki/BioJava:CookBook:Core:FastaReadWrite
> >
> > Andreas
> >
> >
> > On Sun, May 8, 2011 at 10:20 PM, Muhammad Tariq Pervez <
> tariq_cp at hotmail.com
> > > wrote:
> >
> > > Dear concerns,
> > > I want to develop an application for phylogenetic analysis. To get
> started,
> > > I took some lines of code from BioJava cookbook, modified them as per
> my
> > > requirement and have been trying to get the results for a few days but
> in
> > > vain. The code is as follows.
> > >
> > >
> > > package biojavademo;
> > >
> > >
> > > import java.io.File;
> > > import java.util.ArrayList;
> > > import java.util.LinkedHashMap;
> > > import java.util.List;
> > > import java.util.Map.Entry;
> > >
> > > import org.biojava3.alignment.template.Profile;
> > > import org.biojava3.alignment.Alignments;
> > > import org.biojava3.alignment.template.AlignedSequence;
> > > import org.biojava3.core.sequence.MultipleSequenceAlignment;
> > > import org.biojava3.core.sequence.ProteinSequence;
> > > import org.biojava3.core.sequence.compound.AminoAcidCompound;
> > > import org.biojava3.core.sequence.io.FastaReaderHelper;
> > > import org.biojava3.core.sequence.template.Compound;
> > > import org.biojava3.core.sequence.template.Sequence;
> > > import org.biojava3.core.util.ConcurrencyTools;
> > > import org.biojava3.phylo.ProgessListenerStub;
> > > import org.biojava3.phylo.TreeConstructionAlgorithm;
> > > import org.biojava3.phylo.TreeConstructor;
> > > import org.biojava3.phylo.TreeType;
> > >
> > > public class MSA {
> > >
> > >
> > > MSA(){
> > > multipleSequenceAlignment = new MultipleSequenceAlignment
> > > <ProteinSequence, AminoAcidCompound>();
> > > }
> > > public void multipleSequenceAlignment(List<String> ids) throws
> > > Exception {
> > > List<ProteinSequence> lst = new ArrayList<ProteinSequence>();
> > >
> > > for (String id : ids) {
> > > lst.add(getSequenceForId(id));
> > >
> > > }
> > >
> > > profile = Alignments.getMultipleSequenceAlignment(lst);
> > > System.out.println("Compound == "+ profile.getCompoundSet());
> > > seq=new
> > > ProteinSequence(profile.toString(),profile.getCompoundSet());
> > > multipleSequenceAlignment.addAlignedSequence(seq);
> > > TreeConstructor<ProteinSequence, AminoAcidCompound>
> treeConstructor
> > > = new TreeConstructor<ProteinSequence,
> > > AminoAcidCompound>(multipleSequenceAlignment, TreeType.NJ,
> > > TreeConstructionAlgorithm.PID, new ProgessListenerStub());
> > > treeConstructor.process();
> > > String newick = treeConstructor.getNewickString(true, true);
> > > System.out.println("Clustalw:\n Multisequence Alignment\n"+
> > > profile.toString(Profile.StringFormat.CLUSTALW));
> > > System.out.println("Tree === "+ newick);
> > > ConcurrencyTools.shutdown();
> > > }
> > >
> > > private static ProteinSequence getSequenceForId(String fileName)
> > > throws Exception {
> > >
> > > LinkedHashMap<String, ProteinSequence> a =
> > > FastaReaderHelper.readFastaProteinSequence(new File(fileName));
> > >
> > > String seqStr;
> > > ProteinSequence seq=null;
> > > for ( Entry<String, ProteinSequence> entry : a.entrySet() ) {
> > > seqStr=entry.getValue().getSequenceAsString();
> > > seq=new
> ProteinSequence(seqStr);//entry.getValue();
> > >
> > > }
> > > return seq;
> > > }
> > > public Profile<ProteinSequence, AminoAcidCompound> getMSAProfile(){
> > > return profile;
> > > }
> > >
> > > Profile<ProteinSequence, AminoAcidCompound> profile;
> > > MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound>
> > > multipleSequenceAlignment;
> > > ProteinSequence seq=null;
> > > }
> > >
> > > When I run this code the following exception is thrown
> > >
> > > Exception in thread "AWT-EventQueue-0"
> > > org.biojava3.core.exceptions.CompoundNotFoundError: Compound not found
> for:
> > > Cannot find compound for:
> > > at
> > >
> org.biojava3.core.sequence.storage.ArrayListSequenceReader.setContents(ArrayListSequenceReader.java:196)
> > > at
> > >
> org.biojava3.core.sequence.template.AbstractSequence.<init>(AbstractSequence.java:88)
> > > at
> > >
> org.biojava3.core.sequence.ProteinSequence.<init>(ProteinSequence.java:52)
> > > at biojavademo.MSA.multipleSequenceAlignment(MSA.java:41)
> > > at
> > > biojavademo.MSAJFrame.jButton2ActionPerformed(MSAJFrame.java:160)
> > > at biojavademo.MSAJFrame.access$100(MSAJFrame.java:27)
> > > at biojavademo.MSAJFrame$2.actionPerformed(MSAJFrame.java:72)
> > > at
> > >
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
> > > at
> > >
> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
> > > at
> > >
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
> > > at
> > > javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
> > > at
> > >
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
> > > at java.awt.Component.processMouseEvent(Component.java:6038)
> > > at
> javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
> > > at java.awt.Component.processEvent(Component.java:5803)
> > > at java.awt.Container.processEvent(Container.java:2058)
> > > at java.awt.Component.dispatchEventImpl(Component.java:4410)
> > > at java.awt.Container.dispatchEventImpl(Container.java:2116)
> > > at java.awt.Component.dispatchEvent(Component.java:4240)
> > > at
> > > java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
> > > at
> > > java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
> > > at
> > > java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
> > > at java.awt.Container.dispatchEventImpl(Container.java:2102)
> > > at java.awt.Window.dispatchEventImpl(Window.java:2429)
> > > at java.awt.Component.dispatchEvent(Component.java:4240)
> > > at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
> > > at
> > >
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
> > > at
> > >
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
> > > at
> > >
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
> > > at
> > > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
> > > at
> > > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
> > > at
> java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
> > >
> > > Actually I don't know how to construct the multiple sequence alignment
> > > object which is given as a parameter while constructing the
> > > 'TreeConstructor' object.
> > >
> > > Kindly guide/help me to resolve this issue.
> > >
> > >
> > > Muhammad Tariq Pervez
> > > Ph.D (Scholar) - Bioinformatics,
> > > University of Veterinary and Animal Science, Lahore, Pakistan
> > >
> > >
> > >
> > >
> > >
> >
> >
> > ------------------------------
> >
> > _______________________________________________
> > Biojava-l mailing list - Biojava-l at lists.open-bio.org
> > http://lists.open-bio.org/mailman/listinfo/biojava-l
> >
> >
> > End of Biojava-l Digest, Vol 100, Issue 4
> > *****************************************
>
> _______________________________________________
> Biojava-l mailing list - Biojava-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-l
>
More information about the Biojava-l
mailing list