-
Notifications
You must be signed in to change notification settings - Fork 395
CONECT/LINK line-length bug fix for the PDB Parser (already in BioJava Master branch). #707
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
biojava-structure/src/test/java/org/biojava/nbio/structure/io/TestShortLines.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| package org.biojava.nbio.structure.io; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
|
|
||
| import org.biojava.nbio.structure.Atom; | ||
| import org.biojava.nbio.structure.Chain; | ||
| import org.biojava.nbio.structure.Group; | ||
| import org.biojava.nbio.structure.Structure; | ||
| import org.junit.Test; | ||
|
|
||
| /** | ||
| * This class will test parsing short CONECT lines. | ||
| * <p>(c) 2016 DNASTAR, Inc.</p> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this for biojava code |
||
| * @since Nov 30, 2016 | ||
| * @author larsonm | ||
| */ | ||
| public class TestShortLines { | ||
|
|
||
| @Test | ||
| public void testConect() throws IOException { | ||
| PDBFileParser pdbPars = new PDBFileParser(); | ||
| FileParsingParameters params = pdbPars.getFileParsingParameters(); | ||
| params.setCreateAtomBonds(true); | ||
|
|
||
| // CONECTS will be deprecated, but will we create bonds? | ||
| // Like the LINK records, should BioJava create BondImpl when params.setCreateAtomBonds(true)? | ||
|
|
||
| StringBuilder sb = new StringBuilder(); | ||
| sb.append("HETATM 2398 P FAD A 500 8.398 46.448 73.490 1.00 13.51 P \n"); | ||
| sb.append("HETATM 2399 PA FAD A 500 6.089 45.580 75.235 1.00 15.88 P \n"); | ||
| sb.append("HETATM 2400 O1P FAD A 500 7.908 47.684 72.869 1.00 4.19 O \n"); | ||
| sb.append("CONECT 2400 2398\n"); | ||
| String shortLine = sb.toString(); | ||
| Structure s; | ||
| // Parse short | ||
| try(InputStream is = new ByteArrayInputStream(shortLine.getBytes())) { | ||
| s = pdbPars.parsePDBFile(is); | ||
| } | ||
|
|
||
| // After 4.2, CONECTS are deprecated, but there is not yet an implementation | ||
| // describing how CONECTS will be replaced - will Bonds be created? | ||
| assertEquals(1, s.getConnections().size()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLINK() throws IOException { | ||
| Structure s; | ||
| PDBFileParser pdbPars = new PDBFileParser(); | ||
| FileParsingParameters params = pdbPars.getFileParsingParameters(); | ||
| params.setCreateAtomBonds(true); | ||
|
|
||
| StringBuilder sb = new StringBuilder(); | ||
| sb.append("ATOM 2412 C21 2EG A 7 0.888 44.973 72.238 1.00 29.17 C \n"); | ||
| sb.append("ATOM 2413 C22 2EG B 19 0.888 44.973 72.238 1.00 29.17 C \n"); | ||
| //sb.append("LINK C21 2EG A 7 C22 2EG B 19 1555 1555 1.56 "); | ||
| sb.append("LINK C21 2EG A 7 C22 2EG B 19\n"); | ||
| String shortLine = sb.toString(); | ||
|
|
||
| // Parse short | ||
| try(InputStream is = new ByteArrayInputStream(shortLine.getBytes())) { | ||
| s = pdbPars.parsePDBFile(is); | ||
| } | ||
|
|
||
| // Should be a bond present in the Atoms. | ||
| Chain c = s.getChain(0, 0); | ||
| Group g = c.getAtomGroups().get(0); | ||
| Atom a = g.getAtom(0); | ||
| assertEquals(1, a.getBonds().size()); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be warn level