diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java index 70462a9c0b..7d7eab9d43 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java @@ -222,7 +222,8 @@ private void parseFeatureTag(List section) { Qualifier q = new Qualifier(key, val.replace('\n', ' ')); gbFeature.addQualifier(key, q); } else { - if (key.equalsIgnoreCase("translation")) { + if (key.equalsIgnoreCase("translation") || key.equals("anticodon") + || key.equals("transl_except")) { // strip spaces from sequence val = val.replaceAll("\\s+", ""); Qualifier q = new Qualifier(key, val); diff --git a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankReaderTest.java b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankReaderTest.java index f38070c710..325e07a5ef 100644 --- a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankReaderTest.java +++ b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/io/GenbankReaderTest.java @@ -36,10 +36,7 @@ import org.slf4j.LoggerFactory; import java.io.*; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.*; @@ -333,6 +330,35 @@ public void readSequenceWithZeroSpanFeature() throws IOException, CompoundNotFou assertEquals(Strand.NEGATIVE, fLocation.getStrand()); } + /** + * Biojava fails to parse anticodon and transl_except feature qualifiers when they line wrap. + * https://github.com/biojava/biojava/issues/843 + */ + @Test + public void testGithub843() throws Exception { + CheckableInputStream inStream = new CheckableInputStream(this.getClass().getResourceAsStream("/NC_018080.gb")); + assertNotNull(inStream); + + GenbankReader genbankDNA + = new GenbankReader<>( + inStream, + new GenericGenbankHeaderParser<>(), + new DNASequenceCreator(DNACompoundSet.getDNACompoundSet()) + ); + + LinkedHashMap dnaSequences = genbankDNA.process(); + assertNotNull(dnaSequences); + + DNASequence dna = new ArrayList<>(dnaSequences.values()).get(0); + assertNotNull(dna); + + FeatureInterface, NucleotideCompound> tRNAFeature = dna.getFeaturesByType("tRNA").get(0); + String anticodon = tRNAFeature.getQualifiers().get("anticodon").get(0).getValue(); + assertEquals("(pos:complement(1123552..1123554),aa:Leu,seq:caa)", anticodon); + String transl_except = tRNAFeature.getQualifiers().get("transl_except").get(0).getValue(); + assertEquals("(pos:complement(1123552..1123554),aa:Leu)",transl_except); + } + /** * Helper class to be able to verify the closed state of the input stream. */ diff --git a/biojava-core/src/test/resources/NC_018080.gb b/biojava-core/src/test/resources/NC_018080.gb new file mode 100644 index 0000000000..11d2d295ff --- /dev/null +++ b/biojava-core/src/test/resources/NC_018080.gb @@ -0,0 +1,28 @@ +LOCUS NC_018080 6402658 bp DNA circular CON 27-OCT-2020 +DEFINITION Pseudomonas aeruginosa DK2 +ACCESSION +VERSION .0 +KEYWORDS . +FEATURES Location/Qualifiers + source 1..6402658 + /organism="Pseudomonas aeruginosa DK2" + /mol_type="genomic DNA" + /strain="DK2" + /db_xref="taxon:1093787" + gene complement(1123502..1123588) + /locus_tag="PADK2_RS05265" + /old_locus_tag="PADK2_t29613" + tRNA complement(1123502..1123588) + /locus_tag="PADK2_RS05265" + /old_locus_tag="PADK2_t29613" + /product="tRNA-Leu" + /inference="COORDINATES: profile:tRNAscan-SE:2.0.6" + /note="Derived by automated computational analysis using + gene prediction method: tRNAscan-SE." + /anticodon=(pos:complement(1123552..1123554),aa:Leu, + seq:caa) + /transl_except=(pos:complement(1123552..1123554), + aa:Leu) +ORIGIN + 1 tttaaagaga ccggcgattc tagtgaaatc gaacgggcag gtcaatttcc aaccagcgat +// \ No newline at end of file