All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.biojava.nbio.structure.domain.pdp.CutDomain Maven / Gradle / Ivy

There is a newer version: 7.1.3
Show newest version
/*
 *                    BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 *
 */
package org.biojava.nbio.structure.domain.pdp;

import org.biojava.nbio.structure.Atom;

import java.util.ArrayList;
import java.util.List;


public class CutDomain {

	int ndom;

	List domains;

	public static boolean verbose = true;

	int[][] dist;
	Atom[] ca;

	public CutDomain(Atom[]ca, PDPDistanceMatrix pdpMatrix){
		dist = pdpMatrix.getDist();
		this.ca = ca;

		ndom = 0;

		domains = new ArrayList<>();

	}


	public  void cutDomain(Domain dom, CutSites cut_sites, PDPDistanceMatrix pdpMatrix){

		if ( verbose )
		System.out.println("  B ... beginning of cutDomain " +dom + " cutsites: " + cut_sites );

		/* recursive function to cut input domain into two domains */


		int i,site;

		Domain dom1 = new Domain();
		Domain dom2 = new Domain();

		CutValues val = new CutValues();
		val.s_min = 100;
		val.site2 = 0;
		val.first_cut = true;


		Cut cut = new Cut();

		site = cut.cut(ca,dom,val, dist, pdpMatrix);
		if ( verbose )
		System.out.println("  S ... site " + dom + " : site: " + site + " val : " + val);

		if(site<0) {

			/* function cut makes a decision where to cut , returns -1 if no cut */
			//memcpy(&domains[ndom],&dom,sizeof(struct Domain));
			domains.add(dom);
			dom.score = val.s_min;
			//dom = domains[ndom];
			ndom++;
			return;
		}

		if(verbose)
			System.out.printf("   C ... Cutting at position(s): %d %d %f%n%n",site,val.site2,dom.score);

		cut_sites.cut_sites[cut_sites.ncuts++] = site;

		/* create new domains: dom1 and dom2*/
		dom1.size = 0;
		dom1.nseg = 0;
		dom2.size = 0;
		dom2.nseg = 0;
		if(val.site2==0) { /* single cut*/
			for(i=0;idom.getSegmentAtPos(i).getTo()) {
					dom1.getSegmentAtPos(dom1.nseg).setTo(dom.getSegmentAtPos(i).getTo());
					dom1.getSegmentAtPos(dom1.nseg).setFrom(dom.getSegmentAtPos(i).getFrom());
					dom1.nseg++;
					dom1.size+=(dom.getSegmentAtPos(i).getTo() - dom.getSegmentAtPos(i).getFrom() + 1);
				}
				else if(sitedom.getSegmentAtPos(i).getFrom() &&
						site0) { /* double cut */
			for(i=0;idom.getSegmentAtPos(i).getTo()||val.site2dom.getSegmentAtPos(i).getTo()) {
					dom2.getSegmentAtPos(dom1.nseg).setTo(dom.getSegmentAtPos(i).getTo());
					dom2.getSegmentAtPos(dom1.nseg).setFrom(dom.getSegmentAtPos(i).getFrom());
					dom2.nseg++;
					dom2.size+=(dom.getSegmentAtPos(i).getTo() - dom.getSegmentAtPos(i).getFrom() + 1);
				}
				else if(site>dom.getSegmentAtPos(i).getFrom() &&
						sitedom.getSegmentAtPos(i).getFrom() &&
							val.site2dom.getSegmentAtPos(i).getFrom() &&
						val.site2 getDomains() {

		return domains;
	}



}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy