Return True if the agent is a protein/protein family or chemical.
177042
def is_protein_or_chemical(agent):
    ''''''
    # Default is True if agent is None
    if agent is None:
        return True
    dbs = set(['UP', 'HGNC', 'CHEBI', 'PFAM-DEF', 'IP', 'INDRA', 'PUBCHEM',
               'CHEMBL'])
    agent_refs = set(agent.db_refs.keys())
    if agent_refs.intersection(dbs):
        return True
    return False
950005
public static Pattern molecularInteraction()
	{
		Pattern p = new Pattern(SequenceEntityReference.class, "Protein 1");
		p.add(linkedER(true), "Protein 1", "generic Protein 1");
		p.add(erToPE(), "generic Protein 1", "SPE1");
		p.add(linkToComplex(), "SPE1", "PE1");
		p.add(new PathConstraint("PhysicalEntity/participantOf:MolecularInteraction"), "PE1", "MI");
		p.add(participant(), "MI", "PE2");
		p.add(equal(false), "PE1", "PE2");

		// participants are not both baits or preys
		p.add(new NOT(new AND(new MappedConst(isPrey(), 0), new MappedConst(isPrey(), 1))), "PE1", "PE2");
		p.add(new NOT(new AND(new MappedConst(isBait(), 0), new MappedConst(isBait(), 1))), "PE1", "PE2");

		p.add(linkToSpecific(), "PE2", "SPE2");
		p.add(type(SequenceEntity.class), "SPE2");
		p.add(new PEChainsIntersect(false), "SPE1", "PE1", "SPE2", "PE2");
		p.add(peToER(), "SPE2", "generic Protein 2");
		p.add(linkedER(false), "generic Protein 2", "Protein 2");
		p.add(equal(false), "Protein 1", "Protein 2");
		return p;
	}
799237
def get_ligands(self, solvent=True):
        
        if solvent:
            ligand_list = [x for x in self.get_monomers()
                           if isinstance(x, Ligand)]
        else:
            ligand_list = [x for x in self.get_monomers() if isinstance(
                x, Ligand) and not x.is_solvent]
        return LigandGroup(monomers=ligand_list)
74935
def _is_entity(bpe):
    """"""
    if isinstance(bpe, _bp('Protein')) or \
        isinstance(bpe, _bpimpl('Protein')) or \
        isinstance(bpe, _bp('SmallMolecule')) or \
        isinstance(bpe, _bpimpl('SmallMolecule')) or \
        isinstance(bpe, _bp('Complex')) or \
        isinstance(bpe, _bpimpl('Complex')) or \
        isinstance(bpe, _bp('Rna')) or \
        isinstance(bpe, _bpimpl('Rna')) or \
        isinstance(bpe, _bp('RnaRegion')) or \
        isinstance(bpe, _bpimpl('RnaRegion')) or \
        isinstance(bpe, _bp('DnaRegion')) or \
        isinstance(bpe, _bpimpl('DnaRegion')) or \
        isinstance(bpe, _bp('PhysicalEntity')) or \
        isinstance(bpe, _bpimpl('PhysicalEntity')):
        return True
    else:
        return False
731133
@Override
    public boolean matches(IAtom atom) {
        if (!atom.getSymbol().equals("H")) {
            return false;
        }

        if (atom.getFormalCharge() == 1) { // proton matches
            return true;
        }

        // hydrogens connected to other hydrogens, e.g., molecular hydrogen
        List<IAtom> list = invariants(atom).target().getConnectedAtomsList(atom);
        for (IAtom connAtom : list) {
            if (connAtom.getSymbol().equals("H")) {
                return true;
            }
        }

        // hydrogens connected to other than one other atom, e.g., bridging hydrogens
        if (invariants(atom).degree() > 1) {
            return true;
        }

        //isotopic hydrogen specifications, e.g. deuterium [2H] or tritium etc
        if (atom.getMassNumber() != null) {
            if (getMassNumber().intValue() == atom.getMassNumber().intValue()) return true;
        } else {
            // target atom is [H], so make sure query atom has mass number = 1
            if (getMassNumber() == 1) return true;
        }

        return false;
    }
311518
public Protein getCauses_protein(int i) {
    if (Event_Type.featOkTst && ((Event_Type)jcasType).casFeat_causes_protein == null)
      jcasType.jcas.throwFeatMissing("causes_protein", "ch.epfl.bbp.uima.genia.Event");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((Event_Type)jcasType).casFeatCode_causes_protein), i);
    return (Protein)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((Event_Type)jcasType).casFeatCode_causes_protein), i)));}
484857
def is_code(self):
        """"""
        if self.cell_type == 'code':
            return True
        if self.cell_type == 'raw' and 'active' in self.metadata:
            return True
        return False
317093
private boolean isAlleleCorrect(String allele, boolean acceptAmbiguousBases) {
        if (StringUtils.isNotEmpty(allele)) {
            for (char base : allele.toCharArray()) {
                if (!isValidBase(base, acceptAmbiguousBases)) {
                    return false;
                }
            }
        }
        return true;
    }
143527
private static boolean familyHalogen(IAtom atom) {
        String symbol = atom.getSymbol();
        if (symbol.equals("F") || symbol.equals("Cl") || symbol.equals("Br") || symbol.equals("I"))
            return true;
        else
            return false;
    }
504211
function Molecule(classes) {
	var molecule = {
		className: '',
		atoms: [],
		pseudoTypes: [],
		mediaQueries: []
	};

	function stripMoleculeName() {
		molecule.className = _.remove(classes, function (name){
			return name[0] === '_';
		})[0];
	}

	function getAtoms() {
		molecule.atoms = classes.map(function (atom) { return Atom(atom); });
	}

	function getPseudoClassNames() {
		molecule.atoms.map(function (atom){ 
			if(atom.pseudo !== '' && !_.contains(molecule.pseudoTypes, atom.pseudo)){
				molecule.pseudoTypes.push(atom.pseudo);
			}
		});
	}

	function getMediaQueries() {
		molecule.atoms.map(function (atom){ 
			if(atom.mediaQuery !== '' && !_.contains(molecule.mediaQueries, atom.mediaQuery)){
				molecule.mediaQueries.push(atom.mediaQuery);
			}
		});
	}

	stripMoleculeName()
	getAtoms();
	getPseudoClassNames();
	getMediaQueries();

	return molecule;
}
123913
def find_charged(self, mol):
        """"""
        data = namedtuple('pcharge', 'atoms atoms_orig_idx type center restype resnr reschain')
        a_set = []
        # Iterate through all residue, exclude those in chains defined as peptides
        for res in [r for r in pybel.ob.OBResidueIter(mol.OBMol) if not r.GetChain() in config.PEPTIDES]:
            if config.INTRA is not None:
                if res.GetChain() != config.INTRA:
                    continue
            a_contributing = []
            a_contributing_orig_idx = []
            if res.GetName() in ('ARG', 'HIS', 'LYS'):  # Arginine, Histidine or Lysine have charged sidechains
                for a in pybel.ob.OBResidueAtomIter(res):
                    if a.GetType().startswith('N') and res.GetAtomProperty(a, 8) \
                            and not self.Mapper.mapid(a.GetIdx(), mtype='protein') in self.altconf:
                        a_contributing.append(pybel.Atom(a))
                        a_contributing_orig_idx.append(self.Mapper.mapid(a.GetIdx(), mtype='protein'))
                if not len(a_contributing) == 0:
                    a_set.append(data(atoms=a_contributing,
                                      atoms_orig_idx=a_contributing_orig_idx,
                                      type='positive',
                                      center=centroid([ac.coords for ac in a_contributing]),
                                      restype=res.GetName(),
                                      resnr=res.GetNum(),
                                      reschain=res.GetChain()))
            if res.GetName() in ('GLU', 'ASP'):  # Aspartic or Glutamic Acid
                for a in pybel.ob.OBResidueAtomIter(res):
                    if a.GetType().startswith('O') and res.GetAtomProperty(a, 8) \
                            and not self.Mapper.mapid(a.GetIdx(), mtype='protein') in self.altconf:
                        a_contributing.append(pybel.Atom(a))
                        a_contributing_orig_idx.append(self.Mapper.mapid(a.GetIdx(), mtype='protein'))
                if not len(a_contributing) == 0:
                    a_set.append(data(atoms=a_contributing,
                                      atoms_orig_idx=a_contributing_orig_idx,
                                      type='negative',
                                      center=centroid([ac.coords for ac in a_contributing]),
                                      restype=res.GetName(),
                                      resnr=res.GetNum(),
                                      reschain=res.GetChain()))
        return a_set
790592
protected boolean semanticallyEquivalent(BioPAXElement element)
	{
		final deltaGprimeO that = (deltaGprimeO) element;

		return
			(Float.compare(that.getDELTA_G_PRIME_O(), DELTA_G_PRIME_O) == 0)
				&& (Float.compare(that.getIONIC_STRENGTH(), IONIC_STRENGTH) == 0)
				&& (Float.compare(that.getPH(), PH) == 0)
				&& (Float.compare(that.getPMG(), PMG) == 0)
				&& (Float.compare(that.getTEMPERATURE(), TEMPERATURE) == 0);
	}
937410
protected boolean semanticallyEquivalent(BioPAXElement element)
	{
		final kPrime aKPrime = (kPrime) element;
		return
			(Float.compare(aKPrime.getIONIC_STRENGTH(), IONIC_STRENGTH) == 0) &&
				(Float.compare(aKPrime.getK_PRIME(), K_PRIME) == 0) &&
				(Float.compare(aKPrime.getPH(), PH) == 0) &&
				(Float.compare(aKPrime.getPMG(), PMG) == 0) &&
				(Float.compare(aKPrime.getTEMPERATURE(), TEMPERATURE) == 0);
	}
646148
def _is_from_chemical_system(chemical_system, struct):
        
        chemsys = list(set([sp.symbol for sp in struct.composition]))
        if len(chemsys) != len(chemical_system):
            return False
        for el in chemsys:
            if not el in chemical_system:
                return False
        return True
458971
private boolean matchAtoms(Match match) {
        IAtom atom = match.getTargetAtom();
        if (match.getQueryNode().countNeighbors() > target.countNeighbors(atom)) {
            return false;
        }
        return match.getQueryNode().getAtomMatcher().matches(target, atom);
    }
2892
def is_protein_package(self):
        '''

        '''
        if not hasattr(self, '_is_protein_package'):
            self._is_protein_package = GraftMPackageVersion3.graftm_package_is_protein(self)
        return self._is_protein_package
614398
public Chemicals getLigand() {
    if (GeneRegulationTemplate_Type.featOkTst && ((GeneRegulationTemplate_Type)jcasType).casFeat_ligand == null)
      jcasType.jcas.throwFeatMissing("ligand", "de.julielab.jules.types.bootstrep.GeneRegulationTemplate");
    return (Chemicals)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((GeneRegulationTemplate_Type)jcasType).casFeatCode_ligand)));}