Collections:
Read FASTA File with FastaReaderTeat.java
How to read a FASTA fie with FastaReaderTeat.java?
✍: FYIcenter.com
If you compiled the example program, FastaReaderTeat.java, with Maven as shown in the previous tutorial, you can follow these steps to read a FASTA file.
1. Prepare a FASTA file, example.fasta.
fyicenter$ cd bio fyicenter$ vi example.fasta >seq0 FQTWEEFSRAAEKLYLADPMKVRVVLKYRHVDGNLCIKVTDDLVCLVYRTDQAQDVKKIEKF >seq1 KYRTWEEFTRAAEKLYQADPMKVRVVLKYRHCDGNLCIKVTDDVVCLLYRTDQAQDVKKIEKFHSQLMRLME LKVTDNKECLKFKTDQAQEAKKMEKLNNIFFTLM >seq2 EEYQTWEEFARAAEKLYLTDPMKVRVVLKYRHCDGNLCMKVTDDAVCLQYKTDQAQDVKKVEKLHGK >seq3 MYQVWEEFSRAVEKLYLTDPMKVRVVLKYRHCDGNLCIKVTDNSVCLQYKTDQAQDVK >seq4 EEFSRAVEKLYLTDPMKVRVVLKYRHCDGNLCIKVTDNSVVSYEMRLFGVQKDNFALEHSLL >seq5 SWEEFAKAAEVLYLEDPMKCRMCTKYRHVDHKLVVKLTDNHTVLKYVTDMAQDVKKIEKLTTLLMR >seq6 FTNWEEFAKAAERLHSANPEKCRFVTKYNHTKGELVLKLTDDVVCLQYSTNQLQDVKKLEKLSSTLLRSI >seq7 SWEEFVERSVQLFRGDPNATRYVMKYRHCEGKLVLKVTDDRECLKFKTDQAQDAKKMEKLNNIFF >seq8 SWDEFVDRSVQLFRADPESTRYVMKYRHCDGKLVLKVTDNKECLKFKTDQAQEAKKMEKLNNIFFTLM >seq9 KNWEDFEIAAENMYMANPQNCRYTMKYVHSKGHILLKMSDNVKCVQYRAENMPDLKK >seq10 FDSWDEFVSKSVELFRNHPDTTRYVVKYRHCEGKLVLKVTDNHECLKFKTDQAQDAKKMEK
2. Run FastaReaderTeat.java with BioJava Core JAR file.
fyicenter$ java -cp target/bio-1.0.jar:$Core_JAR com.fyicenter.FastaReaderTeat example.fasta Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.biojava.nbio.core.sequence.io.FastaReader.<clinit>(FastaReader.java:46) at com.fyicenter.FastaReaderTeat.main(FastaReaderTeat.java:30) Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
3. Add SLF4J JAR file into the class path and run it again.
fyicenter$ export SLF4J_JAR=/home/fyicenter/.m2/repository/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar fyicenter$ java -cp target/bio-1.0.jar:$Core_JAR:$SLF4J_JAR com.fyicenter.FastaReaderTeat example.fasta SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 1 : seq0 FQTWEEFSRAAEKLYLADPMKVRVVLKYRHVDGNLCIKVTDDLVCLVYRTDQAQDVKKIEKF 2 : seq2 EEYQTWEEFARAAEKLYLTDPMKVRVVLKYRHCDGNLCMKVTDDAVCLQYKTDQAQDVKKVEKLHGK 3 : seq3 MYQVWEEFSRAVEKLYLTDPMKVRVVLKYRHCDGNLCIKVTDNSVCLQYKTDQAQDVK 4 : seq4 EEFSRAVEKLYLTDPMKVRVVLKYRHCDGNLCIKVTDNSVVSYEMRLFGVQKDNFALEHSLL 5 : seq5 SWEEFAKAAEVLYLEDPMKCRMCTKYRHVDHKLVVKLTDNHTVLKYVTDMAQDVKKIEKLTTLLMR 6 : seq6 FTNWEEFAKAAERLHSANPEKCRFVTKYNHTKGELVLKLTDDVVCLQYSTNQLQDVKKLEKLSSTLLRSI 7 : seq7 SWEEFVERSVQLFRGDPNATRYVMKYRHCEGKLVLKVTDDRECLKFKTDQAQDAKKMEKLNNIFF 8 : seq8 SWDEFVDRSVQLFRADPESTRYVMKYRHCDGKLVLKVTDNKECLKFKTDQAQEAKKMEKLNNIFFTLM 9 : seq9 KNWEDFEIAAENMYMANPQNCRYTMKYVHSKGHILLKMSDNVKCVQYRAENMPDLKK 10 : seq10 FDSWDEFVSKSVELFRNHPDTTRYVVKYRHCEGKLVLKVTDNHECLKFKTDQAQDAKKMEK
As you can see, FastaReaderTeat.java is able to read a FASTA file. But "seq1" seqence is missing in the output, and the SLF4J implementation JAR is also missing. See next tutorial on how to build the class path properly with Maven.
⇒ "mvn dependency:build-classpath" - Generate Class Pass
⇐ Use BioJava with "Maven" Build Tool
2023-04-17, 409🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1002967 Names: InChIKey: DBKMYJIXKRGPTB-UHFFFAOYS A-NSMILES: O=c3c(N1CCCCC...
Molecule Summary: ID: FYI-1003256 Names: InChIKey: ZSYPGADQMCKYDM-LADVCJOIS A-NSMILES: CSc1ccccc1C[C...
Molecule Summary: ID: FYI-1000962 SMILES: CCCc1ccccc1NCC(C)c1ccc(N [SH](C)(=O)Nc2cccnc2C(N) =O)cn1Rec...
Molecule Summary: ID: FYI-1001099 SMILES: Received at FYIcenter.com on: 2021-12-26
Molecule Summary: ID: FYI-1001002 SMILES: C#CC#CC=[NH+]C1=CC=CC=C1 CC(O)NC(C(N)O)C(C)(C)CReceived at...