Java Code Examples for org.biojava.nbio.structure.io.FileParsingParameters#setParseSecStruc()

The following examples show how to use org.biojava.nbio.structure.io.FileParsingParameters#setParseSecStruc() . 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: DemoAtomCache.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void demoAtomCache() {
	AtomCache cache = new AtomCache();

	FileParsingParameters params = cache.getFileParsingParams();

	params.setAlignSeqRes(true);
	params.setHeaderOnly(false);
	params.setParseCAOnly(false);
	params.setParseSecStruc(false);

	String[] pdbIDs = new String[]{"4hhb", "1cdg","5pti","1gav", "WRONGID" };

	for (String pdbID : pdbIDs){

		try {
			Structure s = cache.getStructure(pdbID);
			if ( s == null) {
				System.out.println("could not find structure " + pdbID);
				continue;
			}
			// do something with the structure
			System.out.println(s);

		} catch (Exception e){
			// something crazy happened...
			System.err.println("Can't load structure " + pdbID + " reason: " + e.getMessage());
			//e.printStackTrace();
		}
	}

}
 
Example 2
Source File: DemoLoadSecStruc.java    From biojava with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void main(String[] args) throws IOException,
		StructureException {

	String pdbID = "5pti";

	// Only change needed to the DEFAULT Structure loading
	FileParsingParameters params = new FileParsingParameters();
	params.setParseSecStruc(true);

	AtomCache cache = new AtomCache();
	cache.setFileParsingParams(params);

	// Use PDB format, because SS cannot be parsed from mmCIF yet
	cache.setUseMmCif(false);

	// The loaded Structure contains the SS assigned by Author (simple)
	Structure s = cache.getStructure(pdbID);

	// Print the Author's assignment (from PDB file)
	System.out.println("Author's assignment: ");
	printSecStruc(s);

	// If the more detailed DSSP prediction is required call this
	DSSPParser.fetch(pdbID, s, true);

	// Print the assignment residue by residue
	System.out.println("DSSP assignment: ");
	printSecStruc(s);

	// finally use BioJava's built in DSSP-like secondary structure assigner
	SecStrucCalc secStrucCalc = new SecStrucCalc();

	// calculate and assign
	secStrucCalc.calculate(s,true);
	printSecStruc(s);

}
 
Example 3
Source File: DemoSCOP.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void alignSuperfamily(){
	// download SCOP if required and load into memory
	ScopDatabase scop = ScopFactory.getSCOP();
	List<ScopDescription> superfams = scop.getByCategory(ScopCategory.Superfamily);

	System.out.println("Total nr. of superfamilies:" + superfams.size());


	// configure where to load PDB files from and
	// what information to load
	AtomCache cache = new AtomCache();
	FileParsingParameters fileparams = new FileParsingParameters() ;
	fileparams.setAlignSeqRes(false);
	fileparams.setParseSecStruc(false);
	cache.setFileParsingParams(fileparams);

	// get tge first superfamily
	ScopDescription superfam1 = superfams.get(0);
	System.out.println("First superfamily: " + superfam1);

	ScopNode node = scop.getScopNode(superfam1.getSunID());
	System.out.println("scopNode for first superfamily:" + node);

	List<ScopDomain> doms4superfam1 = scop.getScopDomainsBySunid(superfam1.getSunID());
	ScopDomain dom1 = doms4superfam1.get(0);

	// align the first domain against all others members of this superfamily
	for ( int i = 1 ; i < doms4superfam1.size() ; i ++){

		ScopDomain dom2 = doms4superfam1.get(i);

		try {
			Structure s1 = cache.getStructureForDomain(dom1);
			Structure s2 = cache.getStructureForDomain(dom2);

			Atom[] ca1 = StructureTools.getAtomCAArray(s1);
			Atom[] ca2 = StructureTools.getAtomCAArray(s2);
			StructureAlignment ce = StructureAlignmentFactory.getAlgorithm(CeMain.algorithmName);
			AFPChain afpChain = ce.align(ca1, ca2);

			//System.out.println(afpChain.toCE(ca1, ca2));

			//StructureAlignmentDisplay.display(afpChain, ca1, ca2);

			System.out.println(dom1.getScopId() + " vs. " + dom2.getScopId()+ " :" + afpChain.getProbability());
			double tmScore = AFPChainScorer.getTMScore(afpChain, ca1, ca2);
			afpChain.setTMScore(tmScore);
			System.out.println(AfpChainWriter.toScoresList(afpChain));

		} catch (Exception e){
			e.printStackTrace();
		}
	}

}
 
Example 4
Source File: DemoDomainsplit.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void basicLoad(String pdbId){

		try {

			// This utility class can automatically download missing PDB files.
			AtomCache cache = new AtomCache();

			//
			// configure the parameters of file parsing (optional)

			FileParsingParameters params = new FileParsingParameters();

			// should the ATOM and SEQRES residues be aligned when creating the internal data model?
			params.setAlignSeqRes(true);
			// should secondary structure get parsed from the file
			params.setParseSecStruc(false);

			// and set the params in the cache.
			cache.setFileParsingParams(params);

			// end of optional part

			Structure struc = cache.getStructure(pdbId);

			System.out.println("structure loaded: " + struc);

			List<Domain> domains = LocalProteinDomainParser.suggestDomains(struc);

			System.out.println("RESULTS: =====");
			for ( Domain dom : domains){
				System.out.println("DOMAIN:" + dom.getSize() + " " +  dom.getScore());
				List<Segment> segments = dom.getSegments();
				for ( Segment s : segments){
					System.out.println("   Segment: " + s);
				}
			}
		} catch (Exception e){
			e.printStackTrace();
		}

	}
 
Example 5
Source File: TestNucleotides.java    From biojava with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void test1REP() throws StructureException, IOException{

	PDBFileReader reader = new PDBFileReader();
	FileParsingParameters params = new FileParsingParameters();
	params.setParseSecStruc(true);
	params.setAlignSeqRes(true);
	params.setParseCAOnly(false);
	reader.setFileParsingParameters(params);



	Structure s = reader.getStructureById("1REP");
	//System.out.println(s);
	//System.out.println(s.toPDB());
	Chain b = s.getPolyChainByPDB("B");

	assertEquals(22,b.getSeqResGroups().size());
	assertEquals(21,b.getAtomGroups().size());

	Group n1 = b.getSeqResGroup(0);
	Group n2 = b.getAtomGroup(0);
	//System.out.println(n1);
	//System.out.println(n2);
	//System.out.println(n1.getChemComp());


	assertNotNull("Could not acces Chem Comp file!" , n1.getChemComp());
	assertTrue("ChemComp is not DC",n1.getChemComp().getId().equals("DC"));
	assertNotNull("Could not determine polymer type " , n1.getChemComp().getPolymerType());
	//System.out.println(n1.getChemComp().getPolymerType());
	assertTrue(n1.getChemComp().getPolymerType().equals(PolymerType.dna));

	assertNotNull(n1.getPDBName());
	assertNotNull(n1.getResidueNumber());
	assertNotNull(n2.getResidueNumber());
	assertEquals("23", n2.getResidueNumber().toString());
	assertTrue(n1.getResidueNumber().equals(n2.getResidueNumber()));


}
 
Example 6
Source File: DemoLoadStructure.java    From biojava with GNU Lesser General Public License v2.1 3 votes vote down vote up
public void basicLoad(){
	try {

		PDBFileReader reader = new PDBFileReader();

		// the path to the local PDB installation
		reader.setPath("/tmp");

		// configure the parameters of file parsing

		FileParsingParameters params = new FileParsingParameters();

		// should the ATOM and SEQRES residues be aligned when creating the internal data model?
		params.setAlignSeqRes(true);

		// should secondary structure get parsed from the file
		params.setParseSecStruc(false);

		reader.setFileParsingParameters(params);

		Structure structure = reader.getStructureById("4hhb");

		System.out.println(structure);

		Chain c = structure.getPolyChainByPDB("C");


		System.out.print(c);

		System.out.println(c.getEntityInfo());


	} catch (Exception e){
		e.printStackTrace();
	}

}
 
Example 7
Source File: DemoChangeChemCompProvider.java    From biojava with GNU Lesser General Public License v2.1 3 votes vote down vote up
public void basicLoad(PDBFileReader reader, boolean loadChemComp, String pdbId){

		try {
			// configure the parameters of file parsing

			FileParsingParameters params = new FileParsingParameters();

			// should the ATOM and SEQRES residues be aligned when creating the internal data model?
			// only do this if you need to work with SEQRES sequences. If all you need are ATOMs, then
			// set it to false to have quicker file loading.
			params.setAlignSeqRes(true);

			//
			// should secondary structure get parsed from the file
			params.setParseSecStruc(false);

			reader.setFileParsingParameters(params);

			Structure struc = reader.getStructureById(pdbId);

			printStructure(struc);


		} catch (Exception e){
			e.printStackTrace();
		}

	}
 
Example 8
Source File: TestNucleotides.java    From biojava with GNU Lesser General Public License v2.1 2 votes vote down vote up
@Test
public void test3T5N() throws IOException, StructureException{

	String pdbId = "3T5N";
	Structure s = getStructure(pdbId);


	assertEquals(2,s.getPolyChains().size());

	Chain c = s.getChains().get(1);
	System.out.println(c);
	assertEquals("C", c.getName());
	List<Group> ngr = c.getAtomGroups(GroupType.NUCLEOTIDE);
	assertEquals(6,ngr.size());


	// now test if we download all definitions correctly for this one...
	PDBFileReader reader = new PDBFileReader();
	FileParsingParameters params = new FileParsingParameters();
	params.setParseSecStruc(true);
	params.setAlignSeqRes(true);
	params.setParseCAOnly(false);
	reader.setFileParsingParameters(params);

	ChemCompProvider chemProv = ChemCompGroupFactory.getChemCompProvider();

	DownloadChemCompProvider download = new DownloadChemCompProvider();

	ChemCompGroupFactory.setChemCompProvider(download);

	Structure s1 = reader.getStructureById(pdbId);

	assertNotNull(s1);

	assertEquals(2,s1.getPolyChains().size());

	Chain c1 = s1.getChains().get(1);

	assertEquals("C", c1.getName());

	Group g = c1.getAtomGroup(0);
	assertNotNull(g);
	assertNotNull(g.getChemComp());
	assertNotNull(g.getChemComp().getPolymerType());
	assertNotNull(g.getChemComp().getPolymerType().name());

	assertTrue("Found an unknown polymertype!", (! g.getChemComp().getPolymerType().equals(PolymerType.unknown)));
	//System.out.println(g.getChemComp().getPolymerType());

	List<Group> ngr1 = c1.getAtomGroups(GroupType.NUCLEOTIDE);
	assertEquals(6,ngr1.size());


	ChemCompGroupFactory.setChemCompProvider(chemProv);


}