Skip to content

Commit

Permalink
fix bug where some discontinued chains were not fully loaded as prote…
Browse files Browse the repository at this point in the history
…in (e.g. in 1O6U)
  • Loading branch information
rdk committed Apr 10, 2024
1 parent 881c35f commit 2035ca9
Show file tree
Hide file tree
Showing 7 changed files with 25,031 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'groovy'
apply plugin: 'java'

group = 'cz.siret'
version = '2.5.0-dev.4.1'
version = '2.5.0-dev.4.2'


description = 'Ligand binding site prediction based on machine learning.'
Expand Down
13 changes: 12 additions & 1 deletion src/main/groovy/cz/siret/prank/geom/Struct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ class Struct {
group?.getAtom("OXT") != null
}

private static int getLastTerminalResidue(List<Group> chainGroups) {
for (int i=chainGroups.size()-1; i<=0; i--) {
if (isTerminalResidue(chainGroups[i])) {
return i
}
}
return -1
}

static List<Group> getResidueGroupsFromChain(Chain chain) {

List<Group> chainGroups = chain.getAtomGroups()
Expand All @@ -224,11 +233,13 @@ class Struct {

log.info "groups in chain {}: {}", getAuthorId(chain), n

int lastTerminalResidueIdx = getLastTerminalResidue(chainGroups)

for (int i=0; i!=n; i++) {
if (isAminoAcidResidueHeuristic(i, chainGroups)) {
Group g = chainGroups[i]
res.add g
if (isTerminalResidue(g)) {
if (i == lastTerminalResidueIdx) {
break // this is done so amino acid ligands at the end are excluded
}
}
Expand Down
67 changes: 67 additions & 0 deletions src/test/groovy/cz/siret/prank/DiscontinuedChainsTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package cz.siret.prank

import cz.siret.prank.domain.Protein
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.junit.jupiter.api.Test

import static org.junit.jupiter.api.Assertions.assertEquals

/**
*
*/
@Slf4j
@CompileStatic
class DiscontinuedChainsTest {

String PDB_1O6U = 'src/test/resources/data/tricky_cases/1o6u.pdb'
String CIF_1O6U = 'src/test/resources/data/tricky_cases/1o6u.cif'

@Test
void discontinuedChainsLoading_1O6U_pdb() throws Exception {
Protein prot = Protein.load(PDB_1O6U)

def chainA = prot.getResidueChain('A')
def chainC = prot.getResidueChain('C')


log.info "All Atoms: {}", prot.allAtoms.count
log.info "Protein Atoms: {}", prot.proteinAtoms.count
log.info "Chain A Length: {}", chainA.length
log.info "Chain C Length: {}", chainC.length

assertEquals(394, chainA.length, "Expected length of chain A")
assertEquals(387, chainC.length, "Expected length of chain C")
assertEquals(10203, prot.allAtoms.count, "Expected number of all structure atoms")
assertEquals(9311, prot.proteinAtoms.count, "Expected number of protein atoms")


// P2Rank 2.4.1
// All Atoms: 10203
// Protein Atoms: 8229
// Chain A Length: 321
// Chain C Length: 322

// P2Rank after fix
// All Atoms: 10203
// Protein Atoms: 9311
// Chain A Length: 394
// Chain C Length: 387

}

@Test
void discontinuedChainsLoading_1O6U_cif() throws Exception {
Protein prot = Protein.load(CIF_1O6U)

def chainA = prot.getResidueChain('A')
def chainC = prot.getResidueChain('C')

assertEquals(394, chainA.length, "Expected length of chain A")
assertEquals(387, chainC.length, "Expected length of chain C")
assertEquals(10203, prot.allAtoms.count, "Expected number of all structure atoms")
assertEquals(9311, prot.proteinAtoms.count, "Expected number of protein atoms")

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ class ConfigLoaderTest {
assert p.seed == 42
}

// TODO test rescore params

}
Loading

0 comments on commit 2035ca9

Please sign in to comment.