Skip to content

Commit

Permalink
fix discontinued chains 2
Browse files Browse the repository at this point in the history
  • Loading branch information
rdk committed Apr 11, 2024
1 parent 2035ca9 commit ca5670f
Show file tree
Hide file tree
Showing 6 changed files with 10,274 additions and 17 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.2'
version = '2.5.0-dev.4.3'


description = 'Ligand binding site prediction based on machine learning.'
Expand Down
21 changes: 13 additions & 8 deletions src/main/groovy/cz/siret/prank/geom/Struct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ class Struct {
}

private static int getLastTerminalResidue(List<Group> chainGroups) {
for (int i=chainGroups.size()-1; i<=0; i--) {
if (isTerminalResidue(chainGroups[i])) {
for (int i=chainGroups.size()-1; i>=0; i--) {
if (isAminoAcidResidueHeuristic(i, chainGroups) && isTerminalResidue(chainGroups[i])) {
return i
}
}
Expand All @@ -231,17 +231,22 @@ class Struct {
int n = chainGroups.size()
List<Group> res = new ArrayList<>(n)

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

int lastTerminalResidueIdx = getLastTerminalResidue(chainGroups)
//int lastTerminalResidueIdx = getLastTerminalResidue(chainGroups)
//log.info "lastTerminalResidueIdx: {}", lastTerminalResidueIdx

for (int i=0; i!=n; i++) {
Group g = chainGroups[i]
if (isAminoAcidResidueHeuristic(i, chainGroups)) {
Group g = chainGroups[i]
res.add g
if (i == lastTerminalResidueIdx) {
break // this is done so amino acid ligands at the end are excluded
}

// Note: commented out because this just doesn't work in proteins with discontinued chains (OXT atom is not present at the last residue)
//if (i == lastTerminalResidueIdx) {
// break // this is done so amino acid ligands at the end are excluded
//}
} else {
log.warn "group {} ({}) considered non-protein", i, g.getPDBName()
}
}

Expand Down
42 changes: 39 additions & 3 deletions src/test/groovy/cz/siret/prank/DiscontinuedChainsTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals
@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'
String DIR = 'src/test/resources/data/tricky_cases/'
String PDB_1O6U = DIR +'1o6u.pdb'
String CIF_1O6U = DIR +'1o6u.cif'
String PDB_1UWY = DIR +'1uwy.pdb'
String CIF_1UWY = DIR +'1uwy.cif'

@Test
void discontinuedChainsLoading_1O6U_pdb() throws Exception {
Expand Down Expand Up @@ -57,11 +60,44 @@ class DiscontinuedChainsTest {
def chainA = prot.getResidueChain('A')
def chainC = prot.getResidueChain('C')

assertEquals(394, chainA.length, "Expected length of chain A")
assertEquals(394, chainA.length, "Expected length of chain A") // TODO pdb says different
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")

}


@Test
void discontinuedChainsLoading_1UWY_pdb() throws Exception {
Protein prot = Protein.load(PDB_1UWY)

def chainA = prot.getResidueChain('A')

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

assertEquals(394, chainA.length, "Expected length of chain A") // TODO pdb says 426!
assertEquals(3230, prot.allAtoms.count, "Expected number of all structure atoms")
assertEquals(3116, prot.proteinAtoms.count, "Expected number of protein atoms")

}

@Test
void discontinuedChainsLoading_1UWY_cif() throws Exception {
Protein prot = Protein.load(CIF_1UWY)

def chainA = prot.getResidueChain('A')

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

assertEquals(394, chainA.length, "Expected length of chain A") // TODO pdb says 426!
assertEquals(3230, prot.allAtoms.count, "Expected number of all structure atoms")
assertEquals(3116, prot.proteinAtoms.count, "Expected number of protein atoms")

}

}
Loading

0 comments on commit ca5670f

Please sign in to comment.