Java Code Examples for org.biojava.nbio.structure.align.model.AFPChain#getAlgorithmName()
The following examples show how to use
org.biojava.nbio.structure.align.model.AFPChain#getAlgorithmName() .
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 |
/** 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 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: MultipleAligPanel.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** * Constructor using an afpChain and the atom arrays for pairwise * alignments. The AFPChain is converted into a MultipleAlignment. * * @param afpChain * @param ca1 * @param ca2 * @throws StructureException */ public MultipleAligPanel(AFPChain afpChain, Atom[] ca1, Atom[] ca2, AbstractAlignmentJmol jmol) throws StructureException { this(); String algorithm = afpChain.getAlgorithmName(); boolean flex = false; if (algorithm != null){ if (algorithm.contains("flexible")) flex = true; } //Convert the apfChain into a MultipleAlignment object MultipleAlignmentEnsembleImpl ensemble = new MultipleAlignmentEnsembleImpl(afpChain, ca1, ca2, flex); this.multAln = ensemble.getMultipleAlignment(0); //Create the sequence alignment and the structure-sequence mapping. this.mapSeqToStruct = new ArrayList<Integer>(); this.alnSeq = MultipleAlignmentTools.getSequenceAlignment( this.multAln, this.mapSeqToStruct); //Initialize other memeber variables of the panel this.size = multAln.size(); this.length = alnSeq.get(0).length(); coordManager = new MultipleAlignmentCoordManager(size, length); this.jmol = jmol; }
Example 5
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 6
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 7
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; }