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

com.actelion.research.chem.phesa.pharmacophore.pp.ChargePoint Maven / Gradle / Ivy

There is a newer version: 2024.11.2
Show newest version
package com.actelion.research.chem.phesa.pharmacophore.pp;

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

import com.actelion.research.chem.Coordinates;
import com.actelion.research.chem.StereoMolecule;

public class ChargePoint implements IPharmacophorePoint {
	private int chargeAtom;
	private List neighbours;
	private int charge;
	private Coordinates center;
	private static final Coordinates directionality = new Coordinates(1.0,0.0,0.0);
	
	public ChargePoint(StereoMolecule mol, int a, List neighbours, int charge) {
		if(charge==0) 
			throw new IllegalArgumentException("charge should not be 0 ");
		chargeAtom = a;
		this.neighbours = neighbours;
		this.charge = charge;
		updateCoordinates(mol.getAtomCoordinates());
	}
	
	public ChargePoint(ChargePoint cP) {
		chargeAtom = cP.chargeAtom;
		charge = cP.charge;
		center = new Coordinates(cP.center);
		neighbours = new ArrayList();
		for(int neighbour : cP.neighbours) {
			neighbours.add(neighbour);
		}
	}

	@Override
	public Coordinates getCenter() {
		return center;
	}

	@Override
	public void updateCoordinates(Coordinates[] coords) {
		Coordinates com = new Coordinates(coords[chargeAtom]);
		if(neighbours!=null) {
			for(int neighbour:neighbours) {
				com.add(coords[neighbour]);
			}
			com.scale(1.0/(neighbours.size()+1));
		}

		center = com;
	}
	

	

	@Override
	public Coordinates getDirectionality() {
		// TODO Auto-generated method stub
		return directionality;
	}
	
	@Override
	public Coordinates getRotatedDirectionality(double[][] rotMatrix,double scaleFactor) {
		Coordinates directMod = new Coordinates(directionality);
		return directMod;
	}
	
	private ChargePoint(String ppString, StereoMolecule mol) {
		decode(ppString,mol);
	}
	
	public static ChargePoint fromString(String ppString, StereoMolecule mol) {
		return new ChargePoint(ppString,mol);
	}
	

	private void decode(String ppString, StereoMolecule mol) {
		String[] strings = ppString.split(" ");
		chargeAtom = Integer.decode(strings[1]);
		charge = Integer.decode(strings[2]);
		neighbours = new ArrayList();
		for(int i=3;i 0 ? 1.0 : 0.0;
		}
		return result;
	}

	@Override
	public int getCenterID() {
		return chargeAtom;
	}
	
	@Override
	public void setCenterID(int centerID) {
		chargeAtom = centerID;
	}

	@Override
	public void setDirectionality(Coordinates directionality) {
		return;

	}
	
	public int getCharge() {
		return charge;
	}
	
	@Override
	public void updateAtomIndeces(int[] map) {
		chargeAtom = map[chargeAtom];

		for(int i=0;i getNeighbours() {
		return neighbours;
	}

	public void setNeighbours(List neighbours) {
		this.neighbours = neighbours;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy