Java Code Examples for org.biojava.nbio.structure.align.model.AFPChain#setAlgorithmName()
The following examples show how to use
org.biojava.nbio.structure.align.model.AFPChain#setAlgorithmName() .
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: AFPChainXMLParser.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** Takes an XML representation of the alignment and flips the positions of name1 and name2 * * @param xml String representing the alignment * @return XML representation of the flipped alignment */ public static String flipAlignment(String xml) throws IOException,StructureException{ AFPChain[] afps = parseMultiXML( xml); if ( afps.length < 1 ) return null; if ( afps.length == 1) { AFPChain newChain = AFPChainFlipper.flipChain(afps[0]); if ( newChain.getAlgorithmName() == null) { newChain.setAlgorithmName(DEFAULT_ALGORITHM_NAME); } return AFPChainXMLConverter.toXML(newChain); } throw new StructureException("not Implemented yet!"); }
Example 2
Source File: FatCatFlexible.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
@Override public AFPChain align(Atom[] ca1, Atom[] ca2) throws StructureException { AFPChain afpChain = alignFlexible(ca1, ca2, params); afpChain.setAlgorithmName(algorithmName); afpChain.setVersion(VERSION+""); return afpChain; }
Example 3
Source File: FatCatFlexible.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
@Override public AFPChain align(Atom[] ca1, Atom[] ca2, Object param) throws StructureException { if ( ! (param instanceof FatCatParameters)){ throw new IllegalArgumentException("FatCat algorithm needs FatCatParameters object as argument."); } params = (FatCatParameters) param; AFPChain afpChain= alignFlexible(ca1, ca2, params); afpChain.setAlgorithmName(algorithmName); afpChain.setVersion(VERSION+""); return afpChain; }
Example 4
Source File: FatCat.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
public AFPChain alignRigid(Atom[] ca1, Atom[] ca2, FatCatParameters params) throws StructureException{ AFPChain afpChain = align(ca1,ca2,params,true); afpChain.setAlgorithmName(FatCatRigid.algorithmName); afpChain.setVersion(VERSION+""); return afpChain; }
Example 5
Source File: FatCat.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
public AFPChain alignFlexible(Atom[] ca1, Atom[] ca2, FatCatParameters params) throws StructureException{ AFPChain afpChain = align(ca1,ca2,params,false); afpChain.setAlgorithmName(FatCatFlexible.algorithmName); afpChain.setVersion(VERSION+""); return afpChain; }
Example 6
Source File: FatCatRigid.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
@Override public AFPChain align(Atom[] ca1, Atom[] ca2) throws StructureException { AFPChain afpChain = alignRigid(ca1, ca2, params); afpChain.setAlgorithmName(algorithmName); afpChain.setVersion(VERSION+""); return afpChain; }
Example 7
Source File: FatCatRigid.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
@Override public AFPChain align(Atom[] ca1, Atom[] ca2, Object param) throws StructureException { if ( ! (param instanceof FatCatParameters)){ throw new IllegalArgumentException("FatCat algorithm needs FatCatParameters object as argument."); } params = (FatCatParameters) param; AFPChain afpChain= alignRigid(ca1, ca2, params); afpChain.setAlgorithmName(algorithmName); afpChain.setVersion(VERSION+""); return afpChain; }
Example 8
Source File: FastaAFPChainConverter.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** * Builds an {@link AFPChain} from already-matched arrays of atoms and residues. * * @param ca1 * An array of atoms in the first structure * @param ca2 * An array of atoms in the second structure * @param residues1 * An array of {@link ResidueNumber ResidueNumbers} in the first structure that are aligned. Only null ResidueNumbers are considered to be unaligned * @param residues2 * An array of {@link ResidueNumber ResidueNumbers} in the second structure that are aligned. Only null ResidueNumbers are considered to be unaligned * @throws StructureException */ private static AFPChain buildAlignment(Atom[] ca1, Atom[] ca2, ResidueNumber[] residues1, ResidueNumber[] residues2) throws StructureException { // remove any gap // this includes the ones introduced by the nullifying above List<ResidueNumber> alignedResiduesList1 = new ArrayList<ResidueNumber>(); List<ResidueNumber> alignedResiduesList2 = new ArrayList<ResidueNumber>(); for (int i = 0; i < residues1.length; i++) { if (residues1[i] != null && residues2[i] != null) { alignedResiduesList1.add(residues1[i]); alignedResiduesList2.add(residues2[i]); } } ResidueNumber[] alignedResidues1 = alignedResiduesList1.toArray(new ResidueNumber[alignedResiduesList1.size()]); ResidueNumber[] alignedResidues2 = alignedResiduesList2.toArray(new ResidueNumber[alignedResiduesList2.size()]); AFPChain afpChain = AlignmentTools.createAFPChain(ca1, ca2, alignedResidues1, alignedResidues2); afpChain.setAlgorithmName("unknown"); AlignmentTools.updateSuperposition(afpChain, ca1, ca2); afpChain.setBlockSize(new int[] {afpChain.getNrEQR()}); afpChain.setBlockRmsd(new double[] {afpChain.getTotalRmsdOpt()}); afpChain.setBlockGap(new int[] {afpChain.getGapLen()}); return afpChain; }
Example 9
Source File: CeSymm.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
private static Matrix align(AFPChain afpChain, Atom[] ca1, Atom[] ca2, CESymmParameters params, Matrix origM, CECalculator calculator, int counter) throws StructureException { int fragmentLength = params.getWinSize(); Atom[] ca2clone = StructureTools.cloneAtomArray(ca2); int rows = ca1.length; int cols = ca2.length; // Matrix that tracks similarity of a fragment of length fragmentLength // starting a position i,j. int blankWindowSize = fragmentLength; if (origM == null) { // Build alignment ca1 to ca2-ca2 afpChain = calculator.extractFragments(afpChain, ca1, ca2clone); origM = SymmetryTools.blankOutPreviousAlignment(afpChain, ca2, rows, cols, calculator, null, blankWindowSize); } else { // we are doing an iteration on a previous alignment // mask the previous alignment origM = SymmetryTools.blankOutPreviousAlignment(afpChain, ca2, rows, cols, calculator, origM, blankWindowSize); } Matrix clone = (Matrix) origM.clone(); // that's the matrix to run the alignment on.. calculator.setMatMatrix(clone.getArray()); calculator.traceFragmentMatrix(afpChain, ca1, ca2clone); final Matrix origMfinal = (Matrix) origM.clone(); // Add a matrix listener to keep the blacked zones in max. calculator.addMatrixListener(new MatrixListener() { @Override public double[][] matrixInOptimizer(double[][] max) { // Check every entry of origM for blacked out regions for (int i = 0; i < max.length; i++) { for (int j = 0; j < max[i].length; j++) { if (origMfinal.getArray()[i][j] > 1e9) { max[i][j] = -origMfinal.getArray()[i][j]; } } } return max; } @Override public boolean[][] initializeBreakFlag(boolean[][] brkFlag) { return brkFlag; } }); calculator.nextStep(afpChain, ca1, ca2clone); afpChain.setAlgorithmName(algorithmName); afpChain.setVersion(version); afpChain.setDistanceMatrix(origM); return origMfinal; }
Example 10
Source File: AFPChainXMLParser.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** replace the PDB res nums with atom positions: * * @param afpChain * @param ca1 * @param ca2 */ public static void rebuildAFPChain(AFPChain afpChain, Atom[] ca1, Atom[] ca2){ if ( afpChain.getAlgorithmName() == null) { afpChain.setAlgorithmName(DEFAULT_ALGORITHM_NAME); } if ( afpChain.getVersion() == null){ afpChain.setVersion("1.0"); } int blockNum = afpChain.getBlockNum(); int ca1Length = afpChain.getCa1Length(); int ca2Length = afpChain.getCa2Length(); int minLength = Math.min(ca1Length, ca2Length); int[][][] optAln = new int[blockNum][2][minLength]; int[][][] blockResList = afpChain.getBlockResList(); if ( blockResList == null){ blockResList = new int[blockNum][2][minLength]; } int[] optLen = afpChain.getOptLen(); String[][][] pdbAln = afpChain.getPdbAln(); int[] verifiedOptLen = null; if ( optLen != null) verifiedOptLen = afpChain.getOptLen().clone(); else { logger.warn("did not find optimal alignment, building up empty alignment."); optLen = new int[1]; optLen[0] = 0; } for (int blockNr = 0 ; blockNr < blockNum ; blockNr++){ //System.out.println("got block " + blockNr + " size: " + optLen[blockNr]); int verifiedEQR = -1; for ( int eqrNr = 0 ; eqrNr < optLen[blockNr] ; eqrNr++ ){ String pdbResnum1 = pdbAln[blockNr][0][eqrNr]; String pdbResnum2 = pdbAln[blockNr][1][eqrNr]; //System.out.println(blockNr + " " + 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]; int pos1 = getPositionForPDBresunm(pdbres1,chain1,ca1); int pos2 = getPositionForPDBresunm(pdbres2,chain2,ca2); if ( pos1 == -1 || pos2 == -1 ){ // this can happen when parsing old files that contained Calcium atoms... logger.warn("pos1: {} (residue {}), pos2: {} (residue {}), should never be -1. Probably parsing an old file.", pos1, pdbResnum1, pos2, pdbResnum2); verifiedOptLen[blockNr]-- ; continue; } verifiedEQR++; //System.out.println(blockNr + " " + eqrNr + " " + pos1 + " " + pos2); optAln[blockNr][0][verifiedEQR] = pos1; optAln[blockNr][1][verifiedEQR] = pos2; blockResList[blockNr][0][verifiedEQR] = pos1; blockResList[blockNr][1][verifiedEQR] = pos2; } } afpChain.setOptLen(verifiedOptLen); afpChain.setOptAln(optAln); afpChain.setBlockResList(blockResList); // build up alignment image: AFPAlignmentDisplay.getAlign(afpChain, ca1, ca2); }
Example 11
Source File: CeMain.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** * Align ca2 onto ca1. */ @Override public AFPChain align(Atom[] ca1, Atom[] ca2, Object param) throws StructureException{ if ( ! (param instanceof CeParameters)) throw new IllegalArgumentException("CE algorithm needs an object of call CeParameters as argument."); params = (CeParameters) param; // we don't want to rotate input atoms, do we? ca2clone = new Atom[ca2.length]; int pos = 0; for (Atom a : ca2){ Group g = (Group)a.getGroup().clone(); // works because each group has only a CA atom ca2clone[pos] = g.getAtom(a.getName()); pos++; } calculator = new CECalculator(params); //Build alignment ca1 to ca2-ca2 AFPChain afpChain = new AFPChain(algorithmName); afpChain = calculator.extractFragments(afpChain, ca1, ca2clone); calculator.traceFragmentMatrix( afpChain,ca1, ca2clone); calculator.nextStep( afpChain,ca1, ca2clone); afpChain.setAlgorithmName(getAlgorithmName()); afpChain.setVersion(version); // Try to guess names if (ca1.length!=0 && ca1[0].getGroup().getChain()!=null && ca1[0].getGroup().getChain().getStructure()!=null) afpChain.setName1(ca1[0].getGroup().getChain().getStructure().getName()); if (ca2.length!=0 && ca2[0].getGroup().getChain()!=null && ca2[0].getGroup().getChain().getStructure()!=null) afpChain.setName2(ca2[0].getGroup().getChain().getStructure().getName()); if ( afpChain.getNrEQR() == 0) return afpChain; // Set the distance matrix int winSize = params.getWinSize(); int winSizeComb1 = (winSize-1)*(winSize-2)/2; double[][] m = calculator.initSumOfDistances(ca1.length, ca2.length, winSize, winSizeComb1, ca1, ca2clone); afpChain.setDistanceMatrix(new Matrix(m)); afpChain.setSequentialAlignment(true); return afpChain; }