Add a bond between two Particles.

        Parameters
        ----------
        particle_pair : indexable object, length=2, dtype=mb.Compound
            The pair of Particles to add a bond between
767335
def add_bond(self, particle_pair):
        
        if self.root.bond_graph is None:
            self.root.bond_graph = BondGraph()

        self.root.bond_graph.add_edge(particle_pair[0], particle_pair[1])
933057
def get_pair(self, pair):
        
        i, j = pair
        return (self._nodes[i.name()], self._nodes[j.name()])
258605
private void addSelfToAtoms() {
		List<Bond> bonds = atomA.getBonds();
		if (bonds==null) {
			bonds = new ArrayList<Bond>(AtomImpl.BONDS_INITIAL_CAPACITY);
			atomA.setBonds(bonds);
		}

		boolean exists = false;
		for (Bond bond : bonds) {
			// TODO is it equals() what we want here, or is it == ? - JD 2016-03-02
			if (bond.getOther(atomA).equals(atomB)) {
				exists = true;
				break;
			}
		}
		if (!exists) {
			atomA.addBond(this);
			atomB.addBond(this);
		}
	}
1045145
def add_vertex(self, vertex):
        
        if vertex not in self._vertices:
            self._vertices.add(vertex)
            return True

        return False
1277208
def add_edge(self, a, b):
        
        neighbors_of_a = self.adjacency_lists.get(a)
        if not neighbors_of_a:
            neighbors_of_a = set()
            self.adjacency_lists[a] = neighbors_of_a

        neighbors_of_a.add(b)

        neighbors_of_b = self.adjacency_lists.get(b)
        if not neighbors_of_b:
            neighbors_of_b = set()
            self.adjacency_lists[b] = neighbors_of_b

        neighbors_of_b.add(a)
1237533
def add_related(self, *objects):
        
        master = None # this will become the common cluster of all related items
        slaves = set([]) # set of clusters that are going to be merged in the master
        solitaire = set([]) # set of new items that are not yet part of a cluster
        for new in objects:
            if isinstance(new, self.cls):
                if master is None:
                    master = new
                else:
                    slaves.add(new)
                for item in new.items:
                    existing = self.lookup.get(item)
                    if existing is not None:
                        slaves.add(existing)
            else:
                cluster = self.lookup.get(new)
                if cluster is None:
                    #print "solitaire", new
                    solitaire.add(new)
                elif master is None:
                    #print "starting master", new
                    master = cluster
                elif master != cluster:
                    #print "in slave", new
                    slaves.add(cluster)
                #else:
                    ##nothing to do
                    #print "new in master", new

        if master is None:
            master = self.cls([])

        for slave in slaves:
            master.update(slave)
        for item in solitaire:
            master.add_item(item)

        for item in master.items:
            self.lookup[item] = master
820080
def pair(self, pair):
        ''''''
        if len(pair) == 1:
            # if only one value is passed, the value must implement a
            # score function which retrieve the first value of the pair
            # (score in zset, timevalue in timeseries, field value in
            # hashtable)
            return (pair[0].score(), pair[0])
        elif len(pair) != 2:
            raise TypeError('add expected 2 arguments, got {0}'
                            .format(len(pair)))
        else:
            return pair
1299508
def yield_pair_energies(self, index1, index2):
        """"""
        A = self.As[index1, index2]
        B = self.Bs[index1, index2]
        distance = self.distances[index1, index2]
        yield A*np.exp(-B*distance), 1
1237122
def _find_particle_image(self, query, match, all_particles):
        
        _, idxs = self.particle_kdtree.query(query.pos, k=10)

        neighbors = all_particles[idxs]

        for particle in neighbors:
            if particle.index == match.index:
                return particle
        raise MBuildError('Unable to find matching particle image while'
                          ' stitching bonds.')
564961
def add_object(self, obj, properties=()):
        """"""
        self._objects.add(obj)
        self._properties |= properties
        self._pairs.update((obj, p) for p in properties)
259190
def add_to_pairtree(output_path, meta_id):
    """"""
    # create the pair path
    paired_path = pair_tree_creator(meta_id)
    path_append = ''
    # for each directory in the pair path
    for pair_dir in paired_path.split(os.sep):
        # append the pair path together, one directory at a time
        path_append = os.path.join(path_append, pair_dir)
        # append the pair path to the output path
        combined_path = os.path.join(output_path, path_append)
        # if the path doesn't already exist, create it
        if not os.path.exists(combined_path):
            os.mkdir(combined_path)
    return combined_path
441371
def add(self, parent, obj_type, **attributes):
        
        return self.ixnCommand('add', parent.obj_ref(), obj_type, get_args_pairs(attributes))
194709
private void addFunGroup(String funGroupToken, int addPos) {
        //BOND MODIFICATION
        //Alkanes - Single bond
        if ("an".equals(funGroupToken)) {
            //Do nothing since all bonds are single by default.
        }
        //Alkenes - Double bond
        else if ("en".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                //Set the first bond to an order of 2 (i.e. a double bond)
                currentMolecule.getBond(0).setOrder(IBond.Order.DOUBLE);
            } else {
                //Set the addPos'th bond to an order of 2 (i.e. a double bond)
                currentMolecule.getBond(addPos).setOrder(IBond.Order.DOUBLE);
            }
        }
        //Alkynes - Tripple bond
        else if ("yn".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                //Set the first bond to an order of 3 (i.e. a tripple bond)
                currentMolecule.getBond(0).setOrder(IBond.Order.TRIPLE);
            } else {
                //Set the addPos'th bond to an order of 3 (i.e. a tripple bond)
                currentMolecule.getBond(addPos).setOrder(IBond.Order.TRIPLE);
            }
        }
        //FUNCTIONAL GROUP SUFFIXES
        //Ending "e"
        else if ("e".equals(funGroupToken)) {
            //Do nothing, since the "e" is found at the end of chain names
            //with a bond modifer but no functional groups.
        }
        //Alcohols
        else if ("ol".equals(funGroupToken) || "hydroxy".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("O", endOfChain, IBond.Order.SINGLE, 1);
            } else {
                addAtom("O", currentMolecule.getAtom(addPos), IBond.Order.SINGLE, 1);
            }
        }
        //Aldehydes
        else if ("al".equals(funGroupToken)) {
            addAtom("O", endOfChain, IBond.Order.DOUBLE, 0);
        }
        //Carboxylic acid
        else if ("oic acid".equals(funGroupToken)) {
            addAtom("O", endOfChain, IBond.Order.DOUBLE, 0);
            addAtom("O", endOfChain, IBond.Order.SINGLE, 1);
        }
        //Carboxylic Acid Chloride
        else if ("oyl chloride".equals(funGroupToken)) {
            addAtom("O", endOfChain, IBond.Order.DOUBLE, 0);
            addAtom("Cl", endOfChain, IBond.Order.SINGLE, 0);
        }
        //PREFIXES
        //Halogens
        //Chlorine
        else if ("chloro".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("Cl", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.SINGLE, 0);
            } else {
                addAtom("Cl", currentMolecule.getAtom(addPos), IBond.Order.SINGLE, 0);
            }
        }
        //Fluorine
        else if ("fluoro".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("F", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.SINGLE, 0);
            } else {
                addAtom("F", currentMolecule.getAtom(addPos), IBond.Order.SINGLE, 0);
            }
        }
        //Bromine
        else if ("bromo".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("Br", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.SINGLE, 0);
            } else {
                addAtom("Br", currentMolecule.getAtom(addPos), IBond.Order.SINGLE, 0);
            }
        }
        //Iodine
        else if ("iodo".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("I", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.SINGLE, 0);
            } else {
                addAtom("I", currentMolecule.getAtom(addPos), IBond.Order.SINGLE, 0);
            }
        }
        //Nitro
        else if ("nitro".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("N", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.SINGLE, 0);
            } else {
                addAtom("N", currentMolecule.getAtom(addPos), IBond.Order.SINGLE, 0);
            }

            //Stuff which applied no matter where the N atom is:
            IAtom nitrogenAtom = currentMolecule.getAtom(currentMolecule.getAtomCount());
            nitrogenAtom.setFormalCharge(+1);
            addAtom("O", nitrogenAtom, IBond.Order.SINGLE, 0);
            currentMolecule.getAtom(currentMolecule.getAtomCount()).setFormalCharge(-1);
            addAtom("O", nitrogenAtom, IBond.Order.DOUBLE, 0);
        }
        //Oxo
        else if ("oxo".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("O", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.DOUBLE, 0);
            } else {
                addAtom("O", currentMolecule.getAtom(addPos), IBond.Order.DOUBLE, 0);
            }
        }
        //Nitrile
        else if ("nitrile".equals(funGroupToken)) {
            addAtom("N", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.TRIPLE, 0);
        }
        //Benzene
        else if ("phenyl".equals(funGroupToken)) {
            IAtomContainer benzene = makeBenzene();
            //Detect Aromacity in the benzene ring.
            try {
                AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(benzene);
                Aromaticity.cdkLegacy().apply(benzene);
            } catch (CDKException exc) {
                //                logger.debug("No atom detected");
            }
            currentMolecule.add(benzene);

            IBond joiningBond;
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                joiningBond = currentMolecule.getBuilder().newInstance(IBond.class, currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0),
                        benzene.getAtom(0));
            } else {
                joiningBond = currentMolecule.getBuilder().newInstance(IBond.class, currentMolecule.getAtom(addPos),
                        benzene.getAtom(0));
            }
            currentMolecule.addBond(joiningBond);
        } else if ("amino".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("N", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.SINGLE, 2);
            } else {
                addAtom("N", currentMolecule.getAtom(addPos), IBond.Order.SINGLE, 2);
            }
        }
        //ORGANO METALLICS ADDED AS PREFIXES
        else if ("alumino".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("Al", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.SINGLE, 2);
            } else {
                addAtom("Al", currentMolecule.getAtom(addPos), IBond.Order.SINGLE, 2);
            }
        } else if ("litho".equals(funGroupToken)) {
            //If functional group hasn't had a location specified:
            if (addPos < 0) {
                addAtom("Li", currentMolecule.isEmpty() ? null : currentMolecule.getAtom(0), IBond.Order.SINGLE, 2);
            } else {
                addAtom("Li", currentMolecule.getAtom(addPos), IBond.Order.SINGLE, 2);
            }
        }
        //PRIORITY SUBSTITUENTS

        //FUNCTIONAL GROUPS WHICH MAY HAVE THEIR OWN SUBSTITUENTS
        //Esters ("...oate")
        else if ("oate".equals(funGroupToken)) {
            addAtom("O", endOfChain, IBond.Order.DOUBLE, 0);
            addAtom("O", endOfChain, IBond.Order.SINGLE, 0);
            //Set the end of the chain to be built on for unspecified substituents.
            endOfChain = currentMolecule.getAtom(currentMolecule.getAtomCount());
        }
        //Amines
        else if ("amine".equals(funGroupToken)) {
            addAtom("N", endOfChain, IBond.Order.SINGLE, 1);
            //Set the end of the chain to be built on for unspecified substituents.
            endOfChain = currentMolecule.getAtom(currentMolecule.getAtomCount());
        }
        //Amides
        else if ("amide".equals(funGroupToken)) {
            addAtom("O", endOfChain, IBond.Order.DOUBLE, 0);
            addAtom("N", endOfChain, IBond.Order.SINGLE, 1);
            //Set the end of the chain to be built on for unspecified substituents.
            endOfChain = currentMolecule.getAtom(currentMolecule.getAtomCount());
        }
        //Ketones
        else if ("one".equals(funGroupToken)) {
            addAtom("O", endOfChain, IBond.Order.DOUBLE, 2);
            //End of chain doesn't change in this case
        }
        //Organometals
        else if (getMetalAtomicSymbol(funGroupToken) != null) {
            currentMolecule.addAtom(currentMolecule.getBuilder().newInstance(IAtom.class,
                    getMetalAtomicSymbol(funGroupToken)));
            endOfChain = currentMolecule.getAtom(currentMolecule.getAtomCount());
        } else {
            //            logger.debug("Encountered unknown group: " + funGroupToken + " at " + addPos +
            //            "\nThe parser thinks this is valid but the molecule builder has no logic for it");
        }
    }
350234
def add_boundary(self, p1, p2, btype):
        
        index = self.add_line(p1, p2, self.char_lengths['boundary'])
        # self.Boundaries.append((p1_id,p2_id,btype))
        self.BoundaryIndices.append(index)
        self.Boundaries.append((p1, p2, btype))
829114
async def add_relation(self, relation1, relation2):
        
        connection = self.connection()
        app_facade = client.ApplicationFacade.from_connection(connection)

        log.debug(
            'Adding relation %s <-> %s', relation1, relation2)

        def _find_relation(*specs):
            for rel in self.relations:
                if rel.matches(*specs):
                    return rel
            return None

        try:
            result = await app_facade.AddRelation([relation1, relation2])
        except JujuAPIError as e:
            if 'relation already exists' not in e.message:
                raise
            rel = _find_relation(relation1, relation2)
            if rel:
                return rel
            raise JujuError('Relation {} {} exists but not in model'.format(
                relation1, relation2))

        specs = ['{}:{}'.format(app, data['name'])
                 for app, data in result.endpoints.items()]

        await self.block_until(lambda: _find_relation(*specs) is not None)
        return _find_relation(*specs)
359338
def append(self, item):
        
        if isinstance(item, Polymer):
            self._molecules.append(item)
        else:
            raise TypeError(
                'Only Polymer objects can be appended to an Assembly.')
        return
1166957
private void addBonds(Atom atom, List<Atom> atomsInGroup, List<Atom> allAtoms) {
		if(atom.getBonds()==null){
			return;
		}
		for(Bond bond : atom.getBonds()) {
			// Now set the bonding information.
			Atom other = bond.getOther(atom);
			// If both atoms are in the group
			if (atomsInGroup.indexOf(other)!=-1){
				Integer firstBondIndex = atomsInGroup.indexOf(atom);
				Integer secondBondIndex = atomsInGroup.indexOf(other);
				// Don't add the same bond twice
				if(firstBondIndex>secondBondIndex){
					int bondOrder = bond.getBondOrder();
					mmtfDecoderInterface.setGroupBond(firstBondIndex, secondBondIndex, bondOrder);
				}
			}
			// Otherwise it's an inter group bond - so add it here
			else {
				Integer firstBondIndex = allAtoms.indexOf(atom);
				Integer secondBondIndex = allAtoms.indexOf(other);
				if(firstBondIndex>secondBondIndex){
					// Don't add the same bond twice
					int bondOrder = bond.getBondOrder();
					mmtfDecoderInterface.setInterGroupBond(firstBondIndex, secondBondIndex, bondOrder);
				}
			}
		}
	}