Question: Reading FASTA with BioJava 4.0.0
gravatar for priess1991
3.9 years ago by
priess19910 wrote:


I searched for possible solutions but did not find anything helpful. I'm trying to use the Gen Ontology sequence database in order to test an algorithm my professor gave to me on this huge set of data. I thought the easiest way would be to read out the FASTA-file via BioJava. 

It is the first time for me to work with BioJava. I downloaded BioJava 4.0.0 via Manual Download an imported the external jars into my Eclipse project.

I simply tried to read the FASTA-file for now:

package controle;

import java.util.LinkedHashMap;
import java.util.Map.Entry;

import org.biojava.nbio.core.sequence.ProteinSequence;
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound;
import org.biojava.nbio.core.sequence.compound.AminoAcidCompoundSet;

public class ReadFasta {

    public static void readFasta() throws IOException {
        //Try with the FastaReaderHelper
        LinkedHashMap<String, ProteinSequence> a;
        try {
            File file = new File("C:\\Users\\Patrick\\workspace\\Bachelor\\src\\go_20150425-seqdb.fasta");
            a = FastaReaderHelper.readFastaProteinSequence(file);
            for (  Entry<String, ProteinSequence> entry : a.entrySet() ) {
                System.out.println( entry.getValue().getOriginalHeader() + "=" + entry.getValue().getSequenceAsString() );
        } catch (IOException e) {
            // TODO Auto-generated catch block


When I try to call my method readFasta() in main i get the following error code:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at controle.ReadFasta.readFasta(
    at controle.Main.main(
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 5 more


Im not totally sure if I have "installed" BioJava correctly or why this Problem occurs. Like I said I'm new to this and it would be nice if someone knows an solution or an easier way to deal with FASTA-files.



rna-seq software error • 2.1k views
ADD COMMENTlink modified 3.9 years ago by Jose Manuel Duarte290 • written 3.9 years ago by priess19910

Tagging the BioJava expert Pierre Lindenbaum

ADD REPLYlink written 3.9 years ago by RamRS21k
gravatar for Pierre Lindenbaum
3.9 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum119k wrote:

you need to add log4j  in the claspath :

ADD COMMENTlink written 3.9 years ago by Pierre Lindenbaum119k
gravatar for Jose Manuel Duarte
3.9 years ago by
Jose Manuel Duarte290 wrote:

As Pierre says it is an issue with a missing dependency in your class path (log4j 2). You can get the jar manually and then point your eclipse project to it. However it is a lot easier and much more powerful to use maven to deal with the dependencies automatically. 

BioJava is all set up already to use maven. In eclipse you simply need the m2e (maven 2 eclipse) plugin. Once you have it, then maven should start working and do the dependencies automatically for you.

ADD COMMENTlink written 3.9 years ago by Jose Manuel Duarte290
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1513 users visited in the last hour