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

HI! 

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.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
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;
import org.biojava.nbio.core.sequence.io.FastaReader;
import org.biojava.nbio.core.sequence.io.FastaReaderHelper;
import org.biojava.nbio.core.sequence.io.GenericFastaHeaderParser;
import org.biojava.nbio.core.sequence.io.ProteinSequenceCreator;

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
            e.printStackTrace();
        }
    }
}

 

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 org.biojava.nbio.core.sequence.io.FastaReader.<clinit>(FastaReader.java:46)
    at org.biojava.nbio.core.sequence.io.FastaReaderHelper.readFastaProteinSequence(FastaReaderHelper.java:97)
    at org.biojava.nbio.core.sequence.io.FastaReaderHelper.readFastaProteinSequence(FastaReaderHelper.java:82)
    at controle.ReadFasta.readFasta(ReadFasta.java:32)
    at controle.Main.main(Main.java:13)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader.findClass(Unknown 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.

Greetings,

Patrick

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

Tagging the BioJava expert Pierre Lindenbaum

ADD REPLYlink written 4.3 years ago by RamRS24k
1
gravatar for Pierre Lindenbaum
4.3 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum122k wrote:

you need to add log4j http://logging.apache.org/log4j/2.x/download.html  in the claspath :  http://javarevisited.blogspot.fr/2012/10/5-ways-to-add-multiple-jar-to-classpath-java.html

ADD COMMENTlink written 4.3 years ago by Pierre Lindenbaum122k
0
gravatar for Jose Manuel Duarte
4.3 years ago by
Zurich
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 4.3 years ago by Jose Manuel Duarte290
Please log in to add an answer.

Help
Access

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