[Biojava-l] NullPointerException Exception While Creating DNA MultipleSequenceAlignment

Muhammad Tariq Pervez tariq_cp at hotmail.com
Mon Jul 25 10:27:02 UTC 2011


Following is tmpLst filled with two DNA sequences. Scorers object is displayed from inside the object of Alignments (getMultipleSequenceAlignment method).  All==1 is displayed from inside the method of public static <S extends Sequence<C>, C extends Compound> int[] runPairwiseScorers(
            List<PairwiseSequenceScorer<S, C>> scorers) { (class is Alignments)  as follows

all = scorers.size();

But the line System.out.println("futures==="+futures.get(0).get()); causes NullPointer Exception. 

List<Future<Integer>> futures = new ArrayList<Future<Integer>>();
        for (PairwiseSequenceScorer<S, C> scorer : scorers) {
            futures.add(ConcurrencyTools.submit(new CallablePairwiseSequenceScorer<S, C>(scorer),
                    String.format("Scoring pair %d of %d", n++, all)));
        }
        try{ // perhaps this code is not working fine.
        System.out.println("futures==="+futures.get(0).get());

tmpLst==[GAATCTATAGGGCGATTGGGCCTCTAGATGCATGCTCGAGCGGCCGCCAGTGTGATGGATATCTGCAGAATTCAGGTAGTCGACTCAGATTCTTGTAGTGGCTCTCATCTGATCAAGGGTATTATTCCCAAGCCATAGTAAGGTCTTCTGTTGTGCCTTTTGCTTATACATCAGGTAACATGATAGAACTAGGCTAAGTG, ATGGGCTCCAAACCTTCTACCAGGATCCCAGCACCTCTAATGCTGATCACTCGGACTATGCTGATATTGAGCTGTATCCGTCTGACAAGCTCTCTTGACGGCAGGCCCCTTGCAGCTGCAGGAATTGTAGTAACAGGAGATAAGGCAGTCAATGTATACACCTCGTCTCAGACAGGGTCAATCATAGTCAAGTTGCTCCCGAATATGCCCAGAGATAAGGAGGCATGTGCAAAAGCCCCATTGGAGGCATATAACAGAACACTGACTACTCTGCTCACTC]
sequences=== [GAATCTATAGGGCGATTGGGCCTCTAGATGCATGCTCGAGCGGCCGCCAGTGTGATGGATATCTGCAGAATTCAGGTAGTCGACTCAGATTCTTGTAGTGGCTCTCATCTGATCAAGGGTATTATTCCCAAGCCATAGTAAGGTCTTCTGTTGTGCCTTTTGCTTATACATCAGGTAACATGATAGAACTAGGCTAAGTG, ATGGGCTCCAAACCTTCTACCAGGATCCCAGCACCTCTAATGCTGATCACTCGGACTATGCTGATATTGAGCTGTATCCGTCTGACAAGCTCTCTTGACGGCAGGCCCCTTGCAGCTGCAGGAATTGTAGTAACAGGAGATAAGGCAGTCAATGTATACACCTCGTCTCAGACAGGGTCAATCATAGTCAAGTTGCTCCCGAATATGCCCAGAGATAAGGAGGCATGTGCAAAAGCCCCATTGGAGGCATATAACAGAACACTGACTACTCTGCTCACTC]
scorers=== [org.biojava3.alignment.FractionalIdentityScorer at d337d3]
all===1
scorers===org.biojava3.alignment.FractionalIdentityScorer at d337d3
java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
    at java.util.concurrent.FutureTask.get(FutureTask.java:83)
    at pakjalphiew.Alignments.getListFromFutures(Alignments.java:304)
    at pakjalphiew.Alignments.runPairwiseScorers(Alignments.java:631)
    at pakjalphiew.Alignments.getMultipleSequenceAlignment(Alignments.java:194)
    at pakjalphiew.MSA.msaDNAFromFiles(MSA.java:109)
    at pakjalphiew.MSACalculation.calculateDNAMSAFromFiles(MSACalculation.java:42)
    at pakjalphiew.MSAInterFrame.<init>(MSAInterFrame.java:60)
    at pakjalphiew.LaunchingFrame.newDNAFromFileActionPerformed(LaunchingFrame.java:265)
    at pakjalphiew.LaunchingFrame.access$000(LaunchingFrame.java:26)
    at pakjalphiew.LaunchingFrame$1.actionPerformed(LaunchingFrame.java:83)
    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.AbstractButton.doClick(AbstractButton.java:357)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850)
    at java.awt.Component.processMouseEvent(Component.java:6288)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6053)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4651)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4481)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478)
    at java.awt.Component.dispatchEvent(Component.java:4481)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
    at java.awt.EventQueue.access$000(EventQueue.java:84)
    at java.awt.EventQueue$1.run(EventQueue.java:602)
    at java.awt.EventQueue$1.run(EventQueue.java:600)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
    at java.awt.EventQueue$2.run(EventQueue.java:616)
    at java.awt.EventQueue$2.run(EventQueue.java:614)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.NullPointerException
    at org.biojava3.alignment.FractionalIdentityScorer.align(FractionalIdentityScorer.java:112)
    at org.biojava3.alignment.FractionalIdentityScorer.getScore(FractionalIdentityScorer.java:105)
    at org.biojava3.alignment.template.CallablePairwiseSequenceScorer.call(CallablePairwiseSequenceScorer.java:53)
    at org.biojava3.alignment.template.CallablePairwiseSequenceScorer.call(CallablePairwiseSequenceScorer.java:38)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at pakjalphiew.AlignmentRuler.getRuler(AlignmentRuler.java:34)
    at pakjalphiew.AlignmentRuler.<init>(AlignmentRuler.java:26)
    at pakjalphiew.MSAInterFrame.initComponents(MSAInterFrame.java:81)
    at pakjalphiew.MSAInterFrame.<init>(MSAInterFrame.java:62)
    at pakjalphiew.LaunchingFrame.newDNAFromFileActionPerformed(LaunchingFrame.java:265)
    at pakjalphiew.LaunchingFrame.access$000(LaunchingFrame.java:26)
    at pakjalphiew.LaunchingFrame$1.actionPerformed(LaunchingFrame.java:83)
    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.AbstractButton.doClick(AbstractButton.java:357)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850)
    at java.awt.Component.processMouseEvent(Component.java:6288)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6053)
    at java.awt.Container.processEvent(Container.java:2041)
    at java.awt.Component.dispatchEventImpl(Component.java:4651)
    at java.awt.Container.dispatchEventImpl(Container.java:2099)
    at java.awt.Component.dispatchEvent(Component.java:4481)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
    at java.awt.Container.dispatchEventImpl(Container.java:2085)
    at java.awt.Window.dispatchEventImpl(Window.java:2478)
    at java.awt.Component.dispatchEvent(Component.java:4481)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
    at java.awt.EventQueue.access$000(EventQueue.java:84)
    at java.awt.EventQueue$1.run(EventQueue.java:602)
    at java.awt.EventQueue$1.run(EventQueue.java:600)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
    at java.awt.EventQueue$2.run(EventQueue.java:616)
    at java.awt.EventQueue$2.run(EventQueue.java:614)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Muhammad Tariq Pervez

Assistant Professor,
Department of Computer Science
Virtual University of Pakistan, Lahore
Tel: (042) 9203114-7  
URL: www.vu.edu.pk
Mobile: +923364120541, +923214602694


> From: HWillis at scripps.edu
> To: tariq_cp at hotmail.com; biojava-l at lists.open-bio.org
> Date: Fri, 22 Jul 2011 08:11:34 -0400
> Subject: Re: [Biojava-l] NullPointerException Exception While Creating DNA MultipleSequenceAlignment
> 
> Can you include the output of the stack trace as well as a small working
> example that causes the exception?
> 
> On 7/22/11 7:56 AM, "Muhammad Tariq Pervez" <tariq_cp at hotmail.com> wrote:
> 
> >
> >
> >
> >Dear all,
> >
> >I faced the NullPointerException exception while creating the DNA
> >MultipleSequenceAlignment. The same goes right with protein sequence.
> >Exception is thrown at the following line
> >
> >dnaProfile = Alignments.getMultipleSequenceAlignment(tmpLst);
> >
> >tmpLst is list of DNA sequences created/declared as follows
> >List<DNASequence> tmpLst=new ArrayList<DNASequence>();
> >
> >Note: the tmpLst is filled/populated with two or more two sequences.
> >
> >I traced the exception by going into
> >Alignments.getMultipleSequenceAlignmen method of the Alignments class and
> >found the following line of code the cause of exception.
> >
> >static <E> List<E> getListFromFutures(List<Future<E>> futures) {
> >        List<E> list = new ArrayList<E>();
> >        for (Future<E> f : futures) {
> >            // TODO when added to ConcurrencyTools, log completions and
> >exceptions instead of printing stack traces
> >            try {
> >                
> >                list.add(f.get());**
> >            } catch (InterruptedException e) {
> >                e.printStackTrace();
> >            } catch (ExecutionException e) {
> >                e.printStackTrace();
> >            }
> >        }
> >        return list;
> >    }
> >** is the cause of exception. All is right with the protein sequences.
> >Can any body help/guide me regarding the problem.
> >
> >Best Regards.
> >
> >
> >
> >Tariq, PhD Scholar
> > 		 	   		  
> >_______________________________________________
> >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