Java Code Examples for org.biojava.nbio.structure.align.model.AFPChain#getName1()
The following examples show how to use
org.biojava.nbio.structure.align.model.AFPChain#getName1() .
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: DisplayAFP.java From biojava with GNU Lesser General Public License v2.1 | 6 votes |
public static void showAlignmentImage(AFPChain afpChain, String result) { JFrame frame = new JFrame(); String title = afpChain.getAlgorithmName() + " V."+afpChain.getVersion() + " : " + afpChain.getName1() + " vs. " + afpChain.getName2() ; frame.setTitle(title); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); AlignmentTextPanel txtPanel = new AlignmentTextPanel(); txtPanel.setText(result); JMenuBar menu = MenuCreator.getAlignmentTextMenu(frame,txtPanel,afpChain,null); frame.setJMenuBar(menu); JScrollPane js = new JScrollPane(); js.getViewport().add(txtPanel); js.getViewport().setBorder(null); //js.setViewportBorder(null); //js.setBorder(null); //js.setBackground(Color.white); frame.getContentPane().add(js); frame.pack(); frame.setVisible(true); }
Example 2
Source File: AFPChainXMLParser.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** new utility method that checks that the order of the pair in the XML alignment is correct and flips the direction if needed * * @param xml * @param name1 * @param name1 * @param ca1 * @param ca2 * @return */ public static AFPChain fromXML(String xml, String name1, String name2, Atom[] ca1, Atom[] ca2) throws IOException, StructureException{ AFPChain[] afps = parseMultiXML( xml); if ( afps.length > 0 ) { AFPChain afpChain = afps[0]; String n1 = afpChain.getName1(); String n2 = afpChain.getName2(); if ( n1 == null ) n1 = ""; if ( n2 == null) n2 = ""; //System.out.println("from AFPCHAIN: " + n1 + " " + n2); if ( n1.equals(name2) && n2.equals(name1)){ // flipped order //System.out.println("AfpChain in wrong order, flipping..."); afpChain = AFPChainFlipper.flipChain(afpChain); } rebuildAFPChain(afpChain, ca1, ca2); return afpChain; } return null; }
Example 3
Source File: AbstractUserArgumentProcessor.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
private String getAutoFileName(AFPChain afpChain){ String fileName =afpChain.getName1()+"_" + afpChain.getName2()+"_"+afpChain.getAlgorithmName(); if (params.isOutputPDB() ) fileName += ".pdb"; else fileName += ".xml"; return fileName; }
Example 4
Source File: CeCPMain.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** * Swaps the order of structures in an AFPChain * @param a * @return */ public AFPChain invertAlignment(AFPChain a) { String name1 = a.getName1(); String name2 = a.getName2(); a.setName1(name2); a.setName2(name1); int len1 = a.getCa1Length(); a.setCa1Length( a.getCa2Length() ); a.setCa2Length( len1 ); int beg1 = a.getAlnbeg1(); a.setAlnbeg1(a.getAlnbeg2()); a.setAlnbeg2(beg1); char[] alnseq1 = a.getAlnseq1(); a.setAlnseq1(a.getAlnseq2()); a.setAlnseq2(alnseq1); Matrix distab1 = a.getDisTable1(); a.setDisTable1(a.getDisTable2()); a.setDisTable2(distab1); int[] focusRes1 = a.getFocusRes1(); a.setFocusRes1(a.getFocusRes2()); a.setFocusRes2(focusRes1); //What are aftIndex and befIndex used for? How are they indexed? //a.getAfpAftIndex() String[][][] pdbAln = a.getPdbAln(); if( pdbAln != null) { for(int block = 0; block < a.getBlockNum(); block++) { String[] paln1 = pdbAln[block][0]; pdbAln[block][0] = pdbAln[block][1]; pdbAln[block][1] = paln1; } } int[][][] optAln = a.getOptAln(); if( optAln != null ) { for(int block = 0; block < a.getBlockNum(); block++) { int[] aln1 = optAln[block][0]; optAln[block][0] = optAln[block][1]; optAln[block][1] = aln1; } } a.setOptAln(optAln); // triggers invalidate() Matrix distmat = a.getDistanceMatrix(); if(distmat != null) a.setDistanceMatrix(distmat.transpose()); // invert the rotation matrices Matrix[] blockRotMat = a.getBlockRotationMatrix(); Atom[] shiftVec = a.getBlockShiftVector(); if( blockRotMat != null) { for(int block = 0; block < a.getBlockNum(); block++) { if(blockRotMat[block] != null) { // if y=x*A+b, then x=y*inv(A)-b*inv(A) blockRotMat[block] = blockRotMat[block].inverse(); Calc.rotate(shiftVec[block],blockRotMat[block]); shiftVec[block] = Calc.invert(shiftVec[block]); } } } return a; }
Example 5
Source File: AbstractUserArgumentProcessor.java From biojava with GNU Lesser General Public License v2.1 | 4 votes |
/** check if the result should be written to the local file system * * @param params2 * @param afpChain * @param ca1 * @param ca2 * @throws IOException If an error occurs when writing the afpChain to XML * @throws ClassNotFoundException If an error occurs when invoking jmol * @throws NoSuchMethodException If an error occurs when invoking jmol * @throws InvocationTargetException If an error occurs when invoking jmol * @throws IllegalAccessException If an error occurs when invoking jmol * @throws StructureException */ private void checkWriteFile( AFPChain afpChain, Atom[] ca1, Atom[] ca2, boolean dbsearch) throws IOException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, StructureException { String output = null; if ( params.isOutputPDB()){ if (! GuiWrapper.isGuiModuleInstalled()) { System.err.println("The biojava-structure-gui module is not installed. Please install!"); output = AFPChainXMLConverter.toXML(afpChain,ca1,ca2); } else { Structure tmp = AFPAlignmentDisplay.createArtificalStructure(afpChain, ca1, ca2); output = "TITLE " + afpChain.getAlgorithmName() + " " + afpChain.getVersion() + " "; output += afpChain.getName1() + " vs. " + afpChain.getName2(); output += newline; output += tmp.toPDB(); } } else if ( params.getOutFile() != null) { // output by default is XML // write the XML to a file... output = AFPChainXMLConverter.toXML(afpChain,ca1,ca2); } else if ( params.getSaveOutputDir() != null){ output = AFPChainXMLConverter.toXML(afpChain,ca1,ca2); } // no output requested. if ( output == null) return; String fileName = null; if ( dbsearch ){ if ( params.getSaveOutputDir() != null) { // we currently don't have a naming convention for how to store results for custom files // they will be re-created on the fly if ( afpChain.getName1().startsWith("file:") || afpChain.getName2().startsWith("file:")) return; fileName = params.getSaveOutputDir(); fileName += getAutoFileName(afpChain); } else { return; } // //else { // fileName = getAutoFileName(afpChain); //} } else if ( params.getOutFile() != null) { fileName = params.getOutFile(); } if (fileName == null) { System.err.println("Can't write outputfile. Either provide a filename using -outFile or set -autoOutputFile to true ."); System.exit(1); return; } //System.out.println("writing results to " + fileName + " " + params.getSaveOutputDir()); FileOutputStream out; // declare a file output object PrintStream p; // declare a print stream object // Create a new file output stream out = new FileOutputStream(fileName); // Connect print stream to the output stream p = new PrintStream( out ); p.println (output); p.close(); }
Example 6
Source File: DisplayAFP.java From biojava with GNU Lesser General Public License v2.1 | 2 votes |
/** Note: ca2, hetatoms2 and nucleotides2 should not be rotated. This will be done here... * */ public static final StructureAlignmentJmol display(AFPChain afpChain,Group[] twistedGroups, Atom[] ca1, Atom[] ca2,List<Group> hetatms1, List<Group> hetatms2 ) throws StructureException { List<Atom> twistedAs = new ArrayList<Atom>(); for ( Group g: twistedGroups){ if ( g == null ) continue; if ( g.size() < 1) continue; Atom a = g.getAtom(0); twistedAs.add(a); } Atom[] twistedAtoms = twistedAs.toArray(new Atom[twistedAs.size()]); twistedAtoms = StructureTools.cloneAtomArray(twistedAtoms); Atom[] arr1 = getAtomArray(ca1, hetatms1); Atom[] arr2 = getAtomArray(twistedAtoms, hetatms2); // //if ( hetatms2.size() > 0) // System.out.println("atom after:" + hetatms2.get(0).getAtom(0)); //if ( hetatms2.size() > 0) // System.out.println("atom after:" + hetatms2.get(0).getAtom(0)); String title = afpChain.getAlgorithmName() + " V." +afpChain.getVersion() + " : " + afpChain.getName1() + " vs. " + afpChain.getName2(); //System.out.println(artificial.toPDB()); StructureAlignmentJmol jmol = new StructureAlignmentJmol(afpChain,arr1,arr2); //jmol.setStructure(artificial); System.out.format("CA2[0]=(%.2f,%.2f,%.2f)%n", arr2[0].getX(), arr2[0].getY(), arr2[0].getZ()); //jmol.setTitle("Structure Alignment: " + afpChain.getName1() + " vs. " + afpChain.getName2()); jmol.setTitle(title); return jmol; }