Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github issue 843 - Genebank parser #919

Merged
merged 5 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private void parseFeatureTag(List<String[]> 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")) {
// strip spaces from sequence
val = val.replaceAll("\\s+", "");
Qualifier q = new Qualifier(key, val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -333,6 +330,36 @@ 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
* File NC_018080.gb downloaded from https://www.ncbi.nlm.nih.gov/nuccore/NC_018080
*/
@Test
public void testGithub843() throws Exception {
CheckableInputStream inStream = new CheckableInputStream(this.getClass().getResourceAsStream("/NC_018080.gb"));
assertNotNull(inStream);

GenbankReader<DNASequence, NucleotideCompound> genbankDNA
= new GenbankReader<>(
inStream,
new GenericGenbankHeaderParser<>(),
new DNASequenceCreator(DNACompoundSet.getDNACompoundSet())
);

LinkedHashMap<String, DNASequence> dnaSequences = genbankDNA.process();
assertNotNull(dnaSequences);

DNASequence dna = new ArrayList<>(dnaSequences.values()).get(0);
assertNotNull(dna);

for (Iterator<FeatureInterface<AbstractSequence<NucleotideCompound>, NucleotideCompound>> it = dna.getFeaturesByType("tRNA").iterator(); it.hasNext();) {
FeatureInterface<AbstractSequence<NucleotideCompound>, NucleotideCompound> tRNAFeature = it.next();
String anticodon = tRNAFeature.getQualifiers().get("anticodon").get(0).getValue();
assertFalse(anticodon.contains(" "));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about also asserting that the string is exactly as expected? If I understand it right, it should be: (pos:complement(1123552..1123554),aa:Leu,seq:caa)

}
}

/**
* Helper class to be able to verify the closed state of the input stream.
*/
Expand Down
Loading