Calculate the coordinates of the H atoms. They are usually
missing in the PDB files as only few experimental methods allow
to resolve their location.
351576
private void calculateHAtoms() throws StructureException {

		for ( int i = 0 ; i < groups.length-1  ; i++) {

			SecStrucGroup a  = groups[i];
			SecStrucGroup b  = groups[i+1];

			if ( !b.hasAtom("H") ) {
				//Atom H = calc_H(a.getC(), b.getN(), b.getCA());
				Atom H = calcSimple_H(a.getC(), a.getO(), b.getN());
				b.setH(H);
			}
		}
	}
126867
public IAtom getPlacedHeavyAtomInAtomContainer(IAtom atomA, IAtom atomB, IAtomContainer ac) {
        List atoms = ac.getConnectedAtomsList(atomA);
        IAtom atom = null;
        for (int i = 0; i < atoms.size(); i++) {
            IAtom curAtom = (IAtom) atoms.get(i);
            if (curAtom.getFlag(CDKConstants.ISPLACED) && !curAtom.getSymbol().equals("H") && !Objects.equals(curAtom, atomB)) {
                return curAtom;
            }
        }
        return atom;
    }
1318325
public static List<Point3d> atomsToPoints(Collection<Atom> atoms) {
		ArrayList<Point3d> points = new ArrayList<>(atoms.size());
		for (Atom atom : atoms) {
			points.add(atom.getCoordsAsPoint3d());
		}
		return points;
	}
66489
@Override
    public DescriptorValue calculate(IAtomContainer atomContainer) {
        double zagreb = 0;
        for (IAtom atom : atomContainer.atoms()) {
            if (atom.getSymbol().equals("H")) continue;
            int atomDegree = 0;
            List<IAtom> neighbours = atomContainer.getConnectedAtomsList(atom);
            for (IAtom neighbour : neighbours) {
                if (!neighbour.getSymbol().equals("H")) {
                    atomDegree += 1;
                }
            }
            zagreb += (atomDegree * atomDegree);
        }
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(zagreb),
                getDescriptorNames());
    }
501899
public double[] findGridBoundaries() {
        IAtom[] atoms = AtomContainerManipulator.getAtomArray(protein);
        double[] minMax = new double[6];
        minMax[0] = atoms[0].getPoint3d().x;
        minMax[1] = atoms[0].getPoint3d().x;
        minMax[2] = atoms[0].getPoint3d().y;
        minMax[3] = atoms[0].getPoint3d().y;
        minMax[4] = atoms[0].getPoint3d().z;
        minMax[5] = atoms[0].getPoint3d().z;
        for (int i = 0; i < atoms.length; i++) {
            if (atoms[i].getPoint3d().x > minMax[1]) {
                minMax[1] = atoms[i].getPoint3d().x;
            } else if (atoms[i].getPoint3d().y > minMax[3]) {
                minMax[3] = atoms[i].getPoint3d().y;
            } else if (atoms[i].getPoint3d().z > minMax[5]) {
                minMax[5] = atoms[i].getPoint3d().z;
            } else if (atoms[i].getPoint3d().x < minMax[0]) {
                minMax[0] = atoms[i].getPoint3d().x;
            } else if (atoms[i].getPoint3d().y < minMax[2]) {
                minMax[2] = atoms[i].getPoint3d().y;
            } else if (atoms[i].getPoint3d().z < minMax[4]) {
                minMax[4] = atoms[i].getPoint3d().z;
            }
        }
        return minMax;
    }
1267122
private int getAtomPosition(IAtom atom, IAtomContainer container) {
        for (int i = 0; i < container.getAtomCount(); i++) {
            if (atom.equals(container.getAtom(i))) {
                return i;
            }
        }
        return -1;
    }
1139033
def read_nwchem(basis_lines, fname):
    '''
    '''

    skipchars = '#'
    basis_lines = [l for l in basis_lines if l and not l[0] in skipchars]

    bs_data = create_skel('component')

    i = 0

    while i < len(basis_lines):
        line = basis_lines[i]

        if line.lower().startswith('basis'):
            i += 1

            # NWChem doesn't seem to really block by element
            # It just has shells labeled with each element symbol

            while i < len(basis_lines) and not basis_lines[i].lower().startswith('end'):
                line = basis_lines[i]
                lsplt = line.split()
                elementsym = lsplt[0]
                shell_am = lut.amchar_to_int(lsplt[1])

                element_Z = lut.element_Z_from_sym(elementsym)
                element_Z = str(element_Z)

                if not element_Z in bs_data['elements']:
                    bs_data['elements'][element_Z] = {}
                if not 'electron_shells' in bs_data['elements'][element_Z]:
                    bs_data['elements'][element_Z]['electron_shells'] = []

                element_data = bs_data['elements'][element_Z]

                if max(shell_am) <= 1:
                    func_type = 'gto'
                else:
                    func_type = 'gto_spherical'

                shell = {
                    'function_type': func_type,
                    'region': '',
                    'angular_momentum': shell_am
                }

                exponents = []
                coefficients = []

                i += 1
                while True:
                    if i >= len(basis_lines) or basis_lines[i][0].isalpha():
                        break

                    line = basis_lines[i].replace('D', 'E')
                    line = line.replace('d', 'E')
                    lsplt = line.split()
                    exponents.append(lsplt[0])
                    coefficients.append(lsplt[1:])
                    i += 1

                shell['exponents'] = exponents

                # We need to transpose the coefficient matrix
                # (we store a matrix with primitives being the column index and
                # general contraction being the row index)
                shell['coefficients'] = list(map(list, zip(*coefficients)))

                element_data['electron_shells'].append(shell)

        elif line.lower().startswith('ecp'):
            i += 1
            while i < len(basis_lines) and not basis_lines[i].lower().startswith('end'):
                line = basis_lines[i]
                if 'nelec' in line.lower():
                    lsplt = line.split()
                    elementsym = lsplt[0]
                    n_elec = int(lsplt[2])

                    element_Z = lut.element_Z_from_sym(elementsym)
                    element_Z = str(element_Z)

                    if not element_Z in bs_data['elements']:
                        bs_data['elements'][element_Z] = {}
                    if not 'ecp_electrons' in bs_data['elements'][element_Z]:
                        bs_data['elements'][element_Z]['ecp_electrons'] = n_elec

                    i += 1
                    continue

                # Now parsing a shell
                lsplt = line.split()
                elementsym = lsplt[0]

                shell_am = lsplt[1]
                if shell_am.lower() == 'ul':
                    shell_am = -1  # Placeholder - leave for later
                else:
                    shell_am = lut.amchar_to_int(lsplt[1])

                element_Z = lut.element_Z_from_sym(elementsym)
                element_Z = str(element_Z)

                if not element_Z in bs_data['elements']:
                    bs_data['elements'][element_Z] = {}
                if not 'ecp_potentials' in bs_data['elements'][element_Z]:
                    bs_data['elements'][element_Z]['ecp_potentials'] = []
                element_data = bs_data['elements'][element_Z]

                ecp_shell = {'angular_momentum': shell_am, 'ecp_type': 'scalar_ecp'}

                rexponents = []
                gexponents = []
                coefficients = []

                i += 1
                while True:
                    if i >= len(basis_lines) or basis_lines[i][0].isalpha():
                        break

                    line = basis_lines[i].replace('D', 'E')
                    line = line.replace('d', 'E')
                    lsplt = line.split()
                    rexponents.append(int(lsplt[0]))
                    gexponents.append(lsplt[1])
                    coefficients.append(lsplt[2:])
                    i += 1

                ecp_shell['r_exponents'] = rexponents
                ecp_shell['gaussian_exponents'] = gexponents

                # We need to transpose the coefficient matrix
                # (we store a matrix with primitives being the column index and
                # general contraction being the row index)
                ecp_shell['coefficients'] = list(map(list, zip(*coefficients)))

                element_data['ecp_potentials'].append(ecp_shell)
        i += 1

        # Fix ecp angular momentum now that everything has been read
        for el, v in bs_data['elements'].items():
            if not 'ecp_potentials' in v:
                continue

            max_ecp_am = -1
            for s in v['ecp_potentials']:
                if s['angular_momentum'] == -1:
                    continue
                max_ecp_am = max(max_ecp_am, max(s['angular_momentum']))

            for s in v['ecp_potentials']:
                if s['angular_momentum'] == -1:
                    s['angular_momentum'] = [max_ecp_am + 1]

    return bs_data
1019199
def get_atom_mapping(self):
        """"""
        # Atom mappings
        smiles_to_pdb_mapping = self.bindingsite.xpath('mappings/smiles_to_pdb/text()')
        if smiles_to_pdb_mapping == []:
            self.mappings = {'smiles_to_pdb': None, 'pdb_to_smiles': None}
        else:
            smiles_to_pdb_mapping = {int(y[0]): int(y[1]) for y in [x.split(':')
                                                                    for x in smiles_to_pdb_mapping[0].split(',')]}
            self.mappings = {'smiles_to_pdb': smiles_to_pdb_mapping}
            self.mappings['pdb_to_smiles'] = {v: k for k, v in self.mappings['smiles_to_pdb'].items()}
352925
def from_ase_atoms(cls, atoms):
        
        return cls(atoms=atoms.get_chemical_symbols(), coords=atoms.positions)
781387
def get_projection_on_elements(self, structure):
        
        dico = {}
        for spin in self.data.keys():
            dico[spin] = [[defaultdict(float)
                           for i in range(self.nkpoints)]
                          for j in range(self.nbands)]

        for iat in range(self.nions):
            name = structure.species[iat].symbol
            for spin, d in self.data.items():
                for k, b in itertools.product(range(self.nkpoints),
                                              range(self.nbands)):
                    dico[spin][b][k][name] = np.sum(d[k, b, iat, :])

        return dico
642662
public static int getHydrogenCount(IAtomContainer atomContainer, IAtom atom) {
        return getExplicitHydrogenCount(atomContainer, atom) + getImplicitHydrogenCount(atom);
    }
1117957
@Override
    public DescriptorValue calculate(IAtomContainer atomContainer) {
        IAtomContainer ac = null;
        try {
            ac = (IAtomContainer) atomContainer.clone();
        } catch (CloneNotSupportedException e) {
            return getDummyDescriptorValue(e);
        }

        int carbonCount = 0;
        int heteroCount = 0;
        for (IAtom atom : ac.atoms()) {
            if (!Elements.HYDROGEN.getSymbol().equals(atom.getSymbol())) {
                if (Elements.CARBON.getSymbol().equals(atom.getSymbol())) {
                    carbonCount++;
                } else {
                    heteroCount++;
                }
            }
        }
        double mLogP = 1.46 + 0.11 * carbonCount - 0.11 * heteroCount;

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(mLogP),
                getDescriptorNames());
    }
51727
private static Atom[] getAtoms(Atom[] ca, int[] positions, int length,
			boolean clone) {

		List<Atom> atoms = new ArrayList<Atom>();
		for (int i = 0; i < length; i++) {
			int p = positions[i];
			Atom a;
			if (clone) {
				a = (Atom) ca[p].clone();
				a.setGroup((Group) ca[p].getGroup().clone());
			} else {
				a = ca[p];
			}
			atoms.add(a);
		}
		return atoms.toArray(new Atom[atoms.size()]);
	}
276900
public static int getMolecularGraphRadius(IAtomContainer atomContainer) {
        int natom = atomContainer.getAtomCount();

        int[][] admat = AdjacencyMatrix.getMatrix(atomContainer);
        int[][] distanceMatrix = computeFloydAPSP(admat);

        int[] eta = new int[natom];
        for (int i = 0; i < natom; i++) {
            int max = -99999;
            for (int j = 0; j < natom; j++) {
                if (distanceMatrix[i][j] > max) max = distanceMatrix[i][j];
            }
            eta[i] = max;
        }
        int min = 999999;
        for (int anEta : eta) {
            if (anEta < min) min = anEta;
        }
        return min;
    }
432318
private static final double getEnd2EndDistance(Atom[] ca1, Atom[] ca2, int p1b, int p1e, int p2b, int p2e)
	{

		double min = 99;
			double dist1 = Calc.getDistance(ca1[p1b], ca1[p1e]);
			double dist2 = Calc.getDistance(ca2[p2b], ca2[p2e]);
			min = dist1 - dist2;

		return Math.abs(min);
	}
500277
private int getNearestBondtoAGivenAtom(IAtomContainer mol, IAtom atom, IBond bond) {
        int nearestBond = 0;
        double[] values;
        double distance = 0;
        IAtom atom0 = bond.getBegin();
        List<IBond> bondsAtLeft = mol.getConnectedBondsList(atom0);
        int partial;
        for (int i = 0; i < bondsAtLeft.size(); i++) {
            IBond curBond = bondsAtLeft.get(i);
            values = calculateDistanceBetweenAtomAndBond(atom, curBond);
            partial = mol.indexOf(curBond);
            if (i == 0) {
                nearestBond = mol.indexOf(curBond);
                distance = values[0];
            } else {
                if (values[0] < distance) {
                    nearestBond = partial;
                }
            }
        }
        return nearestBond;

    }
122036
private void calcBoundaries() {
		minBoundary.x = Double.MAX_VALUE;
		maxBoundary.x = Double.MIN_VALUE;
		minBoundary.y = Double.MAX_VALUE;
		maxBoundary.x = Double.MIN_VALUE;
		minBoundary.z = Double.MAX_VALUE;
		maxBoundary.z = Double.MIN_VALUE;
		xzRadiusMax = Double.MIN_VALUE;

		Point3d probe = new Point3d();

		for (Point3d[] list: subunits.getTraces()) {
			for (Point3d p: list) {
				probe.set(p);
				transformationMatrix.transform(probe);

				minBoundary.x = Math.min(minBoundary.x, probe.x);
				maxBoundary.x = Math.max(maxBoundary.x, probe.x);
				minBoundary.y = Math.min(minBoundary.y, probe.y);
				maxBoundary.y = Math.max(maxBoundary.y, probe.y);
				minBoundary.z = Math.min(minBoundary.z, probe.z);
				maxBoundary.z = Math.max(maxBoundary.z, probe.z);
				xzRadiusMax = Math.max(xzRadiusMax, Math.sqrt(probe.x*probe.x + probe.z * probe.z));
			}
		}
//		System.out.println("MinBoundary: " + minBoundary);
//		System.out.println("MaxBoundary: " + maxBoundary);
//		System.out.println("zxRadius: " + xzRadiusMax);
	}