@@ -144,7 +144,6 @@ public class CifStructureConsumerImpl implements CifStructureConsumer {
144144 private StructNcsOper structNcsOper ;
145145 private PdbxStructOperList structOpers ;
146146 private StructRef structRef ;
147- private StructRefSeq structRefSeq ;
148147 private StructRefSeqDif structRefSeqDif ;
149148 private StructSiteGen structSiteGen ;
150149
@@ -690,7 +689,7 @@ public void consumeEntitySrcSyn(PdbxEntitySrcSyn entitySrcSyn) {
690689 @ Override
691690 public void consumeEntityPolySeq (EntityPolySeq entityPolySeq ) {
692691 for (int rowIndex = 0 ; rowIndex < entityPolySeq .getRowCount (); rowIndex ++) {
693- Chain entityChain = getEntityChain (entityPolySeq .getEntityId ().get (rowIndex ), true );
692+ Chain entityChain = getEntityChain (entityPolySeq .getEntityId ().get (rowIndex ));
694693
695694 // first we check through the chemcomp provider, if it fails we do some heuristics to guess the type of group
696695 // TODO some of this code is analogous to getNewGroup() and we should try to unify them - JD 2016-03-08
@@ -729,27 +728,19 @@ public void consumeEntityPolySeq(EntityPolySeq entityPolySeq) {
729728 }
730729 }
731730
732- /**
733- * Get a chain from the temporary list holding them. If createNewChains is true, a new chain
734- * will be added is none are found with the given entityId
735- * @param entityId the entity id
736- * @param createNewChains whether to add new chains if not found or not. If false, null will be returned if chain not found
737- * @return the chain
738- */
739- private Chain getEntityChain (String entityId , boolean createNewChains ) {
731+ private Chain getEntityChain (String entityId ) {
740732 for (Chain chain : entityChains ) {
741733 if (chain .getId ().equals (entityId )) {
742734 return chain ;
743735 }
744736 }
745- if (createNewChains ) {
746- // does not exist yet, so create...
747- Chain chain = new ChainImpl ();
748- chain .setId (entityId );
749- entityChains .add (chain );
750- return chain ;
751- }
752- return null ;
737+
738+ // does not exist yet, so create...
739+ Chain chain = new ChainImpl ();
740+ chain .setId (entityId );
741+ entityChains .add (chain );
742+
743+ return chain ;
753744 }
754745
755746 @ Override
@@ -976,7 +967,6 @@ public void consumeStructRef(StructRef structRef) {
976967
977968 @ Override
978969 public void consumeStructRefSeq (StructRefSeq structRefSeq ) {
979- this .structRefSeq = structRefSeq ;
980970 for (int rowIndex = 0 ; rowIndex < structRefSeq .getRowCount (); rowIndex ++) {
981971 String refId = structRefSeq .getRefId ().get (rowIndex );
982972
@@ -1183,7 +1173,7 @@ public void finish() {
11831173 String entityId = structAsym .getEntityId ().get (rowIndex );
11841174 logger .debug ("Entity {} matches asym_id: {}" , entityId , id );
11851175
1186- Chain chain = getEntityChain (entityId , true );
1176+ Chain chain = getEntityChain (entityId );
11871177 Chain seqRes = (Chain ) chain .clone ();
11881178 // to solve issue #160 (e.g. 3u7t)
11891179 seqRes = removeSeqResHeterogeneity (seqRes );
@@ -1302,8 +1292,7 @@ public void finish() {
13021292 setStructNcsOps ();
13031293 setCrystallographicInfoMetadata ();
13041294
1305- // entity id to list of SeqMisMatch
1306- Map <Integer , List <SeqMisMatch >> misMatchMap = new HashMap <>();
1295+ Map <String , List <SeqMisMatch >> misMatchMap = new HashMap <>();
13071296 for (int rowIndex = 0 ; rowIndex < structRefSeqDif .getRowCount (); rowIndex ++) {
13081297 SeqMisMatch seqMisMatch = new SeqMisMatchImpl ();
13091298 seqMisMatch .setDetails (structRefSeqDif .getDetails ().get (rowIndex ));
@@ -1322,54 +1311,20 @@ public void finish() {
13221311 seqMisMatch .setUniProtId (structRefSeqDif .getPdbxSeqDbAccessionCode ().isDefined ()? structRefSeqDif .getPdbxSeqDbAccessionCode ().get (rowIndex ):null );
13231312 seqMisMatch .setSeqNum (structRefSeqDif .getSeqNum ().get (rowIndex ));
13241313
1325- // try to trace the reference entity_id to struct_ref_seq -> struct_ref
1326- String alignId = findRefIdInStructRefSeq (structRefSeqDif .getAlignId ().get (rowIndex ));
1327- if (alignId !=null ) {
1328- int entityId = findEntityIdInStructRef (alignId );
1329- if (entityId > 0 ) {
1330- List <SeqMisMatch > seqMisMatches = misMatchMap .computeIfAbsent (entityId , k -> new ArrayList <>());
1331- seqMisMatches .add (seqMisMatch );
1332- }
1333- }
1314+ String strandId = structRefSeqDif .getPdbxPdbStrandId ().get (rowIndex );
1315+ List <SeqMisMatch > seqMisMatches = misMatchMap .computeIfAbsent (strandId , k -> new ArrayList <>());
1316+ seqMisMatches .add (seqMisMatch );
13341317 }
13351318
1336- for (int entityId : misMatchMap .keySet ()){
1337- Chain chain = getEntityChain ( String . valueOf ( entityId ), false );
1319+ for (String chainId : misMatchMap .keySet ()){
1320+ Chain chain = structure . getPolyChainByPDB ( chainId );
13381321 if (chain == null ) {
1339- logger .warn ("Could not set mismatches for chain with entity id {}" , entityId );
1322+ logger .warn ("Could not set mismatches for chain with author id {}" , chainId );
13401323 continue ;
13411324 }
1342- chain .setSeqMisMatches (misMatchMap .get (entityId ));
1343- }
1344- }
13451325
1346- private String findRefIdInStructRefSeq (String alignId ) {
1347- for (int rowIndex = 0 ; rowIndex < structRefSeq .getRowCount (); rowIndex ++) {
1348- String currentAlignId = structRefSeq .getAlignId ().get (rowIndex );
1349- if (alignId .equals (currentAlignId )) {
1350- return structRefSeq .getRefId ().isDefined ()? structRefSeq .getRefId ().get (rowIndex ) : null ;
1351- }
1352- }
1353- return null ;
1354- }
1355-
1356- private int findEntityIdInStructRef (String refId ) {
1357- String entityIdStr = null ;
1358- for (int rowIndex = 0 ; rowIndex < structRef .getRowCount (); rowIndex ++) {
1359- String currentId = structRef .getId ().get (rowIndex );
1360- if (refId .equals (currentId )) {
1361- entityIdStr = structRef .getEntityId ().isDefined ()? structRef .getEntityId ().get (rowIndex ) : null ;
1362- }
1363- }
1364- int entityId = -1 ;
1365- if (entityIdStr != null ) {
1366- try {
1367- entityId = Integer .parseInt (entityIdStr );
1368- } catch (NumberFormatException e ) {
1369- logger .warn ("Could not parse entity id from '{}'" , entityIdStr );
1370- }
1326+ chain .setSeqMisMatches (misMatchMap .get (chainId ));
13711327 }
1372- return entityId ;
13731328 }
13741329
13751330 private String getEntityType (String entityId ) {
0 commit comments