Java Code Examples for org.biojava.nbio.structure.StructureException#printStackTrace()

The following examples show how to use org.biojava.nbio.structure.StructureException#printStackTrace() . 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: 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 2
Source File: MultipleAlignmentCalc.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void run() {

	MultipleStructureAligner algorithm =
			parent.getMultipleStructureAligner();
	try {

		List<Atom[]> atomArrays = new ArrayList<Atom[]>();
		for (Structure s:structures){
			Atom[] ca = StructureTools.getRepresentativeAtomArray(s);
			atomArrays.add(ca);
		}

		MultipleAlignment msa = algorithm.align(atomArrays);
		msa.getEnsemble().setStructureIdentifiers(names);

		MultipleAlignmentJmolDisplay.display(msa);

	} catch (StructureException e) {
		e.printStackTrace();
		logger.warn(e.getMessage());
	}

	parent.notifyCalcFinished();
}
 
Example 3
Source File: MultipleAlignmentJmol.java    From biojava with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
protected void initCoords() {
	try {
		if (multAln == null) {
			if (structure != null)
				setStructure(structure);
			else {
				logger.error("Could not find anything to display!");
				return;
			}
		}
		Structure artificial = MultipleAlignmentTools.toMultimodelStructure(multAln, transformedAtoms);
		setStructure(artificial);
		logger.info(artificial.getPDBHeader().getTitle());
	} catch (StructureException e) {
		e.printStackTrace();
	}
}
 
Example 4
Source File: BiojavaAligner.java    From mmtf-spark with Apache License 2.0 5 votes vote down vote up
/**
	 * Calculates a structural alignment and returns alignment metrics.
	 * 
	 * @param alignmentAlgorithm name of the algorithm
	 * @param key unique identifier for protein chain pair
	 * @param points1 C-alpha positions of chain 1
	 * @param points2 C-alpha positions of chain 2
	 * @return
	 */
	public static List<Row> getAlignment(String alignmentAlgorithm, String key, Point3d[] points1, Point3d[] points2) {
		// create input for BioJava alignment method
		Atom[] ca1 = getCAAtoms(points1);
		Atom[] ca2 = getCAAtoms(points2);
		
		// calculate the alignment
		AFPChain afp = null;
		try {
			StructureAlignment algorithm  = StructureAlignmentFactory.getAlgorithm(alignmentAlgorithm);
			afp = algorithm.align(ca1,ca2);
			double tmScore = AFPChainScorer.getTMScore(afp, ca1, ca2);
			afp.setTMScore(tmScore);
		} catch (StructureException e) {
			e.printStackTrace();
			return Collections.emptyList();
		} 
		
		// TODO add alignments as arrays to results
//		int[][] alignment = afp.getAfpIndex();
//		for (int i = 0; i < alignment.length; i++) {
//			System.out.println(alignment[i][0] + " - " + alignment[i][1]);
//		}

		// record the alignment metrics
		Row row = RowFactory.create(key, afp.getOptLength(), afp.getCoverage1(), 
				afp.getCoverage2(), (float) afp.getTotalRmsdOpt(), (float) afp.getTMScore());

		return Collections.singletonList(row);
	}
 
Example 5
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 6
Source File: MultipleAlignmentGUI.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void updatePairwiseAlgorithm(String algorithmName) {
	try {
		pairwise = StructureAlignmentFactory.getAlgorithm(algorithmName);
		//Update also the multiple structure algorithm
		ConfigStrucAligParams params = multiple.getParameters();
		updateMultipleAlgorithm();
		multiple.setParameters(params);

	} catch (StructureException ex){
		ex.printStackTrace();
	}
}
 
Example 7
Source File: StatusDisplay.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void rangeSelected(AlignedPosition start, AlignedPosition end) {
	char[] aligs1  = afpChain.getAlnseq1();
	char[] aligs2  = afpChain.getAlnseq2();

	char c1 = aligs1[start.getPos1()];
	char c3 = aligs1[end.getPos1()];

	char c2 = aligs2[start.getPos2()];
	char c4 = aligs2[end.getPos2()];

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

		Atom a3 = DisplayAFP.getAtomForAligPos(afpChain, 0, end.getPos1(), ca1,false);
		Atom a4 = DisplayAFP.getAtomForAligPos(afpChain, 1, end.getPos2(), ca2,true);

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

		String pdbInfo3 = JmolTools.getPdbInfo(a3);
		String pdbInfo4 = JmolTools.getPdbInfo(a4);

		String msg =  "Selected range1: " + pdbInfo1 + " ("+c1+") - " + pdbInfo3 + " ("+c3+")";
		msg       +=  " range2: "         + pdbInfo2 + " ("+c2+") - " + pdbInfo4 + " ("+c4+")";


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


}
 
Example 8
Source File: AligPanel.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void updateJmolDisplay() {

		if ( jmol == null)
			return;

		int size = afpChain.getAlnLength();

		StringBuffer cmd = new StringBuffer("select ");

		int nrSelected = 0;
		try {

			for (int i = 0 ; i< size ; i++){
				if ( selection.get(i)){

					Atom a1 = DisplayAFP.getAtomForAligPos(afpChain, 0,i, ca1, false);
					Atom a2 = DisplayAFP.getAtomForAligPos(afpChain, 1,i, ca2, false);

					String select1 = "";

					if ( a1 != null )
						select1 = JmolTools.getPdbInfo(a1);
					String select2 = "" ;
					if ( a2 != null)
						select2 = JmolTools.getPdbInfo(a2);

					// nothing to display
					if ( select1.equals("") && select2.equals(""))
						continue;

					if ( nrSelected > 0)
						cmd.append(", ");

					cmd.append(select1);
					cmd.append("/1, ");
					cmd.append(select2);
					cmd.append("/2");
					nrSelected++;
				}
			}


		} catch (StructureException e){
			e.printStackTrace();
		}
		if ( nrSelected == 0)
			cmd.append(" none;");
		else
			cmd.append("; set display selected;");

		jmol.evalString(cmd.toString());


	}
 
Example 9
Source File: StatusDisplay.java    From biojava with GNU Lesser General Public License v2.1 3 votes vote down vote up
@Override
public void mouseOverPosition(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 = "alig pos:" + p.getPos1()+ " " +  pdbInfo1 + " ("+c1+") : " + pdbInfo2 + " ("+c2+")";

		this.setText(msg);



	} catch (StructureException e){
		e.printStackTrace();
	}

	this.repaint();

}
 
Example 10
Source File: AlignmentCalc.java    From biojava with GNU Lesser General Public License v2.1 2 votes vote down vote up
@Override
public void run() {

	// both structure have been downloaded, now calculate the alignment ...

	StructureAlignment algorithm = parent.getStructureAlignment();
	//StructurePairAligner aligner = new StructurePairAligner();
	//aligner.setDebug(true);
	try {

		Atom[] ca1 = StructureTools.getRepresentativeAtomArray(structure1);
		Atom[] ca2 = StructureTools.getRepresentativeAtomArray(structure2);

		//System.out.println("ca1 size:" + ca1.length + " ca2 size: " + ca2.length);
		AFPChain afpChain = algorithm.align(ca1, ca2);

		afpChain.setName1(name1);
		afpChain.setName2(name2);

		StructureAlignmentJmol jmol =   StructureAlignmentDisplay.display(afpChain, ca1, ca2);

		String title = jmol.getTitle();
		ConfigStrucAligParams params = algorithm.getParameters();
		if ( params != null)
			title += " " + algorithm.getParameters().toString();
		jmol.setTitle(title);

		DisplayAFP.showAlignmentPanel(afpChain,ca1,ca2,jmol);

		System.out.println(afpChain.toCE(ca1,ca2));

	} catch (StructureException e){
		e.printStackTrace();
		logger.warn(e.getMessage());
	}



	//logger.info("done!");

	parent.notifyCalcFinished();

}