Java Code Examples for org.biojava.nbio.structure.align.model.AFPChain#getAlnLength()
The following examples show how to use
org.biojava.nbio.structure.align.model.AFPChain#getAlnLength() .
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: AlignmentTools.java From biojava with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates a Map specifying the alignment as a mapping between residue indices * of protein 1 and residue indices of protein 2. * * <p>For example,<pre> * 1234 * 5678</pre> * becomes<pre> * 1->5 * 2->6 * 3->7 * 4->8</pre> * * @param afpChain An alignment * @return A mapping from aligned residues of protein 1 to their partners in protein 2. * @throws StructureException If afpChain is not one-to-one */ public static Map<Integer, Integer> alignmentAsMap(AFPChain afpChain) throws StructureException { Map<Integer,Integer> map = new HashMap<Integer,Integer>(); if( afpChain.getAlnLength() < 1 ) { return map; } int[][][] optAln = afpChain.getOptAln(); int[] optLen = afpChain.getOptLen(); for(int block = 0; block < afpChain.getBlockNum(); block++) { for(int pos = 0; pos < optLen[block]; pos++) { int res1 = optAln[block][0][pos]; int res2 = optAln[block][1][pos]; if(map.containsKey(res1)) { throw new StructureException(String.format("Residue %d aligned to both %d and %d.", res1,map.get(res1),res2)); } map.put(res1,res2); } } return map; }
Example 2
Source File: RotationAxis.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** * Calculate the rotation axis for the first block of an AFPChain * @param afpChain * @throws StructureException * @throws NullPointerException if afpChain does not contain a valid rotation matrix and shift vector */ public RotationAxis(AFPChain afpChain) throws StructureException { if(afpChain.getAlnLength() < 1) { throw new StructureException("No aligned residues"); } init(afpChain.getBlockRotationMatrix()[0],afpChain.getBlockShiftVector()[0]); }
Example 3
Source File: AligPanel.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
public void setAFPChain(AFPChain afpChain) { this.afpChain = afpChain; coordManager.setAFPChain(afpChain); if ( afpChain != null) { selection = new BitSet (afpChain.getAlnLength()); if ( afpChain.getBlockNum() > 1) { colorByAlignmentBlock = true; } } }
Example 4
Source File: AligPanelMouseMotionListener.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
private AlignedPosition getCurrentAlignedPosition(MouseEvent e){ AFPChainCoordManager coordManager = parent.getCoordManager(); int aligSeq = coordManager.getAligSeq(e.getPoint()); // we are over a position in the sequences if ( aligSeq == -1) { return null; } //get sequence positions int seqPos = coordManager.getSeqPos(aligSeq, e.getPoint()); //if ( prevPos == seqPos) // return null; //prevPos = seqPos; if ( seqPos < 0) return null; AFPChain afpChain = parent.getAFPChain(); char[] aligs1 = afpChain.getAlnseq1(); char[] aligs2 = afpChain.getAlnseq2(); if ( seqPos >= afpChain.getAlnLength()) { //System.err.println("seqpos " + seqPos +" >= " + afpChain.getAlnLength()); return null; } //System.out.println("alignment " + aligSeq + " " + seqPos + " : "); AlignedPosition pos = new AlignedPosition(); pos.setPos1(seqPos); pos.setPos2(seqPos); if ( aligs1[seqPos] != '-' && aligs2[seqPos] != '-'){ pos.setEquivalent(AlignedPosition.EQUIVALENT); } return pos; }