Skip to content
Merged
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
Prev Previous commit
Next Next commit
Revert "Dealing with struct_ref_seq_dif strand_id by referencing thro…
…ugh struct_ref_seq and struct_ref"

This reverts commit 8286260.
  • Loading branch information
josemduarte committed Feb 28, 2025
commit fdf98644c046416531cb53da0f67e8b7fc6a44cf
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public class CifStructureConsumerImpl implements CifStructureConsumer {
private StructNcsOper structNcsOper;
private PdbxStructOperList structOpers;
private StructRef structRef;
private StructRefSeq structRefSeq;
private StructRefSeqDif structRefSeqDif;
private StructSiteGen structSiteGen;

Expand Down Expand Up @@ -690,7 +689,7 @@ public void consumeEntitySrcSyn(PdbxEntitySrcSyn entitySrcSyn) {
@Override
public void consumeEntityPolySeq(EntityPolySeq entityPolySeq) {
for (int rowIndex = 0; rowIndex < entityPolySeq.getRowCount(); rowIndex++) {
Chain entityChain = getEntityChain(entityPolySeq.getEntityId().get(rowIndex), true);
Chain entityChain = getEntityChain(entityPolySeq.getEntityId().get(rowIndex));

// first we check through the chemcomp provider, if it fails we do some heuristics to guess the type of group
// TODO some of this code is analogous to getNewGroup() and we should try to unify them - JD 2016-03-08
Expand Down Expand Up @@ -729,27 +728,19 @@ public void consumeEntityPolySeq(EntityPolySeq entityPolySeq) {
}
}

/**
* Get a chain from the temporary list holding them. If createNewChains is true, a new chain
* will be added is none are found with the given entityId
* @param entityId the entity id
* @param createNewChains whether to add new chains if not found or not. If false, null will be returned if chain not found
* @return the chain
*/
private Chain getEntityChain(String entityId, boolean createNewChains) {
private Chain getEntityChain(String entityId) {
for (Chain chain : entityChains) {
if (chain.getId().equals(entityId)) {
return chain;
}
}
if (createNewChains) {
// does not exist yet, so create...
Chain chain = new ChainImpl();
chain.setId(entityId);
entityChains.add(chain);
return chain;
}
return null;

// does not exist yet, so create...
Chain chain = new ChainImpl();
chain.setId(entityId);
entityChains.add(chain);

return chain;
}

@Override
Expand Down Expand Up @@ -976,7 +967,6 @@ public void consumeStructRef(StructRef structRef) {

@Override
public void consumeStructRefSeq(StructRefSeq structRefSeq) {
this.structRefSeq = structRefSeq;
for (int rowIndex = 0; rowIndex < structRefSeq.getRowCount(); rowIndex++) {
String refId = structRefSeq.getRefId().get(rowIndex);

Expand Down Expand Up @@ -1183,7 +1173,7 @@ public void finish() {
String entityId = structAsym.getEntityId().get(rowIndex);
logger.debug("Entity {} matches asym_id: {}", entityId, id);

Chain chain = getEntityChain(entityId, true);
Chain chain = getEntityChain(entityId);
Chain seqRes = (Chain) chain.clone();
// to solve issue #160 (e.g. 3u7t)
seqRes = removeSeqResHeterogeneity(seqRes);
Expand Down Expand Up @@ -1302,8 +1292,7 @@ public void finish() {
setStructNcsOps();
setCrystallographicInfoMetadata();

// entity id to list of SeqMisMatch
Map<Integer, List<SeqMisMatch>> misMatchMap = new HashMap<>();
Map<String, List<SeqMisMatch>> misMatchMap = new HashMap<>();
for (int rowIndex = 0; rowIndex < structRefSeqDif.getRowCount(); rowIndex++) {
SeqMisMatch seqMisMatch = new SeqMisMatchImpl();
seqMisMatch.setDetails(structRefSeqDif.getDetails().get(rowIndex));
Expand All @@ -1322,54 +1311,20 @@ public void finish() {
seqMisMatch.setUniProtId(structRefSeqDif.getPdbxSeqDbAccessionCode().isDefined()? structRefSeqDif.getPdbxSeqDbAccessionCode().get(rowIndex):null);
seqMisMatch.setSeqNum(structRefSeqDif.getSeqNum().get(rowIndex));

// try to trace the reference entity_id to struct_ref_seq -> struct_ref
String alignId = findRefIdInStructRefSeq(structRefSeqDif.getAlignId().get(rowIndex));
if (alignId!=null) {
int entityId = findEntityIdInStructRef(alignId);
if (entityId > 0) {
List<SeqMisMatch> seqMisMatches = misMatchMap.computeIfAbsent(entityId, k -> new ArrayList<>());
seqMisMatches.add(seqMisMatch);
}
}
String strandId = structRefSeqDif.getPdbxPdbStrandId().get(rowIndex);
List<SeqMisMatch> seqMisMatches = misMatchMap.computeIfAbsent(strandId, k -> new ArrayList<>());
seqMisMatches.add(seqMisMatch);
}

for (int entityId : misMatchMap.keySet()){
Chain chain = getEntityChain(String.valueOf(entityId), false);
for (String chainId : misMatchMap.keySet()){
Chain chain = structure.getPolyChainByPDB(chainId);
if (chain == null) {
logger.warn("Could not set mismatches for chain with entity id {}", entityId);
logger.warn("Could not set mismatches for chain with author id {}", chainId);
continue;
}
chain.setSeqMisMatches(misMatchMap.get(entityId));
}
}

private String findRefIdInStructRefSeq(String alignId) {
for (int rowIndex = 0; rowIndex < structRefSeq.getRowCount(); rowIndex++) {
String currentAlignId = structRefSeq.getAlignId().get(rowIndex);
if (alignId.equals(currentAlignId)) {
return structRefSeq.getRefId().isDefined()? structRefSeq.getRefId().get(rowIndex) : null;
}
}
return null;
}

private int findEntityIdInStructRef(String refId) {
String entityIdStr = null;
for (int rowIndex = 0; rowIndex < structRef.getRowCount(); rowIndex++) {
String currentId = structRef.getId().get(rowIndex);
if (refId.equals(currentId)) {
entityIdStr = structRef.getEntityId().isDefined()? structRef.getEntityId().get(rowIndex) : null;
}
}
int entityId = -1;
if (entityIdStr != null) {
try {
entityId = Integer.parseInt(entityIdStr);
} catch (NumberFormatException e) {
logger.warn("Could not parse entity id from '{}'", entityIdStr);
}
chain.setSeqMisMatches(misMatchMap.get(chainId));
}
return entityId;
}

private String getEntityType(String entityId) {
Expand Down