Aligns ca1 with ca2 permuted by <i>cp</i> residues.
<p><strong>WARNING:</strong> Modifies ca2 during the permutation. Be sure
to make a copy before calling this method.

@param ca1
@param ca2
@param param
@param cp
@return
@throws StructureException
173681
public AFPChain alignPermuted(Atom[] ca1, Atom[] ca2, Object param, int cp) throws StructureException {
		// initial permutation
		permuteArray(ca2,cp);

		// perform alignment
		AFPChain afpChain = super.align(ca1, ca2, param);

		// un-permute alignment
		permuteAFPChain(afpChain, -cp);

		if(afpChain.getName2() != null) {
			afpChain.setName2(afpChain.getName2()+" CP="+cp);
		}

		// Specify the permuted
		return afpChain;
	}
115491
@Pure
	public static <P1, P2> Procedure1<P2> curry(final Procedure2<? super P1, ? super P2> procedure, final P1 argument) {
		if (procedure == null)
			throw new NullPointerException("procedure");
		return new Procedure1<P2>() {
			@Override
			public void apply(P2 p) {
				procedure.apply(argument, p);
			}
		};
	}
119865
public final void synpred39_InternalXbase_fragment() throws RecognitionException {   
        // InternalXbase.g:2414:2: ( ( ( rule__XMemberFeatureCall__MemberCallArgumentsAssignment_1_1_3_1_0 ) ) )
        // InternalXbase.g:2414:2: ( ( rule__XMemberFeatureCall__MemberCallArgumentsAssignment_1_1_3_1_0 ) )
        {
        // InternalXbase.g:2414:2: ( ( rule__XMemberFeatureCall__MemberCallArgumentsAssignment_1_1_3_1_0 ) )
        // InternalXbase.g:2415:3: ( rule__XMemberFeatureCall__MemberCallArgumentsAssignment_1_1_3_1_0 )
        {
        if ( state.backtracking==0 ) {
           before(grammarAccess.getXMemberFeatureCallAccess().getMemberCallArgumentsAssignment_1_1_3_1_0()); 
        }
        // InternalXbase.g:2416:3: ( rule__XMemberFeatureCall__MemberCallArgumentsAssignment_1_1_3_1_0 )
        // InternalXbase.g:2416:4: rule__XMemberFeatureCall__MemberCallArgumentsAssignment_1_1_3_1_0
        {
        pushFollow(FOLLOW_2);
        rule__XMemberFeatureCall__MemberCallArgumentsAssignment_1_1_3_1_0();

        state._fsp--;
        if (state.failed) return ;

        }


        }


        }
    }
633414
public void set( double x1, double y1, double z1,
					 double x2, double y2, double z2 ) {
		this.p1.set(x1,y1,z1);
		this.p2.set(x2,y2,z2);
	}
775745
private static Group[] chainAfp(FatCatParameters params,AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException{

		// we don;t want to rotate input atoms, do we?
		Atom[] ca2clone = StructureTools.cloneAtomArray(ca2);

		List<AFP> afpSet = afpChain.getAfpSet();

		if (debug)
			System.out.println("entering chainAfp");
		int afpNum = afpSet.size();

		if ( afpNum < 1)
			return new Group[0];

		long bgtime = System.currentTimeMillis();
		if(debug)    {
			System.out.println(String.format("total AFP %d\n", afpNum));
		}

		//run AFP chaining

		AFPChainer.doChainAfp(params,afpChain ,ca1,ca2);

		int afpChainLen = afpChain.getAfpChainLen();

		if(afpChainLen < 1)     {

			afpChain.setShortAlign(true);
			return new Group[0];
		} //very short alignment

		long chaintime = System.currentTimeMillis();
		if(debug)    {

			System.out.println("Afp chaining: time " + (chaintime-bgtime));
		}

		// do post processing

		AFPPostProcessor.postProcess(params, afpChain,ca1,ca2);

		// Optimize the final alignment

		AFPOptimizer.optimizeAln(params, afpChain,ca1,ca2);

		AFPOptimizer.blockInfo( afpChain);

		AFPOptimizer.updateScore(params,afpChain);

		AFPAlignmentDisplay.getAlign(afpChain,ca1,ca2);

		Group[] twistedPDB = AFPTwister.twistPDB(afpChain, ca1, ca2clone);

		SigEva sig =  new SigEva();
		double probability = sig.calSigAll(params, afpChain);
		afpChain.setProbability(probability);
		double normAlignScore = sig.calNS(params,afpChain);
		afpChain.setNormAlignScore(normAlignScore);
		double tmScore = AFPChainScorer.getTMScore(afpChain, ca1, ca2,false);
		afpChain.setTMScore(tmScore);

		/*

		SIGEVA  sig;
		probability = sig.calSigAll(maxTra, sparse, pro1Len, pro2Len, alignScore, totalRmsdOpt, optLength, blockNum - 1);
		normAlignScore = sig.calNS(pro1Len, pro2Len, alignScore, totalRmsdOpt, optLength, blockNum - 1);

		 */

		//if(maxTra == 0)       probability = sig.calSigRigid(pro1Len, pro2Len, alignScore, totalRmsdOpt, optLength);
		//else  probability = sig.calSigFlexi(pro1Len, pro2Len, alignScore, totalRmsdOpt, optLength, blockNum - 1);

		if(debug)    {

			long nowtime = System.currentTimeMillis();
			long diff = nowtime - chaintime;
			System.out.println("Alignment optimization: time "+ diff);

			System.out.println("score:      " + afpChain.getAlignScore());
			System.out.println("opt length: " + afpChain.getOptLength());
			System.out.println("opt rmsd:   "+ afpChain.getTotalRmsdOpt());

		}
		return twistedPDB;

	}
1048866
def _preprocess(self, struct1, struct2, niggli=True):
        
        struct1 = struct1.copy()
        struct2 = struct2.copy()

        if niggli:
            struct1 = struct1.get_reduced_structure(reduction_algo="niggli")
            struct2 = struct2.get_reduced_structure(reduction_algo="niggli")

        # primitive cell transformation
        if self._primitive_cell:
            struct1 = struct1.get_primitive_structure()
            struct2 = struct2.get_primitive_structure()

        if self._supercell:
            fu, s1_supercell = self._get_supercell_size(struct1, struct2)
        else:
            fu, s1_supercell = 1, True
        mult = fu if s1_supercell else 1/fu

        # rescale lattice to same volume
        if self._scale:
            ratio = (struct2.volume / (struct1.volume * mult)) ** (1 / 6)
            nl1 = Lattice(struct1.lattice.matrix * ratio)
            struct1.lattice = nl1
            nl2 = Lattice(struct2.lattice.matrix / ratio)
            struct2.lattice = nl2

        return struct1, struct2, fu, s1_supercell
986359
@SuppressWarnings("unchecked")
  public static <E, C extends Counter<E>> C union(C c1, C c2) {
    C result = (C) c1.getFactory().create();
    addInPlace(result, c1);
    addInPlace(result, c2);
    return result;
  }
497468
public static void updateSymmetryScores(MultipleAlignment symm)
			throws StructureException {

		// Multiply by the order of symmetry to normalize score
		double tmScore = MultipleAlignmentScorer.getAvgTMScore(symm)
				* symm.size();
		double rmsd = MultipleAlignmentScorer.getRMSD(symm);

		symm.putScore(MultipleAlignmentScorer.AVGTM_SCORE, tmScore);
		symm.putScore(MultipleAlignmentScorer.RMSD, rmsd);
	}
642498
public static void checkAssignability(Class<?> c1, Class<?> c2) {
		COMPARISON_TYPE ct1 = COMPARISON_TYPE.fromClass(c1);
		COMPARISON_TYPE ct2 = COMPARISON_TYPE.fromClass(c2);
		try {
			COMPARISON_TYPE.fromOperands(ct1, ct2);
		} catch (Exception e) {
			throw DBLogger.newUser("Cannot assign " + c2 + " to " + c1, e);
		}
	}
432250
public void calcScores(Atom[] ca1, Atom[] ca2){
		eqr0 = idx1.length;
		gaps0 = count_gaps(idx1,idx2);

		percId = 0;
		// calc the % id
		for (int i=0 ; i< idx1.length; i++){
			Atom a1 = ca1[idx1[i]];
			Atom a2 = ca2[idx2[i]];

			Group g1 = a1.getGroup();
			Group g2 = a2.getGroup();
			if ( g1.getPDBName().equals(g2.getPDBName())){
				percId++;
			}

		}
	}
728554
public static final List<Chain> getAlignedModel(Atom[] ca){

		List<Chain> model = new ArrayList<Chain>();
		for ( Atom a: ca){

			Group g = a.getGroup();
			Chain parentC = g.getChain();

			Chain newChain = null;
			for ( Chain c :  model) {
				if ( c.getId().equals(parentC.getId())){
					newChain = c;
					break;
				}
			}
			if ( newChain == null){

				newChain = new ChainImpl();

				newChain.setId(parentC.getId());

				model.add(newChain);
			}

			newChain.addGroup(g);

		}

		return model;
	}
38837
public static StructureAlignmentJmol display(AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException {

		if ( ca1.length < 1 || ca2.length < 1){
			throw new StructureException("length of atoms arrays is too short! " + ca1.length + "," + ca2.length);
		}

		Group[] twistedGroups = AlignmentTools.prepareGroupsForDisplay(afpChain, ca1, ca2);

		List<Group> hetatms  = StructureTools.getUnalignedGroups(ca1);
		List<Group> hetatms2 = StructureTools.getUnalignedGroups(ca2);

		return DisplayAFP.display(afpChain, twistedGroups, ca1, ca2, hetatms, hetatms2);

	}
699077
public void identify(final Structure structure,
			final Set<ProteinModification> potentialModifications) {
		if (structure==null) {
			throw new IllegalArgumentException("Null structure.");
		}

		identify(structure.getChains(), potentialModifications);
	}
625715
@Override
	public Structure loadStructure(AtomCache cache) throws StructureException,
			IOException {
		StructureFiletype format = StructureFiletype.UNKNOWN;

		// Use user-specified format
		try {
			Map<String, String> params = parseQuery(url);
			if(params.containsKey(FORMAT_PARAM)) {
				String formatStr = params.get(FORMAT_PARAM);
				format = StructureIO.guessFiletype("."+formatStr);
			}
		} catch (UnsupportedEncodingException e) {
			logger.error("Unable to decode URL "+url,e);
		}

		// Guess format from extension
		if(format == StructureFiletype.UNKNOWN) {
			format = StructureIO.guessFiletype(url.getPath());
		}

		switch(format) {
		case CIF:
			// need to do mmcif parsing!

			InputStreamProvider prov = new InputStreamProvider();
			InputStream inStream =  prov.getInputStream(url);

			MMcifParser parser = new SimpleMMcifParser();

			SimpleMMcifConsumer consumer = new SimpleMMcifConsumer();
			consumer.setFileParsingParameters(cache.getFileParsingParams());


			parser.addMMcifConsumer(consumer);

			try {
				parser.parse(new BufferedReader(new InputStreamReader(inStream)));
			} catch (IOException e){
				e.printStackTrace();
			}

			// now get the protein structure.
			return consumer.getStructure();
		default:
		case PDB:
			// pdb file based parsing

			PDBFileReader reader = new PDBFileReader(cache.getPath());
			reader.setFetchBehavior(cache.getFetchBehavior());
			reader.setObsoleteBehavior(cache.getObsoleteBehavior());
			reader.setFileParsingParameters(cache.getFileParsingParams());
			return reader.getStructure(url);
		}
	}
402326
public void process() throws IOException, StructureException {
		if(sequences == null) { // only process once, then return cached values
			LinkedHashMap<String, ProteinSequence> sequenceMap = reader.process();

			sequences = sequenceMap.values().toArray(new ProteinSequence[0]);
			accessions = new String[sequences.length];
			structures = new Structure[sequences.length];
			residues = new ResidueNumber[sequences.length][];

			// Match each sequence  to a series of PDB Residue numbers
			for(int i=0;i<sequences.length;i++) {
				accessions[i] = sequences[i].getAccession().getID();

				//System.out.println("Fetching "+accession);
				structures[i] = cache.getStructure(accessions[i]);

				residues[i] = StructureSequenceMatcher.matchSequenceToStructure(sequences[i], structures[i]);

				assert( residues[i].length == sequences[i].getLength());
			}
		}
	}
809806
public void addParameter(String paramName, String paramValue) {
        this.parameters.add(new StructureParameter(paramName, paramValue));
    }
376798
public void setStructure1(Structure structure){
		this.structure1 = structure;
		if ( structure != null) {
			setAtoms(structure1,panel1);
			label1.setText(structure.getPDBCode());
			label1.repaint();
		}


	}