001/** 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 * Created on 2013-05-28 021 * Created by Douglas Myers-Turnbull 022 * 023 * @since 3.0.6 024 */ 025package demo; 026 027import org.biojava.nbio.structure.Atom; 028import org.biojava.nbio.structure.Structure; 029import org.biojava.nbio.structure.StructureException; 030import org.biojava.nbio.structure.StructureTools; 031import org.biojava.nbio.structure.align.StructureAlignment; 032import org.biojava.nbio.structure.align.gui.StructureAlignmentDisplay; 033import org.biojava.nbio.structure.align.model.AFPChain; 034import org.biojava.nbio.structure.align.model.AfpChainWriter; 035import org.biojava.nbio.structure.align.util.AFPChainScorer; 036import org.biojava.nbio.structure.align.xml.AFPChainXMLConverter; 037import org.biojava.nbio.structure.io.FastaAFPChainConverter; 038import org.biojava.nbio.structure.io.FastaStructureParser; 039 040import java.io.IOException; 041 042/** 043 * Demo displaying a structural alignment from a FASTA file using {@link FastaAFPChainConverter}. 044 * 045 * @author dmyerstu 046 * @see {@link DemoAlignmentFromFasta} Also demonstrates the display of {@link StructureAlignment StructureAlignments} from FASTA sequences, but does so using the more general 047 * {@link FastaStructureParser} 048 */ 049public class AFPFromFasta { 050 051 public static void main(String[] args) throws IOException, StructureException, Exception { 052 Structure structure1 = StructureTools.getStructure("1w0p"); 053 Structure structure2 = StructureTools.getStructure("1w0p"); 054 String first = "alfdynatgdtefdspakqgwmqdntnngsgvltnadgmpawlvqgiggraqwtyslstnqhaqassfgwrmttemkvlsggmitnyyangtqrvlpiisldssgnlvvefegqtgrtvlatgtaateyhkfelvflpgsnpsasfyfdgklirdniqptaskQNMIVWGNGSSntdgvaayrdikfei------------------------------------------------------------------------------------------------------------------QGDVIf------------RGPDRIPSIVASsvTPGVVTAFAEKRVGGgdpgalsntNDIITRTSRDGGITWDTELNLTEQinvsdeFDFSDPRPIYDPs---SNTVLVSYARWPtdaaqngdrikpwmpNGIFYSVYDVASgnWQAPIDVTdqvkersfqiagwggselyrrntslnsqqdwqsnakirivdgaanqiqvadgsrkyvvtlsidesgglvanlngvsapiilqsehakvhsfhdyelqysalnhtttlfvdgqqittwagevsqenniqfgnadaqidgrlhvqkivltqqghnlvefdafylaqqtpevekdleklgwtkiktgntmslygNASVNPGpgHGITLtrqqnisgsqNGRLIYPAIVLdrfFLNVMSIYSDDGgsnwq-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------TGSTLpipfrwksssileTLEPSEADMVELQN--GDLLLTARLDFNQivngvny--SPRQQFLSKDGGITWSLLEANNANvfsnistgTVDASITRFEqsdgSHFLLFTNPQGnpagTNgr------------QNLGLWFSFDEG--VTWKGPIQ--LVNGasaysdiyqldsenaivivetdnsnmrilrmpitllkqklt"; 055 String second = "--------------------------------------------------------------------------------------------kirivdgaanqiqvadgsrkyvvtlsidesgglvanlngvsapiilqsehakvhsfhdyelqysalnhtttLFVDGQQITTWagevsqenniqfgnadaqidgrlhvqkivltqqghnlvefdafylaqqtpevekdleklgwtkiktgntmslygnasvnpgpghgitltrqqnisgsqngrliypaivldrfflnvmsiysddggsnwqTGSTLpipfrwksssileTLEPSEADMVEL--QNGDLLLTARLDFNQivngvny--SPRQQFLSKDGGITWSLLEANNANvfsnisTGTVDASITRFEqsdgSHFLLFTNPQGNpagtngr--------QNLGLWFSFDEG--VTWKGPIQlv---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------NGASAYS--DIYQLd---------SENAIVIVETD---NSNMRILRMPITllkqkltalfdynatgdtefdspakqgwmqdntnngsgvltnadgmpawlvqgiggraqwtyslstnqhaqassfgwrmttemkvlsggmitnyyangtqrvlpiisldssgnlvvefegqtgrtvlatgtaateyhkfelvflpgsnpsasfyfdgklirdniqptaskqnmivwgngssntdgvaayrdikfeiQGDVIf------------RGPDRIPSIVASSVtpGVVTAFAEKRVGGgdpgalsntNDIITRTSRDGGITWDTELNLTEQinvsdefdFSDPRPIYDPs---SNTVLVSYARW----PTdaaqngdrikpwmpNGIFYSVYDVASgnWQAPIDVTdqVKERsfqiagwggselyrrntslnsqqdwqsna------------"; 056 AFPChain afpChain = FastaAFPChainConverter.cpFastaToAfpChain(first, second, structure1, -393); 057 Atom[] ca1 = StructureTools.getAtomCAArray(structure1); 058 Atom[] ca2 = StructureTools.getAtomCAArray(structure2); 059 String xml = AFPChainXMLConverter.toXML(afpChain); 060 System.out.println(xml); 061 double tmScore = AFPChainScorer.getTMScore(afpChain, ca1, ca2); 062 afpChain.setTMScore(tmScore); 063 System.out.println(AfpChainWriter.toScoresList(afpChain)); 064 StructureAlignmentDisplay.display(afpChain, ca1, ca2); 065 } 066 067}