Return true if this package is an Amino Acid alignment package, otherwise
        False i.e. it is a nucleotide package. Cache the result for speed.
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
508147
def is_compatible_assembly_level(self, ncbi_assembly_level):
        """"""
        configured_ncbi_strings = [self._LEVELS[level] for level in self.assembly_level]
        return ncbi_assembly_level in configured_ncbi_strings
856109
public static boolean isValidClassName(String s) {
        if (s.length() < 1) return false;
        if (s.equals("package-info")) return true;
        if (surrogatesSupported) {
            int cp = s.codePointAt(0);
            if (!Character.isJavaIdentifierStart(cp))
                return false;
            for (int j = Character.charCount(cp); j < s.length(); j += Character.charCount(cp)) {
                cp = s.codePointAt(j);
                if (!Character.isJavaIdentifierPart(cp))
                    return false;
            }
        } else {
            if (!Character.isJavaIdentifierStart(s.charAt(0)))
                return false;
            for (int j = 1; j < s.length(); j++)
                if (!Character.isJavaIdentifierPart(s.charAt(j)))
                    return false;
        }
        return true;
    }
785335
def check_structure_chain_quality(self, seqprop, structprop, chain_id,
                                      seq_ident_cutoff=0.5, allow_missing_on_termini=0.2,
                                      allow_mutants=True, allow_deletions=False,
                                      allow_insertions=False, allow_unresolved=True):
        """"""
        alignment = self._get_seqprop_to_structprop_alignment(seqprop=seqprop, structprop=structprop, chain_id=chain_id)

        # Compare sequence to structure's sequence using the alignment
        chain_passes_quality_check = ssbio.protein.structure.properties.quality.sequence_checker(reference_seq_aln=alignment[0],
                                                                   structure_seq_aln=alignment[1],
                                                                   seq_ident_cutoff=seq_ident_cutoff,
                                                                   allow_missing_on_termini=allow_missing_on_termini,
                                                                   allow_mutants=allow_mutants,
                                                                   allow_deletions=allow_deletions,
                                                                   allow_insertions=allow_insertions,
                                                                   allow_unresolved=allow_unresolved)
        return chain_passes_quality_check
141826
public static FastaSequence convertProteinSequencetoFasta(ProteinSequence sequence){
		StringBuffer buf = new StringBuffer();
		for (AminoAcidCompound compound : sequence) {

			String c = compound.getShortName();

			if (! SequenceUtil.NON_AA.matcher(c).find()) {
				buf.append(c);
			} else {
				buf.append("X");
			}
		}

		return new FastaSequence(sequence.getAccession().getID(),buf.toString());
	}
296183
def _is_rna(pe):
    """"""
    val = isinstance(pe, _bp('Rna')) or isinstance(pe, _bpimpl('Rna'))
    return val
678223
public static AFPChain fastaToAfpChain(SequencePair<Sequence<AminoAcidCompound>, AminoAcidCompound> alignment,
			Structure structure1, Structure structure2) throws StructureException {
		List<AlignedSequence<Sequence<AminoAcidCompound>, AminoAcidCompound>> seqs = alignment.getAlignedSequences();
		StringBuilder sb1 = new StringBuilder();
		for (AminoAcidCompound a : seqs.get(0)) {
			sb1.append(a.getBase());
		}
		try {
			ProteinSequence seq1 = new ProteinSequence(sb1.toString());
			StringBuilder sb2 = new StringBuilder();
			for (AminoAcidCompound a : seqs.get(1)) {
				sb1.append(a.getBase());
			}
			ProteinSequence seq2 = new ProteinSequence(sb2.toString());
			LinkedHashMap<String, ProteinSequence> map = new LinkedHashMap<String, ProteinSequence>();
			map.put(structure1.getName(), seq1);
			map.put(structure2.getName(), seq2);
			return fastaToAfpChain(map, structure1, structure2);
		} catch (CompoundNotFoundException e) {
			logger.error("Unexpected error while creating protein sequences: {}. This is most likely a bug.",e.getMessage());
			return null;
		}
	}
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;
    }
181493
private boolean inSamePackage(Class<?> c1, Class<?> c2) {
        String nameC1 = c1.getName();
        String nameC2 = c2.getName();
        int indexDotC1 = nameC1.lastIndexOf('.');
        int indexDotC2 = nameC2.lastIndexOf('.');
        if (indexDotC1 != indexDotC2) {
            return false; // cannot be in the same package if indices are not the same
        }
        if (indexDotC1 == -1) {
            return true; // both of them are in default package
        }
        return nameC1.regionMatches(0, nameC2, 0, indexDotC1);
    }
254063
public function matchesPackage(array $array) {
		if (isset($array['package']) && $array['package'] == $this->package->getName()
				&& isset($array['class']) && $array['class'] == $this->getClassName()) {
			return true;
		} else {
			return false;
		}
	}
1373223
private void identifyAdditionalAttachments(ModifiedCompound mc,
			List<Group> ligands, List<Chain> chains) {
		if (ligands.isEmpty()) {
			return;
		}

		// TODO: should the additional groups only be allowed to the identified
		// ligands or both amino acids and ligands? Currently only on ligands
		// ligands to amino acid bonds for same modification of unknown category
		// will be combined in mergeModComps()
		// TODO: how about chain-chain links?
		List<Group> identifiedGroups = new ArrayList<Group>();
		for (StructureGroup num : mc.getGroups(false)) {
			Group group;
			try {
				//String numIns = "" + num.getResidueNumber();
				//if (num.getInsCode() != null) {
				//	numIns += num.getInsCode();
				//}
				ResidueNumber resNum = new ResidueNumber();
				resNum.setChainName(num.getChainId());
				resNum.setSeqNum(num.getResidueNumber());
				resNum.setInsCode(num.getInsCode());
				//group = chain.getGroupByPDB(numIns);

				group = getGroup(num,chains);
				//group = mapChainIdChain.get(num.getChainId()).getGroupByPDB(resNum);
			} catch (StructureException e) {
				logger.error("Exception: ", e);
				// should not happen
				continue;
			}
			identifiedGroups.add(group);
		}

		int start = 0;

		int n = identifiedGroups.size();
		while (n > start) {
			for (Group group1 : ligands) {
				for (int i=start; i<n; i++) {
					Group group2 = identifiedGroups.get(i);
					if (!identifiedGroups.contains(group1)) {
						List<Atom[]> linkedAtoms = StructureUtil.findAtomLinkages(
								group1, group2, false, bondLengthTolerance);
						if (!linkedAtoms.isEmpty()) {
							for (Atom[] atoms : linkedAtoms) {
								mc.addAtomLinkage(StructureUtil.getStructureAtomLinkage(atoms[0],
										false, atoms[1], false));
							}
							identifiedGroups.add(group1);
							break;
						}
					}
				}
			}

			start = n;
			n = identifiedGroups.size();
		}
	}
595397
private static boolean isInChain(Group g) {
		ChemComp chemComp = g.getChemComp();

		if (chemComp==null) {
			logger.warn("Warning: can't determine PolymerType for group "+g.getResidueNumber()+" ("+g.getPDBName()+"). Will consider it as non-nucleotide/non-protein type.");
			return false;
		}

		PolymerType polyType = chemComp.getPolymerType();
		for (PolymerType protOnlyType: PolymerType.PROTEIN_ONLY) {
			if (polyType==protOnlyType) return true;
		}
		for (PolymerType protOnlyType: PolymerType.POLYNUCLEOTIDE_ONLY) {
			if (polyType==protOnlyType) return true;
		}

		return false;
	}
497056
public static boolean isValidJavaPackage(String packageName) {
        if (isBlank(packageName)) {
            return false;
        }
        final String[] parts = packageName.split("\\.");
        for (String part : parts) {
            if (!isValidJavaIdentifier(part)) {
                return false;
            }
        }
        return true;
    }
676012
static private boolean hasFileMatch(String path, List<String> patterns) {
        path = Util.normalizeDriveLetter(path);
        for (String p : patterns) {
            // Exact match
            if (p.equals(path)) {
                return true;
            }
            // Single dot the end matches this package and all its subpackages.
            if (p.startsWith("*")) {
                // Remove the wildcard
                String patsuffix = p.substring(1);
                // Does the path start with the pattern prefix?
                if (path.endsWith(patsuffix)) {
                    return true;
                }
            }
        }
        return false;
    }
1216533
def sequence_charge(seq, pH=7.4):
    
    if 'X' in seq:
        warnings.warn(_nc_warning_str, NoncanonicalWarning)
    adj_protein_charge = sum(
        [partial_charge(aa, pH) * residue_charge[aa] * n
         for aa, n in Counter(seq).items()])
    adj_protein_charge += (
        partial_charge('N-term', pH) * residue_charge['N-term'])
    adj_protein_charge += (
        partial_charge('C-term', pH) * residue_charge['C-term'])
    return adj_protein_charge
1157459
@SuppressWarnings("unchecked")
	protected void calculateIndirectAmbiguities() {
		Map<NucleotideCompound, List<NucleotideCompound>> equivalentsMap = new HashMap<NucleotideCompound, List<NucleotideCompound>>();

		List<NucleotideCompound> ambiguousCompounds = new ArrayList<NucleotideCompound>();
		for(NucleotideCompound compound: getAllCompounds()) {
			if (!compound.isAmbiguous()) {
				continue;
			}
			ambiguousCompounds.add(compound);
		}

		for(NucleotideCompound sourceCompound: ambiguousCompounds) {
			Set<NucleotideCompound> compoundConstituents = sourceCompound.getConstituents();
			for(NucleotideCompound targetCompound: ambiguousCompounds) {
				Set<NucleotideCompound> targetConstituents = targetCompound.getConstituents();
				if(targetConstituents.containsAll(compoundConstituents)) {
					NucleotideCompound lcSourceCompound = toLowerCase(sourceCompound);
					NucleotideCompound lcTargetCompound = toLowerCase(targetCompound);

				//equivalentsMap.put(sourceCompound, targetCompound);
			//      equivalentsMap.put(sourceCompound, lcTargetCompound);


					checkAdd(equivalentsMap, sourceCompound, targetCompound);
					checkAdd(equivalentsMap, sourceCompound, lcTargetCompound);

					checkAdd(equivalentsMap,targetCompound,sourceCompound);
					checkAdd(equivalentsMap, lcTargetCompound, sourceCompound);

					checkAdd(equivalentsMap, lcSourceCompound, targetCompound);
					checkAdd(equivalentsMap, lcSourceCompound, lcTargetCompound);

				}
			}
		}

		//And once it's all done start adding them to the equivalents map

		for ( NucleotideCompound key: equivalentsMap.keySet()){
			List<NucleotideCompound> vals = equivalentsMap.get(key);
			for (NucleotideCompound value: vals){
				addEquivalent((C)key,(C)value);
				addEquivalent((C)value,(C)key);
			}
		}
	}
342415
public static AminoAcidSequence translate(NucleotideSequence sequence) {
        if (sequence.size() % 3 != 0)
            throw new IllegalArgumentException("Only nucleotide sequences with size multiple " +
                    "of three are supported (in-frame).");
        byte[] aaData = new byte[sequence.size() / 3];
        GeneticCode.translate(aaData, 0, sequence, 0, sequence.size());
        return new AminoAcidSequence(aaData, true);
    }