本文整理汇总了Java中org.biojava.nbio.structure.Structure.getChains方法的典型用法代码示例。如果您正苦于以下问题:Java Structure.getChains方法的具体用法?Java Structure.getChains怎么用?Java Structure.getChains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.biojava.nbio.structure.Structure
的用法示例。
在下文中一共展示了Structure.getChains方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
public static void convert(File inFile, File outFile) throws IOException {
MMcifParser parser = new SimpleMMcifParser();
SimpleMMcifConsumer consumer = new SimpleMMcifConsumer();
parser.addMMcifConsumer(consumer);
parser.parse(new BufferedReader(new InputStreamReader(new FileInputStream(inFile))));
// now get the protein structure.
Structure cifStructure = consumer.getStructure();
// and write it out as PDB format
PrintWriter pr = new PrintWriter(outFile);
for (Chain c : cifStructure.getChains()) {
// we can override the chain name, the mmCIF chain names might have more than 1 character
c.setName(c.getName().substring(0, 1));
pr.print(c.toPDB());
pr.println("TER");
}
pr.close();
}
示例2: test4letterChains
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
@Test
public void test4letterChains() throws IOException, StructureException, URISyntaxException {
String filename = "/1hh0_4char.cif.gz";
URL url = getClass().getResource(filename);
assumeNotNull("Can't find resource "+filename,url);
File file = new File(url.toURI());
assumeNotNull(file);
assumeTrue(file.exists());
MMCIFFileReader reader = new MMCIFFileReader();
Structure s = reader.getStructure(file);
assertNotNull("Failed to load structure from jar",s);
List<Chain> chains = s.getChains();
assertEquals("Wrong number of chains",chains.size(), 1);
Chain chain = chains.get(0);
assertEquals("Wrong chain ID",chain.getId(),"ABCD");
Chain chain2 = s.getPolyChainByPDB("ABCD");
assertNotNull(chain2);
assertEquals(chain2, chain);
}
示例3: outputPDB
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
/**
* test output essential structure information of input pdb
* @param pdbname
*/
void outputPDB(String pdbname){
try {
//test "4cof"
Structure s = StructureIO.getStructure(pdbname);
for(DBRef db : s.getDBRefs()){
System.out.println("**");
System.out.println(db.getChainId());
System.out.println(db.getDatabase());
System.out.println(db.getDbAccession());
System.out.println(db.getDbIdCode());
System.out.println(db.getInsertBegin());
System.out.println(db.getInsertEnd());
System.out.println(db.getDbSeqBegin());
System.out.println(db.getDbSeqEnd());
System.out.println(db.getIdbnsBegin());
System.out.println(db.getIdbnsEnd());
System.out.println(db.getIdCode());
System.out.println(db.getId());
}
for ( Chain c : s.getChains()) {
System.out.println(c.getChainID()+"\t"+c.getAtomLength()+"\t"+c.getAtomSequence().length()+"\t"+c.getSeqResLength());
// only the observed residues
System.out.println(c.getAtomSequence());
// print biological sequence
System.out.println(c.getSeqResSequence());
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: getChainIds
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
/**
* Returns a list of chain ids in the order they are specified in the ATOM
* records in the asymmetric unit
* @param asymUnit
* @return
*/
private List<String> getChainIds(Structure asymUnit) {
List<String> chainIds = new ArrayList<String>();
for ( Chain c : asymUnit.getChains()){
String intChainID = c.getId();
chainIds.add(intChainID);
}
return chainIds;
}
示例5: convertStructureToAtomSites
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
/**
* Converts a Structure into a List of {@link AtomSite} objects
* @param s
* @return
*/
public static List<AtomSite> convertStructureToAtomSites(Structure s) {
List<AtomSite> list = new ArrayList<AtomSite>();
for (int m=0;m<s.nrModels();m++) {
for (Chain c:s.getChains(m)) {
list.addAll(convertChainToAtomSites(c, m+1, c.getName(), c.getId()));
}
}
return list;
}
示例6: getNumGroups
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
/**
* Count the total number of groups in the structure
* @param structure the input structure
* @return the total number of groups
*/
public static int getNumGroups(Structure structure) {
int count = 0;
for(int i=0; i<structure.nrModels(); i++) {
for(Chain chain : structure.getChains(i)){
count+= chain.getAtomGroups().size();
}
}
return count;
}
示例7: test4cup
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
@Test
public void test4cup() throws IOException, StructureException {
AtomCache cache = new AtomCache();
cache.setUseMmCif(true);
FileParsingParameters params = cache.getFileParsingParams();
cache.setFileParsingParams(params);
StructureIO.setAtomCache(cache);
// Set the test lists
String[] asymChainList = {"A","B","C","D","E","F"};
String[] authChainList = {"A","A","A","A","A","A"};
String[] asymChainListTest = new String[6];
String[] authChainListTest = new String[6];
// Get the structure
Structure bioJavaStruct = StructureIO.getStructure("4cup");
List<Chain> chainList = bioJavaStruct.getChains();
assertEquals(6,chainList.size());
for(int i=0; i<chainList.size();i++){
Chain c = chainList.get(i);
authChainListTest[i] = c.getName();
asymChainListTest[i] = c.getId();
}
// Now check both lists are the same
assertArrayEquals(authChainListTest, authChainList);
assertArrayEquals(asymChainListTest, asymChainList);
}
示例8: getInterBonds
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
/**
* Find all of the inter group bonds in a structure
* @param pdbId the pdb id of the structure to determine
* @return the number of inter group bonds (double counted) in a structure
* @throws IOException
* @throws StructureException
*/
public int getInterBonds(String pdbId) throws IOException, StructureException{
AtomCache cache = new AtomCache();
cache.setUseMmCif(true);
cache.setFetchBehavior(FetchBehavior.FETCH_FILES);
FileParsingParameters params = cache.getFileParsingParams();
params.setCreateAtomBonds(true);
params.setAlignSeqRes(true);
params.setParseBioAssembly(true);
DownloadChemCompProvider dcc = new DownloadChemCompProvider();
ChemCompGroupFactory.setChemCompProvider(dcc);
dcc.checkDoFirstInstall();
cache.setFileParsingParams(params);
StructureIO.setAtomCache(cache);
int counter =0;
// Now get the structure
Structure newStruc = StructureIO.getStructure(pdbId);
// Now loop through the atoms
for(Chain c: newStruc.getChains()){
for(Group g: c.getAtomGroups()){
List<Atom> theseAtoms = g.getAtoms();
for(Atom a: theseAtoms){
List<Bond> theseBonds = a.getBonds();
if(theseBonds != null){
for(Bond b: a.getBonds()){
Atom other = b.getOther(a);
int indexOther = theseAtoms.indexOf(other);
// Check if the index is within the group
if(indexOther<0 || indexOther >= theseAtoms.size()){
counter++;
}
}
}
}
}
}
return counter;
}
示例9: checkChains
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
private void checkChains(Structure s) {
for (Chain chain:s.getChains()) {
int seqResLength = chain.getSeqResLength();
int atomLength = chain.getAtomLength();
System.out.println("chain "+chain.getId()+", atomLength: "+atomLength+", seqResLength: "+seqResLength);
//assertTrue("atom length ("+atomLength+") should be smaller than seqResLength ("+seqResLength+")",atomLength<=seqResLength);
System.out.println("seq res groups size: "+chain.getSeqResGroups().size());
}
}
示例10: doSeqResHaveAtoms
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
/**
* Scan through SeqResGroups, returns true if any have Atoms.
* @param s
* @return
*/
public boolean doSeqResHaveAtoms(Structure s) {
for (int i = 0; i < s.nrModels(); i++) {
for (Chain c : s.getChains(i)) {
for (Group g : c.getSeqResGroups()) {
if (hasAtoms(g)) return true; // Found some Atoms in a Seqres group.
}
}
}
return false;
}
示例11: testXMLSerialization
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
public List<ModifiedCompound> testXMLSerialization(String pdbId){
String xml = null;
ModifiedCompound currentMC = null;
List<ModifiedCompound> all = new ArrayList<ModifiedCompound>();
try {
Structure struc = TmpAtomCache.cache.getStructure(pdbId);
ProteinModificationIdentifier parser = new ProteinModificationIdentifier();
for (Chain c : struc.getChains()) {
parser.identify(c, ProteinModificationRegistry.allModifications());
Set<ModifiedCompound> mcs = parser.getIdentifiedModifiedCompound();
for (ModifiedCompound mc : mcs){
currentMC = mc;
xml = doXMLSerialization(mc) ;
//logger.info( pdbId + " got XML: " + String.format("%n") + xml);
ModifiedCompound newMC = getModifiedCompoundFromXML(xml);
String xml2 = doXMLSerialization(newMC);
assertEquals(xml,xml2);
//logger.info(xml2);
//assertEquals("The two objects are not equal before and after XML serialization" , mc, newMC);
//logger.info(mc.getDescription());
//logger.info(newMC.getDescription());
all.add(mc);
}
}
} catch (Exception e){
logger.error(e.getMessage(),e);
logger.error("Error when serializing {}", pdbId);
logger.error(currentMC.getDescription());
logger.error(xml, e);
fail(e.getMessage());
}
xml = null;
currentMC =null;
return all;
}
示例12: MmtfStructureWriter
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
/**
* Pass data from Biojava structure to another generic output type. Loops through the data
* structure and calls all the set functions.
* @param structure the input {@link Structure} to write
* @param dataTransferInterface the generic interface that
* implements all the set methods.
*/
public MmtfStructureWriter(Structure structure, StructureAdapterInterface dataTransferInterface) {
this.mmtfDecoderInterface = dataTransferInterface;
// Reset structure to consider altloc groups with the same residue number but different group names as seperate groups
MmtfUtils.fixMicroheterogenity(structure);
// Get the chain name to index map
MmtfSummaryDataBean mmtfSummaryDataBean = MmtfUtils.getStructureInfo(structure);
Map<String, Integer> chainIdToIndexMap = mmtfSummaryDataBean.getChainIdToIndexMap();
List<Atom> allAtoms = mmtfSummaryDataBean.getAllAtoms();
int numBonds = mmtfSummaryDataBean.getNumBonds();
List<Chain> allChains = mmtfSummaryDataBean.getAllChains();
mmtfDecoderInterface.initStructure(numBonds, allAtoms.size(), MmtfUtils.getNumGroups(structure), allChains.size(), structure.nrModels(), structure.getPDBCode());
// Generate the secondary structure
MmtfUtils.calculateDsspSecondaryStructure(structure);
// Get the header and the xtal info.
PDBHeader pdbHeader = structure.getPDBHeader();
PDBCrystallographicInfo xtalInfo = pdbHeader.getCrystallographicInfo();
mmtfDecoderInterface.setHeaderInfo(pdbHeader.getRfree(), pdbHeader.getRwork(), pdbHeader.getResolution(), pdbHeader.getTitle(), MmtfUtils.dateToIsoString(pdbHeader.getDepDate()),
MmtfUtils.dateToIsoString(pdbHeader.getRelDate()), MmtfUtils.techniquesToStringArray(pdbHeader.getExperimentalTechniques()));
mmtfDecoderInterface.setXtalInfo(MmtfUtils.getSpaceGroupAsString(xtalInfo.getSpaceGroup()), MmtfUtils.getUnitCellAsArray(xtalInfo), MmtfUtils.getNcsAsArray(xtalInfo.getNcsOperators()));
// Store the bioassembly data
storeBioassemblyInformation(chainIdToIndexMap, pdbHeader.getBioAssemblies());
// Store the entity data
storeEntityInformation(allChains, structure.getEntityInfos());
// Now loop through the data structure
for (int modelIndex=0; modelIndex<structure.nrModels(); modelIndex++) {
List<Chain> modelChains = structure.getChains(modelIndex);
// Set this model
mmtfDecoderInterface.setModelInfo(modelIndex, modelChains.size());
for(int chainInModelIndex=0; chainInModelIndex<modelChains.size(); chainInModelIndex++) {
Chain chain = modelChains.get(chainInModelIndex);
List<Group> groups = chain.getAtomGroups();
List<Group> sequenceGroups = chain.getSeqResGroups();
mmtfDecoderInterface.setChainInfo(chain.getId(), chain.getName(), groups.size());
for(int groupInChainIndex=0; groupInChainIndex<groups.size(); groupInChainIndex++){
Group group = groups.get(groupInChainIndex);
List<Atom> atomsInGroup = MmtfUtils.getAtomsForGroup(group);
ChemComp chemComp = group.getChemComp();
Character insCode = group.getResidueNumber().getInsCode();
if(insCode==null || insCode.equals(' ')){
insCode=MmtfStructure.UNAVAILABLE_CHAR_VALUE;
}
char singleLetterCode = 'X';
if (chemComp.getOne_letter_code().length()==1){
singleLetterCode = chemComp.getOne_letter_code().charAt(0);
}
mmtfDecoderInterface.setGroupInfo(group.getPDBName(), group.getResidueNumber().getSeqNum(), insCode.charValue(),
chemComp.getType().toUpperCase(), atomsInGroup.size(), MmtfUtils.getNumBondsInGroup(atomsInGroup), singleLetterCode,
sequenceGroups.indexOf(group), MmtfUtils.getSecStructType(group));
for (Atom atom : atomsInGroup){
char altLoc = MmtfStructure.UNAVAILABLE_CHAR_VALUE;
if(atom.getAltLoc()!=null){
if(atom.getAltLoc().charValue()!=' '){
altLoc=atom.getAltLoc().charValue();
}
}
mmtfDecoderInterface.setAtomInfo(atom.getName(), atom.getPDBserial(), altLoc, (float) atom.getX(),
(float) atom.getY(), (float) atom.getZ(), atom.getOccupancy(),
atom.getTempFactor(), atom.getElement().toString(), atom.getCharge());
addBonds(atom, atomsInGroup, allAtoms);
}
}
}
}
mmtfDecoderInterface.finalizeStructure();
}
示例13: addCharges
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
/**
* Function to add the charges to a given structure.
*/
public static void addCharges(Structure structure) {
// Loop through the models
for(int i=0; i<structure.nrModels(); i++){
for(Chain c: structure.getChains(i)){
for(Group g: c.getAtomGroups()){
ChemComp thisChemComp = ChemCompGroupFactory.getChemComp(g.getPDBName());
List<ChemCompAtom> chemAtoms = thisChemComp.getAtoms();
for(ChemCompAtom chemCompAtom : chemAtoms) {
Atom atom = g.getAtom(chemCompAtom.getAtom_id());
String stringCharge = chemCompAtom.getCharge();
short shortCharge = 0;
if (stringCharge!=null){
if(!stringCharge.equals("?")){
try{
shortCharge = Short.parseShort(stringCharge);
}
catch(NumberFormatException e){
logger.warn("Number format exception. Parsing '"+stringCharge+"' to short");
}
}
else{
logger.warn("? charge on atom "+chemCompAtom.getAtom_id()+" in group "+thisChemComp.getId());
}
}
else{
logger.warn("Null charge on atom "+chemCompAtom.getAtom_id()+" in group "+thisChemComp.getId());
}
if(atom!=null){
atom.setCharge(shortCharge);
}
// Now do the same for alt locs
for (Group altLoc : g.getAltLocs()) {
Atom altAtom = altLoc.getAtom(chemCompAtom.getAtom_id());
if(altAtom!=null){
altAtom.setCharge(shortCharge);
}
}
}
}
}
}
}
示例14: testEntityId
import org.biojava.nbio.structure.Structure; //导入方法依赖的package包/类
@Test
public void testEntityId() throws IOException, StructureException {
// Set up the atom cache to parse on Internal chain id
AtomCache cache = new AtomCache();
cache.setUseMmCif(true);
FileParsingParameters params = cache.getFileParsingParams();
DownloadChemCompProvider cc = new DownloadChemCompProvider();
ChemCompGroupFactory.setChemCompProvider(cc);
cc.checkDoFirstInstall();
cache.setFileParsingParams(params);
StructureIO.setAtomCache(cache);
// This is hte information we want to test against
String[] typeInformation = new String[] {"POLYMER", "NONPOLYMER", "NONPOLYMER", "NONPOLYMER", "NONPOLYMER", "WATER"};
String[] descriptionInformation = new String[] {"BROMODOMAIN ADJACENT TO ZINC FINGER DOMAIN PROTEIN 2B","4-Fluorobenzamidoxime", "METHANOL", "METHANOL", "METHANOL", "water"};
// Now some other information fields to test this data is collated correctly
String[] geneSourceSciName = new String[] {"HOMO SAPIENS", null, null, null, null, null};
String[] geneSourceTaxId = new String[] {"9606", null, null, null, null, null};
String[] hostOrganismSciName = new String[] {"ESCHERICHIA COLI", null, null, null, null, null};
String[] hostOrganismTaxId = new String[] {"469008", null, null, null, null, null};
/// TODO GET ALL THE ENTITY INFORMATION REQUIRED FOR 4CUP
// Get this structure
Structure bioJavaStruct = StructureIO.getStructure("4cup");
String[] testTypeInfo = new String[6];
String[] testDescInfo = new String[6];
String[] testGeneSourceSciName = new String[6];
String[] testGeneSourceTaxId = new String[6];
String[] testHostOrganismSciName = new String[6];
String[] testHostOrganismTaxId = new String[6];
// Now loop through the structure
int chainCounter = 0;
for (Chain c: bioJavaStruct.getChains()) {
// Now get the entity information we want to test
EntityInfo thisCmpd = c.getEntityInfo();
testTypeInfo[chainCounter] = thisCmpd.getType().toString();
testDescInfo[chainCounter] = thisCmpd.getDescription();
testGeneSourceSciName[chainCounter] = thisCmpd.getOrganismScientific();
testGeneSourceTaxId[chainCounter] = thisCmpd.getOrganismTaxId();
testHostOrganismSciName[chainCounter] = thisCmpd.getExpressionSystem();
testHostOrganismTaxId[chainCounter] = thisCmpd.getExpressionSystemTaxId();
chainCounter++;
}
// Now check they're both the same
assertArrayEquals(descriptionInformation, testDescInfo);
assertArrayEquals(typeInformation, testTypeInfo);
// Now check these work too
assertArrayEquals(geneSourceSciName, testGeneSourceSciName);
assertArrayEquals(geneSourceTaxId, testGeneSourceTaxId);
assertArrayEquals(hostOrganismSciName, testHostOrganismSciName);
assertArrayEquals(hostOrganismTaxId, testHostOrganismTaxId);
}