Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e3bad37
detach mmcif.model.DatabasePdbrevRecord
sbittrich Nov 18, 2020
c290ea9
wip (most of structure parsing done)
sbittrich Jan 13, 2021
993665a
wip (TODO chemcomp parsing)
sbittrich Jan 14, 2021
1b164a9
compiling
sbittrich Jan 20, 2021
b992e74
metal parsing
sbittrich Jan 25, 2021
61bd8e8
new filetype param
sbittrich Jan 25, 2021
e7f563d
fix bcif download
sbittrich Jan 25, 2021
0c00cac
fix chemcomp type
sbittrich Jan 25, 2021
16792bd
Merge remote-tracking branch 'upstream/master' into bcif-integration
sbittrich Jan 26, 2021
85b6c6b
chem comp parsing errors & missing crystal translation
sbittrich Jan 26, 2021
e9c59f6
fix entity parsing
sbittrich Jan 26, 2021
28815db
handle missing rfree/rwork
sbittrich Jan 26, 2021
f36f82c
SCOP hack to force loading of MMTF
sbittrich Jan 26, 2021
63d2ee7
bcif/models URL is a constant
sbittrich Jan 26, 2021
2d4cc74
StructureInterface#toMMCIF
sbittrich Jan 26, 2021
b7a40c5
TODO TestHardBioUnits
sbittrich Jan 27, 2021
2f91dbf
those aren't the FloatColumns you're looking for
sbittrich Jan 27, 2021
9f42c9c
trigger build
sbittrich Jan 27, 2021
454830a
docs
sbittrich Jan 27, 2021
4f44fce
Group.java from upstream
sbittrich Feb 1, 2021
53982b0
update CHANGELOG.md
sbittrich Feb 2, 2021
19766ca
update AtomCacheTest
sbittrich Feb 3, 2021
58efc46
Merge remote-tracking branch 'upstream/master' into bcif-integration
sbittrich Feb 4, 2021
e94f047
increase QCP precision threshold (try to fix #914)
sbittrich Feb 10, 2021
83cf763
Revert "increase QCP precision threshold (try to fix #914)"
sbittrich Feb 12, 2021
54f4c2b
dedicated test for SuperPositionQCP issues (#914)
sbittrich Feb 24, 2021
288b18c
switch from QCP to SVD
sbittrich Feb 24, 2021
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
StructureInterface#toMMCIF
  • Loading branch information
sbittrich committed Jan 26, 2021
commit 2d4cc74edd6f3a88689a6de40b579a701230a351
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
*/
package org.biojava.nbio.structure.contact;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.biojava.nbio.structure.Atom;
import org.biojava.nbio.structure.Chain;
import org.biojava.nbio.structure.Element;
Expand All @@ -40,10 +34,24 @@
import org.biojava.nbio.structure.chem.PolymerType;
import org.biojava.nbio.structure.io.FileConvert;
import org.biojava.nbio.structure.io.FileParsingParameters;
import org.biojava.nbio.structure.io.cif.AbstractCifFileSupplier;
import org.biojava.nbio.structure.xtal.CrystalTransform;
import org.rcsb.cif.CifBuilder;
import org.rcsb.cif.CifIO;
import org.rcsb.cif.model.Category;
import org.rcsb.cif.schema.StandardSchemata;
import org.rcsb.cif.schema.mm.MmCifBlockBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.Serializable;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;


/**
* An interface between 2 molecules (2 sets of atoms).
Expand Down Expand Up @@ -748,45 +756,46 @@ public String toPDB() {
* @return the mmCIF-formatted string
*/
public String toMMCIF() {
StringBuilder sb = new StringBuilder();
String molecId1 = getMoleculeIds().getFirst();
String molecId2 = getMoleculeIds().getSecond();

// TODO impl
// String molecId1 = getMoleculeIds().getFirst();
// String molecId2 = getMoleculeIds().getSecond();
//
// if (isSymRelated()) {
// // if both chains are named equally we want to still named them differently in the output mmcif file
// // so that molecular viewers can handle properly the 2 chains as separate entities
// molecId2 = molecId2 + "_" +getTransforms().getSecond().getTransformId();
// }
//
// sb.append(SimpleMMcifParser.MMCIF_TOP_HEADER).append("BioJava_interface_").append(getId()).append(System.getProperty("line.separator"));
//
// sb.append(FileConvert.getAtomSiteHeader());
//
// // we reassign atom ids if sym related (otherwise atom ids would be duplicated and some molecular viewers can't cope with that)
// int atomId = 1;
// List<AtomSite> atomSites = new ArrayList<>();
// for (Atom atom:this.molecules.getFirst()) {
// if (isSymRelated()) {
// atomSites.add(MMCIFFileTools.convertAtomToAtomSite(atom, 1, molecId1, molecId1, atomId));
// } else {
// atomSites.add(MMCIFFileTools.convertAtomToAtomSite(atom, 1, molecId1, molecId1));
// }
// atomId++;
// }
// for (Atom atom:this.molecules.getSecond()) {
// if (isSymRelated()) {
// atomSites.add(MMCIFFileTools.convertAtomToAtomSite(atom, 1, molecId2, molecId2, atomId));
// } else {
// atomSites.add(MMCIFFileTools.convertAtomToAtomSite(atom, 1, molecId2, molecId2));
// }
// atomId++;
// }
//
// sb.append(MMCIFFileTools.toMMCIF(atomSites,AtomSite.class));
if (isSymRelated()) {
// if both chains are named equally we want to still named them differently in the output mmcif file
// so that molecular viewers can handle properly the 2 chains as separate entities
molecId2 = molecId2 + "_" + getTransforms().getSecond().getTransformId();
}

return sb.toString();
MmCifBlockBuilder mmCifBlockBuilder = CifBuilder.enterFile(StandardSchemata.MMCIF)
.enterBlock("BioJava_interface_" + getId());

// we reassign atom ids if sym related (otherwise atom ids would be duplicated and some molecular viewers can't cope with that)
int atomId = 1;
List<AbstractCifFileSupplier.WrappedAtom> wrappedAtoms = new ArrayList<>();
for (Atom atom : this.molecules.getFirst()) {
if (isSymRelated()) {
wrappedAtoms.add(new AbstractCifFileSupplier.WrappedAtom(1, molecId1, molecId1, atom, atomId));
} else {
wrappedAtoms.add(new AbstractCifFileSupplier.WrappedAtom(1, molecId1, molecId1, atom, atom.getPDBserial()));
}
atomId++;
}
for (Atom atom : this.molecules.getSecond()) {
if (isSymRelated()) {
wrappedAtoms.add(new AbstractCifFileSupplier.WrappedAtom(1, molecId2, molecId2, atom, atomId));
} else {
wrappedAtoms.add(new AbstractCifFileSupplier.WrappedAtom(1, molecId2, molecId2, atom, atom.getPDBserial()));
}
atomId++;
}

Category atomSite = wrappedAtoms.stream().collect(AbstractCifFileSupplier.toAtomSite());
mmCifBlockBuilder.addCategory(atomSite);

try {
return new String(CifIO.writeText(mmCifBlockBuilder.leaveBlock().leaveFile()));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected void handleChain(Chain chain, int model, List<WrappedAtom> wrappedAtom
continue;
}

uniqueAtoms.put(atom.getPDBserial(), new WrappedAtom(chain, model, chainName, chainId, atom, atom.getPDBserial()));
uniqueAtoms.put(atom.getPDBserial(), new WrappedAtom(model, chainName, chainId, atom, atom.getPDBserial()));
}

if (group.hasAltLoc()) {
Expand All @@ -118,7 +118,7 @@ protected void handleChain(Chain chain, int model, List<WrappedAtom> wrappedAtom
continue;
}

uniqueAtoms.put(atom.getPDBserial(), new WrappedAtom(chain, model, chainName, chainId, atom, atom.getPDBserial()));
uniqueAtoms.put(atom.getPDBserial(), new WrappedAtom(model, chainName, chainId, atom, atom.getPDBserial()));
}
}
}
Expand All @@ -127,27 +127,21 @@ protected void handleChain(Chain chain, int model, List<WrappedAtom> wrappedAtom
}
}

static class WrappedAtom {
private final Chain chain;
public static class WrappedAtom {
private final int model;
private final String chainName;
private final String chainId;
private final Atom atom;
private final int atomId;

WrappedAtom(Chain chain, int model, String chainName, String chainId, Atom atom, int atomId) {
this.chain = chain;
public WrappedAtom(int model, String chainName, String chainId, Atom atom, int atomId) {
this.model = model;
this.chainName = chainName;
this.chainId = chainId;
this.atom = atom;
this.atomId = atomId;
}

Chain getChain() {
return chain;
}

int getModel() {
return model;
}
Expand All @@ -169,7 +163,7 @@ int getAtomId() {
}
}

private static Collector<WrappedAtom, ?, Category> toAtomSite() {
public static Collector<WrappedAtom, ?, Category> toAtomSite() {
return Collector.of(AtomSiteCollector::new,
AtomSiteCollector::accept,
AtomSiteCollector::combine,
Expand Down Expand Up @@ -255,7 +249,7 @@ public void accept(WrappedAtom wrappedAtom) {
labelEntityId.add(entityId);
labelSeqId.add(seqId);
String insCode = "";
if (group.getResidueNumber().getInsCode() != null ) {
if (group.getResidueNumber().getInsCode() != null) {
insCode = Character.toString(group.getResidueNumber().getInsCode());
}
if (insCode.isEmpty()) {
Expand All @@ -276,7 +270,7 @@ public void accept(WrappedAtom wrappedAtom) {
}

AtomSiteCollector combine(AtomSiteCollector other) {
throw new UnsupportedOperationException("impl by calling addAll for all collection");
throw new UnsupportedOperationException("impl by calling addAll for all collections");
}

Category get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import org.rcsb.cif.model.CifFile;

import java.util.function.Supplier;

/**
* Create a CifFile instance for a given container of structure data.
* @param <S> the container type used as source
Expand Down