Convert a Chain object to PDB representation

@param chain
@return
548820
public static String toPDB(Chain chain){
		StringBuffer w = new StringBuffer();
		int nrGroups = chain.getAtomLength();

		for ( int h=0; h<nrGroups;h++){

			Group g= chain.getAtomGroup(h);


			toPDB(g,w);


		}

		return w.toString();
	}
17490
public static void verifyChain(List<X509Certificate> chain)
	{
		if (chain == null || chain.isEmpty())
			throw new IllegalArgumentException("Must provide a chain that is non-null and non-empty");

		for (int i = 0; i < chain.size(); i++)
		{
			final X509Certificate certificate = chain.get(i);
			final int issuerIndex = (i != 0) ?
			                        i - 1 :
			                        0; // The index of the issuer is the previous cert (& the root must, of course, sign itself)
			final X509Certificate issuer = chain.get(issuerIndex);

			// Verify the certificate was indeed issued by the previous certificate in the chain
			try
			{
				certificate.verify(issuer.getPublicKey());
			}
			catch (GeneralSecurityException e)
			{
				final String msg = "Failure verifying " + certificate + " against claimed issuer " + issuer;

				throw new IllegalArgumentException(msg + ": " + e.getMessage(), e);
			}
		}
	}
340013
public static ChainableStatement change(JsScope jsScope)
	{
		return new DefaultChainableStatement(StateEvent.CHANGE.getEventLabel(), jsScope.render());
	}
749873
private List<Certificate> convertToBouncyCastleCertificate(
      X509Certificate[] chain)
  {
    final List<Certificate> bcChain = new ArrayList<>();
    for (X509Certificate cert : chain)
    {
      try
      {
        bcChain.add(Certificate.getInstance(cert.getEncoded()));
      }
      catch (CertificateEncodingException ex)
      {
        throw new RuntimeException("Failed to decode the certificate DER data");
      }
    }
    return bcChain;
  }
736662
def check_hex_chain(chain):
    
    return codecs.encode(check_chain([(codecs.decode(i[0], 'hex_codec'), i[1]) for i in chain]), 'hex_codec')
53254
public static VersionMigratorChain chain(String fromVersion, String toVersion) {
        List<IVersionMigrator> matchedMigrators = new ArrayList<>();
        for (Entry entry : migrators) {
            if (entry.isBetween(fromVersion, toVersion)) {
                matchedMigrators.add(entry.migrator);
            }
        }
        return new VersionMigratorChain(matchedMigrators);
    }
738514
def copy(chain: MiningChain) -> MiningChain:
    
    if not isinstance(chain, MiningChain):
        raise ValidationError("`at_block_number` may only be used with 'MiningChain")
    base_db = chain.chaindb.db
    if not isinstance(base_db, AtomicDB):
        raise ValidationError("Unsupported database type: {0}".format(type(base_db)))

    if isinstance(base_db.wrapped_db, MemoryDB):
        db = AtomicDB(MemoryDB(base_db.wrapped_db.kv_store.copy()))
    else:
        raise ValidationError("Unsupported wrapped database: {0}".format(type(base_db.wrapped_db)))

    chain_copy = type(chain)(db, chain.header)
    return chain_copy
859937
@Override
    public synchronized void startChain(ChainData chain) throws ChannelException, ChainException {
        String chainName = (null != chain) ? chain.getName() : null;
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "startChain: " + chainName);
        }
        if (null == chain) {
            throw new InvalidChainNameException("Null chain");
        }

        // Ensure we have an inbound chain.
        if (FlowType.OUTBOUND.equals(chain.getType())) {
            throw new InvalidChainNameException("Outbound chain cannot use this interface.");
        }

        startChainInternal(chain);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "startChain");
        }
    }
332217
private static int getPositionForPDBresunm(String pdbresnum, String authId , Atom[] atoms){
		ResidueNumber residueNumber =  ResidueNumber.fromString(pdbresnum);
		residueNumber.setChainName(authId);

		boolean blankChain = authId == null || authId.equalsIgnoreCase("null") || authId.equals("_");

		for ( int i =0; i< atoms.length ;i++){
			Group g = atoms[i].getGroup();

			// match _ to any chain
			if( blankChain ) {
				residueNumber.setChainName(g.getChain().getName());
			}

			//System.out.println(g.getResidueNumber() + "< ? >" + residueNumber +"<");
			if ( g.getResidueNumber().equals(residueNumber)){
				//System.out.println(g + " == " + residueNumber );
				Chain c = g.getChain();
				if ( blankChain || c.getName().equals(authId)){
					return i;
				}
			}
		}
		return -1;
	}
582253
def get_chain_ids(self, pdb_id = None, safe_call = False):
        ''''''

        if pdb_id == None and len(self.keys()) == 1:
            return self[self.keys()[0]].keys()

        pdbID = pdbID.upper()
        if not self.get(pdbID):
            if not safe_call:
                raise Exception("FASTA object does not contain sequences for PDB %s." % pdbID)
            else:
                return []
        return self[pdbID].keys()
175458
public static final void transform (Chain chain, Matrix4d m) {

		for (Group g : chain.getAtomGroups()) {
			transform(g, m);
		}
	}
699124
def replace_seqres(self, pdb, update_atoms = True):
    """"""
  
    newpdb = PDB()
    inserted_seqres = False
    entries_before_seqres = set(["HEADER", "OBSLTE", "TITLE",  "CAVEAT", "COMPND", "SOURCE", 
                                 "KEYWDS", "EXPDTA", "AUTHOR", "REVDAT", "SPRSDE", "JRNL", 
                                 "REMARK", "DBREF",  "SEQADV"])
  
    mutated_resids = {}
    
    if update_atoms:
      old_seqs = ChainSequences()
      chainresnums = old_seqs.parse_atoms(pdb)
    
      assert self.keys() == old_seqs.keys()
      
      for chain in self.keys():
        assert len(self[chain]) == len(old_seqs[chain])
        for i in xrange(len(self[chain])):
          if self[chain][i] != old_seqs[chain][i]:
            resid = chain + chainresnums[chain][i]
            mutated_resids[resid] = self[chain][i]
    
    for line in pdb.lines:
    
      entry = line[0:6]
      if (not inserted_seqres) and entry not in entries_before_seqres:
        inserted_seqres = True
        newpdb.lines += self.seqres_lines()
      
      if update_atoms and entry == "ATOM  ":
        resid = line[21:27]
        atom = line[12:16].strip()
        if not mutated_resids.has_key(resid):
          newpdb.lines += [line]
        else:
          newpdb.lines += [line[:17] + mutated_resids[resid] + line[20:]]
      elif entry != "SEQRES":
        newpdb.lines += [line]
    
    if update_atoms:
      newpdb.remove_nonbackbone_atoms(mutated_resids.keys())
    
    return newpdb
705837
def make_pdb(self):
        """"""
        pdb_str = write_pdb(
            [self], ' ' if not self.parent else self.parent.id)
        return pdb_str
1214695
def get_chain_mapping(self, pdb_name1, pdb_name2):
        ''''''
        raise Exception('Implement. Map pdb_namex to its equivalence class, call get_representative_chain_mapping, and something something.')
        pprint.pprint(self.chain_mapping)

        d = {}
        for pdb1_chain_id, matched_chain_list in self.chain_mapping[(pdb_name1, pdb_name2)].iteritems():
            d[pdb1_chain_id] = matched_chain_list.get_related_chains_ids(pdb_name2)
        return d
803515
public String toPDB() {


		StringBuffer str = new StringBuffer();
		//int i = 0 ;



		// TODO: print all the PDB header informaton in PDB style
		// some objects (PDBHeader, Compound) are still missing
		//

		PDBHeader header = structure.getPDBHeader();
		header.toPDB(str);


		//REMARK 800
		if (!structure.getSites().isEmpty()) {
			str.append("REMARK 800                                                                      ").append(newline);
			str.append("REMARK 800 SITE                                                                 ").append(newline);
			for (Site site : structure.getSites()) {
				site.remark800toPDB(str);
			}
		}
		//DBREF
		for (DBRef dbref : structure.getDBRefs()){
			dbref.toPDB(str);
			str.append(newline);
		}
		//SSBOND
		List<SSBondImpl> ssbonds = SSBondImpl.getSsBondListFromBondList(structure.getSSBonds());
		for (SSBondImpl ssbond : ssbonds){
			ssbond.toPDB(str);
			str.append(newline);
		}
		//SITE
		for (Site site : structure.getSites()) {
			try {
				site.toPDB(str);
			} catch (Exception e){
				e.printStackTrace();
			}
		}

		//
		// print the atom records
		//

		// do for all models
		int nrModels = structure.nrModels() ;
		if ( structure.isNmr()) {
			str.append("EXPDTA    NMR, "+ nrModels+" STRUCTURES"+newline) ;
		}
		for (int m = 0 ; m < nrModels ; m++) {


			if ( nrModels>1 ) {
				str.append("MODEL      " + (m+1)+ newline);
			}

			List<Chain> polyChains = structure.getPolyChains(m);
			List<Chain> nonPolyChains = structure.getNonPolyChains(m);
			List<Chain> waterChains = structure.getWaterChains(m);

			for (Chain chain : polyChains) {

				// do for all groups
				int nrGroups = chain.getAtomLength();
				for ( int h=0; h<nrGroups;h++){

					Group g= chain.getAtomGroup(h);

					toPDB(g,str);

				}
				// End any polymeric chain with a "TER" record
				if (nrGroups > 0) str.append(String.format("%-80s","TER")).append(newline);

			}

			boolean nonPolyGroupsExist = false;
			for (Chain chain : nonPolyChains) {

				// do for all groups
				int nrGroups = chain.getAtomLength();
				for ( int h=0; h<nrGroups;h++){

					Group g= chain.getAtomGroup(h);

					toPDB(g,str);

					nonPolyGroupsExist = true;
				}

			}
			if (nonPolyGroupsExist) str.append(String.format("%-80s","TER")).append(newline);;

			boolean waterGroupsExist = false;
			for (Chain chain : waterChains) {

				// do for all groups
				int nrGroups = chain.getAtomLength();
				for ( int h=0; h<nrGroups;h++){

					Group g= chain.getAtomGroup(h);

					toPDB(g,str);

					waterGroupsExist = true;
				}

			}
			if (waterGroupsExist) str.append(String.format("%-80s","TER")).append(newline);;


			if ( nrModels>1) {
				str.append(String.format("%-80s","ENDMDL")).append(newline);
			}



		}

		if ( doPrintConnections() )
			str.append(printPDBConnections());

		return str.toString() ;
	}
685595
@Override
    public synchronized ChainData getChain(String chainName) {
        ChainData chainData = null;
        // Ensure the input chain name is not null
        if (null != chainName) {
            chainData = this.chainDataMap.get(chainName);
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "getChain: " + chainName + " found=" + (null != chainData));
        }
        return chainData;
    }
94968
public static ChainableStatement dblclick(JsScope jsScope)
	{
		return new DefaultChainableStatement(MouseEvent.DBLCLICK.getEventLabel(), jsScope.render());
	}