Reading FASTA with BioJava 4.0.0
2
0
Entering edit mode
7.0 years ago
priess1991 • 0

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.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.ProteinSequenceCreator;

public class ReadFasta {

public static void readFasta() throws IOException {

//Try with the FastaReaderHelper
try {
File file = new File("C:\\Users\\Patrick\\workspace\\Bachelor\\src\\go_20150425-seqdb.fasta");
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 controle.Main.main(Main.java:13)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
... 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.9k views
0
Entering edit mode

Tagging the BioJava expert Pierre Lindenbaum

0
Entering edit mode
7.0 years ago

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.