[Biojava-dev] Alignments.getPairwiseAlignment seems a bit choosy

Andreas Prlic andreas at sdsc.edu
Sun Feb 26 19:37:52 UTC 2012


Hi Hannes,

The issue is that the two input sequences are not using the same set
of compounds and then the alignment fails. If you put in both
sequences as DNACompounds it works for me.

The code in Alignments.java should probably check that the input is
correct and fail more gracefully... (illegal argument exception?)

Andreas

On Thu, Feb 23, 2012 at 12:49 PM, Hannes Brandstätter-Müller
<biojava at hannes.oib.com> wrote:
> As a direct consequence (?), the following code generates a
> NullPointerException:
>
>        DNASequence target = new DNASequence("ACTGACGTGTAGCTGACTGA",
> DNACompoundSet.getDNACompoundSet());
>        DNASequence query = new DNASequence("ACTGACGTGTAGCTGACTGA",
> AmbiguityDNACompoundSet.getDNACompoundSet());
>
>        List<DNASequence> lst = new ArrayList<DNASequence>();
>        lst.add(target);
>        lst.add(query);
>
>        Profile<DNASequence, NucleotideCompound> profile =
> Alignments.getMultipleSequenceAlignment(lst);
>
> ava.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 org.biojava3.alignment.Alignments.getListFromFutures(Alignments.java:288)
>        at org.biojava3.alignment.Alignments.runPairwiseScorers(Alignments.java:608)
>        at org.biojava3.alignment.Alignments.getMultipleSequenceAlignment(Alignments.java:179)
>        at org.biojava3.alignment.TestDNAAlignment.testDNAALignmentWithAmbiguity(TestDNAAlignment.java:87)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at junit.framework.TestCase.runTest(TestCase.java:168)
>        at junit.framework.TestCase.runBare(TestCase.java:134)
>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>        at junit.framework.TestResult.run(TestResult.java:113)
>        at junit.framework.TestCase.run(TestCase.java:124)
>        at junit.framework.TestSuite.runTest(TestSuite.java:232)
>        at junit.framework.TestSuite.run(TestSuite.java:227)
>        at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
>        at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
>        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)
>        at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)
>        at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
>        at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
> 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:680)
>
> * How should this be handled? Custom Exception? Simply Set the
> DNACompoundSet one to AmbiguityDNACompoundset? Could that cause
> problems?
>
> Hannes
>
> On Wed, Feb 22, 2012 at 15:38, Hannes Brandstätter-Müller
> <biojava at hannes.oib.com> wrote:
>> On Tue, Feb 21, 2012 at 19:58, Andreas Prlic <andreas at sdsc.edu> wrote:
>>> Hi Hannes,
>>>
>>>> I recently ran into a bit of an annoyance when using
>>>> Alignments.getPairwiseAlignment with DNASequences
>>>>
>>>> If the DNASequences do not have the same CompoundSet, the alignment
>>>> fails (but silently, which is the annoying part) - you just get 0 as
>>>> Similars or Identicals.
>>>
>>> what gap penalties are you using?
>>
>>      SubstitutionMatrix<NucleotideCompound> matrix =
>> SubstitutionMatrixHelper.getNuc4_4();
>>      SimpleGapPenalty gapP = new SimpleGapPenalty();
>>      gapP.setOpenPenalty((short) 5);
>>      gapP.setExtensionPenalty((short) 2);
>>      SequencePair<DNASequence, NucleotideCompound> psa =
>>              Alignments.getPairwiseAlignment(query, target,
>>              PairwiseSequenceAlignerType.LOCAL, gapP, matrix);
>>
>>>
>>> I don't have had enough time to look at the
>>>> code in detail, but there should be something done here, at least
>>>> check and throw an exception or something if it can't be made to work
>>>> regardless.
>>>
>>> Can you provide an example to reproduce this?
>>
>> use the above code, make:
>>
>> query = new DNASequence("ATCGTAGCTAGTCGTGC",
>> AmbiguityDNACompoundSet.getDNACompoundSet()));
>> target = new DNASequence("ATCGTAGCTAGTCGTGT",
>> DNACompoundSet.getDNACompoundSet()));
>>
>> This should (with 3.0.2) fail silently. I.e. psa.getSimilars() == 0
>>
>>
>> Hannes
>>
>> ps: sorry for the triplepost, Andreas, I'm still not used to the
>> mailinglist not defaulting to "reply-to-list" and managed to get the
>> sender wrong in the second try.
>
> _______________________________________________
> biojava-dev mailing list
> biojava-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-dev




More information about the biojava-dev mailing list