[Biojava-l] NullPointerException when using Alignments.getMultipleSequenceAlignment

Hannes Brandstätter-Müller biojava at hannes.oib.com
Wed Oct 5 08:50:33 UTC 2011


Hi!

I read the sequence from a fasta file.

FileInputStream inStream = new FileInputStream(filename);
            FastaReader<DNASequence, NucleotideCompound> fastaReader =
                    new FastaReader<DNASequence, NucleotideCompound>(
                    inStream,
                    new GenericFastaHeaderParser<DNASequence,
NucleotideCompound>(),
                    new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()));
            LinkedHashMap<String, DNASequence> b = fastaReader.process();

and then use
List<DNASequence> sequences = new ArrayList<DNASequence>();
            for (Entry<String, DNASequence> entry : b.entrySet()) {
                sequences.add(entry.getValue());
}

to get the required list of DNA sequences.

I noticed in an earlier discussion, there was some talk about this too
(3-4 months ago, perhaps) and something about a possible fix in SVN.
when will it be released on the maven server?

Hannes

On Wed, Oct 5, 2011 at 10:46, Hashem Koohy <hk3 at sanger.ac.uk> wrote:
> Hi Hannes,
> It seems to me it doesn't like your  dna Sequence!
> Is your sequence in the following format?
>
> Sequence dnaSeq = DNATools.createDNASequence("acccgggttttacagt", "id");
>
> Good luck
> Hashem
>
> On 05/10/2011 08:41, "Hannes Brandstätter-Müller" <biojava at hannes.oib.com>
> wrote:
>
>> Hello!
>>
>> I tried to follow http://biojava.org/wiki/BioJava:CookBook3:MSA, but
>> when I run it, I get:
>>
>> 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 org.biojava3.alignment.Alignments.getListFromFutures(Alignments.java:282)
>> at org.biojava3.alignment.Alignments.runPairwiseScorers(Alignments.java:602)
>> at
>> org.biojava3.alignment.Alignments.getMultipleSequenceAlignment(Alignments.java
>> :173)
>>
>>  What could I be doing wrong?
>>
>> (
>> on the cookbook page, there is also an import missing:
>> import org.biojava3.alignment.Alignments;
>> )
>> -> then the cookbook runs, but my code does not
>>
>> private static void processFile(String filename) {
>>         try {
>>             FileInputStream inStream = new FileInputStream(filename);
>>             FastaReader<DNASequence, NucleotideCompound> fastaReader =
>>                     new FastaReader<DNASequence, NucleotideCompound>(
>>                     inStream,
>>                     new GenericFastaHeaderParser<DNASequence,
>> NucleotideCompound>(),
>>                     new
>> DNASequenceCreator(DNACompoundSet.getDNACompoundSet()));
>>             LinkedHashMap<String, DNASequence> b = fastaReader.process();
>>
>>             List<DNASequence> sequences = new ArrayList<DNASequence>();
>>             for (Entry<String, DNASequence> entry : b.entrySet()) {
>>                 if (sequences.size() < 5) {
>>                     sequences.add(entry.getValue());
>>                 }
>>                 System.out.println(entry.getValue());
>>             }
>>
>>             Profile<DNASequence, NucleotideCompound> profile =
>> Alignments.getMultipleSequenceAlignment(sequences);
>>             System.out.printf("Clustalw:%n%s%n", profile);
>>
>>             ConcurrencyTools.shutdown();
>>         } catch (Exception ex) {
>>             Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
>>         }
>>     }
>> _______________________________________________
>> Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
>> http://lists.open-bio.org/mailman/listinfo/biojava-l
>
> -------------------------------
> Hashem Koohy
> PhD
> Postdoctoral Fellow,
> Sanger Institute,
> Cambridge
> Mobile: 07515425433
>
>
>
>
> --
>  The Wellcome Trust Sanger Institute is operated by Genome Research
>  Limited, a charity registered in England with number 1021457 and a
>  company registered in England with number 2742969, whose registered
>  office is 215 Euston Road, London, NW1 2BE.
>




More information about the Biojava-l mailing list