org.biojava.nbio.structure.StructureException Java Examples

The following examples show how to use org.biojava.nbio.structure.StructureException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SymmetryCalc.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void run() {

	CESymmParameters params = parent.getParameters();

	try {

		Atom[] atoms = SymmetryTools.getRepresentativeAtoms(structure);

		CeSymmResult result = CeSymm.analyze(atoms, params);
		SymmetryDisplay.display(result);

	} catch (StructureException e) {
		logger.warn(e.getMessage());
	}
	parent.notifyCalcFinished();
}
 
Example #2
Source File: SequenceFunctionRefiner.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Refines a CE-Symm alignment so that it is perfectly symmetric.
 *
 * The resulting alignment will have a one-to-one correspondance between
 * aligned residues of each symmetric part.
 *
 * @param afpChain Input alignment from CE-Symm
 * @param k Symmetry order. This can be guessed by {@link CeSymm#getSymmetryOrder(AFPChain)}
 * @return The refined alignment
 * @throws StructureException
 * @throws RefinerFailedException
 */
public static AFPChain refineSymmetry(AFPChain afpChain, Atom[] ca1, Atom[] ca2, int k)
		throws StructureException, RefinerFailedException {

	// Transform alignment to a Map
	Map<Integer, Integer> alignment = AlignmentTools.alignmentAsMap(afpChain);

	// Refine the alignment Map
	Map<Integer, Integer> refined = refineSymmetry(alignment, k);
	if (refined.size() < 1)
		throw new RefinerFailedException("Refiner returned empty alignment");

	//Substitute and partition the alignment
	try {
		AFPChain refinedAFP = AlignmentTools.replaceOptAln(afpChain, ca1, ca2, refined);
		refinedAFP = partitionAFPchain(refinedAFP, ca1, ca2, k);
		if (refinedAFP.getOptLength() < 1)
			throw new IndexOutOfBoundsException("Refined alignment is empty.");
		return refinedAFP;
	} catch (IndexOutOfBoundsException e){
		// This Exception is thrown when the refined alignment is not consistent
		throw new RefinerFailedException("Refiner failure: non-consistent result", e);
	}
}
 
Example #3
Source File: TestNonDepositedFiles.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void test3C5F() throws IOException, StructureException {
	InputStream inStream = new GZIPInputStream(this.getClass().getResourceAsStream("/org/biojava/nbio/structure/io/3c5f_raw.pdb.gz"));
	assertNotNull(inStream);

	PDBFileParser pdbpars = new PDBFileParser();
	FileParsingParameters params = new FileParsingParameters();
	params.setAlignSeqRes(true);
	pdbpars.setFileParsingParameters(params);

	Structure s = pdbpars.parsePDBFile(inStream) ;

	// multi-model X-ray diffraction entry, thus:
	assertFalse(s.isNmr());
	assertTrue(s.isCrystallographic());
	assertTrue(s.nrModels()>1);
	assertNull(s.getPDBHeader().getExperimentalTechniques());

}
 
Example #4
Source File: TestCrystalBuilder.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void test2H2Z() throws IOException, StructureException {

	// a crystallographic structure C 1 2 1.
	// Should have a minimum number of contacts of 3, from the C number given in:
	// Wukowitz & Yeates, Nature Structural Biology, 1995
	// the molecule happens to be placed quite far from the origin, so this tests if we really capture all contacts

	AtomCache cache = new AtomCache();

	StructureIO.setAtomCache(cache);

	cache.setUseMmCif(true);
	Structure s1 = StructureIO.getStructure("2H2Z");
	CrystalBuilder cb = new CrystalBuilder(s1);
	StructureInterfaceList interfaces = cb.getUniqueInterfaces(5.5);
	assertEquals(3,interfaces.size());

}
 
Example #5
Source File: CECalculator.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
private double getRMSDForBestTrace(int ir, Atom[] strBuf1, Atom[] strBuf2,
		int[] bestTracesN2, int[][] bestTraces12, int[] bestTrace22,
		int winSize,Atom[] ca1, Atom[] ca2 ) throws StructureException {
	int is=0;
	for(int jt=0; jt<bestTracesN[ir]; jt++) {
		for(int i=0; i<winSize; i++) {

			setStrBuf(strBuf1, is+i, ca1, bestTraces1[ir][jt]+i);
			setStrBuf(strBuf2, is+i, ca2, bestTraces2[ir][jt]+i);
		}
		is+=winSize;
	}
	//sup_str(strBuf1, strBuf2, bestTracesN[ir]*winSize, d_);
	double rmsdNew=calc_rmsd(strBuf1, strBuf2, bestTracesN[ir]*winSize, true);
	return rmsdNew;

}
 
Example #6
Source File: StatusDisplay.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void toggleSelection(AlignedPosition p) {
	if ( afpChain == null)
		return;

	char[] aligs1  = afpChain.getAlnseq1();
	char[] aligs2  = afpChain.getAlnseq2();

	char c1 = aligs1[p.getPos1()];
	char c2 = aligs2[p.getPos2()];

	try {
		Atom a1 = DisplayAFP.getAtomForAligPos(afpChain, 0, p.getPos1(), ca1,false);
		Atom a2 = DisplayAFP.getAtomForAligPos(afpChain, 1, p.getPos2(), ca2,true);

		String pdbInfo1 = JmolTools.getPdbInfo(a1);
		String pdbInfo2 = JmolTools.getPdbInfo(a2);

		String msg = "Clicked pos:" + p.getPos1()+ " " + pdbInfo1 + " ("+c1+") : " + pdbInfo2 + " ("+c2+")";

		this.setText(msg);
	} catch (StructureException e){
		e.printStackTrace();
	}

}
 
Example #7
Source File: TestQsAlignExamples.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Different: test two completely different proteins (4HHB, 3IFV).
 */
@Test
public void testDifferent() throws StructureException, IOException {

	Structure s1 = StructureIO.getStructure("4hhb");
	Structure s2 = StructureIO.getStructure("3ifv");

	SubunitClustererParameters clusterParams = new SubunitClustererParameters();
	QsAlignParameters alignParams = new QsAlignParameters();

	QsAlignResult result = QsAlign
			.align(s1, s2, clusterParams, alignParams);

	assertEquals(result.length(), 0);
	assertEquals(result.getRelation(), QsRelation.DIFFERENT);

}
 
Example #8
Source File: TestMmtfStructureReader.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Compare structures loaded from MMCIF and MMTF files.
 */
@Test
public void compareMmcif() throws IOException, StructureException {
	
	// Get the MMTF and MMCIF files from the resources folder
	ClassLoader classLoader = getClass().getClassLoader();
	String resource = "org/biojava/nbio/structure/io/mmtf/4CUP";
	
	// Load the structures into memory
	Structure mmtf = MmtfActions.readFromFile((
			Paths.get(classLoader.getResource(resource + ".mmtf").getPath())));
	Structure mmcif = StructureIO.getStructure(classLoader.getResource(resource + ".cif").getPath());
	
	// Compare the dates of the structure
	assertEquals(mmcif.getPDBHeader().getDepDate(), 
			mmtf.getPDBHeader().getDepDate());
	
	// Compare the experimental method
	assertEquals(mmcif.getPDBHeader().getExperimentalTechniques(), 
			mmtf.getPDBHeader().getExperimentalTechniques());
	
	// Compare the SEQRES, see issue https://github.com/biojava/biojava/issues/671
	assertEquals(mmcif.getChainByIndex(0).getSeqResSequence(), 
			mmtf.getChainByIndex(0).getSeqResSequence());
	
}
 
Example #9
Source File: RotationOrderDetectorTest.java    From symmetry with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Test
public void testTrySingleCuspFixedBySSE() throws IOException,
		StructureException {
	String name;
	RotationOrderDetector detector = new RotationOrderDetector(8,
			SINGLE_CUSP_FIXED_SSE);

	// Perform alignment to determine axis
	Atom[] ca1;
	AFPChain alignment;
	RotationAxis axis;
	double[] coefs, expectedHarmonics;

	name = "1MER.A";
	ca1 = StructureTools.getAtomCAArray(StructureTools.getStructure(name));
	alignment = CeSymm.analyze(ca1, params).getSelfAlignment();
	axis = new RotationAxis(alignment);

	coefs = detector.trySingleOrdersBySSE(ca1, axis);
	expectedHarmonics = new double[] { 0.4023477, 0.1485084, 0.3794772,
			0.3946517, 0.3969921, 0.4006527, 0.4033445, 0.4056923, };

	assertArrayEquals(name, expectedHarmonics, coefs, 1e-2);
}
 
Example #10
Source File: OptimalCECPMain.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Aligns ca1 with ca2 permuted by <i>cp</i> residues.
 * <p><strong>WARNING:</strong> Modifies ca2 during the permutation. Be sure
 * to make a copy before calling this method.
 *
 * @param ca1
 * @param ca2
 * @param param
 * @param cp
 * @return
 * @throws StructureException
 */
public AFPChain alignPermuted(Atom[] ca1, Atom[] ca2, Object param, int cp) throws StructureException {
	// initial permutation
	permuteArray(ca2,cp);

	// perform alignment
	AFPChain afpChain = super.align(ca1, ca2, param);

	// un-permute alignment
	permuteAFPChain(afpChain, -cp);

	if(afpChain.getName2() != null) {
		afpChain.setName2(afpChain.getName2()+" CP="+cp);
	}

	// Specify the permuted
	return afpChain;
}
 
Example #11
Source File: TestQuatSymmetryDetectorExamples.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * A structure with very similar entities (clustering at 95% seq id): 4DZ8
 * @throws IOException
 * @throws StructureException
 */
@Test
public void testPseudoIdentity95() throws IOException, StructureException {
	Structure pdb = StructureIO.getStructure("BIO:4DZ8:1");

	SubunitClustererParameters cp = new SubunitClustererParameters();
	cp.setSequenceIdentityThreshold(0.95);
	cp.setSequenceCoverageThreshold(0.95);
	cp.setClustererMethod(SubunitClustererMethod.SEQUENCE);
	QuatSymmetryParameters symmParams = new QuatSymmetryParameters();

	QuatSymmetryResults symmetry = QuatSymmetryDetector.calcGlobalSymmetry(
			pdb, symmParams, cp);

	assertEquals("C2", symmetry.getSymmetry());
	assertEquals("A2", symmetry.getStoichiometry().toString());
	assertFalse(symmetry.isPseudoStoichiometric());
	assertEquals(SubunitClustererMethod.SEQUENCE, symmetry.getSubunitClusters().get(0).getClustererMethod());

}
 
Example #12
Source File: AtomCacheTest.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Tests {@link AtomCache#getStructureForDomain(String)} on a multi-chain domain with two zinc ligands that occurs after the TER. The ligands are in chains E and F, so they should not be included in the domain.
 */
@Test
public void testGetStructureForDomain2() throws IOException, StructureException {
	String ranges = "A:,B:";
	Structure whole = cache.getStructure("1I3O");
	AtomPositionMap map = new AtomPositionMap(StructureTools.getAllAtomArray(whole), AtomPositionMap.ANYTHING_MATCHER);
	List<ResidueRangeAndLength> rrs = ResidueRangeAndLength.parseMultiple(ranges, map);
	int expectedLengthA = rrs.get(0).getLength();
	int expectedLengthB = rrs.get(1).getLength();
	Structure structure = cache.getStructureForDomain("d1i3o.1");
	assertEquals(2, structure.getPolyChains().size());
	Chain a = structure.getPolyChainByPDB("A");
	Chain b = structure.getPolyChainByPDB("B");
	// since biojava 5.0 we have no ligand or water molecules in the polymer chains, we have to subtract the 3 water molecules
	assertEquals(expectedLengthA - 3, a.getAtomGroups().size());
	// since biojava 5.0 we have no ligand or water molecules in the polymer chains, we have to subtract the 4 water molecules
	assertEquals(expectedLengthB - 4, b.getAtomGroups().size());
	List<Group> ligandsA = StructureTools.filterLigands(b.getAtomGroups());
	assertEquals(0, ligandsA.size());
	List<Group> ligandsB = StructureTools.filterLigands(b.getAtomGroups());
	assertEquals(0, ligandsB.size());
}
 
Example #13
Source File: RemoteDomainProvider.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
private SortedSet<String> getPDPDomains(StructureName n) throws IOException, StructureException {
	SortedSet<String> pdpDomains = pdp.getPDPDomainNamesForPDB(n.getPdbId());

	SortedSet<String> r = new TreeSet<String>();
	String chainID = n.getChainId();
	for ( String s : pdpDomains){
		StructureName d = new StructureName(s);
		if ( chainID == null)
			r.add(s);
		else if ( d.getChainId().equals(n.getChainId())){
			r.add(s);
		}
	}
	logger.info(n + " got PDP domains: "+ r);
	return r;
}
 
Example #14
Source File: TestSubunitExtractor.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Make sure that only aminoacid chains are extracted: 5B2I.
 */
@Test
public void testHistone() throws StructureException, IOException {

	Structure s = StructureIO.getStructure("5B2I");

	List<Subunit> subunits = SubunitExtractor.extractSubunits(s, 5, 0.75, 20);

	// We expect all 8 histone subunits to be returned
	assertEquals(subunits.size(), 8);
	assertEquals(subunits.get(0).size(), 99);
	assertEquals(subunits.get(1).size(), 82);
	assertEquals(subunits.get(2).size(), 106);
}
 
Example #15
Source File: AlignmentGui.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void updateAlgorithm(String algorithmName) {

		//String algorithmName = (String)algorithmList.getSelectedItem();
		try {
			algorithm = StructureAlignmentFactory.getAlgorithm(algorithmName);
		} catch (StructureException ex){
			ex.printStackTrace();
		}

	}
 
Example #16
Source File: TestSubunitClustererExamples.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Test modified residues: 1HIV
 */
@Test
public void testPTMs() throws StructureException, IOException {

	Structure s = StructureIO.getStructure("1hiv");
	SubunitClustererParameters params = new SubunitClustererParameters();
	params.setClustererMethod(SubunitClustererMethod.SEQUENCE);

	List<SubunitCluster> clusters = SubunitClusterer.cluster(s, params).getClusters();

	// We expect a single cluster with length 99
	assertEquals(clusters.size(), 1);
	assertEquals(clusters.get(0).length(), 99);
}
 
Example #17
Source File: DSSPParser.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Fetch and parse the DSSP file of the specified pdb code
 * from the PDB web server and return the secondary structure
 * annotation as a List of {@link SecStrucState} objects.
 *
 * @param pdb path to the DSSP file to parse
 * @param structure Structure object associated to the dssp
 * @param assign assigns the SS to the structure if true
 * @return a List of SS annotation objects
 * @throws StructureException
 * @throws IOException
 */
public static List<SecStrucState> fetch(String pdb,
		Structure structure, boolean assign)
				throws IOException, StructureException {

	URL url = new URL("http://files.rcsb.org/dssp/" +
			pdb.toLowerCase().substring(1, 3) + "/" +
			pdb.toLowerCase() + "/" +
			pdb.toLowerCase() + ".dssp.gz");
	InputStream in = new GZIPInputStream(url.openStream());
	Reader read = new InputStreamReader(in);
	BufferedReader reader = new BufferedReader(read);
	return generalParse(reader, structure, assign);
}
 
Example #18
Source File: SequenceFunctionRefiner.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public MultipleAlignment refine(AFPChain selfAlignment, Atom[] atoms,
		int order) throws RefinerFailedException, StructureException {

	if (order < 2)	throw new RefinerFailedException(
			"Symmetry not found in the structure: order < 2.");

	AFPChain afp = refineSymmetry(selfAlignment, atoms, atoms, order);
	return SymmetryTools.fromAFP(afp, atoms);
}
 
Example #19
Source File: BlastClustersTest.java    From mmtf-spark with Apache License 2.0 5 votes vote down vote up
@Test
/**
 * This test runs a pdb level query and compares the results at the PDB entry level
 * @throws IOException
 */
public void test1() throws IOException, StructureException {
	pdb = pdb.filter(new BlastClusters(40));
	List<String> matches = pdb.keys().collect();
	
	assertTrue(matches.contains("1O06"));
	assertFalse(matches.contains("1O06.A"));
	assertFalse(matches.contains("2ONX"));
}
 
Example #20
Source File: FragmentJoiner.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get the RMS of the JointFragments pair frag
 *
 * @param ca1 the array of all atoms of structure1
 * @param ca2 the array of all atoms of structure1
 * @param frag the JointFragments object that contains the list of identical positions
 * @return the rms
 */
public static double getRMS(Atom[] ca1, Atom[]ca2,JointFragments frag) throws StructureException {
	//      now svd ftmp and check if the rms is < X ...
	AlternativeAlignment ali = new AlternativeAlignment();
	ali.apairs_from_idxlst(frag);
	double rms = 999;

	int[] idx1 = ali.getIdx1();
	int[] idx2 = ali.getIdx2();

	Atom[] ca1subset = AlignUtils.getFragmentFromIdxList(ca1, idx1);

	Atom[] ca2subset = AlignUtils.getFragmentFromIdxList(ca2,idx2);

	ali.calculateSuperpositionByIdx(ca1,ca2);

	Matrix rot = ali.getRotationMatrix();
	Atom atom = ali.getShift();

	for (Atom a : ca2subset) {
		Calc.rotate(a, rot);
		Calc.shift(a, atom);
	}

	rms = Calc.rmsd(ca1subset,ca2subset);

	return rms;
}
 
Example #21
Source File: AFPFromFasta.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void main(String[] args) throws IOException, StructureException, Exception {
	Structure structure1 = StructureTools.getStructure("1w0p");
	Structure structure2 = StructureTools.getStructure("1w0p");
	String first = "alfdynatgdtefdspakqgwmqdntnngsgvltnadgmpawlvqgiggraqwtyslstnqhaqassfgwrmttemkvlsggmitnyyangtqrvlpiisldssgnlvvefegqtgrtvlatgtaateyhkfelvflpgsnpsasfyfdgklirdniqptaskQNMIVWGNGSSntdgvaayrdikfei------------------------------------------------------------------------------------------------------------------QGDVIf------------RGPDRIPSIVASsvTPGVVTAFAEKRVGGgdpgalsntNDIITRTSRDGGITWDTELNLTEQinvsdeFDFSDPRPIYDPs---SNTVLVSYARWPtdaaqngdrikpwmpNGIFYSVYDVASgnWQAPIDVTdqvkersfqiagwggselyrrntslnsqqdwqsnakirivdgaanqiqvadgsrkyvvtlsidesgglvanlngvsapiilqsehakvhsfhdyelqysalnhtttlfvdgqqittwagevsqenniqfgnadaqidgrlhvqkivltqqghnlvefdafylaqqtpevekdleklgwtkiktgntmslygNASVNPGpgHGITLtrqqnisgsqNGRLIYPAIVLdrfFLNVMSIYSDDGgsnwq-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------TGSTLpipfrwksssileTLEPSEADMVELQN--GDLLLTARLDFNQivngvny--SPRQQFLSKDGGITWSLLEANNANvfsnistgTVDASITRFEqsdgSHFLLFTNPQGnpagTNgr------------QNLGLWFSFDEG--VTWKGPIQ--LVNGasaysdiyqldsenaivivetdnsnmrilrmpitllkqklt";
	String second = "--------------------------------------------------------------------------------------------kirivdgaanqiqvadgsrkyvvtlsidesgglvanlngvsapiilqsehakvhsfhdyelqysalnhtttLFVDGQQITTWagevsqenniqfgnadaqidgrlhvqkivltqqghnlvefdafylaqqtpevekdleklgwtkiktgntmslygnasvnpgpghgitltrqqnisgsqngrliypaivldrfflnvmsiysddggsnwqTGSTLpipfrwksssileTLEPSEADMVEL--QNGDLLLTARLDFNQivngvny--SPRQQFLSKDGGITWSLLEANNANvfsnisTGTVDASITRFEqsdgSHFLLFTNPQGNpagtngr--------QNLGLWFSFDEG--VTWKGPIQlv---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------NGASAYS--DIYQLd---------SENAIVIVETD---NSNMRILRMPITllkqkltalfdynatgdtefdspakqgwmqdntnngsgvltnadgmpawlvqgiggraqwtyslstnqhaqassfgwrmttemkvlsggmitnyyangtqrvlpiisldssgnlvvefegqtgrtvlatgtaateyhkfelvflpgsnpsasfyfdgklirdniqptaskqnmivwgngssntdgvaayrdikfeiQGDVIf------------RGPDRIPSIVASSVtpGVVTAFAEKRVGGgdpgalsntNDIITRTSRDGGITWDTELNLTEQinvsdefdFSDPRPIYDPs---SNTVLVSYARW----PTdaaqngdrikpwmpNGIFYSVYDVASgnWQAPIDVTdqVKERsfqiagwggselyrrntslnsqqdwqsna------------";
	AFPChain afpChain = FastaAFPChainConverter.cpFastaToAfpChain(first, second, structure1, -393);
	Atom[] ca1 = StructureTools.getAtomCAArray(structure1);
	Atom[] ca2 = StructureTools.getAtomCAArray(structure2);
	String xml = AFPChainXMLConverter.toXML(afpChain);
	System.out.println(xml);
	double tmScore = AFPChainScorer.getTMScore(afpChain, ca1, ca2);
	afpChain.setTMScore(tmScore);
	System.out.println(AfpChainWriter.toScoresList(afpChain));
	StructureAlignmentDisplay.display(afpChain, ca1, ca2);
}
 
Example #22
Source File: RemoteDomainProvider.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void main(String[] args) throws IOException, StructureException{
	String name ="3KIH.A";
	RemoteDomainProvider me = new RemoteDomainProvider(true);
	System.out.println(me.getDomainNames(name));
	StructureName n = new StructureName(name);
	System.out.println(n);
	//System.out.println(new  AtomCache().getStructure(name));
	me.flushCache();
}
 
Example #23
Source File: AFPChainXMLConverter.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void printXMLEQRKnownPositions(PrettyXMLWriter xml,
		AFPChain afpChain, int blockNr) throws IOException, StructureException{
	int[] optLen       = afpChain.getOptLen();


	String[][][] pdbAln = afpChain.getPdbAln();
	if ( pdbAln == null){
		throw new StructureException("Can't convert to XML without known the PDB coordinates. Please provide Ca atoms and call toXML(afpChain,ca1, ca2)");
	}

	for ( int eqrNr = 0 ; eqrNr < optLen[blockNr] ; eqrNr++ ){

		String pdbResnum1 = pdbAln[blockNr][0][eqrNr];
		String pdbResnum2 = pdbAln[blockNr][1][eqrNr];

		//System.out.println(eqrNr + " got resnum: " + pdbResnum1 + " " + pdbResnum2);

		String[] spl1 = pdbResnum1.split(":");
		String[] spl2 = pdbResnum2.split(":");

		String chain1 = spl1[0];
		String pdbres1 = spl1[1];

		String chain2 = spl2[0];
		String pdbres2 = spl2[1];

		xml.openTag("eqr");
		xml.attribute("eqrNr", String.valueOf(eqrNr));
		xml.attribute("pdbres1",pdbres1);
		xml.attribute("chain1", chain1);
		xml.attribute("pdbres2",pdbres2);
		xml.attribute("chain2", chain2);
		xml.closeTag("eqr");
	}
}
 
Example #24
Source File: RotationOrderDetector.java    From symmetry with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * For each order from 1 to maxOrder, calculate the amplitude from fitting
 * a single-order function (with intercept).
 * @param ca
 * @param axis
 * @param orders array of orders to compute
 * @return An array of length maxOrder containing the amplitude of the function
 * @throws StructureException For errors applying the rotation
 */
public double[] trySingleOrdersByAmp(Atom[] ca, RotationAxis axis,int[] orders) throws StructureException {
	double[] amps = new double[orders.length];

	for( int i = 0;i<orders.length;i++) {
		// Calculate RSSE (could save some arithmetic, but this is easier to compare)
		double[] weights = getWeightsForFit(ca, axis, new int[] {0,orders[i]});
		amps[i] = weights[1];
	}

	return amps;
}
 
Example #25
Source File: DBResultTable.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Structure loadCustomStructure(String userPath2, String userChain2) throws StructureException{
	StructureIOFile reader = new PDBFileReader();
	Structure s = null;
	try {
		s = reader.getStructure(userPath2);
	} catch (IOException  e){

		//e.printStackTrace();
		throw new StructureException(e);
	}


	return StructureTools.getReducedStructure(s, userChain2);
}
 
Example #26
Source File: MultipleAlignmentScorer.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Calculates the average TMScore all the possible pairwise structure
 * comparisons of the given a set of superimposed Atoms and the original
 * structure lengths.
 * <p>
 * Complexity: T(n,l) = O(l*n^2), if n=number of structures and l=alignment
 * length.
 *
 * @param transformed
 *            aligned Atoms transformed
 * @param lengths
 *            lengths of the structures in residue number
 * @return double Average TMscore
 * @throws StructureException
 */
public static double getAvgTMScore(List<Atom[]> transformed,
		List<Integer> lengths) throws StructureException {

	if (transformed.size() != lengths.size())
		throw new IllegalArgumentException("Input sizes differ.");

	double sumTM = 0;
	int comparisons = 0;

	for (int r1 = 0; r1 < transformed.size(); r1++) {
		for (int r2 = r1 + 1; r2 < transformed.size(); r2++) {
			int len = transformed.get(r1).length;
			// Remove nulls from both arrays
			Atom[] ref = new Atom[len];
			Atom[] aln = new Atom[len];
			int nonNullLen = 0;
			for (int c = 0; c < len; c++) {
				if (transformed.get(r1)[c] != null
						&& transformed.get(r2)[c] != null) {
					ref[nonNullLen] = transformed.get(r1)[c];
					aln[nonNullLen] = transformed.get(r2)[c];
					nonNullLen++;
				}
			}
			// Truncate nulls
			if (nonNullLen < len) {
				ref = Arrays.copyOf(ref, nonNullLen);
				aln = Arrays.copyOf(aln, nonNullLen);
			}
			sumTM += Calc.getTMScore(ref, aln, lengths.get(r1),
					lengths.get(r2));
			comparisons++;
		}
	}
	return sumTM / comparisons;
}
 
Example #27
Source File: MultipleAlignmentTools.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Get an artificial Structure containing a different model for every
 * input structure, so that the alignment result can be viewed in Jmol.
 * The Atoms have to be rotated beforehand.
 *
 * @param atomArrays an array of Atoms for every aligned structure
 * @return a structure object containing a set of models,
 * 			one for each input array of Atoms.
 * @throws StructureException
 */
public static final Structure getAlignedStructure(List<Atom[]> atomArrays)
		throws StructureException {

	Structure s = new StructureImpl();
	for (int i=0; i<atomArrays.size(); i++){
		List<Chain> model = AlignmentTools.getAlignedModel(atomArrays.get(i));
		s.addModel(model);
	}
	return s;
}
 
Example #28
Source File: FastaAFPChainConverterTest.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testCpSymmetric1() throws IOException,StructureException, CompoundNotFoundException {
	//cat 2GG6-best.fasta |tr -d \\n|pbcopy
	String a = "-SSRPATAR-KSSGLSGTVRIPGDKSISHRSFMFGGLA-SGETRITGLLEG-EDvINTGKAMQAMGARIRKEGd---------TWIIDGVgngglLAPEAPLD---FGNAATGCRLTMGLVGvydFDSTFIGDASLtkrp---MGRVLNPLREMGVQVKSEDgdrLPVTLRGPK---TPT---PITYRVpMASAQVKSAVLLAGLNTPGITTVIEpi---MTRDHTEKMLQGFGANLTVEtdadGVRTIRLEgRGKLTGQVIDVPGDPSSTAFPLVAALLVpGSDVTILNVLMNpTR-TGLILTLQEMGADIEVINprlaggedvaDLRVRSS-----TLKGVTVPedrAPSMIDEYPILAVAAAFAEGATVMNGLEELrvkesdrLSAVANGLKLNGVDCDEGE---TSLVVRGRPdgkGLGNasgAAVAT-HLDHRIAMSFLVMGLVSENPVTVDDatmIATSFPEFMDLMAGLGAKIELS---";
	String b = "dGVRTIRLEgRGKLTGQVIDVPGDPSSTAFPLVAALLVpGSDVTILNVLMNpTR-TGLILTLQEMGADIEVINprlaggedvaDLRVRSS-----TLKGVTVPedrAPSMIDEYPILAVAAAfaeGATVMNGLEELrvkesdrLSAVANGLKLNGVDCDEGE---TSLVVRGRPdgkGLGnasGAAVAT-HLDHRIAMSFLVMGLVSENPVTVDDatmiaTSFPEFMDLMAGLGAKIELS----SSRPATAR-KSSGLSGTVRIPGDKSISHRSFMFGGLA-SGETRITGLLEG-EDvINTGKAMQAMGARIRKEGd---------TWIIDGVgngglLAPEAPLD---FGNAATGCRLTMGLVGVYDFDSTFIGDASLtkrp---MGRVLNPLREMGVQVKSEDgdrLPVTLRGPK---TPTP---ITYRVpMASAQVKSAVLLAGLNTPGITTVIE---PIMTRDHTEKMLQGFGANLTVEtda";
	Structure structure = StructureTools.getStructure("2GG6");
	AFPChain afpChain = FastaAFPChainConverter.cpFastaToAfpChain(a, b, structure, -230); // 215
	assertEquals("Wrong TM-score", 0.7701, afpChain.getTMScore(), 0.001);
	assertEquals("Wrong RMSD", 3.035, afpChain.getTotalRmsdOpt(), 0.001);
}
 
Example #29
Source File: CEMirrorSymm.java    From symmetry with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Reverses an array of atoms. Really only useful for the detection of
 * mirror symmetries, of which there are only few in the PDB.
 * 
 * @param ca2
 *            Array to be reversed
 * @return A cloned and reversed copy of ca2
 * @throws StructureException
 */
public static Atom[] reverseCA2(Atom[] ca2) throws StructureException {
	// we don't want to rotate input atoms, do we?
	Atom[] ca2clone = new Atom[ca2.length];

	int pos = ca2clone.length - 1;

	Chain c = new ChainImpl();
	for (Atom a : ca2) {
		Group g = (Group) a.getGroup().clone(); // works because each group
												// has only a CA atom
		c.addGroup(g);
		ca2clone[pos] = g.getAtom(a.getName());

		pos--;
	}

	// // Duplicate ca2!
	// for (Atom a : ca2){
	// Group g = (Group)a.getGroup().clone();
	// c.addGroup(g);
	// ca2clone[pos] = g.getAtom(StructureTools.caAtomName);
	//
	// pos--;
	// }

	return ca2clone;

}
 
Example #30
Source File: TestSecStrucCalc.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Test that calculating the secondary structure for multi-model systems works.
 * Combine two PDBs into one multi-model system
 * Calculate the secondary structure
 * Combine with the combined list fetching from the server
 * @throws StructureException
 * @throws IOException
 */
@Test
public void testMultiModelPred() throws StructureException, IOException {

	String pdbId = "5pti";
	String pdbIdTwo = "4hhb";
	SecStrucCalc sec = new SecStrucCalc();
	// Combine these into one structure with two models
	AtomCache cache = new AtomCache();
	Structure structure = cache.getStructure(pdbId);
	Structure structureTwo = cache.getStructure(pdbIdTwo);
	// Join them together
	structure.addModel(structureTwo.getChains());

	List<SecStrucState> biojava = sec.calculate(structure, true);

	// Download the original DSSP implementation output
	List<SecStrucState> dssp = DSSPParser.parseInputStream(new GZIPInputStream(
			this.getClass().getResourceAsStream("/org/biojava/nbio/structure/secstruc/"+pdbId+".dssp.gz")),cache.getStructure(pdbId), false);
	dssp.addAll(DSSPParser.parseInputStream(new GZIPInputStream(
			this.getClass().getResourceAsStream("/org/biojava/nbio/structure/secstruc/"+pdbIdTwo+".dssp.gz")), cache.getStructure(pdbIdTwo), false));

	assertEquals("SS assignment lengths do not match",
			biojava.size(), dssp.size());

	for (int i=0; i<dssp.size(); i++){
		assertEquals("SS assignment position "+(i+1)+" does not match",
				biojava.get(i), dssp.get(i));
	}
}