id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31,600 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/pairwise/AlternativeAlignment.java | AlternativeAlignment.super_pos_alig | private void super_pos_alig(Atom[]ca1,Atom[]ca2,int[] idx1, int[] idx2, boolean getRMS) throws StructureException{
//System.out.println("superpos alig ");
Atom[] ca1subset = new Atom[idx1.length];
Atom[] ca2subset = new Atom[idx2.length];
for (int i = 0 ; i < idx1.length;i++){
//System.out.println("idx1 "+ idx1[i] + " " + idx2[i]);
int pos1 = idx1[i];
int pos2 = idx2[i];
ca1subset[i] = ca1[pos1];
ca2subset[i] = (Atom) ca2[pos2].clone();
}
Matrix4d trans = SuperPositions.superpose(Calc.atomsToPoints(ca1subset),
Calc.atomsToPoints(ca2subset));
this.currentRotMatrix = Matrices.getRotationJAMA(trans);
this.currentTranMatrix = Calc.getTranslationVector(trans);
//currentRotMatrix.print(3,3);
if ( getRMS) {
rotateShiftAtoms(ca2subset);
this.rms = Calc.rmsd(ca1subset,ca2subset);
}
} | java | private void super_pos_alig(Atom[]ca1,Atom[]ca2,int[] idx1, int[] idx2, boolean getRMS) throws StructureException{
//System.out.println("superpos alig ");
Atom[] ca1subset = new Atom[idx1.length];
Atom[] ca2subset = new Atom[idx2.length];
for (int i = 0 ; i < idx1.length;i++){
//System.out.println("idx1 "+ idx1[i] + " " + idx2[i]);
int pos1 = idx1[i];
int pos2 = idx2[i];
ca1subset[i] = ca1[pos1];
ca2subset[i] = (Atom) ca2[pos2].clone();
}
Matrix4d trans = SuperPositions.superpose(Calc.atomsToPoints(ca1subset),
Calc.atomsToPoints(ca2subset));
this.currentRotMatrix = Matrices.getRotationJAMA(trans);
this.currentTranMatrix = Calc.getTranslationVector(trans);
//currentRotMatrix.print(3,3);
if ( getRMS) {
rotateShiftAtoms(ca2subset);
this.rms = Calc.rmsd(ca1subset,ca2subset);
}
} | [
"private",
"void",
"super_pos_alig",
"(",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
",",
"int",
"[",
"]",
"idx1",
",",
"int",
"[",
"]",
"idx2",
",",
"boolean",
"getRMS",
")",
"throws",
"StructureException",
"{",
"//System.out.println(\"superpo... | Superimposes two molecules according to residue index list idx1 and idx2.
Does not change the original coordinates.
as an internal result the rotation matrix and shift vectors for are set
@param ca1 Atom set 1
@param ca2 Atom set 2
@param idx1 idx positions in set1
@param idx2 idx positions in set2
@param getRMS a flag if the RMS should be calculated
@throws StructureException | [
"Superimposes",
"two",
"molecules",
"according",
"to",
"residue",
"index",
"list",
"idx1",
"and",
"idx2",
".",
"Does",
"not",
"change",
"the",
"original",
"coordinates",
".",
"as",
"an",
"internal",
"result",
"the",
"rotation",
"matrix",
"and",
"shift",
"vecto... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/pairwise/AlternativeAlignment.java#L768-L794 |
31,601 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/pairwise/AlternativeAlignment.java | AlternativeAlignment.getAlignedStructure | public Structure getAlignedStructure(Structure s1, Structure s2){
// do not change the original coords ..
Structure s3 = s2.clone();
currentRotMatrix.print(3,3);
Calc.rotate(s3, currentRotMatrix);
Calc.shift( s3, currentTranMatrix);
Structure newpdb = new StructureImpl();
newpdb.setPDBCode("Java");
newpdb.setName("Aligned with BioJava");
newpdb.addModel(s1.getChains(0));
newpdb.addModel(s3.getChains(0));
return newpdb;
} | java | public Structure getAlignedStructure(Structure s1, Structure s2){
// do not change the original coords ..
Structure s3 = s2.clone();
currentRotMatrix.print(3,3);
Calc.rotate(s3, currentRotMatrix);
Calc.shift( s3, currentTranMatrix);
Structure newpdb = new StructureImpl();
newpdb.setPDBCode("Java");
newpdb.setName("Aligned with BioJava");
newpdb.addModel(s1.getChains(0));
newpdb.addModel(s3.getChains(0));
return newpdb;
} | [
"public",
"Structure",
"getAlignedStructure",
"(",
"Structure",
"s1",
",",
"Structure",
"s2",
")",
"{",
"// do not change the original coords ..",
"Structure",
"s3",
"=",
"s2",
".",
"clone",
"(",
")",
";",
"currentRotMatrix",
".",
"print",
"(",
"3",
",",
"3",
... | create an artifical Structure object that contains the two
structures superimposed onto each other. Each structure is in a separate model.
Model 1 is structure 1 and Model 2 is structure 2.
@param s1 the first structure. its coordinates will not be changed
@param s2 the second structure, it will be cloned and the cloned coordinates will be rotated according to the alignment results.
@return composite structure containing the 2 aligned structures as a models 1 and 2 | [
"create",
"an",
"artifical",
"Structure",
"object",
"that",
"contains",
"the",
"two",
"structures",
"superimposed",
"onto",
"each",
"other",
".",
"Each",
"structure",
"is",
"in",
"a",
"separate",
"model",
".",
"Model",
"1",
"is",
"structure",
"1",
"and",
"Mo... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/pairwise/AlternativeAlignment.java#L849-L868 |
31,602 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/pairwise/AlternativeAlignment.java | AlternativeAlignment.toPDB | public String toPDB(Structure s1, Structure s2){
Structure newpdb = getAlignedStructure(s1, s2);
return newpdb.toPDB();
} | java | public String toPDB(Structure s1, Structure s2){
Structure newpdb = getAlignedStructure(s1, s2);
return newpdb.toPDB();
} | [
"public",
"String",
"toPDB",
"(",
"Structure",
"s1",
",",
"Structure",
"s2",
")",
"{",
"Structure",
"newpdb",
"=",
"getAlignedStructure",
"(",
"s1",
",",
"s2",
")",
";",
"return",
"newpdb",
".",
"toPDB",
"(",
")",
";",
"}"
] | converts the alignment to a PDB file
each of the structures will be represented as a model.
@param s1
@param s2
@return a PDB file as a String | [
"converts",
"the",
"alignment",
"to",
"a",
"PDB",
"file",
"each",
"of",
"the",
"structures",
"will",
"be",
"represented",
"as",
"a",
"model",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/pairwise/AlternativeAlignment.java#L878-L884 |
31,603 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/ChromosomeSequence.java | ChromosomeSequence.addGene | public GeneSequence addGene(AccessionID accession, int bioBegin, int bioEnd, Strand strand) {
GeneSequence geneSequence = new GeneSequence(this, bioBegin, bioEnd, strand);
geneSequence.setAccession(accession);
geneSequenceHashMap.put(accession.toString(), geneSequence);
return geneSequence;
} | java | public GeneSequence addGene(AccessionID accession, int bioBegin, int bioEnd, Strand strand) {
GeneSequence geneSequence = new GeneSequence(this, bioBegin, bioEnd, strand);
geneSequence.setAccession(accession);
geneSequenceHashMap.put(accession.toString(), geneSequence);
return geneSequence;
} | [
"public",
"GeneSequence",
"addGene",
"(",
"AccessionID",
"accession",
",",
"int",
"bioBegin",
",",
"int",
"bioEnd",
",",
"Strand",
"strand",
")",
"{",
"GeneSequence",
"geneSequence",
"=",
"new",
"GeneSequence",
"(",
"this",
",",
"bioBegin",
",",
"bioEnd",
",",... | Add a gene to the chromosome sequence using bioIndexing starts at 1 instead of 0. The
GeneSequence that is returned will have a reference to parent chromosome sequence
which actually contains the sequence data. Strand is important for positive and negative
direction where negative strand means we need reverse complement. If negative strand then
bioBegin will be greater than bioEnd
@param accession
@param begin
@param end
@param strand
@return | [
"Add",
"a",
"gene",
"to",
"the",
"chromosome",
"sequence",
"using",
"bioIndexing",
"starts",
"at",
"1",
"instead",
"of",
"0",
".",
"The",
"GeneSequence",
"that",
"is",
"returned",
"will",
"have",
"a",
"reference",
"to",
"parent",
"chromosome",
"sequence",
"w... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/ChromosomeSequence.java#L136-L141 |
31,604 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/aligpanel/AFPChainCoordManager.java | AFPChainCoordManager.getPanelPos | public Point getPanelPos(int aligSeq, int i) {
Point p = new Point();
// get line
// we do integer division since we ignore remainders
int lineNr = i / DEFAULT_LINE_LENGTH;
// but we want to have the reminder for the line position.
int linePos = i % DEFAULT_LINE_LENGTH;
int x = linePos * DEFAULT_CHAR_SIZE + DEFAULT_X_SPACE + DEFAULT_LEGEND_SIZE;
int y = lineNr * DEFAULT_Y_STEP + DEFAULT_Y_SPACE;
y += DEFAULT_LINE_SEPARATION * aligSeq;
p.setLocation(x, y);
return p;
} | java | public Point getPanelPos(int aligSeq, int i) {
Point p = new Point();
// get line
// we do integer division since we ignore remainders
int lineNr = i / DEFAULT_LINE_LENGTH;
// but we want to have the reminder for the line position.
int linePos = i % DEFAULT_LINE_LENGTH;
int x = linePos * DEFAULT_CHAR_SIZE + DEFAULT_X_SPACE + DEFAULT_LEGEND_SIZE;
int y = lineNr * DEFAULT_Y_STEP + DEFAULT_Y_SPACE;
y += DEFAULT_LINE_SEPARATION * aligSeq;
p.setLocation(x, y);
return p;
} | [
"public",
"Point",
"getPanelPos",
"(",
"int",
"aligSeq",
",",
"int",
"i",
")",
"{",
"Point",
"p",
"=",
"new",
"Point",
"(",
")",
";",
"// get line",
"// we do integer division since we ignore remainders",
"int",
"lineNr",
"=",
"i",
"/",
"DEFAULT_LINE_LENGTH",
";... | get the position of the sequence position on the Panel
@param aligSeq 0 or 1 for which of the two sequences to ask for.
@param i sequence position
@return the point on a panel for a sequence position | [
"get",
"the",
"position",
"of",
"the",
"sequence",
"position",
"on",
"the",
"Panel"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/aligpanel/AFPChainCoordManager.java#L127-L146 |
31,605 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/aligpanel/AFPChainCoordManager.java | AFPChainCoordManager.getLegendPosition | public Point getLegendPosition(int lineNr, int chainNr) {
int x = DEFAULT_X_SPACE ;
int y = lineNr * DEFAULT_Y_STEP + DEFAULT_Y_SPACE;
y += chainNr * DEFAULT_LINE_SEPARATION;
Point p = new Point(x,y);
return p;
} | java | public Point getLegendPosition(int lineNr, int chainNr) {
int x = DEFAULT_X_SPACE ;
int y = lineNr * DEFAULT_Y_STEP + DEFAULT_Y_SPACE;
y += chainNr * DEFAULT_LINE_SEPARATION;
Point p = new Point(x,y);
return p;
} | [
"public",
"Point",
"getLegendPosition",
"(",
"int",
"lineNr",
",",
"int",
"chainNr",
")",
"{",
"int",
"x",
"=",
"DEFAULT_X_SPACE",
";",
"int",
"y",
"=",
"lineNr",
"*",
"DEFAULT_Y_STEP",
"+",
"DEFAULT_Y_SPACE",
";",
"y",
"+=",
"chainNr",
"*",
"DEFAULT_LINE_SE... | provide the coordinates for where to draw the legend for line X and if it is chain 1 or 2
@param lineNr which line is this for
@param chainNr is it chain 0 or 1
@return get the point where to draw the legend | [
"provide",
"the",
"coordinates",
"for",
"where",
"to",
"draw",
"the",
"legend",
"for",
"line",
"X",
"and",
"if",
"it",
"is",
"chain",
"1",
"or",
"2"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/aligpanel/AFPChainCoordManager.java#L192-L201 |
31,606 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaWriterHelper.java | FastaWriterHelper.writeProteinSequence | public static void writeProteinSequence(File file,
Collection<ProteinSequence> proteinSequences) throws Exception {
FileOutputStream outputStream = new FileOutputStream(file);
BufferedOutputStream bo = new BufferedOutputStream(outputStream);
writeProteinSequence(bo, proteinSequences);
bo.close();
outputStream.close();
} | java | public static void writeProteinSequence(File file,
Collection<ProteinSequence> proteinSequences) throws Exception {
FileOutputStream outputStream = new FileOutputStream(file);
BufferedOutputStream bo = new BufferedOutputStream(outputStream);
writeProteinSequence(bo, proteinSequences);
bo.close();
outputStream.close();
} | [
"public",
"static",
"void",
"writeProteinSequence",
"(",
"File",
"file",
",",
"Collection",
"<",
"ProteinSequence",
">",
"proteinSequences",
")",
"throws",
"Exception",
"{",
"FileOutputStream",
"outputStream",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
... | Write collection of protein sequences to a file
@param file
@param proteinSequences
@throws Exception | [
"Write",
"collection",
"of",
"protein",
"sequences",
"to",
"a",
"file"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaWriterHelper.java#L55-L62 |
31,607 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaWriterHelper.java | FastaWriterHelper.writeSequence | public static void writeSequence(File file, Sequence<?> sequence) throws Exception {
FileOutputStream outputStream = new FileOutputStream(file);
BufferedOutputStream bo = new BufferedOutputStream(outputStream);
writeSequences(bo, singleSeqToCollection(sequence));
bo.close();
outputStream.close();
} | java | public static void writeSequence(File file, Sequence<?> sequence) throws Exception {
FileOutputStream outputStream = new FileOutputStream(file);
BufferedOutputStream bo = new BufferedOutputStream(outputStream);
writeSequences(bo, singleSeqToCollection(sequence));
bo.close();
outputStream.close();
} | [
"public",
"static",
"void",
"writeSequence",
"(",
"File",
"file",
",",
"Sequence",
"<",
"?",
">",
"sequence",
")",
"throws",
"Exception",
"{",
"FileOutputStream",
"outputStream",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"BufferedOutputStream",
"bo"... | Write a sequence to a file
@param file
@param sequence
@throws Exception | [
"Write",
"a",
"sequence",
"to",
"a",
"file"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaWriterHelper.java#L148-L154 |
31,608 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaWriterHelper.java | FastaWriterHelper.writeSequence | public static void writeSequence(OutputStream outputStream, Sequence<?> sequence) throws Exception {
writeSequences(outputStream, singleSeqToCollection(sequence));
} | java | public static void writeSequence(OutputStream outputStream, Sequence<?> sequence) throws Exception {
writeSequences(outputStream, singleSeqToCollection(sequence));
} | [
"public",
"static",
"void",
"writeSequence",
"(",
"OutputStream",
"outputStream",
",",
"Sequence",
"<",
"?",
">",
"sequence",
")",
"throws",
"Exception",
"{",
"writeSequences",
"(",
"outputStream",
",",
"singleSeqToCollection",
"(",
"sequence",
")",
")",
";",
"}... | Write a sequence to OutputStream
@param outputStream
@param sequence
@throws Exception | [
"Write",
"a",
"sequence",
"to",
"OutputStream"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/FastaWriterHelper.java#L162-L164 |
31,609 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/views/WindowedSequence.java | WindowedSequence.get | public SequenceView<C> get(int index) {
int start = toStartIndex(index);
int end = index + (getWindowSize() - 1);
return getBackingSequence().getSubSequence(start, end);
} | java | public SequenceView<C> get(int index) {
int start = toStartIndex(index);
int end = index + (getWindowSize() - 1);
return getBackingSequence().getSubSequence(start, end);
} | [
"public",
"SequenceView",
"<",
"C",
">",
"get",
"(",
"int",
"index",
")",
"{",
"int",
"start",
"=",
"toStartIndex",
"(",
"index",
")",
";",
"int",
"end",
"=",
"index",
"+",
"(",
"getWindowSize",
"(",
")",
"-",
"1",
")",
";",
"return",
"getBackingSequ... | Returns the window specified at the given index in offsets i.e. asking
for position 2 in a moving window sequence of size 3 will get you
the window starting at position 4. | [
"Returns",
"the",
"window",
"specified",
"at",
"the",
"given",
"index",
"in",
"offsets",
"i",
".",
"e",
".",
"asking",
"for",
"position",
"2",
"in",
"a",
"moving",
"window",
"sequence",
"of",
"size",
"3",
"will",
"get",
"you",
"the",
"window",
"starting"... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/views/WindowedSequence.java#L106-L110 |
31,610 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/jmolScript/JmolSymmetryScriptGeneratorPointGroup.java | JmolSymmetryScriptGeneratorPointGroup.getPolyhedronColor | private Color4f getPolyhedronColor() {
Color4f[] colors = getSymmetryColors(5);
Color4f strongestColor = colors[4];
Color4f complement = new Color4f(Color.WHITE);
complement.sub(strongestColor);
return complement;
} | java | private Color4f getPolyhedronColor() {
Color4f[] colors = getSymmetryColors(5);
Color4f strongestColor = colors[4];
Color4f complement = new Color4f(Color.WHITE);
complement.sub(strongestColor);
return complement;
} | [
"private",
"Color4f",
"getPolyhedronColor",
"(",
")",
"{",
"Color4f",
"[",
"]",
"colors",
"=",
"getSymmetryColors",
"(",
"5",
")",
";",
"Color4f",
"strongestColor",
"=",
"colors",
"[",
"4",
"]",
";",
"Color4f",
"complement",
"=",
"new",
"Color4f",
"(",
"Co... | Return a color that is complementary to the symmetry color
@return | [
"Return",
"a",
"color",
"that",
"is",
"complementary",
"to",
"the",
"symmetry",
"color"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/jmolScript/JmolSymmetryScriptGeneratorPointGroup.java#L568-L574 |
31,611 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.countCompounds | public static <C extends Compound> int countCompounds(
Sequence<C> sequence, C... compounds) {
int count = 0;
Map<C, Integer> compositon = getComposition(sequence);
for (C compound : compounds) {
if(compositon.containsKey(compound)) {
count = compositon.get(compound) + count;
}
}
return count;
} | java | public static <C extends Compound> int countCompounds(
Sequence<C> sequence, C... compounds) {
int count = 0;
Map<C, Integer> compositon = getComposition(sequence);
for (C compound : compounds) {
if(compositon.containsKey(compound)) {
count = compositon.get(compound) + count;
}
}
return count;
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"int",
"countCompounds",
"(",
"Sequence",
"<",
"C",
">",
"sequence",
",",
"C",
"...",
"compounds",
")",
"{",
"int",
"count",
"=",
"0",
";",
"Map",
"<",
"C",
",",
"Integer",
">",
"compositon",
... | For the given vargs of compounds this method counts the number of
times those compounds appear in the given sequence
@param sequence The {@link Sequence} to perform the count on
@param compounds The compounds to look for
@param <C> The type of compound we are looking for
@return The number of times the given compounds appear in this Sequence | [
"For",
"the",
"given",
"vargs",
"of",
"compounds",
"this",
"method",
"counts",
"the",
"number",
"of",
"times",
"those",
"compounds",
"appear",
"in",
"the",
"given",
"sequence"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L62-L72 |
31,612 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.countGC | public static int countGC(Sequence<NucleotideCompound> sequence) {
CompoundSet<NucleotideCompound> cs = sequence.getCompoundSet();
NucleotideCompound G = cs.getCompoundForString("G");
NucleotideCompound C = cs.getCompoundForString("C");
NucleotideCompound g = cs.getCompoundForString("g");
NucleotideCompound c = cs.getCompoundForString("c");
return countCompounds(sequence, G, C, g, c);
} | java | public static int countGC(Sequence<NucleotideCompound> sequence) {
CompoundSet<NucleotideCompound> cs = sequence.getCompoundSet();
NucleotideCompound G = cs.getCompoundForString("G");
NucleotideCompound C = cs.getCompoundForString("C");
NucleotideCompound g = cs.getCompoundForString("g");
NucleotideCompound c = cs.getCompoundForString("c");
return countCompounds(sequence, G, C, g, c);
} | [
"public",
"static",
"int",
"countGC",
"(",
"Sequence",
"<",
"NucleotideCompound",
">",
"sequence",
")",
"{",
"CompoundSet",
"<",
"NucleotideCompound",
">",
"cs",
"=",
"sequence",
".",
"getCompoundSet",
"(",
")",
";",
"NucleotideCompound",
"G",
"=",
"cs",
".",
... | Returns the count of GC in the given sequence
@param sequence The {@link NucleotideCompound} {@link Sequence} to perform
the GC analysis on
@return The number of GC compounds in the sequence | [
"Returns",
"the",
"count",
"of",
"GC",
"in",
"the",
"given",
"sequence"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L81-L88 |
31,613 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.countAT | public static int countAT(Sequence<NucleotideCompound> sequence) {
CompoundSet<NucleotideCompound> cs = sequence.getCompoundSet();
NucleotideCompound A = cs.getCompoundForString("A");
NucleotideCompound T = cs.getCompoundForString("T");
NucleotideCompound a = cs.getCompoundForString("a");
NucleotideCompound t = cs.getCompoundForString("t");
return countCompounds(sequence, A, T, a, t);
} | java | public static int countAT(Sequence<NucleotideCompound> sequence) {
CompoundSet<NucleotideCompound> cs = sequence.getCompoundSet();
NucleotideCompound A = cs.getCompoundForString("A");
NucleotideCompound T = cs.getCompoundForString("T");
NucleotideCompound a = cs.getCompoundForString("a");
NucleotideCompound t = cs.getCompoundForString("t");
return countCompounds(sequence, A, T, a, t);
} | [
"public",
"static",
"int",
"countAT",
"(",
"Sequence",
"<",
"NucleotideCompound",
">",
"sequence",
")",
"{",
"CompoundSet",
"<",
"NucleotideCompound",
">",
"cs",
"=",
"sequence",
".",
"getCompoundSet",
"(",
")",
";",
"NucleotideCompound",
"A",
"=",
"cs",
".",
... | Returns the count of AT in the given sequence
@param sequence The {@link NucleotideCompound} {@link Sequence} to perform
the AT analysis on
@return The number of AT compounds in the sequence | [
"Returns",
"the",
"count",
"of",
"AT",
"in",
"the",
"given",
"sequence"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L97-L104 |
31,614 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.getComposition | public static <C extends Compound> Map<C, Integer> getComposition(Sequence<C> sequence) {
Map<C, Integer> results = new HashMap<C, Integer>();
for (C currentCompound : sequence) {
Integer currentInteger = results.get(currentCompound);
if ( currentInteger == null)
currentInteger = 0;
currentInteger++;
results.put(currentCompound, currentInteger);
}
return results;
} | java | public static <C extends Compound> Map<C, Integer> getComposition(Sequence<C> sequence) {
Map<C, Integer> results = new HashMap<C, Integer>();
for (C currentCompound : sequence) {
Integer currentInteger = results.get(currentCompound);
if ( currentInteger == null)
currentInteger = 0;
currentInteger++;
results.put(currentCompound, currentInteger);
}
return results;
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"Map",
"<",
"C",
",",
"Integer",
">",
"getComposition",
"(",
"Sequence",
"<",
"C",
">",
"sequence",
")",
"{",
"Map",
"<",
"C",
",",
"Integer",
">",
"results",
"=",
"new",
"HashMap",
"<",
"C",
... | Does a linear scan over the given Sequence and records the number of
times each base appears. The returned map will return 0 if a compound
is asked for and the Map has no record of it.
@param <C> The type of compound to look for
@param sequence The type of sequence to look over
@return Counts for the instances of all compounds in the sequence | [
"Does",
"a",
"linear",
"scan",
"over",
"the",
"given",
"Sequence",
"and",
"records",
"the",
"number",
"of",
"times",
"each",
"base",
"appears",
".",
"The",
"returned",
"map",
"will",
"return",
"0",
"if",
"a",
"compound",
"is",
"asked",
"for",
"and",
"the... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L135-L146 |
31,615 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.write | public static <C extends Compound> void write(Appendable appendable, Sequence<C> sequence) throws IOException {
for(C compound: sequence) {
appendable.append(compound.toString());
}
} | java | public static <C extends Compound> void write(Appendable appendable, Sequence<C> sequence) throws IOException {
for(C compound: sequence) {
appendable.append(compound.toString());
}
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"void",
"write",
"(",
"Appendable",
"appendable",
",",
"Sequence",
"<",
"C",
">",
"sequence",
")",
"throws",
"IOException",
"{",
"for",
"(",
"C",
"compound",
":",
"sequence",
")",
"{",
"appendable",... | Used as a way of sending a Sequence to a writer without the cost of
converting to a full length String and then writing the data out
@param <C> Type of compound
@param writer The writer to send data to
@param sequence The sequence to write out
@throws IOException Thrown if we encounter a problem | [
"Used",
"as",
"a",
"way",
"of",
"sending",
"a",
"Sequence",
"to",
"a",
"writer",
"without",
"the",
"cost",
"of",
"converting",
"to",
"a",
"full",
"length",
"String",
"and",
"then",
"writing",
"the",
"data",
"out"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L157-L161 |
31,616 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.indexOf | public static <C extends Compound> int indexOf(Sequence<C> sequence,
C compound) {
int index = 1;
for (C currentCompound : sequence) {
if (currentCompound.equals(compound)) {
return index;
}
index++;
}
return 0;
} | java | public static <C extends Compound> int indexOf(Sequence<C> sequence,
C compound) {
int index = 1;
for (C currentCompound : sequence) {
if (currentCompound.equals(compound)) {
return index;
}
index++;
}
return 0;
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"int",
"indexOf",
"(",
"Sequence",
"<",
"C",
">",
"sequence",
",",
"C",
"compound",
")",
"{",
"int",
"index",
"=",
"1",
";",
"for",
"(",
"C",
"currentCompound",
":",
"sequence",
")",
"{",
"if"... | Performs a linear search of the given Sequence for the given compound.
Once we find the compound we return the position. | [
"Performs",
"a",
"linear",
"search",
"of",
"the",
"given",
"Sequence",
"for",
"the",
"given",
"compound",
".",
"Once",
"we",
"find",
"the",
"compound",
"we",
"return",
"the",
"position",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L201-L211 |
31,617 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.createIterator | public static <C extends Compound> Iterator<C> createIterator(
Sequence<C> sequence) {
return new SequenceIterator<C>(sequence);
} | java | public static <C extends Compound> Iterator<C> createIterator(
Sequence<C> sequence) {
return new SequenceIterator<C>(sequence);
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"Iterator",
"<",
"C",
">",
"createIterator",
"(",
"Sequence",
"<",
"C",
">",
"sequence",
")",
"{",
"return",
"new",
"SequenceIterator",
"<",
"C",
">",
"(",
"sequence",
")",
";",
"}"
] | Creates a simple sequence iterator which moves through a sequence going
from 1 to the length of the Sequence. Modification of the Sequence is not
allowed. | [
"Creates",
"a",
"simple",
"sequence",
"iterator",
"which",
"moves",
"through",
"a",
"sequence",
"going",
"from",
"1",
"to",
"the",
"length",
"of",
"the",
"Sequence",
".",
"Modification",
"of",
"the",
"Sequence",
"is",
"not",
"allowed",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L230-L233 |
31,618 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.createSubSequence | public static <C extends Compound> SequenceView<C> createSubSequence(
Sequence<C> sequence, int start, int end) {
return new SequenceProxyView<C>(sequence, start, end);
} | java | public static <C extends Compound> SequenceView<C> createSubSequence(
Sequence<C> sequence, int start, int end) {
return new SequenceProxyView<C>(sequence, start, end);
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"SequenceView",
"<",
"C",
">",
"createSubSequence",
"(",
"Sequence",
"<",
"C",
">",
"sequence",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"new",
"SequenceProxyView",
"<",
"C",
">... | Creates a simple sub sequence view delimited by the given start and end. | [
"Creates",
"a",
"simple",
"sub",
"sequence",
"view",
"delimited",
"by",
"the",
"given",
"start",
"and",
"end",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L238-L241 |
31,619 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.checksum | public static <C extends Compound> String checksum(Sequence<C> sequence) {
CRC64Checksum checksum = new CRC64Checksum();
for (C compound : sequence) {
checksum.update(compound.getShortName());
}
return checksum.toString();
} | java | public static <C extends Compound> String checksum(Sequence<C> sequence) {
CRC64Checksum checksum = new CRC64Checksum();
for (C compound : sequence) {
checksum.update(compound.getShortName());
}
return checksum.toString();
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"String",
"checksum",
"(",
"Sequence",
"<",
"C",
">",
"sequence",
")",
"{",
"CRC64Checksum",
"checksum",
"=",
"new",
"CRC64Checksum",
"(",
")",
";",
"for",
"(",
"C",
"compound",
":",
"sequence",
"... | Performs a simple CRC64 checksum on any given sequence. | [
"Performs",
"a",
"simple",
"CRC64",
"checksum",
"on",
"any",
"given",
"sequence",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L260-L266 |
31,620 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.overlappingKmers | public static <C extends Compound> List<SequenceView<C>> overlappingKmers(Sequence<C> sequence, int kmer) {
List<SequenceView<C>> l = new ArrayList<SequenceView<C>>();
List<Iterator<SequenceView<C>>> windows
= new ArrayList<Iterator<SequenceView<C>>>();
for(int i=1; i<=kmer; i++) {
if(i == 1) {
windows.add(new WindowedSequence<C>(sequence, kmer).iterator());
}
else {
SequenceView<C> sv = sequence.getSubSequence(i, sequence.getLength());
windows.add(new WindowedSequence<C>(sv, kmer).iterator());
}
}
OUTER: while(true) {
for(int i=0; i<kmer; i++) {
Iterator<SequenceView<C>> iterator = windows.get(i);
boolean breakLoop=true;
if(iterator.hasNext()) {
l.add(iterator.next());
breakLoop = false;
}
if(breakLoop) {
break OUTER;
}
}
}
return l;
} | java | public static <C extends Compound> List<SequenceView<C>> overlappingKmers(Sequence<C> sequence, int kmer) {
List<SequenceView<C>> l = new ArrayList<SequenceView<C>>();
List<Iterator<SequenceView<C>>> windows
= new ArrayList<Iterator<SequenceView<C>>>();
for(int i=1; i<=kmer; i++) {
if(i == 1) {
windows.add(new WindowedSequence<C>(sequence, kmer).iterator());
}
else {
SequenceView<C> sv = sequence.getSubSequence(i, sequence.getLength());
windows.add(new WindowedSequence<C>(sv, kmer).iterator());
}
}
OUTER: while(true) {
for(int i=0; i<kmer; i++) {
Iterator<SequenceView<C>> iterator = windows.get(i);
boolean breakLoop=true;
if(iterator.hasNext()) {
l.add(iterator.next());
breakLoop = false;
}
if(breakLoop) {
break OUTER;
}
}
}
return l;
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"List",
"<",
"SequenceView",
"<",
"C",
">",
">",
"overlappingKmers",
"(",
"Sequence",
"<",
"C",
">",
"sequence",
",",
"int",
"kmer",
")",
"{",
"List",
"<",
"SequenceView",
"<",
"C",
">>",
"l",
... | Used to generate overlapping k-mers such i.e. ATGTA will give rise to
ATG, TGT & GTA
@param <C> Compound to use
@param sequence Sequence to build from
@param kmer Kmer size
@return The list of overlapping K-mers | [
"Used",
"to",
"generate",
"overlapping",
"k",
"-",
"mers",
"such",
"i",
".",
"e",
".",
"ATGTA",
"will",
"give",
"rise",
"to",
"ATG",
"TGT",
"&",
"GTA"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L295-L324 |
31,621 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.sequenceEqualityIgnoreCase | public static <C extends Compound> boolean sequenceEqualityIgnoreCase(Sequence<C> source, Sequence<C> target) {
return baseSequenceEquality(source, target, true);
} | java | public static <C extends Compound> boolean sequenceEqualityIgnoreCase(Sequence<C> source, Sequence<C> target) {
return baseSequenceEquality(source, target, true);
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"boolean",
"sequenceEqualityIgnoreCase",
"(",
"Sequence",
"<",
"C",
">",
"source",
",",
"Sequence",
"<",
"C",
">",
"target",
")",
"{",
"return",
"baseSequenceEquality",
"(",
"source",
",",
"target",
"... | A case-insensitive manner of comparing two sequence objects together.
We will throw out any compounds which fail to match on their sequence
length & compound sets used. The code will also bail out the moment
we find something is wrong with a Sequence. Cost to run is linear to
the length of the Sequence.
@param <C> The type of compound
@param source Source sequence to assess
@param target Target sequence to assess
@return Boolean indicating if the sequences matched ignoring case | [
"A",
"case",
"-",
"insensitive",
"manner",
"of",
"comparing",
"two",
"sequence",
"objects",
"together",
".",
"We",
"will",
"throw",
"out",
"any",
"compounds",
"which",
"fail",
"to",
"match",
"on",
"their",
"sequence",
"length",
"&",
"compound",
"sets",
"used... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L355-L357 |
31,622 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java | SequenceMixin.sequenceEquality | public static <C extends Compound> boolean sequenceEquality(Sequence<C> source, Sequence<C> target) {
return baseSequenceEquality(source, target, false);
} | java | public static <C extends Compound> boolean sequenceEquality(Sequence<C> source, Sequence<C> target) {
return baseSequenceEquality(source, target, false);
} | [
"public",
"static",
"<",
"C",
"extends",
"Compound",
">",
"boolean",
"sequenceEquality",
"(",
"Sequence",
"<",
"C",
">",
"source",
",",
"Sequence",
"<",
"C",
">",
"target",
")",
"{",
"return",
"baseSequenceEquality",
"(",
"source",
",",
"target",
",",
"fal... | A case-sensitive manner of comparing two sequence objects together.
We will throw out any compounds which fail to match on their sequence
length & compound sets used. The code will also bail out the moment
we find something is wrong with a Sequence. Cost to run is linear to
the length of the Sequence.
@param <C> The type of compound
@param source Source sequence to assess
@param target Target sequence to assess
@return Boolean indicating if the sequences matched | [
"A",
"case",
"-",
"sensitive",
"manner",
"of",
"comparing",
"two",
"sequence",
"objects",
"together",
".",
"We",
"will",
"throw",
"out",
"any",
"compounds",
"which",
"fail",
"to",
"match",
"on",
"their",
"sequence",
"length",
"&",
"compound",
"sets",
"used",... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/SequenceMixin.java#L371-L373 |
31,623 | biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/LocIterator.java | LocIterator.hasNext | public boolean hasNext( int windowSize, int increment )
{
if( windowSize <= 0 )
{
throw new IllegalArgumentException( "Window size must be positive." );
}
try
{
if( increment > 0 )
{
return windowSize == mBounds.suffix( mPosition ).prefix( windowSize ).length();
}
else
{
if( mPosition == 0 )
{
return windowSize == mBounds.suffix( - windowSize ).length();
}
else
{
return windowSize == mBounds.prefix( mPosition ).suffix( - windowSize ).length();
}
}
}
catch( Exception e )
{
return false;
}
} | java | public boolean hasNext( int windowSize, int increment )
{
if( windowSize <= 0 )
{
throw new IllegalArgumentException( "Window size must be positive." );
}
try
{
if( increment > 0 )
{
return windowSize == mBounds.suffix( mPosition ).prefix( windowSize ).length();
}
else
{
if( mPosition == 0 )
{
return windowSize == mBounds.suffix( - windowSize ).length();
}
else
{
return windowSize == mBounds.prefix( mPosition ).suffix( - windowSize ).length();
}
}
}
catch( Exception e )
{
return false;
}
} | [
"public",
"boolean",
"hasNext",
"(",
"int",
"windowSize",
",",
"int",
"increment",
")",
"{",
"if",
"(",
"windowSize",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Window size must be positive.\"",
")",
";",
"}",
"try",
"{",
"if",
... | Check if next window of specified size is available.
@param windowSize Size of window. May be smaller or larger than default window size.
@param increment The increment by which to move the window at each iteration. Note that this
method does not actually change the position. However, it checks the sign of the increment parameter to determine
the direction of the iteration.
@return True if window of specified size is available.
@throws IllegalArgumentException Window size parameter was not positive. | [
"Check",
"if",
"next",
"window",
"of",
"specified",
"size",
"is",
"available",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/LocIterator.java#L91-L120 |
31,624 | biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/LocIterator.java | LocIterator.next | public Location next( int windowSize, int increment )
{
if( windowSize <= 0 )
{
throw new IllegalArgumentException( "Window size must be positive." );
}
if( increment == 0 )
{
throw new IllegalArgumentException( "Increment must be non-zero." );
}
Location r;
try
{
if( increment > 0 )
{
r= mBounds.suffix( mPosition ).prefix( windowSize );
}
else
{
if( mPosition == 0 )
{
r= mBounds.suffix( - windowSize );
}
else
{
r= mBounds.prefix( mPosition ).suffix( - windowSize );
}
}
mPosition+= increment;
}
catch( Exception e )
{
throw new IndexOutOfBoundsException( e.toString() );
}
return r;
} | java | public Location next( int windowSize, int increment )
{
if( windowSize <= 0 )
{
throw new IllegalArgumentException( "Window size must be positive." );
}
if( increment == 0 )
{
throw new IllegalArgumentException( "Increment must be non-zero." );
}
Location r;
try
{
if( increment > 0 )
{
r= mBounds.suffix( mPosition ).prefix( windowSize );
}
else
{
if( mPosition == 0 )
{
r= mBounds.suffix( - windowSize );
}
else
{
r= mBounds.prefix( mPosition ).suffix( - windowSize );
}
}
mPosition+= increment;
}
catch( Exception e )
{
throw new IndexOutOfBoundsException( e.toString() );
}
return r;
} | [
"public",
"Location",
"next",
"(",
"int",
"windowSize",
",",
"int",
"increment",
")",
"{",
"if",
"(",
"windowSize",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Window size must be positive.\"",
")",
";",
"}",
"if",
"(",
"increment"... | Get next window of specified size, then increment position by specified amount.
@return Location of next window.
@param windowSize Size of window to get.
@param increment Amount by which to shift position. If increment is positive, the position is shifted
toward the end of the bounding location; if increment is negative, the position is shifted toward
the beginning of the bounding location.
@throws IndexOutOfBoundsException The next window was not within the bounding location.
@throws IllegalArgumentException The increment was zero, or windowSize was not positive. | [
"Get",
"next",
"window",
"of",
"specified",
"size",
"then",
"increment",
"position",
"by",
"specified",
"amount",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/LocIterator.java#L190-L231 |
31,625 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java | AbstractSequence.setProxySequenceReader | public void setProxySequenceReader(SequenceReader<C> proxyLoader) {
this.sequenceStorage = proxyLoader;
if (proxyLoader instanceof FeaturesKeyWordInterface) {
this.setFeaturesKeyWord((FeaturesKeyWordInterface) sequenceStorage);
}
if (proxyLoader instanceof DatabaseReferenceInterface) {
this.setDatabaseReferences((DatabaseReferenceInterface) sequenceStorage);
}
if (proxyLoader instanceof FeatureRetriever) {
this.setFeatureRetriever((FeatureRetriever) sequenceStorage);
HashMap<String, ArrayList<AbstractFeature>> ff = getFeatureRetriever().getFeatures();
for (String k: ff.keySet()){
for (AbstractFeature f: ff.get(k)){
this.addFeature(f);
}
}
// success of next statement guaranteed because source is a compulsory field
//DBReferenceInfo dbQualifier = (DBReferenceInfo)ff.get("source").get(0).getQualifiers().get("db_xref");
ArrayList<DBReferenceInfo> dbQualifiers = (ArrayList)ff.get("source").get(0).getQualifiers().get("db_xref");
DBReferenceInfo dbQualifier = dbQualifiers.get(0);
if (dbQualifier != null) this.setTaxonomy(new TaxonomyID(dbQualifier.getDatabase()+":"+dbQualifier.getId(), DataSource.UNKNOWN));
}
if(getAccession() == null && proxyLoader instanceof UniprotProxySequenceReader){ // we have lots of unsupported operations for this call so quick fix to allow this tow rork
this.setAccession(proxyLoader.getAccession());
}
} | java | public void setProxySequenceReader(SequenceReader<C> proxyLoader) {
this.sequenceStorage = proxyLoader;
if (proxyLoader instanceof FeaturesKeyWordInterface) {
this.setFeaturesKeyWord((FeaturesKeyWordInterface) sequenceStorage);
}
if (proxyLoader instanceof DatabaseReferenceInterface) {
this.setDatabaseReferences((DatabaseReferenceInterface) sequenceStorage);
}
if (proxyLoader instanceof FeatureRetriever) {
this.setFeatureRetriever((FeatureRetriever) sequenceStorage);
HashMap<String, ArrayList<AbstractFeature>> ff = getFeatureRetriever().getFeatures();
for (String k: ff.keySet()){
for (AbstractFeature f: ff.get(k)){
this.addFeature(f);
}
}
// success of next statement guaranteed because source is a compulsory field
//DBReferenceInfo dbQualifier = (DBReferenceInfo)ff.get("source").get(0).getQualifiers().get("db_xref");
ArrayList<DBReferenceInfo> dbQualifiers = (ArrayList)ff.get("source").get(0).getQualifiers().get("db_xref");
DBReferenceInfo dbQualifier = dbQualifiers.get(0);
if (dbQualifier != null) this.setTaxonomy(new TaxonomyID(dbQualifier.getDatabase()+":"+dbQualifier.getId(), DataSource.UNKNOWN));
}
if(getAccession() == null && proxyLoader instanceof UniprotProxySequenceReader){ // we have lots of unsupported operations for this call so quick fix to allow this tow rork
this.setAccession(proxyLoader.getAccession());
}
} | [
"public",
"void",
"setProxySequenceReader",
"(",
"SequenceReader",
"<",
"C",
">",
"proxyLoader",
")",
"{",
"this",
".",
"sequenceStorage",
"=",
"proxyLoader",
";",
"if",
"(",
"proxyLoader",
"instanceof",
"FeaturesKeyWordInterface",
")",
"{",
"this",
".",
"setFeatu... | Very important method that allows external mappings of sequence data and features. This method
will gain additional interface inspection that allows external data sources with knowledge
of features for a sequence to be supported.
@param proxyLoader | [
"Very",
"important",
"method",
"that",
"allows",
"external",
"mappings",
"of",
"sequence",
"data",
"and",
"features",
".",
"This",
"method",
"will",
"gain",
"additional",
"interface",
"inspection",
"that",
"allows",
"external",
"data",
"sources",
"with",
"knowledg... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java#L118-L146 |
31,626 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java | AbstractSequence.getSource | public String getSource() {
if (source != null) {
return source;
}
if (parentSequence != null) {
return parentSequence.getSource();
}
return null;
} | java | public String getSource() {
if (source != null) {
return source;
}
if (parentSequence != null) {
return parentSequence.getSource();
}
return null;
} | [
"public",
"String",
"getSource",
"(",
")",
"{",
"if",
"(",
"source",
"!=",
"null",
")",
"{",
"return",
"source",
";",
"}",
"if",
"(",
"parentSequence",
"!=",
"null",
")",
"{",
"return",
"parentSequence",
".",
"getSource",
"(",
")",
";",
"}",
"return",
... | Added support for the source of this sequence for GFF3 export
If a sub sequence doesn't have source then check for parent source
@return the source | [
"Added",
"support",
"for",
"the",
"source",
"of",
"this",
"sequence",
"for",
"GFF3",
"export",
"If",
"a",
"sub",
"sequence",
"doesn",
"t",
"have",
"source",
"then",
"check",
"for",
"parent",
"source"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java#L267-L275 |
31,627 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java | AbstractSequence.getFeatures | public List<FeatureInterface<AbstractSequence<C>, C>> getFeatures(int bioSequencePosition) {
ArrayList<FeatureInterface<AbstractSequence<C>, C>> featureHits =
new ArrayList<FeatureInterface<AbstractSequence<C>, C>>();
if (features != null) {
for (FeatureInterface<AbstractSequence<C>, C> feature : features) {
if (bioSequencePosition >= feature.getLocations().getStart().getPosition() && bioSequencePosition <= feature.getLocations().getEnd().getPosition()) {
featureHits.add(feature);
}
}
}
return featureHits;
} | java | public List<FeatureInterface<AbstractSequence<C>, C>> getFeatures(int bioSequencePosition) {
ArrayList<FeatureInterface<AbstractSequence<C>, C>> featureHits =
new ArrayList<FeatureInterface<AbstractSequence<C>, C>>();
if (features != null) {
for (FeatureInterface<AbstractSequence<C>, C> feature : features) {
if (bioSequencePosition >= feature.getLocations().getStart().getPosition() && bioSequencePosition <= feature.getLocations().getEnd().getPosition()) {
featureHits.add(feature);
}
}
}
return featureHits;
} | [
"public",
"List",
"<",
"FeatureInterface",
"<",
"AbstractSequence",
"<",
"C",
">",
",",
"C",
">",
">",
"getFeatures",
"(",
"int",
"bioSequencePosition",
")",
"{",
"ArrayList",
"<",
"FeatureInterface",
"<",
"AbstractSequence",
"<",
"C",
">",
",",
"C",
">",
... | Return features at a sequence position
@param bioSequencePosition
@return | [
"Return",
"features",
"at",
"a",
"sequence",
"position"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java#L369-L380 |
31,628 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java | AbstractSequence.addFeature | public void addFeature(int bioStart, int bioEnd, FeatureInterface<AbstractSequence<C>, C> feature) {
SequenceLocation<AbstractSequence<C>, C> sequenceLocation =
new SequenceLocation<AbstractSequence<C>, C>(bioStart, bioEnd, this);
feature.setLocation(sequenceLocation);
addFeature(feature);
} | java | public void addFeature(int bioStart, int bioEnd, FeatureInterface<AbstractSequence<C>, C> feature) {
SequenceLocation<AbstractSequence<C>, C> sequenceLocation =
new SequenceLocation<AbstractSequence<C>, C>(bioStart, bioEnd, this);
feature.setLocation(sequenceLocation);
addFeature(feature);
} | [
"public",
"void",
"addFeature",
"(",
"int",
"bioStart",
",",
"int",
"bioEnd",
",",
"FeatureInterface",
"<",
"AbstractSequence",
"<",
"C",
">",
",",
"C",
">",
"feature",
")",
"{",
"SequenceLocation",
"<",
"AbstractSequence",
"<",
"C",
">",
",",
"C",
">",
... | Method to help set the proper details for a feature as it relates to a sequence
where the feature needs to have a location on the sequence
@param bioStart
@param bioEnd
@param feature | [
"Method",
"to",
"help",
"set",
"the",
"proper",
"details",
"for",
"a",
"feature",
"as",
"it",
"relates",
"to",
"a",
"sequence",
"where",
"the",
"feature",
"needs",
"to",
"have",
"a",
"location",
"on",
"the",
"sequence"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java#L397-L402 |
31,629 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java | AbstractSequence.addFeature | public void addFeature(FeatureInterface<AbstractSequence<C>, C> feature) {
features.add(feature);
ArrayList<FeatureInterface<AbstractSequence<C>, C>> featureList = groupedFeatures.get(feature.getType());
if (featureList == null) {
featureList = new ArrayList<FeatureInterface<AbstractSequence<C>, C>>();
groupedFeatures.put(feature.getType(), featureList);
}
featureList.add(feature);
Collections.sort(features, AbstractFeature.LOCATION_LENGTH);
Collections.sort(featureList, AbstractFeature.LOCATION_LENGTH);
} | java | public void addFeature(FeatureInterface<AbstractSequence<C>, C> feature) {
features.add(feature);
ArrayList<FeatureInterface<AbstractSequence<C>, C>> featureList = groupedFeatures.get(feature.getType());
if (featureList == null) {
featureList = new ArrayList<FeatureInterface<AbstractSequence<C>, C>>();
groupedFeatures.put(feature.getType(), featureList);
}
featureList.add(feature);
Collections.sort(features, AbstractFeature.LOCATION_LENGTH);
Collections.sort(featureList, AbstractFeature.LOCATION_LENGTH);
} | [
"public",
"void",
"addFeature",
"(",
"FeatureInterface",
"<",
"AbstractSequence",
"<",
"C",
">",
",",
"C",
">",
"feature",
")",
"{",
"features",
".",
"add",
"(",
"feature",
")",
";",
"ArrayList",
"<",
"FeatureInterface",
"<",
"AbstractSequence",
"<",
"C",
... | Add a feature to this sequence. The feature will be added to the collection where the order is start position and if more than
one feature at the same start position then longest is added first. This helps on doing feature layout for displaying features
in SequenceFeaturePanel
@param feature | [
"Add",
"a",
"feature",
"to",
"this",
"sequence",
".",
"The",
"feature",
"will",
"be",
"added",
"to",
"the",
"collection",
"where",
"the",
"order",
"is",
"start",
"position",
"and",
"if",
"more",
"than",
"one",
"feature",
"at",
"the",
"same",
"start",
"po... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java#L410-L420 |
31,630 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java | AbstractSequence.removeFeature | public void removeFeature(FeatureInterface<AbstractSequence<C>, C> feature) {
features.remove(feature);
ArrayList<FeatureInterface<AbstractSequence<C>, C>> featureList = groupedFeatures.get(feature.getType());
if (featureList != null) {
featureList.remove(feature);
if (featureList.isEmpty()) {
groupedFeatures.remove(feature.getType());
}
}
} | java | public void removeFeature(FeatureInterface<AbstractSequence<C>, C> feature) {
features.remove(feature);
ArrayList<FeatureInterface<AbstractSequence<C>, C>> featureList = groupedFeatures.get(feature.getType());
if (featureList != null) {
featureList.remove(feature);
if (featureList.isEmpty()) {
groupedFeatures.remove(feature.getType());
}
}
} | [
"public",
"void",
"removeFeature",
"(",
"FeatureInterface",
"<",
"AbstractSequence",
"<",
"C",
">",
",",
"C",
">",
"feature",
")",
"{",
"features",
".",
"remove",
"(",
"feature",
")",
";",
"ArrayList",
"<",
"FeatureInterface",
"<",
"AbstractSequence",
"<",
"... | Remove a feature from the sequence
@param feature | [
"Remove",
"a",
"feature",
"from",
"the",
"sequence"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/AbstractSequence.java#L426-L435 |
31,631 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java | CrystalCell.getCellIndices | public Point3i getCellIndices(Tuple3d pt) {
Point3d p = new Point3d(pt);
this.transfToCrystal(p);
int x = (int)Math.floor(p.x);
int y = (int)Math.floor(p.y);
int z = (int)Math.floor(p.z);
return new Point3i(x,y,z);
} | java | public Point3i getCellIndices(Tuple3d pt) {
Point3d p = new Point3d(pt);
this.transfToCrystal(p);
int x = (int)Math.floor(p.x);
int y = (int)Math.floor(p.y);
int z = (int)Math.floor(p.z);
return new Point3i(x,y,z);
} | [
"public",
"Point3i",
"getCellIndices",
"(",
"Tuple3d",
"pt",
")",
"{",
"Point3d",
"p",
"=",
"new",
"Point3d",
"(",
"pt",
")",
";",
"this",
".",
"transfToCrystal",
"(",
"p",
")",
";",
"int",
"x",
"=",
"(",
"int",
")",
"Math",
".",
"floor",
"(",
"p",... | Get the index of a unit cell to which the query point belongs.
<p>For instance, all points in the unit cell at the origin will return (0,0,0);
Points in the unit cell one unit further along the `a` axis will return (1,0,0),
etc.
@param pt Input point (in orthonormal coordinates)
@return A new point with the three indices of the cell containing pt | [
"Get",
"the",
"index",
"of",
"a",
"unit",
"cell",
"to",
"which",
"the",
"query",
"point",
"belongs",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java#L155-L163 |
31,632 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java | CrystalCell.transfToOriginCell | public void transfToOriginCell(Tuple3d[] points, Tuple3d reference) {
reference = new Point3d(reference);//clone
transfToCrystal(reference);
int x = (int)Math.floor(reference.x);
int y = (int)Math.floor(reference.y);
int z = (int)Math.floor(reference.z);
for( Tuple3d point: points ) {
transfToCrystal(point);
point.x -= x;
point.y -= y;
point.z -= z;
transfToOrthonormal(point);
}
} | java | public void transfToOriginCell(Tuple3d[] points, Tuple3d reference) {
reference = new Point3d(reference);//clone
transfToCrystal(reference);
int x = (int)Math.floor(reference.x);
int y = (int)Math.floor(reference.y);
int z = (int)Math.floor(reference.z);
for( Tuple3d point: points ) {
transfToCrystal(point);
point.x -= x;
point.y -= y;
point.z -= z;
transfToOrthonormal(point);
}
} | [
"public",
"void",
"transfToOriginCell",
"(",
"Tuple3d",
"[",
"]",
"points",
",",
"Tuple3d",
"reference",
")",
"{",
"reference",
"=",
"new",
"Point3d",
"(",
"reference",
")",
";",
"//clone",
"transfToCrystal",
"(",
"reference",
")",
";",
"int",
"x",
"=",
"(... | Converts a set of points so that the reference point falls in the unit cell.
This is useful to transform a whole chain at once, allowing some of the
atoms to be outside the unit cell, but forcing the centroid to be within it.
@param points A set of points to transform (in orthonormal coordinates)
@param reference The reference point, which is unmodified but which would
be in the unit cell were it to have been transformed. It is safe to
use a member of the points array here. | [
"Converts",
"a",
"set",
"of",
"points",
"so",
"that",
"the",
"reference",
"point",
"falls",
"in",
"the",
"unit",
"cell",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java#L191-L206 |
31,633 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java | CrystalCell.getMaxDimension | public double getMaxDimension() {
if (maxDimension!=0) {
return maxDimension;
}
Point3d vert0 = new Point3d(0,0,0);
Point3d vert1 = new Point3d(1,0,0);
transfToOrthonormal(vert1);
Point3d vert2 = new Point3d(0,1,0);
transfToOrthonormal(vert2);
Point3d vert3 = new Point3d(0,0,1);
transfToOrthonormal(vert3);
Point3d vert4 = new Point3d(1,1,0);
transfToOrthonormal(vert4);
Point3d vert5 = new Point3d(1,0,1);
transfToOrthonormal(vert5);
Point3d vert6 = new Point3d(0,1,1);
transfToOrthonormal(vert6);
Point3d vert7 = new Point3d(1,1,1);
transfToOrthonormal(vert7);
ArrayList<Double> vertDists = new ArrayList<Double>();
vertDists.add(vert0.distance(vert7));
vertDists.add(vert3.distance(vert4));
vertDists.add(vert1.distance(vert6));
vertDists.add(vert2.distance(vert5));
maxDimension = Collections.max(vertDists);
return maxDimension;
} | java | public double getMaxDimension() {
if (maxDimension!=0) {
return maxDimension;
}
Point3d vert0 = new Point3d(0,0,0);
Point3d vert1 = new Point3d(1,0,0);
transfToOrthonormal(vert1);
Point3d vert2 = new Point3d(0,1,0);
transfToOrthonormal(vert2);
Point3d vert3 = new Point3d(0,0,1);
transfToOrthonormal(vert3);
Point3d vert4 = new Point3d(1,1,0);
transfToOrthonormal(vert4);
Point3d vert5 = new Point3d(1,0,1);
transfToOrthonormal(vert5);
Point3d vert6 = new Point3d(0,1,1);
transfToOrthonormal(vert6);
Point3d vert7 = new Point3d(1,1,1);
transfToOrthonormal(vert7);
ArrayList<Double> vertDists = new ArrayList<Double>();
vertDists.add(vert0.distance(vert7));
vertDists.add(vert3.distance(vert4));
vertDists.add(vert1.distance(vert6));
vertDists.add(vert2.distance(vert5));
maxDimension = Collections.max(vertDists);
return maxDimension;
} | [
"public",
"double",
"getMaxDimension",
"(",
")",
"{",
"if",
"(",
"maxDimension",
"!=",
"0",
")",
"{",
"return",
"maxDimension",
";",
"}",
"Point3d",
"vert0",
"=",
"new",
"Point3d",
"(",
"0",
",",
"0",
",",
"0",
")",
";",
"Point3d",
"vert1",
"=",
"new... | Gets the maximum dimension of the unit cell.
@return | [
"Gets",
"the",
"maximum",
"dimension",
"of",
"the",
"unit",
"cell",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java#L471-L498 |
31,634 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/io/sifts/SiftsXMLParser.java | SiftsXMLParser.getSiftsSegment | private SiftsSegment getSiftsSegment(Element el) {
String segId = el.getAttribute("segId");
String start = el.getAttribute("start");
String end = el.getAttribute("end");
SiftsSegment seg = new SiftsSegment(segId,start,end);
if ( debug )
System.out.println("parsed " + seg);
// get nodelist of segments...
NodeList nl = el.getElementsByTagName("listResidue");
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the entity element
Element listResidueEl = (Element)nl.item(i);
NodeList residueNodes = listResidueEl.getElementsByTagName("residue");
if(residueNodes != null && residueNodes.getLength() > 0) {
for(int j = 0 ; j < residueNodes.getLength();j++) {
Element residue = (Element) residueNodes.item(j);
SiftsResidue pos = getResidue(residue);
seg.addResidue(pos);
}
}
}
}
return seg;
} | java | private SiftsSegment getSiftsSegment(Element el) {
String segId = el.getAttribute("segId");
String start = el.getAttribute("start");
String end = el.getAttribute("end");
SiftsSegment seg = new SiftsSegment(segId,start,end);
if ( debug )
System.out.println("parsed " + seg);
// get nodelist of segments...
NodeList nl = el.getElementsByTagName("listResidue");
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the entity element
Element listResidueEl = (Element)nl.item(i);
NodeList residueNodes = listResidueEl.getElementsByTagName("residue");
if(residueNodes != null && residueNodes.getLength() > 0) {
for(int j = 0 ; j < residueNodes.getLength();j++) {
Element residue = (Element) residueNodes.item(j);
SiftsResidue pos = getResidue(residue);
seg.addResidue(pos);
}
}
}
}
return seg;
} | [
"private",
"SiftsSegment",
"getSiftsSegment",
"(",
"Element",
"el",
")",
"{",
"String",
"segId",
"=",
"el",
".",
"getAttribute",
"(",
"\"segId\"",
")",
";",
"String",
"start",
"=",
"el",
".",
"getAttribute",
"(",
"\"start\"",
")",
";",
"String",
"end",
"="... | segId="4hhb_A_1_140" start="1" end="140"
@param el
@return | [
"segId",
"=",
"4hhb_A_1_140",
"start",
"=",
"1",
"end",
"=",
"140"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/sifts/SiftsXMLParser.java#L149-L181 |
31,635 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/ColorUtils.java | ColorUtils.rotateHue | public static Color rotateHue (Color color, float fraction) {
float[] af = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
float hue = af[0];
float saturation = af[1];
float brightness = af[2];
float hueNew = hue + fraction;
Color hsb = Color.getHSBColor(hueNew, saturation, brightness);
return new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue(), color.getAlpha());
} | java | public static Color rotateHue (Color color, float fraction) {
float[] af = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
float hue = af[0];
float saturation = af[1];
float brightness = af[2];
float hueNew = hue + fraction;
Color hsb = Color.getHSBColor(hueNew, saturation, brightness);
return new Color(hsb.getRed(), hsb.getGreen(), hsb.getBlue(), color.getAlpha());
} | [
"public",
"static",
"Color",
"rotateHue",
"(",
"Color",
"color",
",",
"float",
"fraction",
")",
"{",
"float",
"[",
"]",
"af",
"=",
"Color",
".",
"RGBtoHSB",
"(",
"color",
".",
"getRed",
"(",
")",
",",
"color",
".",
"getGreen",
"(",
")",
",",
"color",... | Rotate a color through HSB space
@param color Starting color
@param fraction Amount to add to the hue. The integer part is discarded to leave a number in [0,1)
@return | [
"Rotate",
"a",
"color",
"through",
"HSB",
"space"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/ColorUtils.java#L67-L79 |
31,636 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/client/FarmJobRunnable.java | FarmJobRunnable.getAlignmentPairsFromServer | protected PdbPairsMessage getAlignmentPairsFromServer() {
String url = params.getServer();
int nrPairs = params.getStepSize();
if ( maxNrAlignments < nrPairs )
nrPairs = maxNrAlignments;
SortedSet<PdbPair> allPairs = new TreeSet<PdbPair>();
PdbPairsMessage msg = null;
try {
if ( progressListeners != null)
notifyRequestingAlignments(nrPairs);
if ( ! waitForAlignments) {
msg = JFatCatClient.getPdbPairs(url, nrPairs, userName);
allPairs = msg.getPairs();
} else {
while (allPairs.isEmpty()) {
msg = JFatCatClient.getPdbPairs(url, nrPairs, userName);
allPairs = msg.getPairs();
if (allPairs.isEmpty()) {
randomSleep();
}
}
}
} catch ( JobKillException k ){
logger.debug("Terminating job", k);
terminate();
} catch (Exception e) {
logger.error("Error while requesting alignment pairs", e);
// an error has occured sleep 30 sec.
randomSleep();
}
return msg;
} | java | protected PdbPairsMessage getAlignmentPairsFromServer() {
String url = params.getServer();
int nrPairs = params.getStepSize();
if ( maxNrAlignments < nrPairs )
nrPairs = maxNrAlignments;
SortedSet<PdbPair> allPairs = new TreeSet<PdbPair>();
PdbPairsMessage msg = null;
try {
if ( progressListeners != null)
notifyRequestingAlignments(nrPairs);
if ( ! waitForAlignments) {
msg = JFatCatClient.getPdbPairs(url, nrPairs, userName);
allPairs = msg.getPairs();
} else {
while (allPairs.isEmpty()) {
msg = JFatCatClient.getPdbPairs(url, nrPairs, userName);
allPairs = msg.getPairs();
if (allPairs.isEmpty()) {
randomSleep();
}
}
}
} catch ( JobKillException k ){
logger.debug("Terminating job", k);
terminate();
} catch (Exception e) {
logger.error("Error while requesting alignment pairs", e);
// an error has occured sleep 30 sec.
randomSleep();
}
return msg;
} | [
"protected",
"PdbPairsMessage",
"getAlignmentPairsFromServer",
"(",
")",
"{",
"String",
"url",
"=",
"params",
".",
"getServer",
"(",
")",
";",
"int",
"nrPairs",
"=",
"params",
".",
"getStepSize",
"(",
")",
";",
"if",
"(",
"maxNrAlignments",
"<",
"nrPairs",
"... | talk to centralized server and fetch all alignments to run.
@return a list of pairs to align. | [
"talk",
"to",
"centralized",
"server",
"and",
"fetch",
"all",
"alignments",
"to",
"run",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/client/FarmJobRunnable.java#L524-L576 |
31,637 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.alignmentAsMap | public static Map<Integer, Integer> alignmentAsMap(AFPChain afpChain) throws StructureException {
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
if( afpChain.getAlnLength() < 1 ) {
return map;
}
int[][][] optAln = afpChain.getOptAln();
int[] optLen = afpChain.getOptLen();
for(int block = 0; block < afpChain.getBlockNum(); block++) {
for(int pos = 0; pos < optLen[block]; pos++) {
int res1 = optAln[block][0][pos];
int res2 = optAln[block][1][pos];
if(map.containsKey(res1)) {
throw new StructureException(String.format("Residue %d aligned to both %d and %d.", res1,map.get(res1),res2));
}
map.put(res1,res2);
}
}
return map;
} | java | public static Map<Integer, Integer> alignmentAsMap(AFPChain afpChain) throws StructureException {
Map<Integer,Integer> map = new HashMap<Integer,Integer>();
if( afpChain.getAlnLength() < 1 ) {
return map;
}
int[][][] optAln = afpChain.getOptAln();
int[] optLen = afpChain.getOptLen();
for(int block = 0; block < afpChain.getBlockNum(); block++) {
for(int pos = 0; pos < optLen[block]; pos++) {
int res1 = optAln[block][0][pos];
int res2 = optAln[block][1][pos];
if(map.containsKey(res1)) {
throw new StructureException(String.format("Residue %d aligned to both %d and %d.", res1,map.get(res1),res2));
}
map.put(res1,res2);
}
}
return map;
} | [
"public",
"static",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"alignmentAsMap",
"(",
"AFPChain",
"afpChain",
")",
"throws",
"StructureException",
"{",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"map",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"Integer",... | Creates a Map specifying the alignment as a mapping between residue indices
of protein 1 and residue indices of protein 2.
<p>For example,<pre>
1234
5678</pre>
becomes<pre>
1->5
2->6
3->7
4->8</pre>
@param afpChain An alignment
@return A mapping from aligned residues of protein 1 to their partners in protein 2.
@throws StructureException If afpChain is not one-to-one | [
"Creates",
"a",
"Map",
"specifying",
"the",
"alignment",
"as",
"a",
"mapping",
"between",
"residue",
"indices",
"of",
"protein",
"1",
"and",
"residue",
"indices",
"of",
"protein",
"2",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L159-L178 |
31,638 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.getSymmetryOrder | public static int getSymmetryOrder(Map<Integer, Integer> alignment, Map<Integer,Integer> identity,
final int maxSymmetry, final float minimumMetricChange) {
List<Integer> preimage = new ArrayList<Integer>(alignment.keySet()); // currently unmodified
List<Integer> image = new ArrayList<Integer>(preimage);
int bestSymmetry = 1;
double bestMetric = Double.POSITIVE_INFINITY; //lower is better
boolean foundSymmetry = false;
if(debug) {
logger.trace("Symm\tPos\tDelta");
}
for(int n=1;n<=maxSymmetry;n++) {
int deltasSq = 0;
int numDeltas = 0;
// apply alignment
for(int i=0;i<image.size();i++) {
Integer pre = image.get(i);
Integer intermediate = (pre==null?null: alignment.get(pre));
Integer post = (intermediate==null?null: identity.get(intermediate));
image.set(i, post);
if(post != null) {
int delta = post-preimage.get(i);
deltasSq += delta*delta;
numDeltas++;
if(debug) {
logger.debug("%d\t%d\t%d\n",n,preimage.get(i),delta);
}
}
}
// Metrics: RMS compensates for the trend of smaller numDeltas with higher order
// Not normalizing by numDeltas favors smaller orders
double metric = Math.sqrt((double)deltasSq/numDeltas); // root mean squared distance
if(!foundSymmetry && metric < bestMetric * minimumMetricChange) {
// n = 1 is never the best symmetry
if(bestMetric < Double.POSITIVE_INFINITY) {
foundSymmetry = true;
}
bestSymmetry = n;
bestMetric = metric;
}
// When debugging need to loop over everything. Unneeded in production
if(!debug && foundSymmetry) {
break;
}
}
if(foundSymmetry) {
return bestSymmetry;
} else {
return 1;
}
} | java | public static int getSymmetryOrder(Map<Integer, Integer> alignment, Map<Integer,Integer> identity,
final int maxSymmetry, final float minimumMetricChange) {
List<Integer> preimage = new ArrayList<Integer>(alignment.keySet()); // currently unmodified
List<Integer> image = new ArrayList<Integer>(preimage);
int bestSymmetry = 1;
double bestMetric = Double.POSITIVE_INFINITY; //lower is better
boolean foundSymmetry = false;
if(debug) {
logger.trace("Symm\tPos\tDelta");
}
for(int n=1;n<=maxSymmetry;n++) {
int deltasSq = 0;
int numDeltas = 0;
// apply alignment
for(int i=0;i<image.size();i++) {
Integer pre = image.get(i);
Integer intermediate = (pre==null?null: alignment.get(pre));
Integer post = (intermediate==null?null: identity.get(intermediate));
image.set(i, post);
if(post != null) {
int delta = post-preimage.get(i);
deltasSq += delta*delta;
numDeltas++;
if(debug) {
logger.debug("%d\t%d\t%d\n",n,preimage.get(i),delta);
}
}
}
// Metrics: RMS compensates for the trend of smaller numDeltas with higher order
// Not normalizing by numDeltas favors smaller orders
double metric = Math.sqrt((double)deltasSq/numDeltas); // root mean squared distance
if(!foundSymmetry && metric < bestMetric * minimumMetricChange) {
// n = 1 is never the best symmetry
if(bestMetric < Double.POSITIVE_INFINITY) {
foundSymmetry = true;
}
bestSymmetry = n;
bestMetric = metric;
}
// When debugging need to loop over everything. Unneeded in production
if(!debug && foundSymmetry) {
break;
}
}
if(foundSymmetry) {
return bestSymmetry;
} else {
return 1;
}
} | [
"public",
"static",
"int",
"getSymmetryOrder",
"(",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"alignment",
",",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"identity",
",",
"final",
"int",
"maxSymmetry",
",",
"final",
"float",
"minimumMetricChange",
")",
"... | Tries to detect symmetry in an alignment.
<p>Conceptually, an alignment is a function f:A->B between two sets of
integers. The function may have simple topology (meaning that if two
elements of A are close, then their images in B will also be close), or
may have more complex topology (such as a circular permutation). This
function checks <i>alignment</i> against a reference function
<i>identity</i>, which should have simple topology. It then tries to
determine the symmetry order of <i>alignment</i> relative to
<i>identity</i>, up to a maximum order of <i>maxSymmetry</i>.
<p><strong>Details</strong><br/>
Considers the offset (in number of residues) which a residue moves
after undergoing <i>n</i> alternating transforms by alignment and
identity. If <i>n</i> corresponds to the intrinsic order of the alignment,
this will be small. This algorithm tries increasing values of <i>n</i>
and looks for abrupt decreases in the root mean squared offset.
If none are found at <i>n</i><=maxSymmetry, the alignment is reported as
non-symmetric.
@param alignment The alignment to test for symmetry
@param identity An alignment with simple topology which approximates
the sequential relationship between the two proteins. Should map in the
reverse direction from alignment.
@param maxSymmetry Maximum symmetry to consider. High values increase
the calculation time and can lead to overfitting.
@param minimumMetricChange Percent decrease in root mean squared offsets
in order to declare symmetry. 0.4f seems to work well for CeSymm.
@return The order of symmetry of alignment, or 1 if no order <=
maxSymmetry is found.
@see IdentityMap For a simple identity function | [
"Tries",
"to",
"detect",
"symmetry",
"in",
"an",
"alignment",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L322-L383 |
31,639 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.getSymmetryOrder | public static int getSymmetryOrder(AFPChain afpChain, int maxSymmetry, float minimumMetricChange) throws StructureException {
// alignment comes from the afpChain alignment
Map<Integer,Integer> alignment = AlignmentTools.alignmentAsMap(afpChain);
// Now construct identity to map aligned residues in sequential order
Map<Integer, Integer> identity = guessSequentialAlignment(alignment, true);
return AlignmentTools.getSymmetryOrder(alignment,
identity,
maxSymmetry, minimumMetricChange);
} | java | public static int getSymmetryOrder(AFPChain afpChain, int maxSymmetry, float minimumMetricChange) throws StructureException {
// alignment comes from the afpChain alignment
Map<Integer,Integer> alignment = AlignmentTools.alignmentAsMap(afpChain);
// Now construct identity to map aligned residues in sequential order
Map<Integer, Integer> identity = guessSequentialAlignment(alignment, true);
return AlignmentTools.getSymmetryOrder(alignment,
identity,
maxSymmetry, minimumMetricChange);
} | [
"public",
"static",
"int",
"getSymmetryOrder",
"(",
"AFPChain",
"afpChain",
",",
"int",
"maxSymmetry",
",",
"float",
"minimumMetricChange",
")",
"throws",
"StructureException",
"{",
"// alignment comes from the afpChain alignment",
"Map",
"<",
"Integer",
",",
"Integer",
... | Guesses the order of symmetry in an alignment
<p>Uses {@link #getSymmetryOrder(Map alignment, Map identity, int, float)}
to determine the the symmetry order. For the identity alignment, sorts
the aligned residues of each protein sequentially, then defines the ith
residues of each protein to be equivalent.
<p>Note that the selection of the identity alignment here is <i>very</i>
naive, and only works for proteins with very good coverage. Wherever
possible, it is better to construct an identity function explicitly
from a sequence alignment (or use an {@link IdentityMap} for internally
symmetric proteins) and use {@link #getSymmetryOrder(Map, Map, int, float)}. | [
"Guesses",
"the",
"order",
"of",
"symmetry",
"in",
"an",
"alignment"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L400-L411 |
31,640 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.guessSequentialAlignment | public static Map<Integer, Integer> guessSequentialAlignment(
Map<Integer,Integer> alignment, boolean inverseAlignment) {
Map<Integer,Integer> identity = new HashMap<Integer,Integer>();
SortedSet<Integer> aligned1 = new TreeSet<Integer>();
SortedSet<Integer> aligned2 = new TreeSet<Integer>();
for(Entry<Integer,Integer> pair : alignment.entrySet()) {
aligned1.add(pair.getKey());
if( !aligned2.add(pair.getValue()) )
throw new IllegalArgumentException("Alignment is not one-to-one for residue "+pair.getValue()+" of the second structure.");
}
Iterator<Integer> it1 = aligned1.iterator();
Iterator<Integer> it2 = aligned2.iterator();
while(it1.hasNext()) {
if(inverseAlignment) { // 2->1
identity.put(it2.next(),it1.next());
} else { // 1->2
identity.put(it1.next(),it2.next());
}
}
return identity;
} | java | public static Map<Integer, Integer> guessSequentialAlignment(
Map<Integer,Integer> alignment, boolean inverseAlignment) {
Map<Integer,Integer> identity = new HashMap<Integer,Integer>();
SortedSet<Integer> aligned1 = new TreeSet<Integer>();
SortedSet<Integer> aligned2 = new TreeSet<Integer>();
for(Entry<Integer,Integer> pair : alignment.entrySet()) {
aligned1.add(pair.getKey());
if( !aligned2.add(pair.getValue()) )
throw new IllegalArgumentException("Alignment is not one-to-one for residue "+pair.getValue()+" of the second structure.");
}
Iterator<Integer> it1 = aligned1.iterator();
Iterator<Integer> it2 = aligned2.iterator();
while(it1.hasNext()) {
if(inverseAlignment) { // 2->1
identity.put(it2.next(),it1.next());
} else { // 1->2
identity.put(it1.next(),it2.next());
}
}
return identity;
} | [
"public",
"static",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"guessSequentialAlignment",
"(",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"alignment",
",",
"boolean",
"inverseAlignment",
")",
"{",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"identity",
"=... | Takes a potentially non-sequential alignment and guesses a sequential
version of it. Residues from each structure are sorted sequentially and
then compared directly.
<p>The results of this method are consistent with what one might expect
from an identity function, and are therefore useful with
{@link #getSymmetryOrder(Map, Map identity, int, float)}.
<ul>
<li>Perfect self-alignments will have the same pre-image and image,
so will map X->X</li>
<li>Gaps and alignment errors will cause errors in the resulting map,
but only locally. Errors do not propagate through the whole
alignment.</li>
</ul>
<h4>Example:</h4>
A non sequential alignment, represented schematically as
<pre>
12456789
78912345</pre>
would result in a map
<pre>
12456789
12345789</pre>
@param alignment The non-sequential input alignment
@param inverseAlignment If false, map from structure1 to structure2. If
true, generate the inverse of that map.
@return A mapping from sequential residues of one protein to those of the other
@throws IllegalArgumentException if the input alignment is not one-to-one. | [
"Takes",
"a",
"potentially",
"non",
"-",
"sequential",
"alignment",
"and",
"guesses",
"a",
"sequential",
"version",
"of",
"it",
".",
"Residues",
"from",
"each",
"structure",
"are",
"sorted",
"sequentially",
"and",
"then",
"compared",
"directly",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L444-L467 |
31,641 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.createAFPChain | public static AFPChain createAFPChain(Atom[] ca1, Atom[] ca2,
ResidueNumber[] aligned1, ResidueNumber[] aligned2 ) throws StructureException {
//input validation
int alnLen = aligned1.length;
if(alnLen != aligned2.length) {
throw new IllegalArgumentException("Alignment lengths are not equal");
}
AFPChain a = new AFPChain(AFPChain.UNKNOWN_ALGORITHM);
try {
a.setName1(ca1[0].getGroup().getChain().getStructure().getName());
if(ca2[0].getGroup().getChain().getStructure() != null) {
// common case for cloned ca2
a.setName2(ca2[0].getGroup().getChain().getStructure().getName());
}
} catch(Exception e) {
// One of the structures wasn't fully created. Ignore
}
a.setBlockNum(1);
a.setCa1Length(ca1.length);
a.setCa2Length(ca2.length);
a.setOptLength(alnLen);
a.setOptLen(new int[] {alnLen});
Matrix[] ms = new Matrix[a.getBlockNum()];
a.setBlockRotationMatrix(ms);
Atom[] blockShiftVector = new Atom[a.getBlockNum()];
a.setBlockShiftVector(blockShiftVector);
String[][][] pdbAln = new String[1][2][alnLen];
for(int i=0;i<alnLen;i++) {
pdbAln[0][0][i] = aligned1[i].getChainName()+":"+aligned1[i];
pdbAln[0][1][i] = aligned2[i].getChainName()+":"+aligned2[i];
}
a.setPdbAln(pdbAln);
// convert pdbAln to optAln, and fill in some other basic parameters
AFPChainXMLParser.rebuildAFPChain(a, ca1, ca2);
return a;
// Currently a single block. Split into several blocks by sequence if needed
// return AlignmentTools.splitBlocksByTopology(a,ca1,ca2);
} | java | public static AFPChain createAFPChain(Atom[] ca1, Atom[] ca2,
ResidueNumber[] aligned1, ResidueNumber[] aligned2 ) throws StructureException {
//input validation
int alnLen = aligned1.length;
if(alnLen != aligned2.length) {
throw new IllegalArgumentException("Alignment lengths are not equal");
}
AFPChain a = new AFPChain(AFPChain.UNKNOWN_ALGORITHM);
try {
a.setName1(ca1[0].getGroup().getChain().getStructure().getName());
if(ca2[0].getGroup().getChain().getStructure() != null) {
// common case for cloned ca2
a.setName2(ca2[0].getGroup().getChain().getStructure().getName());
}
} catch(Exception e) {
// One of the structures wasn't fully created. Ignore
}
a.setBlockNum(1);
a.setCa1Length(ca1.length);
a.setCa2Length(ca2.length);
a.setOptLength(alnLen);
a.setOptLen(new int[] {alnLen});
Matrix[] ms = new Matrix[a.getBlockNum()];
a.setBlockRotationMatrix(ms);
Atom[] blockShiftVector = new Atom[a.getBlockNum()];
a.setBlockShiftVector(blockShiftVector);
String[][][] pdbAln = new String[1][2][alnLen];
for(int i=0;i<alnLen;i++) {
pdbAln[0][0][i] = aligned1[i].getChainName()+":"+aligned1[i];
pdbAln[0][1][i] = aligned2[i].getChainName()+":"+aligned2[i];
}
a.setPdbAln(pdbAln);
// convert pdbAln to optAln, and fill in some other basic parameters
AFPChainXMLParser.rebuildAFPChain(a, ca1, ca2);
return a;
// Currently a single block. Split into several blocks by sequence if needed
// return AlignmentTools.splitBlocksByTopology(a,ca1,ca2);
} | [
"public",
"static",
"AFPChain",
"createAFPChain",
"(",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
",",
"ResidueNumber",
"[",
"]",
"aligned1",
",",
"ResidueNumber",
"[",
"]",
"aligned2",
")",
"throws",
"StructureException",
"{",
"//input validation"... | Fundamentally, an alignment is just a list of aligned residues in each
protein. This method converts two lists of ResidueNumbers into an
AFPChain.
<p>Parameters are filled with defaults (often null) or sometimes
calculated.
<p>For a way to modify the alignment of an existing AFPChain, see
{@link AlignmentTools#replaceOptAln(AFPChain, Atom[], Atom[], Map)}
@param ca1 CA atoms of the first protein
@param ca2 CA atoms of the second protein
@param aligned1 A list of aligned residues from the first protein
@param aligned2 A list of aligned residues from the second protein.
Must be the same length as aligned1.
@return An AFPChain representing the alignment. Many properties may be
null or another default.
@throws StructureException if an error occured during superposition
@throws IllegalArgumentException if aligned1 and aligned2 have different
lengths
@see AlignmentTools#replaceOptAln(AFPChain, Atom[], Atom[], Map) | [
"Fundamentally",
"an",
"alignment",
"is",
"just",
"a",
"list",
"of",
"aligned",
"residues",
"in",
"each",
"protein",
".",
"This",
"method",
"converts",
"two",
"lists",
"of",
"ResidueNumbers",
"into",
"an",
"AFPChain",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L567-L613 |
31,642 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.replaceOptAln | public static AFPChain replaceOptAln(int[][][] newAlgn, AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException {
//The order is the number of groups in the newAlgn
int order = newAlgn.length;
//Calculate the alignment length from all the subunits lengths
int[] optLens = new int[order];
for(int s=0;s<order;s++) {
optLens[s] = newAlgn[s][0].length;
}
int optLength = 0;
for(int s=0;s<order;s++) {
optLength += optLens[s];
}
//Create a copy of the original AFPChain and set everything needed for the structure update
AFPChain copyAFP = (AFPChain) afpChain.clone();
//Set the new parameters of the optimal alignment
copyAFP.setOptLength(optLength);
copyAFP.setOptLen(optLens);
copyAFP.setOptAln(newAlgn);
//Set the block information of the new alignment
copyAFP.setBlockNum(order);
copyAFP.setBlockSize(optLens);
copyAFP.setBlockResList(newAlgn);
copyAFP.setBlockResSize(optLens);
copyAFP.setBlockGap(calculateBlockGap(newAlgn));
//Recalculate properties: superposition, tm-score, etc
Atom[] ca2clone = StructureTools.cloneAtomArray(ca2); // don't modify ca2 positions
AlignmentTools.updateSuperposition(copyAFP, ca1, ca2clone);
//It re-does the sequence alignment strings from the OptAlgn information only
copyAFP.setAlnsymb(null);
AFPAlignmentDisplay.getAlign(copyAFP, ca1, ca2clone);
return copyAFP;
} | java | public static AFPChain replaceOptAln(int[][][] newAlgn, AFPChain afpChain, Atom[] ca1, Atom[] ca2) throws StructureException {
//The order is the number of groups in the newAlgn
int order = newAlgn.length;
//Calculate the alignment length from all the subunits lengths
int[] optLens = new int[order];
for(int s=0;s<order;s++) {
optLens[s] = newAlgn[s][0].length;
}
int optLength = 0;
for(int s=0;s<order;s++) {
optLength += optLens[s];
}
//Create a copy of the original AFPChain and set everything needed for the structure update
AFPChain copyAFP = (AFPChain) afpChain.clone();
//Set the new parameters of the optimal alignment
copyAFP.setOptLength(optLength);
copyAFP.setOptLen(optLens);
copyAFP.setOptAln(newAlgn);
//Set the block information of the new alignment
copyAFP.setBlockNum(order);
copyAFP.setBlockSize(optLens);
copyAFP.setBlockResList(newAlgn);
copyAFP.setBlockResSize(optLens);
copyAFP.setBlockGap(calculateBlockGap(newAlgn));
//Recalculate properties: superposition, tm-score, etc
Atom[] ca2clone = StructureTools.cloneAtomArray(ca2); // don't modify ca2 positions
AlignmentTools.updateSuperposition(copyAFP, ca1, ca2clone);
//It re-does the sequence alignment strings from the OptAlgn information only
copyAFP.setAlnsymb(null);
AFPAlignmentDisplay.getAlign(copyAFP, ca1, ca2clone);
return copyAFP;
} | [
"public",
"static",
"AFPChain",
"replaceOptAln",
"(",
"int",
"[",
"]",
"[",
"]",
"[",
"]",
"newAlgn",
",",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
")",
"throws",
"StructureException",
"{",
"//The order is the num... | It replaces an optimal alignment of an AFPChain and calculates all the new alignment scores and variables. | [
"It",
"replaces",
"an",
"optimal",
"alignment",
"of",
"an",
"AFPChain",
"and",
"calculates",
"all",
"the",
"new",
"alignment",
"scores",
"and",
"variables",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L698-L737 |
31,643 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.replaceOptAln | public static AFPChain replaceOptAln(AFPChain afpChain, Atom[] ca1, Atom[] ca2,
Map<Integer, Integer> alignment) throws StructureException {
// Determine block lengths
// Sort ca1 indices, then start a new block whenever ca2 indices aren't
// increasing monotonically.
Integer[] res1 = alignment.keySet().toArray(new Integer[0]);
Arrays.sort(res1);
List<Integer> blockLens = new ArrayList<Integer>(2);
int optLength = 0;
Integer lastRes = alignment.get(res1[0]);
int blkLen = lastRes==null?0:1;
for(int i=1;i<res1.length;i++) {
Integer currRes = alignment.get(res1[i]); //res2 index
assert(currRes != null);// could be converted to if statement if assertion doesn't hold; just modify below as well.
if(lastRes<currRes) {
blkLen++;
} else {
// CP!
blockLens.add(blkLen);
optLength+=blkLen;
blkLen = 1;
}
lastRes = currRes;
}
blockLens.add(blkLen);
optLength+=blkLen;
// Create array structure for alignment
int[][][] optAln = new int[blockLens.size()][][];
int pos1 = 0; //index into res1
for(int blk=0;blk<blockLens.size();blk++) {
optAln[blk] = new int[2][];
blkLen = blockLens.get(blk);
optAln[blk][0] = new int[blkLen];
optAln[blk][1] = new int[blkLen];
int pos = 0; //index into optAln
while(pos<blkLen) {
optAln[blk][0][pos]=res1[pos1];
Integer currRes = alignment.get(res1[pos1]);
optAln[blk][1][pos]=currRes;
pos++;
pos1++;
}
}
assert(pos1 == optLength);
// Create length array
int[] optLens = new int[blockLens.size()];
for(int i=0;i<blockLens.size();i++) {
optLens[i] = blockLens.get(i);
}
return replaceOptAln(afpChain, ca1, ca2, blockLens.size(), optLens, optAln);
} | java | public static AFPChain replaceOptAln(AFPChain afpChain, Atom[] ca1, Atom[] ca2,
Map<Integer, Integer> alignment) throws StructureException {
// Determine block lengths
// Sort ca1 indices, then start a new block whenever ca2 indices aren't
// increasing monotonically.
Integer[] res1 = alignment.keySet().toArray(new Integer[0]);
Arrays.sort(res1);
List<Integer> blockLens = new ArrayList<Integer>(2);
int optLength = 0;
Integer lastRes = alignment.get(res1[0]);
int blkLen = lastRes==null?0:1;
for(int i=1;i<res1.length;i++) {
Integer currRes = alignment.get(res1[i]); //res2 index
assert(currRes != null);// could be converted to if statement if assertion doesn't hold; just modify below as well.
if(lastRes<currRes) {
blkLen++;
} else {
// CP!
blockLens.add(blkLen);
optLength+=blkLen;
blkLen = 1;
}
lastRes = currRes;
}
blockLens.add(blkLen);
optLength+=blkLen;
// Create array structure for alignment
int[][][] optAln = new int[blockLens.size()][][];
int pos1 = 0; //index into res1
for(int blk=0;blk<blockLens.size();blk++) {
optAln[blk] = new int[2][];
blkLen = blockLens.get(blk);
optAln[blk][0] = new int[blkLen];
optAln[blk][1] = new int[blkLen];
int pos = 0; //index into optAln
while(pos<blkLen) {
optAln[blk][0][pos]=res1[pos1];
Integer currRes = alignment.get(res1[pos1]);
optAln[blk][1][pos]=currRes;
pos++;
pos1++;
}
}
assert(pos1 == optLength);
// Create length array
int[] optLens = new int[blockLens.size()];
for(int i=0;i<blockLens.size();i++) {
optLens[i] = blockLens.get(i);
}
return replaceOptAln(afpChain, ca1, ca2, blockLens.size(), optLens, optAln);
} | [
"public",
"static",
"AFPChain",
"replaceOptAln",
"(",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
",",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"alignment",
")",
"throws",
"StructureException",
"{",
"// Determine bl... | Takes an AFPChain and replaces the optimal alignment based on an alignment map
<p>Parameters are filled with defaults (often null) or sometimes
calculated.
<p>For a way to create a new AFPChain, see
{@link AlignmentTools#createAFPChain(Atom[], Atom[], ResidueNumber[], ResidueNumber[])}
@param afpChain The alignment to be modified
@param alignment The new alignment, as a Map
@throws StructureException if an error occurred during superposition
@see AlignmentTools#createAFPChain(Atom[], Atom[], ResidueNumber[], ResidueNumber[]) | [
"Takes",
"an",
"AFPChain",
"and",
"replaces",
"the",
"optimal",
"alignment",
"based",
"on",
"an",
"alignment",
"map"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L753-L807 |
31,644 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.toConciseAlignmentString | public static <S,T> String toConciseAlignmentString(Map<S,T> alignment, Map<T,S> identity) {
// Clone input to prevent changes
Map<S,T> alig = new HashMap<S,T>(alignment);
// Generate inverse alignment
Map<S,List<S>> inverse = new HashMap<S,List<S>>();
for(Entry<S,T> e: alig.entrySet()) {
S val = identity.get(e.getValue());
if( inverse.containsKey(val) ) {
List<S> l = inverse.get(val);
l.add(e.getKey());
} else {
List<S> l = new ArrayList<S>();
l.add(e.getKey());
inverse.put(val,l);
}
}
StringBuilder str = new StringBuilder();
while(!alig.isEmpty()){
// Pick an edge and work upstream to a root or cycle
S seedNode = alig.keySet().iterator().next();
S node = seedNode;
if( inverse.containsKey(seedNode)) {
node = inverse.get(seedNode).iterator().next();
while( node != seedNode && inverse.containsKey(node)) {
node = inverse.get(node).iterator().next();
}
}
// Now work downstream, deleting edges as we go
seedNode = node;
str.append(node);
while(alig.containsKey(node)) {
S lastNode = node;
node = identity.get( alig.get(lastNode) );
// Output
str.append('>');
str.append(node);
// Remove edge
alig.remove(lastNode);
List<S> inv = inverse.get(node);
if(inv.size() > 1) {
inv.remove(node);
} else {
inverse.remove(node);
}
}
if(!alig.isEmpty()) {
str.append(' ');
}
}
return str.toString();
} | java | public static <S,T> String toConciseAlignmentString(Map<S,T> alignment, Map<T,S> identity) {
// Clone input to prevent changes
Map<S,T> alig = new HashMap<S,T>(alignment);
// Generate inverse alignment
Map<S,List<S>> inverse = new HashMap<S,List<S>>();
for(Entry<S,T> e: alig.entrySet()) {
S val = identity.get(e.getValue());
if( inverse.containsKey(val) ) {
List<S> l = inverse.get(val);
l.add(e.getKey());
} else {
List<S> l = new ArrayList<S>();
l.add(e.getKey());
inverse.put(val,l);
}
}
StringBuilder str = new StringBuilder();
while(!alig.isEmpty()){
// Pick an edge and work upstream to a root or cycle
S seedNode = alig.keySet().iterator().next();
S node = seedNode;
if( inverse.containsKey(seedNode)) {
node = inverse.get(seedNode).iterator().next();
while( node != seedNode && inverse.containsKey(node)) {
node = inverse.get(node).iterator().next();
}
}
// Now work downstream, deleting edges as we go
seedNode = node;
str.append(node);
while(alig.containsKey(node)) {
S lastNode = node;
node = identity.get( alig.get(lastNode) );
// Output
str.append('>');
str.append(node);
// Remove edge
alig.remove(lastNode);
List<S> inv = inverse.get(node);
if(inv.size() > 1) {
inv.remove(node);
} else {
inverse.remove(node);
}
}
if(!alig.isEmpty()) {
str.append(' ');
}
}
return str.toString();
} | [
"public",
"static",
"<",
"S",
",",
"T",
">",
"String",
"toConciseAlignmentString",
"(",
"Map",
"<",
"S",
",",
"T",
">",
"alignment",
",",
"Map",
"<",
"T",
",",
"S",
">",
"identity",
")",
"{",
"// Clone input to prevent changes",
"Map",
"<",
"S",
",",
"... | Print an alignment map in a concise representation. Edges are given
as two numbers separated by '>'. They are chained together where possible,
or separated by spaces where disjoint or branched.
<p>Note that more concise representations may be possible.</p>
Examples:
<li>1>2>3>1</li>
<li>1>2>3>2 4>3</li>
@param alignment The input function, as a map (see {@link AlignmentTools#alignmentAsMap(AFPChain)})
@param identity An identity-like function providing the isomorphism between
the codomain of alignment (of type <T>) and the domain (type <S>).
@return | [
"Print",
"an",
"alignment",
"map",
"in",
"a",
"concise",
"representation",
".",
"Edges",
"are",
"given",
"as",
"two",
"numbers",
"separated",
"by",
">",
".",
"They",
"are",
"chained",
"together",
"where",
"possible",
"or",
"separated",
"by",
"spaces",
"where... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L990-L1048 |
31,645 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.calculateBlockGap | public static int[] calculateBlockGap(int[][][] optAln){
//Initialize the array to be returned
int [] blockGap = new int[optAln.length];
//Loop for every block and look in both chains for non-contiguous residues.
for (int i=0; i<optAln.length; i++){
int gaps = 0; //the number of gaps in that block
int last1 = 0; //the last residue position in chain 1
int last2 = 0; //the last residue position in chain 2
//Loop for every position in the block
for (int j=0; j<optAln[i][0].length; j++){
//If the first position is evaluated initialize the last positions
if (j==0){
last1 = optAln[i][0][j];
last2 = optAln[i][1][j];
}
else{
//If one of the positions or both are not contiguous increment the number of gaps
if (optAln[i][0][j] > last1+1 || optAln[i][1][j] > last2+1){
gaps++;
last1 = optAln[i][0][j];
last2 = optAln[i][1][j];
}
//Otherwise just set the last position to the current one
else{
last1 = optAln[i][0][j];
last2 = optAln[i][1][j];
}
}
}
blockGap[i] = gaps;
}
return blockGap;
} | java | public static int[] calculateBlockGap(int[][][] optAln){
//Initialize the array to be returned
int [] blockGap = new int[optAln.length];
//Loop for every block and look in both chains for non-contiguous residues.
for (int i=0; i<optAln.length; i++){
int gaps = 0; //the number of gaps in that block
int last1 = 0; //the last residue position in chain 1
int last2 = 0; //the last residue position in chain 2
//Loop for every position in the block
for (int j=0; j<optAln[i][0].length; j++){
//If the first position is evaluated initialize the last positions
if (j==0){
last1 = optAln[i][0][j];
last2 = optAln[i][1][j];
}
else{
//If one of the positions or both are not contiguous increment the number of gaps
if (optAln[i][0][j] > last1+1 || optAln[i][1][j] > last2+1){
gaps++;
last1 = optAln[i][0][j];
last2 = optAln[i][1][j];
}
//Otherwise just set the last position to the current one
else{
last1 = optAln[i][0][j];
last2 = optAln[i][1][j];
}
}
}
blockGap[i] = gaps;
}
return blockGap;
} | [
"public",
"static",
"int",
"[",
"]",
"calculateBlockGap",
"(",
"int",
"[",
"]",
"[",
"]",
"[",
"]",
"optAln",
")",
"{",
"//Initialize the array to be returned",
"int",
"[",
"]",
"blockGap",
"=",
"new",
"int",
"[",
"optAln",
".",
"length",
"]",
";",
"//Lo... | Method that calculates the number of gaps in each subunit block of an optimal AFP alignment.
INPUT: an optimal alignment in the format int[][][].
OUTPUT: an int[] array of <order> length containing the gaps in each block as int[block]. | [
"Method",
"that",
"calculates",
"the",
"number",
"of",
"gaps",
"in",
"each",
"subunit",
"block",
"of",
"an",
"optimal",
"AFP",
"alignment",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L1083-L1117 |
31,646 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.getAlignedModel | 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;
} | java | 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;
} | [
"public",
"static",
"final",
"List",
"<",
"Chain",
">",
"getAlignedModel",
"(",
"Atom",
"[",
"]",
"ca",
")",
"{",
"List",
"<",
"Chain",
">",
"model",
"=",
"new",
"ArrayList",
"<",
"Chain",
">",
"(",
")",
";",
"for",
"(",
"Atom",
"a",
":",
"ca",
"... | get an artificial List of chains containing the Atoms and groups.
Does NOT rotate anything.
@param ca
@return a list of Chains that is built up from the Atoms in the ca array
@throws StructureException | [
"get",
"an",
"artificial",
"List",
"of",
"chains",
"containing",
"the",
"Atoms",
"and",
"groups",
".",
"Does",
"NOT",
"rotate",
"anything",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L1202-L1231 |
31,647 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.getAlignedStructure | public static final Structure getAlignedStructure(Atom[] ca1, Atom[] ca2) throws StructureException{
/* Previous implementation commented
Structure s = new StructureImpl();
List<Chain>model1 = getAlignedModel(ca1);
List<Chain>model2 = getAlignedModel(ca2);
s.addModel(model1);
s.addModel(model2);
return s;*/
Structure s = new StructureImpl();
List<Chain>model1 = getAlignedModel(ca1);
s.addModel(model1);
List<Chain> model2 = getAlignedModel(ca2);
s.addModel(model2);
return s;
} | java | public static final Structure getAlignedStructure(Atom[] ca1, Atom[] ca2) throws StructureException{
/* Previous implementation commented
Structure s = new StructureImpl();
List<Chain>model1 = getAlignedModel(ca1);
List<Chain>model2 = getAlignedModel(ca2);
s.addModel(model1);
s.addModel(model2);
return s;*/
Structure s = new StructureImpl();
List<Chain>model1 = getAlignedModel(ca1);
s.addModel(model1);
List<Chain> model2 = getAlignedModel(ca2);
s.addModel(model2);
return s;
} | [
"public",
"static",
"final",
"Structure",
"getAlignedStructure",
"(",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
")",
"throws",
"StructureException",
"{",
"/* Previous implementation commented\n\n\t\tStructure s = new StructureImpl();\n\n\n\t\tList<Chain>model1 = ge... | Get an artifical Structure containing both chains.
Does NOT rotate anything
@param ca1
@param ca2
@return a structure object containing two models, one for each set of Atoms.
@throws StructureException | [
"Get",
"an",
"artifical",
"Structure",
"containing",
"both",
"chains",
".",
"Does",
"NOT",
"rotate",
"anything"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L1241-L1263 |
31,648 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.shiftCA2 | public static void shiftCA2(AFPChain afpChain, Atom[] ca2, Matrix m, Atom shift, Group[] twistedGroups) {
int i = -1;
for (Atom a: ca2){
i++;
Group g = a.getGroup();
Calc.rotate(g,m);
Calc.shift(g, shift);
if (g.hasAltLoc()){
for (Group alt: g.getAltLocs()){
for (Atom alta : alt.getAtoms()){
if ( g.getAtoms().contains(alta))
continue;
Calc.rotate(alta,m);
Calc.shift(alta,shift);
}
}
}
twistedGroups[i]=g;
}
} | java | public static void shiftCA2(AFPChain afpChain, Atom[] ca2, Matrix m, Atom shift, Group[] twistedGroups) {
int i = -1;
for (Atom a: ca2){
i++;
Group g = a.getGroup();
Calc.rotate(g,m);
Calc.shift(g, shift);
if (g.hasAltLoc()){
for (Group alt: g.getAltLocs()){
for (Atom alta : alt.getAtoms()){
if ( g.getAtoms().contains(alta))
continue;
Calc.rotate(alta,m);
Calc.shift(alta,shift);
}
}
}
twistedGroups[i]=g;
}
} | [
"public",
"static",
"void",
"shiftCA2",
"(",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca2",
",",
"Matrix",
"m",
",",
"Atom",
"shift",
",",
"Group",
"[",
"]",
"twistedGroups",
")",
"{",
"int",
"i",
"=",
"-",
"1",
";",
"for",
"(",
"Atom",
"a",... | only shift CA positions. | [
"only",
"shift",
"CA",
"positions",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L1340-L1362 |
31,649 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.fillAlignedAtomArrays | public static void fillAlignedAtomArrays(AFPChain afpChain, Atom[] ca1,
Atom[] ca2, Atom[] ca1aligned, Atom[] ca2aligned) {
int pos=0;
int[] blockLens = afpChain.getOptLen();
int[][][] optAln = afpChain.getOptAln();
assert(afpChain.getBlockNum() <= optAln.length);
for (int block=0; block < afpChain.getBlockNum(); block++) {
for(int i=0;i<blockLens[block];i++) {
int pos1 = optAln[block][0][i];
int pos2 = optAln[block][1][i];
Atom a1 = ca1[pos1];
Atom a2 = (Atom) ca2[pos2].clone();
ca1aligned[pos] = a1;
ca2aligned[pos] = a2;
pos++;
}
}
// this can happen when we load an old XML serialization which did not support modern ChemComp representation of modified residues.
if (pos != afpChain.getOptLength()){
logger.warn("AFPChainScorer getTMScore: Problems reconstructing alignment! nr of loaded atoms is " + pos + " but should be " + afpChain.getOptLength());
// we need to resize the array, because we allocated too many atoms earlier on.
ca1aligned = (Atom[]) resizeArray(ca1aligned, pos);
ca2aligned = (Atom[]) resizeArray(ca2aligned, pos);
}
} | java | public static void fillAlignedAtomArrays(AFPChain afpChain, Atom[] ca1,
Atom[] ca2, Atom[] ca1aligned, Atom[] ca2aligned) {
int pos=0;
int[] blockLens = afpChain.getOptLen();
int[][][] optAln = afpChain.getOptAln();
assert(afpChain.getBlockNum() <= optAln.length);
for (int block=0; block < afpChain.getBlockNum(); block++) {
for(int i=0;i<blockLens[block];i++) {
int pos1 = optAln[block][0][i];
int pos2 = optAln[block][1][i];
Atom a1 = ca1[pos1];
Atom a2 = (Atom) ca2[pos2].clone();
ca1aligned[pos] = a1;
ca2aligned[pos] = a2;
pos++;
}
}
// this can happen when we load an old XML serialization which did not support modern ChemComp representation of modified residues.
if (pos != afpChain.getOptLength()){
logger.warn("AFPChainScorer getTMScore: Problems reconstructing alignment! nr of loaded atoms is " + pos + " but should be " + afpChain.getOptLength());
// we need to resize the array, because we allocated too many atoms earlier on.
ca1aligned = (Atom[]) resizeArray(ca1aligned, pos);
ca2aligned = (Atom[]) resizeArray(ca2aligned, pos);
}
} | [
"public",
"static",
"void",
"fillAlignedAtomArrays",
"(",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
",",
"Atom",
"[",
"]",
"ca1aligned",
",",
"Atom",
"[",
"]",
"ca2aligned",
")",
"{",
"int",
"pos",
"=",
"0",
... | Fill the aligned Atom arrays with the equivalent residues in the afpChain.
@param afpChain
@param ca1
@param ca2
@param ca1aligned
@param ca2aligned | [
"Fill",
"the",
"aligned",
"Atom",
"arrays",
"with",
"the",
"equivalent",
"residues",
"in",
"the",
"afpChain",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L1372-L1400 |
31,650 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.deleteHighestDistanceColumn | public static AFPChain deleteHighestDistanceColumn(AFPChain afpChain,
Atom[] ca1, Atom[] ca2) throws StructureException {
int[][][] optAln = afpChain.getOptAln();
int maxBlock = 0;
int maxPos = 0;
double maxDistance = Double.MIN_VALUE;
for (int b = 0; b < optAln.length; b++) {
for (int p = 0; p < optAln[b][0].length; p++) {
Atom ca2clone = ca2[optAln[b][1][p]];
Calc.rotate(ca2clone, afpChain.getBlockRotationMatrix()[b]);
Calc.shift(ca2clone, afpChain.getBlockShiftVector()[b]);
double distance = Calc.getDistance(ca1[optAln[b][0][p]],
ca2clone);
if (distance > maxDistance) {
maxBlock = b;
maxPos = p;
maxDistance = distance;
}
}
}
return deleteColumn(afpChain, ca1, ca2, maxBlock, maxPos);
} | java | public static AFPChain deleteHighestDistanceColumn(AFPChain afpChain,
Atom[] ca1, Atom[] ca2) throws StructureException {
int[][][] optAln = afpChain.getOptAln();
int maxBlock = 0;
int maxPos = 0;
double maxDistance = Double.MIN_VALUE;
for (int b = 0; b < optAln.length; b++) {
for (int p = 0; p < optAln[b][0].length; p++) {
Atom ca2clone = ca2[optAln[b][1][p]];
Calc.rotate(ca2clone, afpChain.getBlockRotationMatrix()[b]);
Calc.shift(ca2clone, afpChain.getBlockShiftVector()[b]);
double distance = Calc.getDistance(ca1[optAln[b][0][p]],
ca2clone);
if (distance > maxDistance) {
maxBlock = b;
maxPos = p;
maxDistance = distance;
}
}
}
return deleteColumn(afpChain, ca1, ca2, maxBlock, maxPos);
} | [
"public",
"static",
"AFPChain",
"deleteHighestDistanceColumn",
"(",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
")",
"throws",
"StructureException",
"{",
"int",
"[",
"]",
"[",
"]",
"[",
"]",
"optAln",
"=",
"afpChain"... | Find the alignment position with the highest atomic distance between the
equivalent atomic positions of the arrays and remove it from the
alignment.
@param afpChain
original alignment, will be modified
@param ca1
atom array, will not be modified
@param ca2
atom array, will not be modified
@return the original alignment, with the alignment position at the
highest distance removed
@throws StructureException | [
"Find",
"the",
"alignment",
"position",
"with",
"the",
"highest",
"atomic",
"distance",
"between",
"the",
"equivalent",
"atomic",
"positions",
"of",
"the",
"arrays",
"and",
"remove",
"it",
"from",
"the",
"alignment",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L1417-L1443 |
31,651 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java | AlignmentTools.deleteColumn | public static AFPChain deleteColumn(AFPChain afpChain, Atom[] ca1,
Atom[] ca2, int block, int pos) throws StructureException {
// Check validity of the inputs
if (afpChain.getBlockNum() <= block) {
throw new IndexOutOfBoundsException(String.format(
"Block index requested (%d) is higher than the total number of AFPChain blocks (%d).",
block, afpChain.getBlockNum()));
}
if (afpChain.getOptAln()[block][0].length <= pos) {
throw new IndexOutOfBoundsException(String.format(
"Position index requested (%d) is higher than the total number of aligned position in the AFPChain block (%d).",
block, afpChain.getBlockSize()[block]));
}
int[][][] optAln = afpChain.getOptAln();
int[] newPos0 = new int[optAln[block][0].length - 1];
int[] newPos1 = new int[optAln[block][1].length - 1];
int position = 0;
for (int p = 0; p < optAln[block][0].length; p++) {
if (p == pos)
continue;
newPos0[position] = optAln[block][0][p];
newPos1[position] = optAln[block][1][p];
position++;
}
optAln[block][0] = newPos0;
optAln[block][1] = newPos1;
return AlignmentTools.replaceOptAln(optAln, afpChain, ca1, ca2);
} | java | public static AFPChain deleteColumn(AFPChain afpChain, Atom[] ca1,
Atom[] ca2, int block, int pos) throws StructureException {
// Check validity of the inputs
if (afpChain.getBlockNum() <= block) {
throw new IndexOutOfBoundsException(String.format(
"Block index requested (%d) is higher than the total number of AFPChain blocks (%d).",
block, afpChain.getBlockNum()));
}
if (afpChain.getOptAln()[block][0].length <= pos) {
throw new IndexOutOfBoundsException(String.format(
"Position index requested (%d) is higher than the total number of aligned position in the AFPChain block (%d).",
block, afpChain.getBlockSize()[block]));
}
int[][][] optAln = afpChain.getOptAln();
int[] newPos0 = new int[optAln[block][0].length - 1];
int[] newPos1 = new int[optAln[block][1].length - 1];
int position = 0;
for (int p = 0; p < optAln[block][0].length; p++) {
if (p == pos)
continue;
newPos0[position] = optAln[block][0][p];
newPos1[position] = optAln[block][1][p];
position++;
}
optAln[block][0] = newPos0;
optAln[block][1] = newPos1;
return AlignmentTools.replaceOptAln(optAln, afpChain, ca1, ca2);
} | [
"public",
"static",
"AFPChain",
"deleteColumn",
"(",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
",",
"int",
"block",
",",
"int",
"pos",
")",
"throws",
"StructureException",
"{",
"// Check validity of the inputs",
"if",
... | Delete an alignment position from the original alignment object.
@param afpChain
original alignment, will be modified
@param ca1
atom array, will not be modified
@param ca2
atom array, will not be modified
@param block
block of the alignment position
@param pos
position index in the block
@return the original alignment, with the alignment position removed
@throws StructureException | [
"Delete",
"an",
"alignment",
"position",
"from",
"the",
"original",
"alignment",
"object",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java#L1461-L1497 |
31,652 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java | ProteinModificationIdentifier.identify | public void identify(final Structure structure,
final Set<ProteinModification> potentialModifications) {
if (structure==null) {
throw new IllegalArgumentException("Null structure.");
}
identify(structure.getChains(), potentialModifications);
} | java | public void identify(final Structure structure,
final Set<ProteinModification> potentialModifications) {
if (structure==null) {
throw new IllegalArgumentException("Null structure.");
}
identify(structure.getChains(), potentialModifications);
} | [
"public",
"void",
"identify",
"(",
"final",
"Structure",
"structure",
",",
"final",
"Set",
"<",
"ProteinModification",
">",
"potentialModifications",
")",
"{",
"if",
"(",
"structure",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Nu... | Identify a set of modifications in a structure.
@param structure query {@link Structure}.
@param potentialModifications query {@link ProteinModification}s. | [
"Identify",
"a",
"set",
"of",
"modifications",
"in",
"a",
"structure",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java#L211-L218 |
31,653 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java | ProteinModificationIdentifier.identify | public void identify(final Chain chain,
final Set<ProteinModification> potentialModifications) {
identify(Collections.singletonList(chain), potentialModifications);
} | java | public void identify(final Chain chain,
final Set<ProteinModification> potentialModifications) {
identify(Collections.singletonList(chain), potentialModifications);
} | [
"public",
"void",
"identify",
"(",
"final",
"Chain",
"chain",
",",
"final",
"Set",
"<",
"ProteinModification",
">",
"potentialModifications",
")",
"{",
"identify",
"(",
"Collections",
".",
"singletonList",
"(",
"chain",
")",
",",
"potentialModifications",
")",
"... | Identify a set of modifications in a a chains.
@param chain query {@link Chain}.
@param potentialModifications query {@link ProteinModification}s. | [
"Identify",
"a",
"set",
"of",
"modifications",
"in",
"a",
"a",
"chains",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java#L241-L244 |
31,654 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java | ProteinModificationIdentifier.identify | public void identify(final List<Chain> chains,
final Set<ProteinModification> potentialModifications) {
if (chains==null) {
throw new IllegalArgumentException("Null structure.");
}
if (potentialModifications==null) {
throw new IllegalArgumentException("Null potentialModifications.");
}
reset();
if (potentialModifications.isEmpty()) {
return;
}
residues = new ArrayList<Group>();
List<Group> ligands = new ArrayList<Group>();
Map<Component, Set<Group>> mapCompGroups = new HashMap<Component, Set<Group>>();
for (Chain chain : chains) {
List<Group> ress = StructureUtil.getAminoAcids(chain);
//List<Group> ligs = chain.getAtomLigands();
List<Group> ligs = StructureTools.filterLigands(chain.getAtomGroups());
residues.addAll(ress);
residues.removeAll(ligs);
ligands.addAll(ligs);
addModificationGroups(potentialModifications, ress, ligs, mapCompGroups);
}
if (residues.isEmpty()) {
String pdbId = "?";
if ( chains.size() > 0) {
Structure struc = chains.get(0).getStructure();
if ( struc != null)
pdbId = struc.getPDBCode();
}
logger.warn("No amino acids found for {}. Either you did not parse the PDB file with alignSEQRES records, or this record does not contain any amino acids.", pdbId);
}
List<ModifiedCompound> modComps = new ArrayList<ModifiedCompound>();
for (ProteinModification mod : potentialModifications) {
ModificationCondition condition = mod.getCondition();
List<Component> components = condition.getComponents();
if (!mapCompGroups.keySet().containsAll(components)) {
// not all components exist for this mod.
continue;
}
int sizeComps = components.size();
if (sizeComps==1) {
processCrosslink1(mapCompGroups, modComps, mod, components);
} else {
processMultiCrosslink(mapCompGroups, modComps, mod, condition);
}
}
if (recordAdditionalAttachments) {
// identify additional groups that are not directly attached to amino acids.
for (ModifiedCompound mc : modComps) {
identifyAdditionalAttachments(mc, ligands, chains);
}
}
mergeModComps(modComps);
identifiedModifiedCompounds.addAll(modComps);
// record unidentifiable linkage
if (recordUnidentifiableModifiedCompounds) {
recordUnidentifiableAtomLinkages(modComps, ligands);
recordUnidentifiableModifiedResidues(modComps);
}
} | java | public void identify(final List<Chain> chains,
final Set<ProteinModification> potentialModifications) {
if (chains==null) {
throw new IllegalArgumentException("Null structure.");
}
if (potentialModifications==null) {
throw new IllegalArgumentException("Null potentialModifications.");
}
reset();
if (potentialModifications.isEmpty()) {
return;
}
residues = new ArrayList<Group>();
List<Group> ligands = new ArrayList<Group>();
Map<Component, Set<Group>> mapCompGroups = new HashMap<Component, Set<Group>>();
for (Chain chain : chains) {
List<Group> ress = StructureUtil.getAminoAcids(chain);
//List<Group> ligs = chain.getAtomLigands();
List<Group> ligs = StructureTools.filterLigands(chain.getAtomGroups());
residues.addAll(ress);
residues.removeAll(ligs);
ligands.addAll(ligs);
addModificationGroups(potentialModifications, ress, ligs, mapCompGroups);
}
if (residues.isEmpty()) {
String pdbId = "?";
if ( chains.size() > 0) {
Structure struc = chains.get(0).getStructure();
if ( struc != null)
pdbId = struc.getPDBCode();
}
logger.warn("No amino acids found for {}. Either you did not parse the PDB file with alignSEQRES records, or this record does not contain any amino acids.", pdbId);
}
List<ModifiedCompound> modComps = new ArrayList<ModifiedCompound>();
for (ProteinModification mod : potentialModifications) {
ModificationCondition condition = mod.getCondition();
List<Component> components = condition.getComponents();
if (!mapCompGroups.keySet().containsAll(components)) {
// not all components exist for this mod.
continue;
}
int sizeComps = components.size();
if (sizeComps==1) {
processCrosslink1(mapCompGroups, modComps, mod, components);
} else {
processMultiCrosslink(mapCompGroups, modComps, mod, condition);
}
}
if (recordAdditionalAttachments) {
// identify additional groups that are not directly attached to amino acids.
for (ModifiedCompound mc : modComps) {
identifyAdditionalAttachments(mc, ligands, chains);
}
}
mergeModComps(modComps);
identifiedModifiedCompounds.addAll(modComps);
// record unidentifiable linkage
if (recordUnidentifiableModifiedCompounds) {
recordUnidentifiableAtomLinkages(modComps, ligands);
recordUnidentifiableModifiedResidues(modComps);
}
} | [
"public",
"void",
"identify",
"(",
"final",
"List",
"<",
"Chain",
">",
"chains",
",",
"final",
"Set",
"<",
"ProteinModification",
">",
"potentialModifications",
")",
"{",
"if",
"(",
"chains",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
... | Identify a set of modifications in a a list of chains.
@param chains query {@link Chain}s.
@param potentialModifications query {@link ProteinModification}s. | [
"Identify",
"a",
"set",
"of",
"modifications",
"in",
"a",
"a",
"list",
"of",
"chains",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java#L251-L333 |
31,655 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java | ProteinModificationIdentifier.identifyAdditionalAttachments | 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();
}
} | java | 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();
}
} | [
"private",
"void",
"identifyAdditionalAttachments",
"(",
"ModifiedCompound",
"mc",
",",
"List",
"<",
"Group",
">",
"ligands",
",",
"List",
"<",
"Chain",
">",
"chains",
")",
"{",
"if",
"(",
"ligands",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}"... | identify additional groups that are not directly attached to amino acids.
@param mc {@link ModifiedCompound}
@param ligands {@link Group}
@param chains List of {@link Chain}s
@return a list of added groups | [
"identify",
"additional",
"groups",
"that",
"are",
"not",
"directly",
"attached",
"to",
"amino",
"acids",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java#L384-L444 |
31,656 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java | ProteinModificationIdentifier.mergeModComps | private void mergeModComps(List<ModifiedCompound> modComps) {
TreeSet<Integer> remove = new TreeSet<Integer>();
int n = modComps.size();
for (int icurr=1; icurr<n; icurr++) {
ModifiedCompound curr = modComps.get(icurr);
String id = curr.getModification().getId();
if (ProteinModificationRegistry.getById(id).getCategory()
!=ModificationCategory.UNDEFINED)
continue;
// find linked compounds that before curr
//List<Integer> merging = new ArrayList<Integer>();
int ipre = 0;
for (; ipre<icurr; ipre++) {
if (remove.contains(ipre)) continue;
ModifiedCompound pre = modComps.get(ipre);
if (!Collections.disjoint(pre.getGroups(false),
curr.getGroups(false))) {
break;
}
}
if (ipre<icurr) {
ModifiedCompound mcKeep = modComps.get(ipre);
// merge modifications of the same type
if (mcKeep.getModification().getId().equals(id)) {
// merging the current one to the previous one
mcKeep.addAtomLinkages(curr.getAtomLinkages());
remove.add(icurr);
}
}
}
Iterator<Integer> it = remove.descendingIterator();
while (it.hasNext()) {
modComps.remove(it.next().intValue());
}
} | java | private void mergeModComps(List<ModifiedCompound> modComps) {
TreeSet<Integer> remove = new TreeSet<Integer>();
int n = modComps.size();
for (int icurr=1; icurr<n; icurr++) {
ModifiedCompound curr = modComps.get(icurr);
String id = curr.getModification().getId();
if (ProteinModificationRegistry.getById(id).getCategory()
!=ModificationCategory.UNDEFINED)
continue;
// find linked compounds that before curr
//List<Integer> merging = new ArrayList<Integer>();
int ipre = 0;
for (; ipre<icurr; ipre++) {
if (remove.contains(ipre)) continue;
ModifiedCompound pre = modComps.get(ipre);
if (!Collections.disjoint(pre.getGroups(false),
curr.getGroups(false))) {
break;
}
}
if (ipre<icurr) {
ModifiedCompound mcKeep = modComps.get(ipre);
// merge modifications of the same type
if (mcKeep.getModification().getId().equals(id)) {
// merging the current one to the previous one
mcKeep.addAtomLinkages(curr.getAtomLinkages());
remove.add(icurr);
}
}
}
Iterator<Integer> it = remove.descendingIterator();
while (it.hasNext()) {
modComps.remove(it.next().intValue());
}
} | [
"private",
"void",
"mergeModComps",
"(",
"List",
"<",
"ModifiedCompound",
">",
"modComps",
")",
"{",
"TreeSet",
"<",
"Integer",
">",
"remove",
"=",
"new",
"TreeSet",
"<",
"Integer",
">",
"(",
")",
";",
"int",
"n",
"=",
"modComps",
".",
"size",
"(",
")"... | Merge identified modified compounds if linked. | [
"Merge",
"identified",
"modified",
"compounds",
"if",
"linked",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java#L466-L505 |
31,657 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java | ProteinModificationIdentifier.recordUnidentifiableAtomLinkages | private void recordUnidentifiableAtomLinkages(List<ModifiedCompound> modComps,
List<Group> ligands) {
// first put identified linkages in a map for fast query
Set<StructureAtomLinkage> identifiedLinkages = new HashSet<StructureAtomLinkage>();
for (ModifiedCompound mc : modComps) {
identifiedLinkages.addAll(mc.getAtomLinkages());
}
// record
// cross link
int nRes = residues.size();
for (int i=0; i<nRes-1; i++) {
Group group1 = residues.get(i);
for (int j=i+1; j<nRes; j++) {
Group group2 = residues.get(j);
List<Atom[]> linkages = StructureUtil.findAtomLinkages(
group1, group2, true, bondLengthTolerance);
for (Atom[] atoms : linkages) {
StructureAtomLinkage link = StructureUtil.getStructureAtomLinkage(atoms[0],
true, atoms[1], true);
unidentifiableAtomLinkages.add(link);
}
}
}
// attachment
int nLig = ligands.size();
for (int i=0; i<nRes; i++) {
Group group1 = residues.get(i);
for (int j=0; j<nLig; j++) {
Group group2 = ligands.get(j);
if (group1.equals(group2)) { // overlap between residues and ligands
continue;
}
List<Atom[]> linkages = StructureUtil.findAtomLinkages(
group1, group2, false, bondLengthTolerance);
for (Atom[] atoms : linkages) {
StructureAtomLinkage link = StructureUtil.getStructureAtomLinkage(atoms[0],
true, atoms[1], false);
unidentifiableAtomLinkages.add(link);
}
}
}
} | java | private void recordUnidentifiableAtomLinkages(List<ModifiedCompound> modComps,
List<Group> ligands) {
// first put identified linkages in a map for fast query
Set<StructureAtomLinkage> identifiedLinkages = new HashSet<StructureAtomLinkage>();
for (ModifiedCompound mc : modComps) {
identifiedLinkages.addAll(mc.getAtomLinkages());
}
// record
// cross link
int nRes = residues.size();
for (int i=0; i<nRes-1; i++) {
Group group1 = residues.get(i);
for (int j=i+1; j<nRes; j++) {
Group group2 = residues.get(j);
List<Atom[]> linkages = StructureUtil.findAtomLinkages(
group1, group2, true, bondLengthTolerance);
for (Atom[] atoms : linkages) {
StructureAtomLinkage link = StructureUtil.getStructureAtomLinkage(atoms[0],
true, atoms[1], true);
unidentifiableAtomLinkages.add(link);
}
}
}
// attachment
int nLig = ligands.size();
for (int i=0; i<nRes; i++) {
Group group1 = residues.get(i);
for (int j=0; j<nLig; j++) {
Group group2 = ligands.get(j);
if (group1.equals(group2)) { // overlap between residues and ligands
continue;
}
List<Atom[]> linkages = StructureUtil.findAtomLinkages(
group1, group2, false, bondLengthTolerance);
for (Atom[] atoms : linkages) {
StructureAtomLinkage link = StructureUtil.getStructureAtomLinkage(atoms[0],
true, atoms[1], false);
unidentifiableAtomLinkages.add(link);
}
}
}
} | [
"private",
"void",
"recordUnidentifiableAtomLinkages",
"(",
"List",
"<",
"ModifiedCompound",
">",
"modComps",
",",
"List",
"<",
"Group",
">",
"ligands",
")",
"{",
"// first put identified linkages in a map for fast query",
"Set",
"<",
"StructureAtomLinkage",
">",
"identif... | Record unidentifiable atom linkages in a chain. Only linkages between two
residues or one residue and one ligand will be recorded. | [
"Record",
"unidentifiable",
"atom",
"linkages",
"in",
"a",
"chain",
".",
"Only",
"linkages",
"between",
"two",
"residues",
"or",
"one",
"residue",
"and",
"one",
"ligand",
"will",
"be",
"recorded",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java#L511-L555 |
31,658 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java | ProteinModificationIdentifier.getMatchedAtomsOfLinkages | private List<List<Atom[]>> getMatchedAtomsOfLinkages(
ModificationCondition condition, Map<Component, Set<Group>> mapCompGroups) {
List<ModificationLinkage> linkages = condition.getLinkages();
int nLink = linkages.size();
List<List<Atom[]>> matchedAtomsOfLinkages =
new ArrayList<List<Atom[]>>(nLink);
for (int iLink=0; iLink<nLink; iLink++) {
ModificationLinkage linkage = linkages.get(iLink);
Component comp1 = linkage.getComponent1();
Component comp2 = linkage.getComponent2();
// boolean isAA1 = comp1.;
// boolean isAA2 = comp2.getType()==true;
Set<Group> groups1 = mapCompGroups.get(comp1);
Set<Group> groups2 = mapCompGroups.get(comp2);
List<Atom[]> list = new ArrayList<Atom[]>();
List<String> potentialNamesOfAtomOnGroup1 = linkage.getPDBNameOfPotentialAtomsOnComponent1();
for (String name : potentialNamesOfAtomOnGroup1) {
if (name.equals("*")) {
// wildcard
potentialNamesOfAtomOnGroup1 = null; // search all atoms
break;
}
}
List<String> potentialNamesOfAtomOnGroup2 = linkage.getPDBNameOfPotentialAtomsOnComponent2();
for (String name : potentialNamesOfAtomOnGroup2) {
if (name.equals("*")) {
// wildcard
potentialNamesOfAtomOnGroup2 = null; // search all atoms
break;
}
}
for (Group g1 : groups1) {
for (Group g2 : groups2) {
if (g1.equals(g2)) {
continue;
}
// only for wildcard match of two residues
boolean ignoreNCLinkage =
potentialNamesOfAtomOnGroup1 == null &&
potentialNamesOfAtomOnGroup2 == null &&
residues.contains(g1) &&
residues.contains(g2);
Atom[] atoms = StructureUtil.findNearestAtomLinkage(
g1, g2,
potentialNamesOfAtomOnGroup1,
potentialNamesOfAtomOnGroup2,
ignoreNCLinkage,
bondLengthTolerance);
if (atoms!=null) {
list.add(atoms);
}
}
}
if (list.isEmpty()) {
// broken linkage
break;
}
matchedAtomsOfLinkages.add(list);
}
return matchedAtomsOfLinkages;
} | java | private List<List<Atom[]>> getMatchedAtomsOfLinkages(
ModificationCondition condition, Map<Component, Set<Group>> mapCompGroups) {
List<ModificationLinkage> linkages = condition.getLinkages();
int nLink = linkages.size();
List<List<Atom[]>> matchedAtomsOfLinkages =
new ArrayList<List<Atom[]>>(nLink);
for (int iLink=0; iLink<nLink; iLink++) {
ModificationLinkage linkage = linkages.get(iLink);
Component comp1 = linkage.getComponent1();
Component comp2 = linkage.getComponent2();
// boolean isAA1 = comp1.;
// boolean isAA2 = comp2.getType()==true;
Set<Group> groups1 = mapCompGroups.get(comp1);
Set<Group> groups2 = mapCompGroups.get(comp2);
List<Atom[]> list = new ArrayList<Atom[]>();
List<String> potentialNamesOfAtomOnGroup1 = linkage.getPDBNameOfPotentialAtomsOnComponent1();
for (String name : potentialNamesOfAtomOnGroup1) {
if (name.equals("*")) {
// wildcard
potentialNamesOfAtomOnGroup1 = null; // search all atoms
break;
}
}
List<String> potentialNamesOfAtomOnGroup2 = linkage.getPDBNameOfPotentialAtomsOnComponent2();
for (String name : potentialNamesOfAtomOnGroup2) {
if (name.equals("*")) {
// wildcard
potentialNamesOfAtomOnGroup2 = null; // search all atoms
break;
}
}
for (Group g1 : groups1) {
for (Group g2 : groups2) {
if (g1.equals(g2)) {
continue;
}
// only for wildcard match of two residues
boolean ignoreNCLinkage =
potentialNamesOfAtomOnGroup1 == null &&
potentialNamesOfAtomOnGroup2 == null &&
residues.contains(g1) &&
residues.contains(g2);
Atom[] atoms = StructureUtil.findNearestAtomLinkage(
g1, g2,
potentialNamesOfAtomOnGroup1,
potentialNamesOfAtomOnGroup2,
ignoreNCLinkage,
bondLengthTolerance);
if (atoms!=null) {
list.add(atoms);
}
}
}
if (list.isEmpty()) {
// broken linkage
break;
}
matchedAtomsOfLinkages.add(list);
}
return matchedAtomsOfLinkages;
} | [
"private",
"List",
"<",
"List",
"<",
"Atom",
"[",
"]",
">",
">",
"getMatchedAtomsOfLinkages",
"(",
"ModificationCondition",
"condition",
",",
"Map",
"<",
"Component",
",",
"Set",
"<",
"Group",
">",
">",
"mapCompGroups",
")",
"{",
"List",
"<",
"ModificationLi... | Get matched atoms for all linkages. | [
"Get",
"matched",
"atoms",
"for",
"all",
"linkages",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java#L725-L798 |
31,659 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java | ProteinModificationIdentifier.assembleLinkages | private void assembleLinkages(List<List<Atom[]>> matchedAtomsOfLinkages,
ProteinModification mod, List<ModifiedCompound> ret) {
ModificationCondition condition = mod.getCondition();
List<ModificationLinkage> modLinks = condition.getLinkages();
int nLink = matchedAtomsOfLinkages.size();
int[] indices = new int[nLink];
Set<ModifiedCompound> identifiedCompounds = new HashSet<ModifiedCompound>();
while (indices[0]<matchedAtomsOfLinkages.get(0).size()) {
List<Atom[]> atomLinkages = new ArrayList<Atom[]>(nLink);
for (int iLink=0; iLink<nLink; iLink++) {
Atom[] atoms = matchedAtomsOfLinkages.get(iLink).get(indices[iLink]);
atomLinkages.add(atoms);
}
if (matchLinkages(modLinks, atomLinkages)) {
// matched
int n = atomLinkages.size();
List<StructureAtomLinkage> linkages = new ArrayList<StructureAtomLinkage>(n);
for (int i=0; i<n; i++) {
Atom[] linkage = atomLinkages.get(i);
StructureAtomLinkage link = StructureUtil.getStructureAtomLinkage(
linkage[0], residues.contains(linkage[0].getGroup()),
linkage[1], residues.contains(linkage[1].getGroup()));
linkages.add(link);
}
ModifiedCompound mc = new ModifiedCompoundImpl(mod, linkages);
if (!identifiedCompounds.contains(mc)) {
ret.add(mc);
identifiedCompounds.add(mc);
}
}
// indices++ (e.g. [0,0,1]=>[0,0,2]=>[1,2,0])
int i = nLink-1;
while (i>=0) {
if (i==0 || indices[i]<matchedAtomsOfLinkages.get(i).size()-1) {
indices[i]++;
break;
} else {
indices[i] = 0;
i--;
}
}
}
} | java | private void assembleLinkages(List<List<Atom[]>> matchedAtomsOfLinkages,
ProteinModification mod, List<ModifiedCompound> ret) {
ModificationCondition condition = mod.getCondition();
List<ModificationLinkage> modLinks = condition.getLinkages();
int nLink = matchedAtomsOfLinkages.size();
int[] indices = new int[nLink];
Set<ModifiedCompound> identifiedCompounds = new HashSet<ModifiedCompound>();
while (indices[0]<matchedAtomsOfLinkages.get(0).size()) {
List<Atom[]> atomLinkages = new ArrayList<Atom[]>(nLink);
for (int iLink=0; iLink<nLink; iLink++) {
Atom[] atoms = matchedAtomsOfLinkages.get(iLink).get(indices[iLink]);
atomLinkages.add(atoms);
}
if (matchLinkages(modLinks, atomLinkages)) {
// matched
int n = atomLinkages.size();
List<StructureAtomLinkage> linkages = new ArrayList<StructureAtomLinkage>(n);
for (int i=0; i<n; i++) {
Atom[] linkage = atomLinkages.get(i);
StructureAtomLinkage link = StructureUtil.getStructureAtomLinkage(
linkage[0], residues.contains(linkage[0].getGroup()),
linkage[1], residues.contains(linkage[1].getGroup()));
linkages.add(link);
}
ModifiedCompound mc = new ModifiedCompoundImpl(mod, linkages);
if (!identifiedCompounds.contains(mc)) {
ret.add(mc);
identifiedCompounds.add(mc);
}
}
// indices++ (e.g. [0,0,1]=>[0,0,2]=>[1,2,0])
int i = nLink-1;
while (i>=0) {
if (i==0 || indices[i]<matchedAtomsOfLinkages.get(i).size()-1) {
indices[i]++;
break;
} else {
indices[i] = 0;
i--;
}
}
}
} | [
"private",
"void",
"assembleLinkages",
"(",
"List",
"<",
"List",
"<",
"Atom",
"[",
"]",
">",
">",
"matchedAtomsOfLinkages",
",",
"ProteinModification",
"mod",
",",
"List",
"<",
"ModifiedCompound",
">",
"ret",
")",
"{",
"ModificationCondition",
"condition",
"=",
... | Assembly the matched linkages
@param matchedAtomsOfLinkages
@param mod
@param ret ModifiedCompound will be stored here | [
"Assembly",
"the",
"matched",
"linkages"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/structure/ProteinModificationIdentifier.java#L806-L852 |
31,660 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/CoordManager.java | CoordManager.getSeqPos | protected int getSeqPos(int panelPos){
int seqPos = Math.round((panelPos - SequenceScalePanel.DEFAULT_X_START) / scale) ;
if ( seqPos < 0)
seqPos = 0;
//int length = chainLength;
//if ( seqPos >= length)
// seqPos = length-1;
return seqPos;
} | java | protected int getSeqPos(int panelPos){
int seqPos = Math.round((panelPos - SequenceScalePanel.DEFAULT_X_START) / scale) ;
if ( seqPos < 0)
seqPos = 0;
//int length = chainLength;
//if ( seqPos >= length)
// seqPos = length-1;
return seqPos;
} | [
"protected",
"int",
"getSeqPos",
"(",
"int",
"panelPos",
")",
"{",
"int",
"seqPos",
"=",
"Math",
".",
"round",
"(",
"(",
"panelPos",
"-",
"SequenceScalePanel",
".",
"DEFAULT_X_START",
")",
"/",
"scale",
")",
";",
"if",
"(",
"seqPos",
"<",
"0",
")",
"se... | start counting at 0...
@param panelPos
@return the sequence position | [
"start",
"counting",
"at",
"0",
"..."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/CoordManager.java#L59-L69 |
31,661 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/jmolScript/JmolSymmetryScriptGeneratorCn.java | JmolSymmetryScriptGeneratorCn.getOrientationName | @Override
public String getOrientationName(int index) {
if (getAxisTransformation().getRotationGroup().getPointGroup().equals("C2")) {
if (index == 0) {
return "Front C2 axis";
} else if (index == 2) {
return "Back C2 axis";
}
}
return getPolyhedron().getViewName(index);
} | java | @Override
public String getOrientationName(int index) {
if (getAxisTransformation().getRotationGroup().getPointGroup().equals("C2")) {
if (index == 0) {
return "Front C2 axis";
} else if (index == 2) {
return "Back C2 axis";
}
}
return getPolyhedron().getViewName(index);
} | [
"@",
"Override",
"public",
"String",
"getOrientationName",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"getAxisTransformation",
"(",
")",
".",
"getRotationGroup",
"(",
")",
".",
"getPointGroup",
"(",
")",
".",
"equals",
"(",
"\"C2\"",
")",
")",
"{",
"if",
... | Returns the name of a specific orientation
@param index orientation index
@return name of orientation | [
"Returns",
"the",
"name",
"of",
"a",
"specific",
"orientation"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/jmolScript/JmolSymmetryScriptGeneratorCn.java#L78-L88 |
31,662 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/UserConfiguration.java | UserConfiguration.toXML | public XMLWriter toXML(PrintWriter pw)
throws IOException
{
XMLWriter xw = new PrettyXMLWriter( pw);
toXML(xw);
return xw ;
} | java | public XMLWriter toXML(PrintWriter pw)
throws IOException
{
XMLWriter xw = new PrettyXMLWriter( pw);
toXML(xw);
return xw ;
} | [
"public",
"XMLWriter",
"toXML",
"(",
"PrintWriter",
"pw",
")",
"throws",
"IOException",
"{",
"XMLWriter",
"xw",
"=",
"new",
"PrettyXMLWriter",
"(",
"pw",
")",
";",
"toXML",
"(",
"xw",
")",
";",
"return",
"xw",
";",
"}"
] | convert Configuration to an XML file so it can be serialized
@param pw
@return XMLWriter
@throws IOException | [
"convert",
"Configuration",
"to",
"an",
"XML",
"file",
"so",
"it",
"can",
"be",
"serialized"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/UserConfiguration.java#L290-L298 |
31,663 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/UserConfiguration.java | UserConfiguration.toXML | public XMLWriter toXML(XMLWriter xw)
throws IOException
{
xw.printRaw("<?xml version='1.0' standalone='no' ?>");
//xw.printRaw("<!DOCTYPE " + XML_CONTENT_TYPE + " SYSTEM '" + XML_DTD + "' >");
xw.openTag("JFatCatConfig");
xw.openTag("PDBFILEPATH");
// we don;t serialize the tempdir...
String tempdir = System.getProperty(TMP_DIR);
if (! pdbFilePath.equals(tempdir))
xw.attribute("path", pdbFilePath);
xw.attribute("fetchBehavior", fetchBehavior+"");
xw.attribute("obsoleteBehavior", obsoleteBehavior+"");
xw.attribute("fileFormat", fileFormat);
xw.closeTag("PDBFILEPATH");
xw.closeTag("JFatCatConfig");
return xw ;
} | java | public XMLWriter toXML(XMLWriter xw)
throws IOException
{
xw.printRaw("<?xml version='1.0' standalone='no' ?>");
//xw.printRaw("<!DOCTYPE " + XML_CONTENT_TYPE + " SYSTEM '" + XML_DTD + "' >");
xw.openTag("JFatCatConfig");
xw.openTag("PDBFILEPATH");
// we don;t serialize the tempdir...
String tempdir = System.getProperty(TMP_DIR);
if (! pdbFilePath.equals(tempdir))
xw.attribute("path", pdbFilePath);
xw.attribute("fetchBehavior", fetchBehavior+"");
xw.attribute("obsoleteBehavior", obsoleteBehavior+"");
xw.attribute("fileFormat", fileFormat);
xw.closeTag("PDBFILEPATH");
xw.closeTag("JFatCatConfig");
return xw ;
} | [
"public",
"XMLWriter",
"toXML",
"(",
"XMLWriter",
"xw",
")",
"throws",
"IOException",
"{",
"xw",
".",
"printRaw",
"(",
"\"<?xml version='1.0' standalone='no' ?>\"",
")",
";",
"//xw.printRaw(\"<!DOCTYPE \" + XML_CONTENT_TYPE + \" SYSTEM '\" + XML_DTD + \"' >\");",
"xw",
".",
"... | convert Configuration to an XML file so it can be serialized
add to an already existing xml file.
@param xw the XML writer to use
@return the writer again
@throws IOException
@see org.biojava.nbio.structure.align.webstart.ConfigXMLHandler | [
"convert",
"Configuration",
"to",
"an",
"XML",
"file",
"so",
"it",
"can",
"be",
"serialized",
"add",
"to",
"an",
"already",
"existing",
"xml",
"file",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/UserConfiguration.java#L310-L331 |
31,664 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastXMLParser.java | BlastXMLParser.mapIds | private void mapIds() {
if (queryReferences != null) {
queryReferencesMap = new HashMap<String,Sequence>(queryReferences.size());
for (int counter=0; counter < queryReferences.size() ; counter ++){
String id = "Query_"+(counter+1);
queryReferencesMap.put(id, queryReferences.get(counter));
}
}
if (databaseReferences != null) {
databaseReferencesMap = new HashMap<String,Sequence>(databaseReferences.size());
for (int counter=0; counter < databaseReferences.size() ; counter ++){
// this is strange: while Query_id are 1 based, Hit (database) id are 0 based
String id = "gnl|BL_ORD_ID|"+(counter);
databaseReferencesMap.put(id, databaseReferences.get(counter));
}
}
} | java | private void mapIds() {
if (queryReferences != null) {
queryReferencesMap = new HashMap<String,Sequence>(queryReferences.size());
for (int counter=0; counter < queryReferences.size() ; counter ++){
String id = "Query_"+(counter+1);
queryReferencesMap.put(id, queryReferences.get(counter));
}
}
if (databaseReferences != null) {
databaseReferencesMap = new HashMap<String,Sequence>(databaseReferences.size());
for (int counter=0; counter < databaseReferences.size() ; counter ++){
// this is strange: while Query_id are 1 based, Hit (database) id are 0 based
String id = "gnl|BL_ORD_ID|"+(counter);
databaseReferencesMap.put(id, databaseReferences.get(counter));
}
}
} | [
"private",
"void",
"mapIds",
"(",
")",
"{",
"if",
"(",
"queryReferences",
"!=",
"null",
")",
"{",
"queryReferencesMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Sequence",
">",
"(",
"queryReferences",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"in... | fill the map association between sequences an a unique id | [
"fill",
"the",
"map",
"association",
"between",
"sequences",
"an",
"a",
"unique",
"id"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/search/io/blast/BlastXMLParser.java#L216-L233 |
31,665 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java | StructureInterfaceList.sort | public void sort() {
Collections.sort(list);
int i=1;
for (StructureInterface interf:list) {
interf.setId(i);
i++;
}
} | java | public void sort() {
Collections.sort(list);
int i=1;
for (StructureInterface interf:list) {
interf.setId(i);
i++;
}
} | [
"public",
"void",
"sort",
"(",
")",
"{",
"Collections",
".",
"sort",
"(",
"list",
")",
";",
"int",
"i",
"=",
"1",
";",
"for",
"(",
"StructureInterface",
"interf",
":",
"list",
")",
"{",
"interf",
".",
"setId",
"(",
"i",
")",
";",
"i",
"++",
";",
... | Sorts the interface list and reassigns ids based on new sorting | [
"Sorts",
"the",
"interface",
"list",
"and",
"reassigns",
"ids",
"based",
"on",
"new",
"sorting"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java#L248-L255 |
31,666 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java | StructureInterfaceList.addNcsEquivalent | public void addNcsEquivalent(StructureInterface interfaceNew, StructureInterface interfaceRef) {
this.add(interfaceNew);
if (clustersNcs == null) {
clustersNcs = new ArrayList<>();
}
if (interfaceRef == null) {
StructureInterfaceCluster newCluster = new StructureInterfaceCluster();
newCluster.addMember(interfaceNew);
clustersNcs.add(newCluster);
return;
}
Optional<StructureInterfaceCluster> clusterRef =
clustersNcs.stream().
filter(r->r.getMembers().stream().
anyMatch(c -> c.equals(interfaceRef))).
findFirst();
if (clusterRef.isPresent()) {
clusterRef.get().addMember(interfaceNew);
return;
}
logger.warn("The specified reference interface, if not null, should have been added to this set previously. " +
"Creating new cluster and adding both interfaces. This is likely a bug.");
this.add(interfaceRef);
StructureInterfaceCluster newCluster = new StructureInterfaceCluster();
newCluster.addMember(interfaceRef);
newCluster.addMember(interfaceNew);
clustersNcs.add(newCluster);
} | java | public void addNcsEquivalent(StructureInterface interfaceNew, StructureInterface interfaceRef) {
this.add(interfaceNew);
if (clustersNcs == null) {
clustersNcs = new ArrayList<>();
}
if (interfaceRef == null) {
StructureInterfaceCluster newCluster = new StructureInterfaceCluster();
newCluster.addMember(interfaceNew);
clustersNcs.add(newCluster);
return;
}
Optional<StructureInterfaceCluster> clusterRef =
clustersNcs.stream().
filter(r->r.getMembers().stream().
anyMatch(c -> c.equals(interfaceRef))).
findFirst();
if (clusterRef.isPresent()) {
clusterRef.get().addMember(interfaceNew);
return;
}
logger.warn("The specified reference interface, if not null, should have been added to this set previously. " +
"Creating new cluster and adding both interfaces. This is likely a bug.");
this.add(interfaceRef);
StructureInterfaceCluster newCluster = new StructureInterfaceCluster();
newCluster.addMember(interfaceRef);
newCluster.addMember(interfaceNew);
clustersNcs.add(newCluster);
} | [
"public",
"void",
"addNcsEquivalent",
"(",
"StructureInterface",
"interfaceNew",
",",
"StructureInterface",
"interfaceRef",
")",
"{",
"this",
".",
"add",
"(",
"interfaceNew",
")",
";",
"if",
"(",
"clustersNcs",
"==",
"null",
")",
"{",
"clustersNcs",
"=",
"new",
... | Add an interface to the list, possibly defining it as NCS-equivalent to an interface already in the list.
Used to build up the NCS clustering.
@param interfaceNew
an interface to be added to the list.
@param interfaceRef
interfaceNew will be added to the cluster which contains interfaceRef.
If interfaceRef is null, new cluster will be created for interfaceNew.
@since 5.0.0 | [
"Add",
"an",
"interface",
"to",
"the",
"list",
"possibly",
"defining",
"it",
"as",
"NCS",
"-",
"equivalent",
"to",
"an",
"interface",
"already",
"in",
"the",
"list",
".",
"Used",
"to",
"build",
"up",
"the",
"NCS",
"clustering",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java#L279-L311 |
31,667 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java | StructureInterfaceList.calculateInterfaces | public static StructureInterfaceList calculateInterfaces(Structure struc) {
CrystalBuilder builder = new CrystalBuilder(struc);
StructureInterfaceList interfaces = builder.getUniqueInterfaces();
logger.debug("Calculating ASA for "+interfaces.size()+" potential interfaces");
interfaces.calcAsas(StructureInterfaceList.DEFAULT_ASA_SPHERE_POINTS, //fewer for performance
Runtime.getRuntime().availableProcessors(),
StructureInterfaceList.DEFAULT_MIN_COFACTOR_SIZE);
interfaces.removeInterfacesBelowArea();
interfaces.getClusters();
logger.debug("Found "+interfaces.size()+" interfaces");
return interfaces;
} | java | public static StructureInterfaceList calculateInterfaces(Structure struc) {
CrystalBuilder builder = new CrystalBuilder(struc);
StructureInterfaceList interfaces = builder.getUniqueInterfaces();
logger.debug("Calculating ASA for "+interfaces.size()+" potential interfaces");
interfaces.calcAsas(StructureInterfaceList.DEFAULT_ASA_SPHERE_POINTS, //fewer for performance
Runtime.getRuntime().availableProcessors(),
StructureInterfaceList.DEFAULT_MIN_COFACTOR_SIZE);
interfaces.removeInterfacesBelowArea();
interfaces.getClusters();
logger.debug("Found "+interfaces.size()+" interfaces");
return interfaces;
} | [
"public",
"static",
"StructureInterfaceList",
"calculateInterfaces",
"(",
"Structure",
"struc",
")",
"{",
"CrystalBuilder",
"builder",
"=",
"new",
"CrystalBuilder",
"(",
"struc",
")",
";",
"StructureInterfaceList",
"interfaces",
"=",
"builder",
".",
"getUniqueInterfaces... | Calculates the interfaces for a structure using default parameters
@param struc
@return | [
"Calculates",
"the",
"interfaces",
"for",
"a",
"structure",
"using",
"default",
"parameters"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java#L462-L473 |
31,668 | biojava/biojava | biojava-alignment/src/main/java/org/biojava/nbio/phylo/ForesterWrapper.java | ForesterWrapper.getNewickString | public static String getNewickString(Phylogeny phylo,
boolean writeDistances) throws IOException {
PhylogenyWriter w = new PhylogenyWriter();
StringBuffer newickString = w.toNewHampshire(phylo, writeDistances);
return newickString.toString();
} | java | public static String getNewickString(Phylogeny phylo,
boolean writeDistances) throws IOException {
PhylogenyWriter w = new PhylogenyWriter();
StringBuffer newickString = w.toNewHampshire(phylo, writeDistances);
return newickString.toString();
} | [
"public",
"static",
"String",
"getNewickString",
"(",
"Phylogeny",
"phylo",
",",
"boolean",
"writeDistances",
")",
"throws",
"IOException",
"{",
"PhylogenyWriter",
"w",
"=",
"new",
"PhylogenyWriter",
"(",
")",
";",
"StringBuffer",
"newickString",
"=",
"w",
".",
... | Convert a Phylogenetic tree to its Newick representation, so that it can
be exported to an external application.
@param phylo
Phylogeny phylogenetic tree
@param writeDistances
write the branch lengths if true
@return
@throws IOException | [
"Convert",
"a",
"Phylogenetic",
"tree",
"to",
"its",
"Newick",
"representation",
"so",
"that",
"it",
"can",
"be",
"exported",
"to",
"an",
"external",
"application",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-alignment/src/main/java/org/biojava/nbio/phylo/ForesterWrapper.java#L94-L100 |
31,669 | biojava/biojava | biojava-alignment/src/main/java/org/biojava/nbio/phylo/ForesterWrapper.java | ForesterWrapper.cloneDM | public static BasicSymmetricalDistanceMatrix cloneDM(
BasicSymmetricalDistanceMatrix distM) {
int n = distM.getSize();
BasicSymmetricalDistanceMatrix cloneDM =
new BasicSymmetricalDistanceMatrix(n);
for (int i = 0; i < n; i++) {
cloneDM.setIdentifier(i, distM.getIdentifier(i));
for (int j = i + 1; j < n; j++) {
cloneDM.setValue(i, j, distM.getValue(i, j));
}
}
return cloneDM;
} | java | public static BasicSymmetricalDistanceMatrix cloneDM(
BasicSymmetricalDistanceMatrix distM) {
int n = distM.getSize();
BasicSymmetricalDistanceMatrix cloneDM =
new BasicSymmetricalDistanceMatrix(n);
for (int i = 0; i < n; i++) {
cloneDM.setIdentifier(i, distM.getIdentifier(i));
for (int j = i + 1; j < n; j++) {
cloneDM.setValue(i, j, distM.getValue(i, j));
}
}
return cloneDM;
} | [
"public",
"static",
"BasicSymmetricalDistanceMatrix",
"cloneDM",
"(",
"BasicSymmetricalDistanceMatrix",
"distM",
")",
"{",
"int",
"n",
"=",
"distM",
".",
"getSize",
"(",
")",
";",
"BasicSymmetricalDistanceMatrix",
"cloneDM",
"=",
"new",
"BasicSymmetricalDistanceMatrix",
... | Helper function to clone a forester symmetrical DistanceMatrix.
@param distM
forester symmetrical DistanceMatrix
@return identical copy of the forester symmetrical DistanceMatrix | [
"Helper",
"function",
"to",
"clone",
"a",
"forester",
"symmetrical",
"DistanceMatrix",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-alignment/src/main/java/org/biojava/nbio/phylo/ForesterWrapper.java#L109-L123 |
31,670 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContact.java | GroupContact.getContactsWithinDistance | public List<AtomContact> getContactsWithinDistance(double distance) {
List<AtomContact> list = new ArrayList<AtomContact>();
for (AtomContact contact:this.atomContacts) {
if (contact.getDistance()<distance) {
list.add(contact);
}
}
return list;
} | java | public List<AtomContact> getContactsWithinDistance(double distance) {
List<AtomContact> list = new ArrayList<AtomContact>();
for (AtomContact contact:this.atomContacts) {
if (contact.getDistance()<distance) {
list.add(contact);
}
}
return list;
} | [
"public",
"List",
"<",
"AtomContact",
">",
"getContactsWithinDistance",
"(",
"double",
"distance",
")",
"{",
"List",
"<",
"AtomContact",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"AtomContact",
">",
"(",
")",
";",
"for",
"(",
"AtomContact",
"contact",
":",
... | Returns the list of atom contacts in this GroupContact that are within the given distance.
@param distance
@return | [
"Returns",
"the",
"list",
"of",
"atom",
"contacts",
"in",
"this",
"GroupContact",
"that",
"are",
"within",
"the",
"given",
"distance",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContact.java#L83-L92 |
31,671 | biojava/biojava | biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/xml/AminoAcidCompositionTable.java | AminoAcidCompositionTable.computeMolecularWeight | public void computeMolecularWeight(ElementTable eTable){
this.aaSymbol2MolecularWeight = new HashMap<Character, Double>();
for(AminoAcidComposition a:aminoacid){
//Check to ensure that the symbol is of single character
if(a.getSymbol().length() != 1){
throw new Error(a.getSymbol() + " is not allowed. Symbols must be single character.\r\nPlease check AminoAcidComposition XML file");
}
//Check to ensure that the symbols are not repeated
char c = a.getSymbol().charAt(0);
if(this.aaSymbol2MolecularWeight.keySet().contains(c)){
throw new Error("Symbol " + c + " is repeated.\r\n" +
"Please check AminoAcidComposition XML file to ensure there are no repeated symbols. Note that this is case-insensitive.\r\n" +
"This means that having 'A' and 'a' would be repeating.");
}
double total = 0.0;
if(a.getElementList() != null){
for(Name2Count element:a.getElementList()){
element.getName();
if(eTable.getElement(element.getName()) == null){
throw new Error("Element " + element.getName() + " could not be found. " +
"\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml.");
}
eTable.getElement(element.getName()).getMass();
total += eTable.getElement(element.getName()).getMass() * element.getCount();
}
}
if(a.getIsotopeList() != null){
for(Name2Count isotope:a.getIsotopeList()){
isotope.getName();
if(eTable.getIsotope(isotope.getName()) == null){
throw new Error("Isotope " + isotope.getName() + " could not be found. " +
"\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml.");
}
eTable.getIsotope(isotope.getName()).getMass();
total += eTable.getIsotope(isotope.getName()).getMass() * isotope.getCount();
}
}
c = a.getSymbol().charAt(0);
this.aaSymbol2MolecularWeight.put(c, total);
}
generatesAminoAcidCompoundSet();
} | java | public void computeMolecularWeight(ElementTable eTable){
this.aaSymbol2MolecularWeight = new HashMap<Character, Double>();
for(AminoAcidComposition a:aminoacid){
//Check to ensure that the symbol is of single character
if(a.getSymbol().length() != 1){
throw new Error(a.getSymbol() + " is not allowed. Symbols must be single character.\r\nPlease check AminoAcidComposition XML file");
}
//Check to ensure that the symbols are not repeated
char c = a.getSymbol().charAt(0);
if(this.aaSymbol2MolecularWeight.keySet().contains(c)){
throw new Error("Symbol " + c + " is repeated.\r\n" +
"Please check AminoAcidComposition XML file to ensure there are no repeated symbols. Note that this is case-insensitive.\r\n" +
"This means that having 'A' and 'a' would be repeating.");
}
double total = 0.0;
if(a.getElementList() != null){
for(Name2Count element:a.getElementList()){
element.getName();
if(eTable.getElement(element.getName()) == null){
throw new Error("Element " + element.getName() + " could not be found. " +
"\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml.");
}
eTable.getElement(element.getName()).getMass();
total += eTable.getElement(element.getName()).getMass() * element.getCount();
}
}
if(a.getIsotopeList() != null){
for(Name2Count isotope:a.getIsotopeList()){
isotope.getName();
if(eTable.getIsotope(isotope.getName()) == null){
throw new Error("Isotope " + isotope.getName() + " could not be found. " +
"\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml.");
}
eTable.getIsotope(isotope.getName()).getMass();
total += eTable.getIsotope(isotope.getName()).getMass() * isotope.getCount();
}
}
c = a.getSymbol().charAt(0);
this.aaSymbol2MolecularWeight.put(c, total);
}
generatesAminoAcidCompoundSet();
} | [
"public",
"void",
"computeMolecularWeight",
"(",
"ElementTable",
"eTable",
")",
"{",
"this",
".",
"aaSymbol2MolecularWeight",
"=",
"new",
"HashMap",
"<",
"Character",
",",
"Double",
">",
"(",
")",
";",
"for",
"(",
"AminoAcidComposition",
"a",
":",
"aminoacid",
... | Computes and store the molecular weight of each amino acid by its symbol in aaSymbol2MolecularWeight.
@param eTable
Stores the mass of elements and isotopes | [
"Computes",
"and",
"store",
"the",
"molecular",
"weight",
"of",
"each",
"amino",
"acid",
"by",
"its",
"symbol",
"in",
"aaSymbol2MolecularWeight",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/xml/AminoAcidCompositionTable.java#L85-L126 |
31,672 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContactSet.java | GroupContactSet.hasContact | public boolean hasContact(Group group1, Group group2) {
return hasContact(group1.getResidueNumber(),group2.getResidueNumber());
} | java | public boolean hasContact(Group group1, Group group2) {
return hasContact(group1.getResidueNumber(),group2.getResidueNumber());
} | [
"public",
"boolean",
"hasContact",
"(",
"Group",
"group1",
",",
"Group",
"group2",
")",
"{",
"return",
"hasContact",
"(",
"group1",
".",
"getResidueNumber",
"(",
")",
",",
"group2",
".",
"getResidueNumber",
"(",
")",
")",
";",
"}"
] | Tell whether the given group pair is a contact in this GroupContactSet,
the comparison is done by matching residue numbers and chain identifiers
@param group1
@param group2
@return | [
"Tell",
"whether",
"the",
"given",
"group",
"pair",
"is",
"a",
"contact",
"in",
"this",
"GroupContactSet",
"the",
"comparison",
"is",
"done",
"by",
"matching",
"residue",
"numbers",
"and",
"chain",
"identifiers"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContactSet.java#L105-L107 |
31,673 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContactSet.java | GroupContactSet.hasContact | public boolean hasContact(ResidueNumber resNumber1, ResidueNumber resNumber2) {
return contacts.containsKey(new Pair<ResidueNumber>(resNumber1, resNumber2));
} | java | public boolean hasContact(ResidueNumber resNumber1, ResidueNumber resNumber2) {
return contacts.containsKey(new Pair<ResidueNumber>(resNumber1, resNumber2));
} | [
"public",
"boolean",
"hasContact",
"(",
"ResidueNumber",
"resNumber1",
",",
"ResidueNumber",
"resNumber2",
")",
"{",
"return",
"contacts",
".",
"containsKey",
"(",
"new",
"Pair",
"<",
"ResidueNumber",
">",
"(",
"resNumber1",
",",
"resNumber2",
")",
")",
";",
"... | Tell whether the given pair is a contact in this GroupContactSet,
the comparison is done by matching residue numbers and chain identifiers
@param resNumber1
@param resNumber2
@return | [
"Tell",
"whether",
"the",
"given",
"pair",
"is",
"a",
"contact",
"in",
"this",
"GroupContactSet",
"the",
"comparison",
"is",
"done",
"by",
"matching",
"residue",
"numbers",
"and",
"chain",
"identifiers"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContactSet.java#L116-L118 |
31,674 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContactSet.java | GroupContactSet.getContact | public GroupContact getContact(Group group1, Group group2) {
return contacts.get(
new Pair<ResidueNumber>(group1.getResidueNumber(),group2.getResidueNumber()));
} | java | public GroupContact getContact(Group group1, Group group2) {
return contacts.get(
new Pair<ResidueNumber>(group1.getResidueNumber(),group2.getResidueNumber()));
} | [
"public",
"GroupContact",
"getContact",
"(",
"Group",
"group1",
",",
"Group",
"group2",
")",
"{",
"return",
"contacts",
".",
"get",
"(",
"new",
"Pair",
"<",
"ResidueNumber",
">",
"(",
"group1",
".",
"getResidueNumber",
"(",
")",
",",
"group2",
".",
"getRes... | Returns the corresponding GroupContact or null if no contact exists between the 2 given groups
@param group1
@param group2
@return | [
"Returns",
"the",
"corresponding",
"GroupContact",
"or",
"null",
"if",
"no",
"contact",
"exists",
"between",
"the",
"2",
"given",
"groups"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/GroupContactSet.java#L140-L143 |
31,675 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/Mutator.java | Mutator.mutate | public Structure mutate(Structure struc, String chainId, String pdbResnum, String newType)
throws PDBParseException{
// create a container for the new structure
Structure newstruc = new StructureImpl();
// first we need to find our corresponding chain
// get the chains for model nr. 0
// if structure is xray there will be only one "model".
List<Chain> chains = struc.getChains(0);
// iterate over all chains.
for (Chain c : chains) {
if (c.getName().equals(chainId)) {
// here is our chain!
Chain newchain = new ChainImpl();
newchain.setName(c.getName());
List<Group> groups = c.getAtomGroups();
// now iterate over all groups in this chain.
// in order to find the amino acid that has this pdbRenum.
for (Group g : groups) {
String rnum = g.getResidueNumber().toString();
// we only mutate amino acids
// and ignore hetatoms and nucleotides in this case
if (rnum.equals(pdbResnum) && (g.getType() == GroupType.AMINOACID)) {
// create the mutated amino acid and add it to our new chain
AminoAcid newgroup = mutateResidue((AminoAcid) g, newType);
newchain.addGroup(newgroup);
} else {
// add the group to the new chain unmodified.
newchain.addGroup(g);
}
}
// add the newly constructed chain to the structure;
newstruc.addChain(newchain);
} else {
// this chain is not requested, add it to the new structure unmodified.
newstruc.addChain(c);
}
}
return newstruc;
} | java | public Structure mutate(Structure struc, String chainId, String pdbResnum, String newType)
throws PDBParseException{
// create a container for the new structure
Structure newstruc = new StructureImpl();
// first we need to find our corresponding chain
// get the chains for model nr. 0
// if structure is xray there will be only one "model".
List<Chain> chains = struc.getChains(0);
// iterate over all chains.
for (Chain c : chains) {
if (c.getName().equals(chainId)) {
// here is our chain!
Chain newchain = new ChainImpl();
newchain.setName(c.getName());
List<Group> groups = c.getAtomGroups();
// now iterate over all groups in this chain.
// in order to find the amino acid that has this pdbRenum.
for (Group g : groups) {
String rnum = g.getResidueNumber().toString();
// we only mutate amino acids
// and ignore hetatoms and nucleotides in this case
if (rnum.equals(pdbResnum) && (g.getType() == GroupType.AMINOACID)) {
// create the mutated amino acid and add it to our new chain
AminoAcid newgroup = mutateResidue((AminoAcid) g, newType);
newchain.addGroup(newgroup);
} else {
// add the group to the new chain unmodified.
newchain.addGroup(g);
}
}
// add the newly constructed chain to the structure;
newstruc.addChain(newchain);
} else {
// this chain is not requested, add it to the new structure unmodified.
newstruc.addChain(c);
}
}
return newstruc;
} | [
"public",
"Structure",
"mutate",
"(",
"Structure",
"struc",
",",
"String",
"chainId",
",",
"String",
"pdbResnum",
",",
"String",
"newType",
")",
"throws",
"PDBParseException",
"{",
"// create a container for the new structure",
"Structure",
"newstruc",
"=",
"new",
"S... | creates a new structure which is identical with the original one.
only one amino acid will be different.
@param struc the structure object that is the container for the residue to be mutated
@param chainId the id (name) of the chain to be mutated. @see Chain.getName()
@param pdbResnum the PDB residue number of the residue
@param newType the new residue type (3 characters)
@return a structure object where one residue has been modified
@throws PDBParseException | [
"creates",
"a",
"new",
"structure",
"which",
"is",
"identical",
"with",
"the",
"original",
"one",
".",
"only",
"one",
"amino",
"acid",
"will",
"be",
"different",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/Mutator.java#L83-L134 |
31,676 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/Mutator.java | Mutator.mutateResidue | public AminoAcid mutateResidue(AminoAcid oldAmino, String newType)
throws PDBParseException {
AminoAcid newgroup = new AminoAcidImpl();
newgroup.setResidueNumber(oldAmino.getResidueNumber());
newgroup.setPDBName(newType);
AtomIterator aiter =new AtomIterator(oldAmino);
while (aiter.hasNext()){
Atom a = aiter.next();
if ( supportedAtoms.contains(a.getName())){
newgroup.addAtom(a);
}
}
return newgroup;
} | java | public AminoAcid mutateResidue(AminoAcid oldAmino, String newType)
throws PDBParseException {
AminoAcid newgroup = new AminoAcidImpl();
newgroup.setResidueNumber(oldAmino.getResidueNumber());
newgroup.setPDBName(newType);
AtomIterator aiter =new AtomIterator(oldAmino);
while (aiter.hasNext()){
Atom a = aiter.next();
if ( supportedAtoms.contains(a.getName())){
newgroup.addAtom(a);
}
}
return newgroup;
} | [
"public",
"AminoAcid",
"mutateResidue",
"(",
"AminoAcid",
"oldAmino",
",",
"String",
"newType",
")",
"throws",
"PDBParseException",
"{",
"AminoAcid",
"newgroup",
"=",
"new",
"AminoAcidImpl",
"(",
")",
";",
"newgroup",
".",
"setResidueNumber",
"(",
"oldAmino",
".",... | create a new residue which is of the new type.
Only the atoms N, Ca, C, O, Cb will be considered.
@param oldAmino
@param newType
@return a new, mutated, residue
@throws PDBParseException | [
"create",
"a",
"new",
"residue",
"which",
"is",
"of",
"the",
"new",
"type",
".",
"Only",
"the",
"atoms",
"N",
"Ca",
"C",
"O",
"Cb",
"will",
"be",
"considered",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/Mutator.java#L143-L162 |
31,677 | biojava/biojava | biojava-alignment/src/main/java/org/biojava/nbio/phylo/Comparison.java | Comparison.PID | public final static float PID(String seq1, String seq2) {
return PID(seq1, seq2, 0, seq1.length());
} | java | public final static float PID(String seq1, String seq2) {
return PID(seq1, seq2, 0, seq1.length());
} | [
"public",
"final",
"static",
"float",
"PID",
"(",
"String",
"seq1",
",",
"String",
"seq2",
")",
"{",
"return",
"PID",
"(",
"seq1",
",",
"seq2",
",",
"0",
",",
"seq1",
".",
"length",
"(",
")",
")",
";",
"}"
] | this is a gapped PID calculation
@param s1
SequenceI
@param s2
SequenceI
@return float | [
"this",
"is",
"a",
"gapped",
"PID",
"calculation"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-alignment/src/main/java/org/biojava/nbio/phylo/Comparison.java#L47-L49 |
31,678 | biojava/biojava | biojava-alignment/src/main/java/org/biojava/nbio/phylo/Comparison.java | Comparison.PID | public final static float PID(String seq1, String seq2, int start, int end) {
int s1len = seq1.length();
int s2len = seq2.length();
int len = Math.min(s1len, s2len);
if (end < len) {
len = end;
}
if (len < start) {
start = len - 1; // we just use a single residue for the difference
}
int bad = 0;
char chr1;
char chr2;
for (int i = start; i < len; i++) {
chr1 = seq1.charAt(i);
chr2 = seq2.charAt(i);
if ('a' <= chr1 && chr1 <= 'z') {
// TO UPPERCASE !!!
// Faster than toUpperCase
chr1 -= caseShift;
}
if ('a' <= chr2 && chr2 <= 'z') {
// TO UPPERCASE !!!
// Faster than toUpperCase
chr2 -= caseShift;
}
if (chr1 != chr2 && !isGap(chr1) && !isGap(chr2)) {
bad++;
}
}
return ((float) 100 * (len - bad)) / len;
} | java | public final static float PID(String seq1, String seq2, int start, int end) {
int s1len = seq1.length();
int s2len = seq2.length();
int len = Math.min(s1len, s2len);
if (end < len) {
len = end;
}
if (len < start) {
start = len - 1; // we just use a single residue for the difference
}
int bad = 0;
char chr1;
char chr2;
for (int i = start; i < len; i++) {
chr1 = seq1.charAt(i);
chr2 = seq2.charAt(i);
if ('a' <= chr1 && chr1 <= 'z') {
// TO UPPERCASE !!!
// Faster than toUpperCase
chr1 -= caseShift;
}
if ('a' <= chr2 && chr2 <= 'z') {
// TO UPPERCASE !!!
// Faster than toUpperCase
chr2 -= caseShift;
}
if (chr1 != chr2 && !isGap(chr1) && !isGap(chr2)) {
bad++;
}
}
return ((float) 100 * (len - bad)) / len;
} | [
"public",
"final",
"static",
"float",
"PID",
"(",
"String",
"seq1",
",",
"String",
"seq2",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"int",
"s1len",
"=",
"seq1",
".",
"length",
"(",
")",
";",
"int",
"s2len",
"=",
"seq2",
".",
"length",
"(",... | Another pid with region specification | [
"Another",
"pid",
"with",
"region",
"specification"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-alignment/src/main/java/org/biojava/nbio/phylo/Comparison.java#L52-L93 |
31,679 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java | RotationSolver.completeRotationGroup | private boolean completeRotationGroup(Rotation... additionalRots) {
PermutationGroup g = new PermutationGroup();
for (Rotation s : rotations) {
g.addPermutation(s.getPermutation());
}
for( Rotation s : additionalRots) {
g.addPermutation(s.getPermutation());
// inputs should not have been added already
assert evaluatedPermutations.get(s.getPermutation()) == null;
}
g.completeGroup();
// the group is complete, nothing to do
if (g.getOrder() == rotations.getOrder()+additionalRots.length) {
for( Rotation s : additionalRots) {
addRotation(s);
}
return true;
}
// try to complete the group
List<Rotation> newRots = new ArrayList<>(g.getOrder());
// First, quick check for whether they're allowed
for (List<Integer> permutation : g) {
if( evaluatedPermutations.containsKey(permutation)) {
Rotation rot = evaluatedPermutations.get(permutation);
if( rot == null ) {
return false;
}
} else {
if( ! isAllowedPermutation(permutation)) {
return false;
}
}
}
// Slower check including the superpositions
for (List<Integer> permutation : g) {
Rotation rot;
if( evaluatedPermutations.containsKey(permutation)) {
rot = evaluatedPermutations.get(permutation);
} else {
rot = isValidPermutation(permutation);
}
if( rot == null ) {
// if any induced rotation is invalid, abort
return false;
}
if(!evaluatedPermutations.containsKey(permutation)){ //novel
newRots.add(rot);
}
}
// Add rotations
for( Rotation rot : newRots) {
addRotation(rot);
}
return true;
} | java | private boolean completeRotationGroup(Rotation... additionalRots) {
PermutationGroup g = new PermutationGroup();
for (Rotation s : rotations) {
g.addPermutation(s.getPermutation());
}
for( Rotation s : additionalRots) {
g.addPermutation(s.getPermutation());
// inputs should not have been added already
assert evaluatedPermutations.get(s.getPermutation()) == null;
}
g.completeGroup();
// the group is complete, nothing to do
if (g.getOrder() == rotations.getOrder()+additionalRots.length) {
for( Rotation s : additionalRots) {
addRotation(s);
}
return true;
}
// try to complete the group
List<Rotation> newRots = new ArrayList<>(g.getOrder());
// First, quick check for whether they're allowed
for (List<Integer> permutation : g) {
if( evaluatedPermutations.containsKey(permutation)) {
Rotation rot = evaluatedPermutations.get(permutation);
if( rot == null ) {
return false;
}
} else {
if( ! isAllowedPermutation(permutation)) {
return false;
}
}
}
// Slower check including the superpositions
for (List<Integer> permutation : g) {
Rotation rot;
if( evaluatedPermutations.containsKey(permutation)) {
rot = evaluatedPermutations.get(permutation);
} else {
rot = isValidPermutation(permutation);
}
if( rot == null ) {
// if any induced rotation is invalid, abort
return false;
}
if(!evaluatedPermutations.containsKey(permutation)){ //novel
newRots.add(rot);
}
}
// Add rotations
for( Rotation rot : newRots) {
addRotation(rot);
}
return true;
} | [
"private",
"boolean",
"completeRotationGroup",
"(",
"Rotation",
"...",
"additionalRots",
")",
"{",
"PermutationGroup",
"g",
"=",
"new",
"PermutationGroup",
"(",
")",
";",
"for",
"(",
"Rotation",
"s",
":",
"rotations",
")",
"{",
"g",
".",
"addPermutation",
"(",... | Combine current rotations to make all possible permutations.
If these are all valid, add them to the rotations
@param additionalRots Additional rotations we are considering adding to this.rotations
@return whether the rotations were valid and added | [
"Combine",
"current",
"rotations",
"to",
"make",
"all",
"possible",
"permutations",
".",
"If",
"these",
"are",
"all",
"valid",
"add",
"them",
"to",
"the",
"rotations"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java#L151-L208 |
31,680 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java | RotationSolver.getAngles | private List<Double> getAngles() {
int n = subunits.getSubunitCount();
// for spherical symmetric cases, n cannot be higher than 60
if (n % 60 == 0 && isSpherical()) {
n = 60;
}
List<Integer> folds = subunits.getFolds();
List<Double> angles = new ArrayList<Double>(folds.size()-1);
// note this loop starts at 1, we do ignore 1-fold symmetry, which is the first entry
for (int fold: folds) {
if (fold > 0 && fold <= n) {
angles.add(2* Math.PI/fold);
}
}
return angles;
} | java | private List<Double> getAngles() {
int n = subunits.getSubunitCount();
// for spherical symmetric cases, n cannot be higher than 60
if (n % 60 == 0 && isSpherical()) {
n = 60;
}
List<Integer> folds = subunits.getFolds();
List<Double> angles = new ArrayList<Double>(folds.size()-1);
// note this loop starts at 1, we do ignore 1-fold symmetry, which is the first entry
for (int fold: folds) {
if (fold > 0 && fold <= n) {
angles.add(2* Math.PI/fold);
}
}
return angles;
} | [
"private",
"List",
"<",
"Double",
">",
"getAngles",
"(",
")",
"{",
"int",
"n",
"=",
"subunits",
".",
"getSubunitCount",
"(",
")",
";",
"// for spherical symmetric cases, n cannot be higher than 60",
"if",
"(",
"n",
"%",
"60",
"==",
"0",
"&&",
"isSpherical",
"(... | Get valid rotation angles given the number of subunits
@return The rotation angle corresponding to each fold of {@link Subunits#getFolds()} | [
"Get",
"valid",
"rotation",
"angles",
"given",
"the",
"number",
"of",
"subunits"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java#L276-L292 |
31,681 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java | RotationSolver.isValidPermutation | private Rotation isValidPermutation(List<Integer> permutation) {
if (permutation.size() == 0) {
return null;
}
// cached value
if (evaluatedPermutations.containsKey(permutation)) {
return evaluatedPermutations.get(permutation);
}
// check if permutation is allowed
if (! isAllowedPermutation(permutation)) {
evaluatedPermutations.put(permutation, null);
return null;
}
// check if superimposes
Rotation rot = superimposePermutation(permutation);
return rot;
} | java | private Rotation isValidPermutation(List<Integer> permutation) {
if (permutation.size() == 0) {
return null;
}
// cached value
if (evaluatedPermutations.containsKey(permutation)) {
return evaluatedPermutations.get(permutation);
}
// check if permutation is allowed
if (! isAllowedPermutation(permutation)) {
evaluatedPermutations.put(permutation, null);
return null;
}
// check if superimposes
Rotation rot = superimposePermutation(permutation);
return rot;
} | [
"private",
"Rotation",
"isValidPermutation",
"(",
"List",
"<",
"Integer",
">",
"permutation",
")",
"{",
"if",
"(",
"permutation",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"// cached value",
"if",
"(",
"evaluatedPermutations",
... | Checks if a particular permutation is allowed and superimposes well.
Caches results.
@param permutation
@return null if invalid, or a rotation if valid | [
"Checks",
"if",
"a",
"particular",
"permutation",
"is",
"allowed",
"and",
"superimposes",
"well",
".",
"Caches",
"results",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java#L305-L324 |
31,682 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java | RotationSolver.isAllowedPermutation | private boolean isAllowedPermutation(List<Integer> permutation) {
List<Integer> seqClusterId = subunits.getClusterIds();
int selfaligned = 0;
for (int i = 0; i < permutation.size(); i++) {
int j = permutation.get(i);
if ( seqClusterId.get(i) != seqClusterId.get(j)) {
return false;
}
if(i == j ) {
selfaligned++;
}
}
// either identity (all self aligned) or all unique
return selfaligned == 0 || selfaligned == permutation.size();
} | java | private boolean isAllowedPermutation(List<Integer> permutation) {
List<Integer> seqClusterId = subunits.getClusterIds();
int selfaligned = 0;
for (int i = 0; i < permutation.size(); i++) {
int j = permutation.get(i);
if ( seqClusterId.get(i) != seqClusterId.get(j)) {
return false;
}
if(i == j ) {
selfaligned++;
}
}
// either identity (all self aligned) or all unique
return selfaligned == 0 || selfaligned == permutation.size();
} | [
"private",
"boolean",
"isAllowedPermutation",
"(",
"List",
"<",
"Integer",
">",
"permutation",
")",
"{",
"List",
"<",
"Integer",
">",
"seqClusterId",
"=",
"subunits",
".",
"getClusterIds",
"(",
")",
";",
"int",
"selfaligned",
"=",
"0",
";",
"for",
"(",
"in... | The permutation must map all subunits onto an equivalent subunit
and no subunit onto itself
@param permutation
@return | [
"The",
"permutation",
"must",
"map",
"all",
"subunits",
"onto",
"an",
"equivalent",
"subunit",
"and",
"no",
"subunit",
"onto",
"itself"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java#L332-L346 |
31,683 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java | RotationSolver.getPermutation | private List<Integer> getPermutation() {
List<Integer> permutation = new ArrayList<Integer>(transformedCoords.length);
double sum = 0.0f;
for (Point3d t: transformedCoords) {
List<Integer> neighbors = box.getNeighborsWithCache(t);
int closest = -1;
double minDist = Double.MAX_VALUE;
for (int j : neighbors) {
double dist = t.distanceSquared(originalCoords[j]);
if (dist < minDist) {
closest = j;
minDist = dist;
}
}
sum += minDist;
if (closest == -1) {
break;
}
permutation.add(closest);
}
double rmsd = Math.sqrt(sum / transformedCoords.length);
if (rmsd > distanceThreshold || permutation.size() != transformedCoords.length) {
permutation.clear();
return permutation;
}
// check uniqueness of indices
Set<Integer> set = new HashSet<Integer>(permutation);
// if size mismatch, clear permutation (its invalid)
if (set.size() != originalCoords.length) {
permutation.clear();
}
return permutation;
} | java | private List<Integer> getPermutation() {
List<Integer> permutation = new ArrayList<Integer>(transformedCoords.length);
double sum = 0.0f;
for (Point3d t: transformedCoords) {
List<Integer> neighbors = box.getNeighborsWithCache(t);
int closest = -1;
double minDist = Double.MAX_VALUE;
for (int j : neighbors) {
double dist = t.distanceSquared(originalCoords[j]);
if (dist < minDist) {
closest = j;
minDist = dist;
}
}
sum += minDist;
if (closest == -1) {
break;
}
permutation.add(closest);
}
double rmsd = Math.sqrt(sum / transformedCoords.length);
if (rmsd > distanceThreshold || permutation.size() != transformedCoords.length) {
permutation.clear();
return permutation;
}
// check uniqueness of indices
Set<Integer> set = new HashSet<Integer>(permutation);
// if size mismatch, clear permutation (its invalid)
if (set.size() != originalCoords.length) {
permutation.clear();
}
return permutation;
} | [
"private",
"List",
"<",
"Integer",
">",
"getPermutation",
"(",
")",
"{",
"List",
"<",
"Integer",
">",
"permutation",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
"transformedCoords",
".",
"length",
")",
";",
"double",
"sum",
"=",
"0.0f",
";",
"for"... | Compare this.transformedCoords with the original coords. For each
subunit, return the transformed subunit with the closest position.
@return A list mapping each subunit to the closest transformed subunit | [
"Compare",
"this",
".",
"transformedCoords",
"with",
"the",
"original",
"coords",
".",
"For",
"each",
"subunit",
"return",
"the",
"transformed",
"subunit",
"with",
"the",
"closest",
"position",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationSolver.java#L401-L440 |
31,684 | biojava/biojava | biojava-structure-gui/src/main/java/demo/DemoShowLargeAssembly.java | DemoShowLargeAssembly.readStructure | public static Structure readStructure(String pdbId, int bioAssemblyId) {
// pre-computed files use lower case PDB IDs
pdbId = pdbId.toLowerCase();
// we just need this to track where to store PDB files
// this checks the PDB_DIR property (and uses a tmp location if not set)
AtomCache cache = new AtomCache();
cache.setUseMmCif(true);
FileParsingParameters p = cache.getFileParsingParams();
// some bio assemblies are large, we want an all atom representation and avoid
// switching to a Calpha-only representation for large molecules
// note, this requires several GB of memory for some of the largest assemblies, such a 1MX4
p.setAtomCaThreshold(Integer.MAX_VALUE);
// parse remark 350
p.setParseBioAssembly(true);
// download missing files
Structure structure = null;
try {
structure = StructureIO.getBiologicalAssembly(pdbId,bioAssemblyId);
} catch (Exception e){
e.printStackTrace();
return null;
}
return structure;
} | java | public static Structure readStructure(String pdbId, int bioAssemblyId) {
// pre-computed files use lower case PDB IDs
pdbId = pdbId.toLowerCase();
// we just need this to track where to store PDB files
// this checks the PDB_DIR property (and uses a tmp location if not set)
AtomCache cache = new AtomCache();
cache.setUseMmCif(true);
FileParsingParameters p = cache.getFileParsingParams();
// some bio assemblies are large, we want an all atom representation and avoid
// switching to a Calpha-only representation for large molecules
// note, this requires several GB of memory for some of the largest assemblies, such a 1MX4
p.setAtomCaThreshold(Integer.MAX_VALUE);
// parse remark 350
p.setParseBioAssembly(true);
// download missing files
Structure structure = null;
try {
structure = StructureIO.getBiologicalAssembly(pdbId,bioAssemblyId);
} catch (Exception e){
e.printStackTrace();
return null;
}
return structure;
} | [
"public",
"static",
"Structure",
"readStructure",
"(",
"String",
"pdbId",
",",
"int",
"bioAssemblyId",
")",
"{",
"// pre-computed files use lower case PDB IDs",
"pdbId",
"=",
"pdbId",
".",
"toLowerCase",
"(",
")",
";",
"// we just need this to track where to store PDB files... | Load a specific biological assembly for a PDB entry
@param pdbId .. the PDB ID
@param bioAssemblyId .. the first assembly has the bioAssemblyId 1
@return a Structure object or null if something went wrong. | [
"Load",
"a",
"specific",
"biological",
"assembly",
"for",
"a",
"PDB",
"entry"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/demo/DemoShowLargeAssembly.java#L72-L101 |
31,685 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.calculate | public List<SecStrucState> calculate(Structure s, boolean assign)
throws StructureException {
List<SecStrucState> secstruc = new ArrayList<SecStrucState>();
for(int i=0; i<s.nrModels(); i++) {
// Reinitialise the global vars
ladders = new ArrayList<Ladder>();
bridges = new ArrayList<BetaBridge>();
groups = initGroupArray(s, i);
// Initialise the contact set for this structure
initContactSet();
if (groups.length < 5) {
// not enough groups to do anything
throw new StructureException("Not enough backbone groups in the"
+ " Structure to calculate the secondary structure ("
+ groups.length+" given, minimum 5)" );
}
calculateHAtoms();
calculateHBonds();
calculateDihedralAngles();
calculateTurns();
buildHelices();
detectBends();
detectStrands();
for (SecStrucGroup sg : groups){
SecStrucState ss = (SecStrucState)
sg.getProperty(Group.SEC_STRUC);
// Add to return list and assign to original if flag is true
secstruc.add(ss);
if (assign) sg.getOriginal().setProperty(Group.SEC_STRUC, ss);
}
}
return secstruc;
} | java | public List<SecStrucState> calculate(Structure s, boolean assign)
throws StructureException {
List<SecStrucState> secstruc = new ArrayList<SecStrucState>();
for(int i=0; i<s.nrModels(); i++) {
// Reinitialise the global vars
ladders = new ArrayList<Ladder>();
bridges = new ArrayList<BetaBridge>();
groups = initGroupArray(s, i);
// Initialise the contact set for this structure
initContactSet();
if (groups.length < 5) {
// not enough groups to do anything
throw new StructureException("Not enough backbone groups in the"
+ " Structure to calculate the secondary structure ("
+ groups.length+" given, minimum 5)" );
}
calculateHAtoms();
calculateHBonds();
calculateDihedralAngles();
calculateTurns();
buildHelices();
detectBends();
detectStrands();
for (SecStrucGroup sg : groups){
SecStrucState ss = (SecStrucState)
sg.getProperty(Group.SEC_STRUC);
// Add to return list and assign to original if flag is true
secstruc.add(ss);
if (assign) sg.getOriginal().setProperty(Group.SEC_STRUC, ss);
}
}
return secstruc;
} | [
"public",
"List",
"<",
"SecStrucState",
">",
"calculate",
"(",
"Structure",
"s",
",",
"boolean",
"assign",
")",
"throws",
"StructureException",
"{",
"List",
"<",
"SecStrucState",
">",
"secstruc",
"=",
"new",
"ArrayList",
"<",
"SecStrucState",
">",
"(",
")",
... | Predicts the secondary structure of this Structure object,
using a DSSP implementation.
@param s Structure to predict the SS
@param assign sets the SS information to the Groups of s
@return a List of SS annotation objects | [
"Predicts",
"the",
"secondary",
"structure",
"of",
"this",
"Structure",
"object",
"using",
"a",
"DSSP",
"implementation",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L119-L154 |
31,686 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.initContactSet | private void initContactSet() {
// Initialise an array of atoms
atoms = new Atom[groups.length];
// Remake this local var
indResMap = new HashMap<>();
for (int i=0 ; i < groups.length ; i++){
SecStrucGroup one = groups[i];
indResMap.put(one.getResidueNumber(), i);
atoms[i] = one.getCA();
}
Grid grid = new Grid(CA_MIN_DIST);
if(atoms.length==0){
contactSet = new AtomContactSet(CA_MIN_DIST);
}
else{
grid.addAtoms(atoms);
contactSet = grid.getAtomContacts();
}
} | java | private void initContactSet() {
// Initialise an array of atoms
atoms = new Atom[groups.length];
// Remake this local var
indResMap = new HashMap<>();
for (int i=0 ; i < groups.length ; i++){
SecStrucGroup one = groups[i];
indResMap.put(one.getResidueNumber(), i);
atoms[i] = one.getCA();
}
Grid grid = new Grid(CA_MIN_DIST);
if(atoms.length==0){
contactSet = new AtomContactSet(CA_MIN_DIST);
}
else{
grid.addAtoms(atoms);
contactSet = grid.getAtomContacts();
}
} | [
"private",
"void",
"initContactSet",
"(",
")",
"{",
"// Initialise an array of atoms",
"atoms",
"=",
"new",
"Atom",
"[",
"groups",
".",
"length",
"]",
";",
"// Remake this local var",
"indResMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"int",
... | Function to generate the contact sets | [
"Function",
"to",
"generate",
"the",
"contact",
"sets"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L159-L178 |
31,687 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.printDSSP | public String printDSSP() {
StringBuffer buf = new StringBuffer();
String nl = System.getProperty("line.separator");
//Header Line
buf.append("==== Secondary Structure Definition by BioJava"
+ " DSSP implementation, Version October 2015 ===="+nl);
//First line with column definition
buf.append(" # RESIDUE AA STRUCTURE BP1 BP2 ACC "
+ "N-H-->O O-->H-N N-H-->O O-->H-N "
+ "TCO KAPPA ALPHA PHI PSI "
+ "X-CA Y-CA Z-CA ");
for (int i =0 ; i < groups.length ;i++){
buf.append(nl);
SecStrucState ss = getSecStrucState(i);
buf.append(ss.printDSSPline(i));
}
return buf.toString();
} | java | public String printDSSP() {
StringBuffer buf = new StringBuffer();
String nl = System.getProperty("line.separator");
//Header Line
buf.append("==== Secondary Structure Definition by BioJava"
+ " DSSP implementation, Version October 2015 ===="+nl);
//First line with column definition
buf.append(" # RESIDUE AA STRUCTURE BP1 BP2 ACC "
+ "N-H-->O O-->H-N N-H-->O O-->H-N "
+ "TCO KAPPA ALPHA PHI PSI "
+ "X-CA Y-CA Z-CA ");
for (int i =0 ; i < groups.length ;i++){
buf.append(nl);
SecStrucState ss = getSecStrucState(i);
buf.append(ss.printDSSPline(i));
}
return buf.toString();
} | [
"public",
"String",
"printDSSP",
"(",
")",
"{",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"String",
"nl",
"=",
"System",
".",
"getProperty",
"(",
"\"line.separator\"",
")",
";",
"//Header Line",
"buf",
".",
"append",
"(",
"\"==== Seco... | Generate a DSSP file format ouput String of this SS prediction.
@return String in DSSP output file format | [
"Generate",
"a",
"DSSP",
"file",
"format",
"ouput",
"String",
"of",
"this",
"SS",
"prediction",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L602-L624 |
31,688 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.printFASTA | public String printFASTA() {
StringBuffer buf = new StringBuffer();
String nl = System.getProperty("line.separator");
buf.append(">"+groups[0].getChain().getStructure().getIdentifier()+nl);
for (int g = 0; g < groups.length; g++){
buf.append(getSecStrucState(g).getType());
}
return buf.toString();
} | java | public String printFASTA() {
StringBuffer buf = new StringBuffer();
String nl = System.getProperty("line.separator");
buf.append(">"+groups[0].getChain().getStructure().getIdentifier()+nl);
for (int g = 0; g < groups.length; g++){
buf.append(getSecStrucState(g).getType());
}
return buf.toString();
} | [
"public",
"String",
"printFASTA",
"(",
")",
"{",
"StringBuffer",
"buf",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"String",
"nl",
"=",
"System",
".",
"getProperty",
"(",
"\"line.separator\"",
")",
";",
"buf",
".",
"append",
"(",
"\">\"",
"+",
"groups",
... | Generate a FASTA sequence with the SS annotation letters in the
aminoacid sequence order.
@return String in FASTA sequence format | [
"Generate",
"a",
"FASTA",
"sequence",
"with",
"the",
"SS",
"annotation",
"letters",
"in",
"the",
"aminoacid",
"sequence",
"order",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L669-L679 |
31,689 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.calculateHAtoms | private void calculateHAtoms() throws StructureException {
for ( int i = 0 ; i < groups.length-1 ; i++) {
SecStrucGroup a = groups[i];
SecStrucGroup b = groups[i+1];
if ( !b.hasAtom("H") ) {
//Atom H = calc_H(a.getC(), b.getN(), b.getCA());
Atom H = calcSimple_H(a.getC(), a.getO(), b.getN());
b.setH(H);
}
}
} | java | private void calculateHAtoms() throws StructureException {
for ( int i = 0 ; i < groups.length-1 ; i++) {
SecStrucGroup a = groups[i];
SecStrucGroup b = groups[i+1];
if ( !b.hasAtom("H") ) {
//Atom H = calc_H(a.getC(), b.getN(), b.getCA());
Atom H = calcSimple_H(a.getC(), a.getO(), b.getN());
b.setH(H);
}
}
} | [
"private",
"void",
"calculateHAtoms",
"(",
")",
"throws",
"StructureException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"groups",
".",
"length",
"-",
"1",
";",
"i",
"++",
")",
"{",
"SecStrucGroup",
"a",
"=",
"groups",
"[",
"i",
"]",
"... | Calculate the coordinates of the H atoms. They are usually
missing in the PDB files as only few experimental methods allow
to resolve their location. | [
"Calculate",
"the",
"coordinates",
"of",
"the",
"H",
"atoms",
".",
"They",
"are",
"usually",
"missing",
"in",
"the",
"PDB",
"files",
"as",
"only",
"few",
"experimental",
"methods",
"allow",
"to",
"resolve",
"their",
"location",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L753-L766 |
31,690 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.calculateHBonds | private void calculateHBonds() {
/**
* More efficient method for calculating C-Alpha pairs
*/
if (groups.length < 5) return;
Iterator<AtomContact> otu = contactSet.iterator();
while(otu.hasNext()){
AtomContact ac = otu.next();
Pair<Atom> pair = ac.getPair();
Group g1 = pair.getFirst().getGroup();
Group g2 = pair.getSecond().getGroup();
// Now I need to get the index of the Group in the list groups
int i = indResMap.get(g1.getResidueNumber());
int j = indResMap.get(g2.getResidueNumber());
// Now check this
checkAddHBond(i,j);
//"backwards" hbonds are not allowed
if (j!=(i+1)) checkAddHBond(j,i);
}
} | java | private void calculateHBonds() {
/**
* More efficient method for calculating C-Alpha pairs
*/
if (groups.length < 5) return;
Iterator<AtomContact> otu = contactSet.iterator();
while(otu.hasNext()){
AtomContact ac = otu.next();
Pair<Atom> pair = ac.getPair();
Group g1 = pair.getFirst().getGroup();
Group g2 = pair.getSecond().getGroup();
// Now I need to get the index of the Group in the list groups
int i = indResMap.get(g1.getResidueNumber());
int j = indResMap.get(g2.getResidueNumber());
// Now check this
checkAddHBond(i,j);
//"backwards" hbonds are not allowed
if (j!=(i+1)) checkAddHBond(j,i);
}
} | [
"private",
"void",
"calculateHBonds",
"(",
")",
"{",
"/**\n\t\t * More efficient method for calculating C-Alpha pairs\n\t\t */",
"if",
"(",
"groups",
".",
"length",
"<",
"5",
")",
"return",
";",
"Iterator",
"<",
"AtomContact",
">",
"otu",
"=",
"contactSet",
".",
"it... | Calculate the HBonds between different groups.
see Creighton page 147 f
Modified to use only the contact map | [
"Calculate",
"the",
"HBonds",
"between",
"different",
"groups",
".",
"see",
"Creighton",
"page",
"147",
"f",
"Modified",
"to",
"use",
"only",
"the",
"contact",
"map"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L775-L794 |
31,691 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.trackHBondEnergy | private void trackHBondEnergy(int i, int j, double energy) {
if (groups[i].getPDBName().equals("PRO")) {
logger.debug("Ignore: PRO {}",groups[i].getResidueNumber());
return;
}
SecStrucState stateOne = getSecStrucState(i);
SecStrucState stateTwo = getSecStrucState(j);
double acc1e = stateOne.getAccept1().getEnergy();
double acc2e = stateOne.getAccept2().getEnergy();
double don1e = stateTwo.getDonor1().getEnergy();
double don2e = stateTwo.getDonor2().getEnergy();
//Acceptor: N-H-->O
if (energy < acc1e) {
logger.debug("{} < {}",energy,acc1e);
stateOne.setAccept2(stateOne.getAccept1());
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(j);
stateOne.setAccept1(bond);
} else if ( energy < acc2e ) {
logger.debug("{} < {}",energy,acc2e);
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(j);
stateOne.setAccept2(bond);
}
//The other side of the bond: donor O-->N-H
if (energy < don1e) {
logger.debug("{} < {}",energy,don1e);
stateTwo.setDonor2(stateTwo.getDonor1());
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(i);
stateTwo.setDonor1(bond);
} else if ( energy < don2e ) {
logger.debug("{} < {}",energy,don2e);
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(i);
stateTwo.setDonor2(bond);
}
} | java | private void trackHBondEnergy(int i, int j, double energy) {
if (groups[i].getPDBName().equals("PRO")) {
logger.debug("Ignore: PRO {}",groups[i].getResidueNumber());
return;
}
SecStrucState stateOne = getSecStrucState(i);
SecStrucState stateTwo = getSecStrucState(j);
double acc1e = stateOne.getAccept1().getEnergy();
double acc2e = stateOne.getAccept2().getEnergy();
double don1e = stateTwo.getDonor1().getEnergy();
double don2e = stateTwo.getDonor2().getEnergy();
//Acceptor: N-H-->O
if (energy < acc1e) {
logger.debug("{} < {}",energy,acc1e);
stateOne.setAccept2(stateOne.getAccept1());
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(j);
stateOne.setAccept1(bond);
} else if ( energy < acc2e ) {
logger.debug("{} < {}",energy,acc2e);
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(j);
stateOne.setAccept2(bond);
}
//The other side of the bond: donor O-->N-H
if (energy < don1e) {
logger.debug("{} < {}",energy,don1e);
stateTwo.setDonor2(stateTwo.getDonor1());
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(i);
stateTwo.setDonor1(bond);
} else if ( energy < don2e ) {
logger.debug("{} < {}",energy,don2e);
HBond bond = new HBond();
bond.setEnergy(energy);
bond.setPartner(i);
stateTwo.setDonor2(bond);
}
} | [
"private",
"void",
"trackHBondEnergy",
"(",
"int",
"i",
",",
"int",
"j",
",",
"double",
"energy",
")",
"{",
"if",
"(",
"groups",
"[",
"i",
"]",
".",
"getPDBName",
"(",
")",
".",
"equals",
"(",
"\"PRO\"",
")",
")",
"{",
"logger",
".",
"debug",
"(",
... | Store Hbonds in the Groups.
DSSP allows two HBonds per aminoacids to allow bifurcated bonds. | [
"Store",
"Hbonds",
"in",
"the",
"Groups",
".",
"DSSP",
"allows",
"two",
"HBonds",
"per",
"aminoacids",
"to",
"allow",
"bifurcated",
"bonds",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L877-L935 |
31,692 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.calculateTurns | private void calculateTurns(){
for (int i = 0 ; i< groups.length; i++){
for (int turn = 3; turn <= 5; turn++) {
if (i+turn >= groups.length) continue;
//Check for H bond from NH(i+n) to CO(i)
if (isBonded(i, i+turn)) {
logger.debug("Turn at ({},{}) turn {}",i,(i+turn),turn);
getSecStrucState(i).setTurn('>', turn);
getSecStrucState(i+turn).setTurn('<', turn);
//Bracketed residues get the helix number
for (int j=i+1; j<i+turn; j++){
Integer t = turn;
char helix = t.toString().charAt(0);
getSecStrucState(j).setTurn(helix, turn);
}
}
}
}
} | java | private void calculateTurns(){
for (int i = 0 ; i< groups.length; i++){
for (int turn = 3; turn <= 5; turn++) {
if (i+turn >= groups.length) continue;
//Check for H bond from NH(i+n) to CO(i)
if (isBonded(i, i+turn)) {
logger.debug("Turn at ({},{}) turn {}",i,(i+turn),turn);
getSecStrucState(i).setTurn('>', turn);
getSecStrucState(i+turn).setTurn('<', turn);
//Bracketed residues get the helix number
for (int j=i+1; j<i+turn; j++){
Integer t = turn;
char helix = t.toString().charAt(0);
getSecStrucState(j).setTurn(helix, turn);
}
}
}
}
} | [
"private",
"void",
"calculateTurns",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"groups",
".",
"length",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"turn",
"=",
"3",
";",
"turn",
"<=",
"5",
";",
"turn",
"++",
")",
"{",
... | Detect helical turn patterns. | [
"Detect",
"helical",
"turn",
"patterns",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L940-L961 |
31,693 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.calc_H | @SuppressWarnings("unused")
private static Atom calc_H(Atom C, Atom N, Atom CA)
throws StructureException {
Atom nc = Calc.subtract(N,C);
Atom nca = Calc.subtract(N,CA);
Atom u_nc = Calc.unitVector(nc) ;
Atom u_nca = Calc.unitVector(nca);
Atom added = Calc.add(u_nc,u_nca);
Atom U = Calc.unitVector(added);
// according to Creighton distance N-H is 1.03 +/- 0.02A
Atom H = Calc.add(N,U);
H.setName("H");
// this atom does not have a pdbserial number ...
return H;
} | java | @SuppressWarnings("unused")
private static Atom calc_H(Atom C, Atom N, Atom CA)
throws StructureException {
Atom nc = Calc.subtract(N,C);
Atom nca = Calc.subtract(N,CA);
Atom u_nc = Calc.unitVector(nc) ;
Atom u_nca = Calc.unitVector(nca);
Atom added = Calc.add(u_nc,u_nca);
Atom U = Calc.unitVector(added);
// according to Creighton distance N-H is 1.03 +/- 0.02A
Atom H = Calc.add(N,U);
H.setName("H");
// this atom does not have a pdbserial number ...
return H;
} | [
"@",
"SuppressWarnings",
"(",
"\"unused\"",
")",
"private",
"static",
"Atom",
"calc_H",
"(",
"Atom",
"C",
",",
"Atom",
"N",
",",
"Atom",
"CA",
")",
"throws",
"StructureException",
"{",
"Atom",
"nc",
"=",
"Calc",
".",
"subtract",
"(",
"N",
",",
"C",
")"... | Use unit vectors NC and NCalpha Add them. Calc unit vector and
substract it from N.
C coordinates are from amino acid i-1
N, CA atoms from amino acid i
@link http://openbioinformatics.blogspot.com/
2009/08/how-to-calculate-h-atoms-for-nitrogens.html | [
"Use",
"unit",
"vectors",
"NC",
"and",
"NCalpha",
"Add",
"them",
".",
"Calc",
"unit",
"vector",
"and",
"substract",
"it",
"from",
"N",
".",
"C",
"coordinates",
"are",
"from",
"amino",
"acid",
"i",
"-",
"1",
"N",
"CA",
"atoms",
"from",
"amino",
"acid",
... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L1011-L1032 |
31,694 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java | SecStrucCalc.setSecStrucType | private void setSecStrucType(int pos, SecStrucType type){
SecStrucState ss = getSecStrucState(pos);
if (type.compareTo(ss.getType()) < 0) ss.setType(type);
} | java | private void setSecStrucType(int pos, SecStrucType type){
SecStrucState ss = getSecStrucState(pos);
if (type.compareTo(ss.getType()) < 0) ss.setType(type);
} | [
"private",
"void",
"setSecStrucType",
"(",
"int",
"pos",
",",
"SecStrucType",
"type",
")",
"{",
"SecStrucState",
"ss",
"=",
"getSecStrucState",
"(",
"pos",
")",
";",
"if",
"(",
"type",
".",
"compareTo",
"(",
"ss",
".",
"getType",
"(",
")",
")",
"<",
"0... | Set the new type only if it has more preference than the
current residue SS type.
@param pos
@param type | [
"Set",
"the",
"new",
"type",
"only",
"if",
"it",
"has",
"more",
"preference",
"than",
"the",
"current",
"residue",
"SS",
"type",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucCalc.java#L1137-L1140 |
31,695 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/ce/CeMain.java | CeMain.align | @Override
public AFPChain align(Atom[] ca1, Atom[] ca2, Object param) throws StructureException{
if ( ! (param instanceof CeParameters))
throw new IllegalArgumentException("CE algorithm needs an object of call CeParameters as argument.");
params = (CeParameters) param;
// we don't want to rotate input atoms, do we?
ca2clone = new Atom[ca2.length];
int pos = 0;
for (Atom a : ca2){
Group g = (Group)a.getGroup().clone(); // works because each group has only a CA atom
ca2clone[pos] = g.getAtom(a.getName());
pos++;
}
calculator = new CECalculator(params);
//Build alignment ca1 to ca2-ca2
AFPChain afpChain = new AFPChain(algorithmName);
afpChain = calculator.extractFragments(afpChain, ca1, ca2clone);
calculator.traceFragmentMatrix( afpChain,ca1, ca2clone);
calculator.nextStep( afpChain,ca1, ca2clone);
afpChain.setAlgorithmName(getAlgorithmName());
afpChain.setVersion(version);
// Try to guess names
if (ca1.length!=0 && ca1[0].getGroup().getChain()!=null && ca1[0].getGroup().getChain().getStructure()!=null)
afpChain.setName1(ca1[0].getGroup().getChain().getStructure().getName());
if (ca2.length!=0 && ca2[0].getGroup().getChain()!=null && ca2[0].getGroup().getChain().getStructure()!=null)
afpChain.setName2(ca2[0].getGroup().getChain().getStructure().getName());
if ( afpChain.getNrEQR() == 0)
return afpChain;
// Set the distance matrix
int winSize = params.getWinSize();
int winSizeComb1 = (winSize-1)*(winSize-2)/2;
double[][] m = calculator.initSumOfDistances(ca1.length, ca2.length, winSize, winSizeComb1, ca1, ca2clone);
afpChain.setDistanceMatrix(new Matrix(m));
afpChain.setSequentialAlignment(true);
return afpChain;
} | java | @Override
public AFPChain align(Atom[] ca1, Atom[] ca2, Object param) throws StructureException{
if ( ! (param instanceof CeParameters))
throw new IllegalArgumentException("CE algorithm needs an object of call CeParameters as argument.");
params = (CeParameters) param;
// we don't want to rotate input atoms, do we?
ca2clone = new Atom[ca2.length];
int pos = 0;
for (Atom a : ca2){
Group g = (Group)a.getGroup().clone(); // works because each group has only a CA atom
ca2clone[pos] = g.getAtom(a.getName());
pos++;
}
calculator = new CECalculator(params);
//Build alignment ca1 to ca2-ca2
AFPChain afpChain = new AFPChain(algorithmName);
afpChain = calculator.extractFragments(afpChain, ca1, ca2clone);
calculator.traceFragmentMatrix( afpChain,ca1, ca2clone);
calculator.nextStep( afpChain,ca1, ca2clone);
afpChain.setAlgorithmName(getAlgorithmName());
afpChain.setVersion(version);
// Try to guess names
if (ca1.length!=0 && ca1[0].getGroup().getChain()!=null && ca1[0].getGroup().getChain().getStructure()!=null)
afpChain.setName1(ca1[0].getGroup().getChain().getStructure().getName());
if (ca2.length!=0 && ca2[0].getGroup().getChain()!=null && ca2[0].getGroup().getChain().getStructure()!=null)
afpChain.setName2(ca2[0].getGroup().getChain().getStructure().getName());
if ( afpChain.getNrEQR() == 0)
return afpChain;
// Set the distance matrix
int winSize = params.getWinSize();
int winSizeComb1 = (winSize-1)*(winSize-2)/2;
double[][] m = calculator.initSumOfDistances(ca1.length, ca2.length, winSize, winSizeComb1, ca1, ca2clone);
afpChain.setDistanceMatrix(new Matrix(m));
afpChain.setSequentialAlignment(true);
return afpChain;
} | [
"@",
"Override",
"public",
"AFPChain",
"align",
"(",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
",",
"Object",
"param",
")",
"throws",
"StructureException",
"{",
"if",
"(",
"!",
"(",
"param",
"instanceof",
"CeParameters",
")",
")",
"throw",
... | Align ca2 onto ca1. | [
"Align",
"ca2",
"onto",
"ca1",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/ce/CeMain.java#L86-L136 |
31,696 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/Site.java | Site.remark800toPDB | public void remark800toPDB(StringBuffer stringBuffer) {
//REMARK 800 SITE_IDENTIFIER: CAT
//REMARK 800 EVIDENCE_CODE: UNKNOWN
//REMARK 800 SITE_DESCRIPTION: ACTIVE SITE
stringBuffer.append(String.format(Locale.UK, "REMARK 800 SITE_IDENTIFIER: %-52s%s", siteID, lineEnd));
stringBuffer.append(String.format(Locale.UK, "REMARK 800 EVIDENCE_CODE: %-54s%s", evCode, lineEnd));
stringBuffer.append(String.format(Locale.UK, "REMARK 800 SITE_DESCRIPTION: %-51s%s", description, lineEnd));
} | java | public void remark800toPDB(StringBuffer stringBuffer) {
//REMARK 800 SITE_IDENTIFIER: CAT
//REMARK 800 EVIDENCE_CODE: UNKNOWN
//REMARK 800 SITE_DESCRIPTION: ACTIVE SITE
stringBuffer.append(String.format(Locale.UK, "REMARK 800 SITE_IDENTIFIER: %-52s%s", siteID, lineEnd));
stringBuffer.append(String.format(Locale.UK, "REMARK 800 EVIDENCE_CODE: %-54s%s", evCode, lineEnd));
stringBuffer.append(String.format(Locale.UK, "REMARK 800 SITE_DESCRIPTION: %-51s%s", description, lineEnd));
} | [
"public",
"void",
"remark800toPDB",
"(",
"StringBuffer",
"stringBuffer",
")",
"{",
"//REMARK 800 SITE_IDENTIFIER: CAT",
"//REMARK 800 EVIDENCE_CODE: UNKNOWN",
"//REMARK 800 SITE_DESCRIPTION: ACTIVE SITE",
"stringBuffer",
".",
"append",
"(",
"String",
".",
"format",
"(",
"Locale... | Appends the REMARK 800 section pertaining to the site onto the end of the
StringBuffer provided.
For example in pdb 1a4w:
REMARK 800 SITE_IDENTIFIER: CAT
REMARK 800 EVIDENCE_CODE: UNKNOWN
REMARK 800 SITE_DESCRIPTION: ACTIVE SITE
@param stringBuffer | [
"Appends",
"the",
"REMARK",
"800",
"section",
"pertaining",
"to",
"the",
"site",
"onto",
"the",
"end",
"of",
"the",
"StringBuffer",
"provided",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/Site.java#L139-L148 |
31,697 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/SigEva.java | SigEva.normScore | private double normScore(double score, double rmsd, int optLen, int r)
{
//double score1 = modScore(score, r);
double score1 = score;
if(r > 0) score1 /= Math.sqrt(r + 1);
//it is tested that flexible score is more linear relevant to 1/r2 than 1/r
if(rmsd < 0.5) score1 *= Math.sqrt((optLen) / 0.5);
else score1 *= Math.sqrt((optLen) / rmsd);
return score1;
} | java | private double normScore(double score, double rmsd, int optLen, int r)
{
//double score1 = modScore(score, r);
double score1 = score;
if(r > 0) score1 /= Math.sqrt(r + 1);
//it is tested that flexible score is more linear relevant to 1/r2 than 1/r
if(rmsd < 0.5) score1 *= Math.sqrt((optLen) / 0.5);
else score1 *= Math.sqrt((optLen) / rmsd);
return score1;
} | [
"private",
"double",
"normScore",
"(",
"double",
"score",
",",
"double",
"rmsd",
",",
"int",
"optLen",
",",
"int",
"r",
")",
"{",
"//double score1 = modScore(score, r);",
"double",
"score1",
"=",
"score",
";",
"if",
"(",
"r",
">",
"0",
")",
"score1",
... | the chaining score is normalized by rmsd, twist and optimal alignment length | [
"the",
"chaining",
"score",
"is",
"normalized",
"by",
"rmsd",
"twist",
"and",
"optimal",
"alignment",
"length"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/SigEva.java#L201-L210 |
31,698 | biojava/biojava | biojava-protein-disorder/src/main/java/org/biojava/nbio/data/sequence/SequenceUtil.java | SequenceUtil.cleanSequence | public static String cleanSequence(String sequence) {
assert sequence != null;
final Matcher m = SequenceUtil.WHITE_SPACE.matcher(sequence);
sequence = m.replaceAll("").toUpperCase();
return sequence;
} | java | public static String cleanSequence(String sequence) {
assert sequence != null;
final Matcher m = SequenceUtil.WHITE_SPACE.matcher(sequence);
sequence = m.replaceAll("").toUpperCase();
return sequence;
} | [
"public",
"static",
"String",
"cleanSequence",
"(",
"String",
"sequence",
")",
"{",
"assert",
"sequence",
"!=",
"null",
";",
"final",
"Matcher",
"m",
"=",
"SequenceUtil",
".",
"WHITE_SPACE",
".",
"matcher",
"(",
"sequence",
")",
";",
"sequence",
"=",
"m",
... | Removes all whitespace chars in the sequence string
@param sequence
@return cleaned up sequence | [
"Removes",
"all",
"whitespace",
"chars",
"in",
"the",
"sequence",
"string"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/data/sequence/SequenceUtil.java#L149-L154 |
31,699 | biojava/biojava | biojava-protein-disorder/src/main/java/org/biojava/nbio/data/sequence/SequenceUtil.java | SequenceUtil.deepCleanSequence | public static String deepCleanSequence(String sequence) {
sequence = SequenceUtil.cleanSequence(sequence);
sequence = SequenceUtil.DIGIT.matcher(sequence).replaceAll("");
sequence = SequenceUtil.NONWORD.matcher(sequence).replaceAll("");
final Pattern othernonSeqChars = Pattern.compile("[_-]+");
sequence = othernonSeqChars.matcher(sequence).replaceAll("");
return sequence;
} | java | public static String deepCleanSequence(String sequence) {
sequence = SequenceUtil.cleanSequence(sequence);
sequence = SequenceUtil.DIGIT.matcher(sequence).replaceAll("");
sequence = SequenceUtil.NONWORD.matcher(sequence).replaceAll("");
final Pattern othernonSeqChars = Pattern.compile("[_-]+");
sequence = othernonSeqChars.matcher(sequence).replaceAll("");
return sequence;
} | [
"public",
"static",
"String",
"deepCleanSequence",
"(",
"String",
"sequence",
")",
"{",
"sequence",
"=",
"SequenceUtil",
".",
"cleanSequence",
"(",
"sequence",
")",
";",
"sequence",
"=",
"SequenceUtil",
".",
"DIGIT",
".",
"matcher",
"(",
"sequence",
")",
".",
... | Removes all special characters and digits as well as whitespace chars
from the sequence
@param sequence
@return cleaned up sequence | [
"Removes",
"all",
"special",
"characters",
"and",
"digits",
"as",
"well",
"as",
"whitespace",
"chars",
"from",
"the",
"sequence"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/data/sequence/SequenceUtil.java#L163-L170 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.