public static AFPChain createAFPChain ( Atom [ ] ca1 , Atom [ ] ca2 , ResidueNumber [ ] aligned1 , ResidueNumber [ ] aligned2 ) throws StructureException { //input validation int alnLen = aligned1 . length ; if ( alnLen != aligned2 . length ) { throw new IllegalArgumentException ( "Alignment lengths are not equal" ) ; } AFPChain a = new AFPChain ( AFPChain . UNKNOWN_ALGORITHM ) ; try { a . setName1 ( ca1 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) . getName ( ) ) ; if ( ca2 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) != null ) { // common case for cloned ca2 a . setName2 ( ca2 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) . getName ( ) ) ; } } catch ( Exception e ) { // One of the structures wasn't fully created. Ignore } a . setBlockNum ( 1 ) ; a . setCa1Length ( ca1 . length ) ; a . setCa2Length ( ca2 . length ) ; a . setOptLength ( alnLen ) ; a . setOptLen ( new int [ ] { alnLen } ) ; Matrix [ ] ms = new Matrix [ a . getBlockNum ( ) ] ; a . setBlockRotationMatrix ( ms ) ; Atom [ ] blockShiftVector = new Atom [ a . getBlockNum ( ) ] ; a . setBlockShiftVector ( blockShiftVector ) ; String [ ] [ ] [ ] pdbAln = new String [ 1 ] [ 2 ] [ alnLen ] ; for ( int i = 0 ; i < alnLen ; i ++ ) { pdbAln [ 0 ] [ 0 ] [ i ] = aligned1 [ i ] . getChainName ( ) + ":" + aligned1 [ i ] ; pdbAln [ 0 ] [ 1 ] [ i ] = aligned2 [ i ] . getChainName ( ) + ":" + aligned2 [ i ] ; } a . setPdbAln ( pdbAln ) ; // convert pdbAln to optAln, and fill in some other basic parameters AFPChainXMLParser . rebuildAFPChain ( a , ca1 , ca2 ) ; return a ; // Currently a single block. Split into several blocks by sequence if needed // return AlignmentTools.splitBlocksByTopology(a,ca1,ca2); }
Fundamentally an alignment is just a list of aligned residues in each protein . This method converts two lists of ResidueNumbers into an AFPChain .