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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
32,100 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/ecod/EcodFactory.java | EcodFactory.releaseReferences | private static void releaseReferences() {
synchronized(versionedEcodDBs) {
Iterator<Entry<String, SoftReference<EcodDatabase>>> it = versionedEcodDBs.entrySet().iterator();
while(it.hasNext()) {
Entry<String, SoftReference<EcodDatabase>> entry = it.next();
SoftReference<EcodDatabase> ref = entry.getValue();
if(ref.get() == null) {
logger.debug("Removed version {} from EcodFactory to save memory.",entry.getKey());
it.remove();
}
}
}
} | java | private static void releaseReferences() {
synchronized(versionedEcodDBs) {
Iterator<Entry<String, SoftReference<EcodDatabase>>> it = versionedEcodDBs.entrySet().iterator();
while(it.hasNext()) {
Entry<String, SoftReference<EcodDatabase>> entry = it.next();
SoftReference<EcodDatabase> ref = entry.getValue();
if(ref.get() == null) {
logger.debug("Removed version {} from EcodFactory to save memory.",entry.getKey());
it.remove();
}
}
}
} | [
"private",
"static",
"void",
"releaseReferences",
"(",
")",
"{",
"synchronized",
"(",
"versionedEcodDBs",
")",
"{",
"Iterator",
"<",
"Entry",
"<",
"String",
",",
"SoftReference",
"<",
"EcodDatabase",
">",
">",
">",
"it",
"=",
"versionedEcodDBs",
".",
"entrySet... | removes SoftReferences which have already been garbage collected | [
"removes",
"SoftReferences",
"which",
"have",
"already",
"been",
"garbage",
"collected"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/ecod/EcodFactory.java#L103-L115 |
32,101 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/CasePreservingProteinSequenceCreator.java | CasePreservingProteinSequenceCreator.getSequence | @Override
public AbstractSequence<AminoAcidCompound> getSequence(
List<AminoAcidCompound> list) {
AbstractSequence<AminoAcidCompound> seq =super.getSequence(list);
Collection<Object> strCase = new ArrayList<Object>(seq.getLength());
for(int i=0;i<seq.getLength();i++) {
strCase.add(true);
}
seq.setUserCollection(strCase);
return seq;
} | java | @Override
public AbstractSequence<AminoAcidCompound> getSequence(
List<AminoAcidCompound> list) {
AbstractSequence<AminoAcidCompound> seq =super.getSequence(list);
Collection<Object> strCase = new ArrayList<Object>(seq.getLength());
for(int i=0;i<seq.getLength();i++) {
strCase.add(true);
}
seq.setUserCollection(strCase);
return seq;
} | [
"@",
"Override",
"public",
"AbstractSequence",
"<",
"AminoAcidCompound",
">",
"getSequence",
"(",
"List",
"<",
"AminoAcidCompound",
">",
"list",
")",
"{",
"AbstractSequence",
"<",
"AminoAcidCompound",
">",
"seq",
"=",
"super",
".",
"getSequence",
"(",
"list",
")... | Assumes all compounds were uppercase
@see org.biojava.nbio.core.sequence.io.ProteinSequenceCreator#getSequence(java.util.List) | [
"Assumes",
"all",
"compounds",
"were",
"uppercase"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/CasePreservingProteinSequenceCreator.java#L91-L101 |
32,102 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/CasePreservingProteinSequenceCreator.java | CasePreservingProteinSequenceCreator.getStringCase | private static List<Object> getStringCase(String str) {
List<Object> types = new ArrayList<Object>(str.length());
for(int i=0;i<str.length();i++) {
types.add(Character.isUpperCase(str.charAt(i)));
}
return types;
} | java | private static List<Object> getStringCase(String str) {
List<Object> types = new ArrayList<Object>(str.length());
for(int i=0;i<str.length();i++) {
types.add(Character.isUpperCase(str.charAt(i)));
}
return types;
} | [
"private",
"static",
"List",
"<",
"Object",
">",
"getStringCase",
"(",
"String",
"str",
")",
"{",
"List",
"<",
"Object",
">",
"types",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
"str",
".",
"length",
"(",
")",
")",
";",
"for",
"(",
"int",
"i... | Returns a list of Booleans of the same length as the input, specifying
whether each character was uppercase or not.
@param str A string. Should not contain unicode supplemental characters.
@return a list of Booleans of the same length as the input, specifying
whether each character was uppercase or not.
This list contains only Booleans. | [
"Returns",
"a",
"list",
"of",
"Booleans",
"of",
"the",
"same",
"length",
"as",
"the",
"input",
"specifying",
"whether",
"each",
"character",
"was",
"uppercase",
"or",
"not",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/CasePreservingProteinSequenceCreator.java#L111-L117 |
32,103 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/rcsb/GetRepresentatives.java | GetRepresentatives.getAll | public static SortedSet<String> getAll() {
SortedSet<String> representatives = new TreeSet<String>();
try {
URL u = new URL(allUrl);
InputStream stream = URLConnectionTools.getInputStream(u, 60000);
if (stream != null) {
BufferedReader reader = new BufferedReader(
new InputStreamReader(stream));
String line = null;
while ((line = reader.readLine()) != null) {
int index = line.lastIndexOf("structureId=");
if (index > 0) {
representatives.add(line.substring(index + 13, index + 17));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return representatives;
} | java | public static SortedSet<String> getAll() {
SortedSet<String> representatives = new TreeSet<String>();
try {
URL u = new URL(allUrl);
InputStream stream = URLConnectionTools.getInputStream(u, 60000);
if (stream != null) {
BufferedReader reader = new BufferedReader(
new InputStreamReader(stream));
String line = null;
while ((line = reader.readLine()) != null) {
int index = line.lastIndexOf("structureId=");
if (index > 0) {
representatives.add(line.substring(index + 13, index + 17));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return representatives;
} | [
"public",
"static",
"SortedSet",
"<",
"String",
">",
"getAll",
"(",
")",
"{",
"SortedSet",
"<",
"String",
">",
"representatives",
"=",
"new",
"TreeSet",
"<",
"String",
">",
"(",
")",
";",
"try",
"{",
"URL",
"u",
"=",
"new",
"URL",
"(",
"allUrl",
")",... | Returns the current list of all PDB IDs.
@return PdbChainKey set of all PDB IDs. | [
"Returns",
"the",
"current",
"list",
"of",
"all",
"PDB",
"IDs",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/rcsb/GetRepresentatives.java#L97-L125 |
32,104 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/Component.java | Component.lazyInit | private static void lazyInit() {
if (components==null) {
components = new HashSet<Component>();
nonTerminalComps = new HashMap<Set<String>, Component>();
nTerminalAminoAcids = new HashMap<Set<String>, Component>();
cTerminalAminoAcids = new HashMap<Set<String>, Component>();
}
} | java | private static void lazyInit() {
if (components==null) {
components = new HashSet<Component>();
nonTerminalComps = new HashMap<Set<String>, Component>();
nTerminalAminoAcids = new HashMap<Set<String>, Component>();
cTerminalAminoAcids = new HashMap<Set<String>, Component>();
}
} | [
"private",
"static",
"void",
"lazyInit",
"(",
")",
"{",
"if",
"(",
"components",
"==",
"null",
")",
"{",
"components",
"=",
"new",
"HashSet",
"<",
"Component",
">",
"(",
")",
";",
"nonTerminalComps",
"=",
"new",
"HashMap",
"<",
"Set",
"<",
"String",
">... | Lazy initialization of the static variables. | [
"Lazy",
"initialization",
"of",
"the",
"static",
"variables",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/Component.java#L51-L58 |
32,105 | biojava/biojava | biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/xml/ElementTable.java | ElementTable.populateMaps | public void populateMaps(){
this.elementName2Element = new HashMap<String, Element>();
this.isotopeName2Isotope = new HashMap<String, Isotope>();
if(this.element != null){
for(Element e:this.element){
this.elementName2Element.put(e.getName(), e);
if(e.getIsotopes() != null){
for(Isotope i:e.getIsotopes()){
this.isotopeName2Isotope.put(i.getName(), i);
}
}
}
}
} | java | public void populateMaps(){
this.elementName2Element = new HashMap<String, Element>();
this.isotopeName2Isotope = new HashMap<String, Isotope>();
if(this.element != null){
for(Element e:this.element){
this.elementName2Element.put(e.getName(), e);
if(e.getIsotopes() != null){
for(Isotope i:e.getIsotopes()){
this.isotopeName2Isotope.put(i.getName(), i);
}
}
}
}
} | [
"public",
"void",
"populateMaps",
"(",
")",
"{",
"this",
".",
"elementName2Element",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Element",
">",
"(",
")",
";",
"this",
".",
"isotopeName2Isotope",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Isotope",
">",
... | Populate the Maps for quick retrieval | [
"Populate",
"the",
"Maps",
"for",
"quick",
"retrieval"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-aa-prop/src/main/java/org/biojava/nbio/aaproperties/xml/ElementTable.java#L60-L73 |
32,106 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/BoundingBox.java | BoundingBox.getDimensions | public double[] getDimensions(){
double[] dim = new double[3];
dim[0] = xmax-xmin;
dim[1] = ymax-ymin;
dim[2] = zmax-zmin;
return dim;
} | java | public double[] getDimensions(){
double[] dim = new double[3];
dim[0] = xmax-xmin;
dim[1] = ymax-ymin;
dim[2] = zmax-zmin;
return dim;
} | [
"public",
"double",
"[",
"]",
"getDimensions",
"(",
")",
"{",
"double",
"[",
"]",
"dim",
"=",
"new",
"double",
"[",
"3",
"]",
";",
"dim",
"[",
"0",
"]",
"=",
"xmax",
"-",
"xmin",
";",
"dim",
"[",
"1",
"]",
"=",
"ymax",
"-",
"ymin",
";",
"dim"... | Returns the dimensions of this bounding box.
@return a double array (x,y,z) with the dimensions of the box. | [
"Returns",
"the",
"dimensions",
"of",
"this",
"bounding",
"box",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/BoundingBox.java#L104-L114 |
32,107 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/BoundingBox.java | BoundingBox.overlaps | public boolean overlaps(BoundingBox o, double cutoff) {
if (this==o) return true;
// x dimension
if (!areOverlapping(xmin,xmax,o.xmin,o.xmax,cutoff)) {
return false;
}
// y dimension
if (!areOverlapping(ymin,ymax,o.ymin,o.ymax,cutoff)) {
return false;
}
// z dimension
if (!areOverlapping(zmin,zmax,o.zmin,o.zmax,cutoff)) {
return false;
}
return true;
} | java | public boolean overlaps(BoundingBox o, double cutoff) {
if (this==o) return true;
// x dimension
if (!areOverlapping(xmin,xmax,o.xmin,o.xmax,cutoff)) {
return false;
}
// y dimension
if (!areOverlapping(ymin,ymax,o.ymin,o.ymax,cutoff)) {
return false;
}
// z dimension
if (!areOverlapping(zmin,zmax,o.zmin,o.zmax,cutoff)) {
return false;
}
return true;
} | [
"public",
"boolean",
"overlaps",
"(",
"BoundingBox",
"o",
",",
"double",
"cutoff",
")",
"{",
"if",
"(",
"this",
"==",
"o",
")",
"return",
"true",
";",
"// x dimension",
"if",
"(",
"!",
"areOverlapping",
"(",
"xmin",
",",
"xmax",
",",
"o",
".",
"xmin",
... | Returns true if this bounding box overlaps given one, i.e. they are within
one cutoff distance in one of their 3 dimensions.
@param cutoff
@return | [
"Returns",
"true",
"if",
"this",
"bounding",
"box",
"overlaps",
"given",
"one",
"i",
".",
"e",
".",
"they",
"are",
"within",
"one",
"cutoff",
"distance",
"in",
"one",
"of",
"their",
"3",
"dimensions",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/BoundingBox.java#L165-L180 |
32,108 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/BoundingBox.java | BoundingBox.contains | public boolean contains(Point3d atom) {
double x = atom.x;
double y = atom.y;
double z = atom.z;
return xmin <= x && x <= xmax
&& ymin <= y && y <= ymax
&& zmin <= z && z <= zmax;
} | java | public boolean contains(Point3d atom) {
double x = atom.x;
double y = atom.y;
double z = atom.z;
return xmin <= x && x <= xmax
&& ymin <= y && y <= ymax
&& zmin <= z && z <= zmax;
} | [
"public",
"boolean",
"contains",
"(",
"Point3d",
"atom",
")",
"{",
"double",
"x",
"=",
"atom",
".",
"x",
";",
"double",
"y",
"=",
"atom",
".",
"y",
";",
"double",
"z",
"=",
"atom",
".",
"z",
";",
"return",
"xmin",
"<=",
"x",
"&&",
"x",
"<=",
"x... | Check if a given point falls within this box
@param atom
@return | [
"Check",
"if",
"a",
"given",
"point",
"falls",
"within",
"this",
"box"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/BoundingBox.java#L208-L215 |
32,109 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/BoundingBox.java | BoundingBox.getMinMax | public double[] getMinMax(double[] array) {
double[] minmax = new double[2];
double max = Double.MIN_VALUE;
double min = Double.MAX_VALUE;
for(double value : array) {
if(value > max) max = value;
if(value < min) min = value;
}
minmax[0] = min;
minmax[1] = max;
return minmax;
} | java | public double[] getMinMax(double[] array) {
double[] minmax = new double[2];
double max = Double.MIN_VALUE;
double min = Double.MAX_VALUE;
for(double value : array) {
if(value > max) max = value;
if(value < min) min = value;
}
minmax[0] = min;
minmax[1] = max;
return minmax;
} | [
"public",
"double",
"[",
"]",
"getMinMax",
"(",
"double",
"[",
"]",
"array",
")",
"{",
"double",
"[",
"]",
"minmax",
"=",
"new",
"double",
"[",
"2",
"]",
";",
"double",
"max",
"=",
"Double",
".",
"MIN_VALUE",
";",
"double",
"min",
"=",
"Double",
".... | Returns an array of size 2 with min and max values of given double array
@param array
@return | [
"Returns",
"an",
"array",
"of",
"size",
"2",
"with",
"min",
"and",
"max",
"values",
"of",
"given",
"double",
"array"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/BoundingBox.java#L231-L245 |
32,110 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/LogColorMapper.java | LogColorMapper.transform | @Override
public double transform(double value) {
double logValue = Math.log(value>0?value:0)/Math.log(base);
return logValue;
} | java | @Override
public double transform(double value) {
double logValue = Math.log(value>0?value:0)/Math.log(base);
return logValue;
} | [
"@",
"Override",
"public",
"double",
"transform",
"(",
"double",
"value",
")",
"{",
"double",
"logValue",
"=",
"Math",
".",
"log",
"(",
"value",
">",
"0",
"?",
"value",
":",
"0",
")",
"/",
"Math",
".",
"log",
"(",
"base",
")",
";",
"return",
"logVa... | Apply log transform.
@param value
@return log_b(value)
@see org.biojava.nbio.structure.gui.util.color.ContinuousColorMapperTransform#transform(double) | [
"Apply",
"log",
"transform",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/LogColorMapper.java#L65-L69 |
32,111 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java | ProteinModificationRegistry.registerCommonProteinModifications | private static void registerCommonProteinModifications(InputStream inStream) {
try {
ProteinModificationXmlReader.registerProteinModificationFromXml(inStream);
} catch (Exception e) {
logger.error("Exception: ", e);
}
} | java | private static void registerCommonProteinModifications(InputStream inStream) {
try {
ProteinModificationXmlReader.registerProteinModificationFromXml(inStream);
} catch (Exception e) {
logger.error("Exception: ", e);
}
} | [
"private",
"static",
"void",
"registerCommonProteinModifications",
"(",
"InputStream",
"inStream",
")",
"{",
"try",
"{",
"ProteinModificationXmlReader",
".",
"registerProteinModificationFromXml",
"(",
"inStream",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{"... | register common protein modifications from XML file. | [
"register",
"common",
"protein",
"modifications",
"from",
"XML",
"file",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java#L65-L72 |
32,112 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java | ProteinModificationRegistry.lazyInit | private static synchronized void lazyInit(InputStream inStream) {
if (registry==null) {
registry = new HashSet<ProteinModification>();
byId = new HashMap<String, ProteinModification>();
byResidId = new HashMap<String, Set<ProteinModification>>();
byPsimodId = new HashMap<String, Set<ProteinModification>>();
byPdbccId = new HashMap<String, Set<ProteinModification>>();
byKeyword = new HashMap<String, Set<ProteinModification>>();
byComponent = new HashMap<Component, Set<ProteinModification>>();
byCategory = new EnumMap<ModificationCategory, Set<ProteinModification>>(
ModificationCategory.class);
for (ModificationCategory cat:ModificationCategory.values()) {
byCategory.put(cat, new HashSet<ProteinModification>());
}
byOccurrenceType = new EnumMap<ModificationOccurrenceType, Set<ProteinModification>>(
ModificationOccurrenceType.class);
for (ModificationOccurrenceType occ:ModificationOccurrenceType.values()) {
byOccurrenceType.put(occ, new HashSet<ProteinModification>());
}
registerCommonProteinModifications(inStream);
}
} | java | private static synchronized void lazyInit(InputStream inStream) {
if (registry==null) {
registry = new HashSet<ProteinModification>();
byId = new HashMap<String, ProteinModification>();
byResidId = new HashMap<String, Set<ProteinModification>>();
byPsimodId = new HashMap<String, Set<ProteinModification>>();
byPdbccId = new HashMap<String, Set<ProteinModification>>();
byKeyword = new HashMap<String, Set<ProteinModification>>();
byComponent = new HashMap<Component, Set<ProteinModification>>();
byCategory = new EnumMap<ModificationCategory, Set<ProteinModification>>(
ModificationCategory.class);
for (ModificationCategory cat:ModificationCategory.values()) {
byCategory.put(cat, new HashSet<ProteinModification>());
}
byOccurrenceType = new EnumMap<ModificationOccurrenceType, Set<ProteinModification>>(
ModificationOccurrenceType.class);
for (ModificationOccurrenceType occ:ModificationOccurrenceType.values()) {
byOccurrenceType.put(occ, new HashSet<ProteinModification>());
}
registerCommonProteinModifications(inStream);
}
} | [
"private",
"static",
"synchronized",
"void",
"lazyInit",
"(",
"InputStream",
"inStream",
")",
"{",
"if",
"(",
"registry",
"==",
"null",
")",
"{",
"registry",
"=",
"new",
"HashSet",
"<",
"ProteinModification",
">",
"(",
")",
";",
"byId",
"=",
"new",
"HashMa... | Lazy Initialization the static variables and register common modifications. | [
"Lazy",
"Initialization",
"the",
"static",
"variables",
"and",
"register",
"common",
"modifications",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java#L109-L131 |
32,113 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java | ProteinModificationRegistry.register | public static void register(final ProteinModification modification) {
if (modification==null) throw new IllegalArgumentException("modification == null!");
lazyInit();
String id = modification.getId();
if (byId.containsKey(id)) {
throw new IllegalArgumentException(id+" has already been registered.");
}
registry.add(modification);
byId.put(id, modification);
ModificationCategory cat = modification.getCategory();
byCategory.get(cat).add(modification);
ModificationOccurrenceType occType = modification.getOccurrenceType();
byOccurrenceType.get(occType).add(modification);
ModificationCondition condition = modification.getCondition();
List<Component> comps = condition.getComponents();
for (Component comp:comps) {
Set<ProteinModification> mods = byComponent.get(comp);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byComponent.put(comp, mods);
}
mods.add(modification);
}
String pdbccId = modification.getPdbccId();
if (pdbccId!=null) {
Set<ProteinModification> mods = byPdbccId.get(pdbccId);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byPdbccId.put(pdbccId, mods);
}
mods.add(modification);
}
String residId = modification.getResidId();
if (residId!=null) {
Set<ProteinModification> mods = byResidId.get(residId);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byResidId.put(residId, mods);
}
mods.add(modification);
}
String psimodId = modification.getPsimodId();
if (psimodId!=null) {
Set<ProteinModification> mods = byPsimodId.get(psimodId);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byPsimodId.put(psimodId, mods);
}
mods.add(modification);
}
for (String keyword : modification.getKeywords()) {
Set<ProteinModification> mods = byKeyword.get(keyword);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byKeyword.put(keyword, mods);
}
mods.add(modification);
}
} | java | public static void register(final ProteinModification modification) {
if (modification==null) throw new IllegalArgumentException("modification == null!");
lazyInit();
String id = modification.getId();
if (byId.containsKey(id)) {
throw new IllegalArgumentException(id+" has already been registered.");
}
registry.add(modification);
byId.put(id, modification);
ModificationCategory cat = modification.getCategory();
byCategory.get(cat).add(modification);
ModificationOccurrenceType occType = modification.getOccurrenceType();
byOccurrenceType.get(occType).add(modification);
ModificationCondition condition = modification.getCondition();
List<Component> comps = condition.getComponents();
for (Component comp:comps) {
Set<ProteinModification> mods = byComponent.get(comp);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byComponent.put(comp, mods);
}
mods.add(modification);
}
String pdbccId = modification.getPdbccId();
if (pdbccId!=null) {
Set<ProteinModification> mods = byPdbccId.get(pdbccId);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byPdbccId.put(pdbccId, mods);
}
mods.add(modification);
}
String residId = modification.getResidId();
if (residId!=null) {
Set<ProteinModification> mods = byResidId.get(residId);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byResidId.put(residId, mods);
}
mods.add(modification);
}
String psimodId = modification.getPsimodId();
if (psimodId!=null) {
Set<ProteinModification> mods = byPsimodId.get(psimodId);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byPsimodId.put(psimodId, mods);
}
mods.add(modification);
}
for (String keyword : modification.getKeywords()) {
Set<ProteinModification> mods = byKeyword.get(keyword);
if (mods==null) {
mods = new HashSet<ProteinModification>();
byKeyword.put(keyword, mods);
}
mods.add(modification);
}
} | [
"public",
"static",
"void",
"register",
"(",
"final",
"ProteinModification",
"modification",
")",
"{",
"if",
"(",
"modification",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"modification == null!\"",
")",
";",
"lazyInit",
"(",
")",
";",
... | Register a new ProteinModification. | [
"Register",
"a",
"new",
"ProteinModification",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java#L136-L205 |
32,114 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java | ProteinModificationRegistry.unregister | public static void unregister(ProteinModification modification) {
if (modification==null) throw new IllegalArgumentException("modification == null!");
registry.remove(modification);
byId.remove(modification.getId());
Set<ProteinModification> mods;
mods = byResidId.get(modification.getResidId());
if (mods!=null) mods.remove(modification);
mods = byPsimodId.get(modification.getPsimodId());
if (mods!=null) mods.remove(modification);
mods = byPdbccId.get(modification.getPdbccId());
if (mods!=null) mods.remove(modification);
for (String keyword : modification.getKeywords()) {
mods = byKeyword.get(keyword);
if (mods!=null) mods.remove(modification);
}
ModificationCondition condition = modification.getCondition();
List<Component> comps = condition.getComponents();
for (Component comp : comps) {
mods = byComponent.get(comp);
if (mods!=null) mods.remove(modification);
}
byCategory.get(modification.getCategory()).remove(modification);
byOccurrenceType.get(modification.getOccurrenceType()).remove(modification);
} | java | public static void unregister(ProteinModification modification) {
if (modification==null) throw new IllegalArgumentException("modification == null!");
registry.remove(modification);
byId.remove(modification.getId());
Set<ProteinModification> mods;
mods = byResidId.get(modification.getResidId());
if (mods!=null) mods.remove(modification);
mods = byPsimodId.get(modification.getPsimodId());
if (mods!=null) mods.remove(modification);
mods = byPdbccId.get(modification.getPdbccId());
if (mods!=null) mods.remove(modification);
for (String keyword : modification.getKeywords()) {
mods = byKeyword.get(keyword);
if (mods!=null) mods.remove(modification);
}
ModificationCondition condition = modification.getCondition();
List<Component> comps = condition.getComponents();
for (Component comp : comps) {
mods = byComponent.get(comp);
if (mods!=null) mods.remove(modification);
}
byCategory.get(modification.getCategory()).remove(modification);
byOccurrenceType.get(modification.getOccurrenceType()).remove(modification);
} | [
"public",
"static",
"void",
"unregister",
"(",
"ProteinModification",
"modification",
")",
"{",
"if",
"(",
"modification",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"modification == null!\"",
")",
";",
"registry",
".",
"remove",
"(",
"m... | Remove a modification from registry.
@param mod | [
"Remove",
"a",
"modification",
"from",
"registry",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java#L211-L243 |
32,115 | biojava/biojava | biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java | ProteinModificationRegistry.getByComponent | public static Set<ProteinModification> getByComponent(final Component comp1,
final Component... comps) {
lazyInit();
Set<ProteinModification> mods = byComponent.get(comp1);
if (mods==null) {
return Collections.emptySet();
}
if (comps.length==0) {
return Collections.unmodifiableSet(mods);
} else {
Set<ProteinModification> ret = new HashSet<ProteinModification>(mods);
for (Component comp:comps) {
mods = byComponent.get(comp);
if (mods==null) {
return Collections.emptySet();
} else {
ret.retainAll(mods);
}
}
return ret;
}
} | java | public static Set<ProteinModification> getByComponent(final Component comp1,
final Component... comps) {
lazyInit();
Set<ProteinModification> mods = byComponent.get(comp1);
if (mods==null) {
return Collections.emptySet();
}
if (comps.length==0) {
return Collections.unmodifiableSet(mods);
} else {
Set<ProteinModification> ret = new HashSet<ProteinModification>(mods);
for (Component comp:comps) {
mods = byComponent.get(comp);
if (mods==null) {
return Collections.emptySet();
} else {
ret.retainAll(mods);
}
}
return ret;
}
} | [
"public",
"static",
"Set",
"<",
"ProteinModification",
">",
"getByComponent",
"(",
"final",
"Component",
"comp1",
",",
"final",
"Component",
"...",
"comps",
")",
"{",
"lazyInit",
"(",
")",
";",
"Set",
"<",
"ProteinModification",
">",
"mods",
"=",
"byComponent"... | Get ProteinModifications that involves one or more components.
@param comp1 a {@link Component}.
@param comps other {@link Component}s.
@return a set of ProteinModifications that involves all the components. | [
"Get",
"ProteinModifications",
"that",
"involves",
"one",
"or",
"more",
"components",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-modfinder/src/main/java/org/biojava/nbio/protmod/ProteinModificationRegistry.java#L300-L323 |
32,116 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/scop/Astral.java | Astral.getRepresentatives | public static Set<String> getRepresentatives(AstralSet cutoff) {
if (instances.containsKey(cutoff.getId()) && instances.get(cutoff.getId()).get() != null) {
return instances.get(cutoff.getId()).get().getNames();
}
Astral astral = new Astral(cutoff);
instances.put(cutoff.getId(), new SoftReference<Astral>(astral));
return astral.getNames();
} | java | public static Set<String> getRepresentatives(AstralSet cutoff) {
if (instances.containsKey(cutoff.getId()) && instances.get(cutoff.getId()).get() != null) {
return instances.get(cutoff.getId()).get().getNames();
}
Astral astral = new Astral(cutoff);
instances.put(cutoff.getId(), new SoftReference<Astral>(astral));
return astral.getNames();
} | [
"public",
"static",
"Set",
"<",
"String",
">",
"getRepresentatives",
"(",
"AstralSet",
"cutoff",
")",
"{",
"if",
"(",
"instances",
".",
"containsKey",
"(",
"cutoff",
".",
"getId",
"(",
")",
")",
"&&",
"instances",
".",
"get",
"(",
"cutoff",
".",
"getId",... | Get a list of representatives' names for the specified ASTRAL cutoff. | [
"Get",
"a",
"list",
"of",
"representatives",
"names",
"for",
"the",
"specified",
"ASTRAL",
"cutoff",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/scop/Astral.java#L114-L121 |
32,117 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/scop/Astral.java | Astral.init | private void init(Reader reader) {
names = new TreeSet<String>();
failedLines = new LinkedHashMap<Integer,String>();
BufferedReader br = null;
try {
br = new BufferedReader(reader);
logger.info("Reading ASTRAL file...");
String line = "";
int i = 0;
while ((line = br.readLine()) != null) {
if (line.startsWith(">")) {
try {
String scopId = line.split("\\s")[0].substring(1);
names.add(scopId);
if (i % 1000 == 0) {
logger.debug("Reading ASTRAL line for " + scopId);
}
i++;
} catch (RuntimeException e) {
failedLines.put(i, line);
logger.warn("Couldn't read line " + line, e);
}
}
}
br.close();
} catch (IOException e) {
throw new RuntimeException("Couldn't read the input stream ", e);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
logger.warn("Could not close stream", e);
}
}
}
} | java | private void init(Reader reader) {
names = new TreeSet<String>();
failedLines = new LinkedHashMap<Integer,String>();
BufferedReader br = null;
try {
br = new BufferedReader(reader);
logger.info("Reading ASTRAL file...");
String line = "";
int i = 0;
while ((line = br.readLine()) != null) {
if (line.startsWith(">")) {
try {
String scopId = line.split("\\s")[0].substring(1);
names.add(scopId);
if (i % 1000 == 0) {
logger.debug("Reading ASTRAL line for " + scopId);
}
i++;
} catch (RuntimeException e) {
failedLines.put(i, line);
logger.warn("Couldn't read line " + line, e);
}
}
}
br.close();
} catch (IOException e) {
throw new RuntimeException("Couldn't read the input stream ", e);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
logger.warn("Could not close stream", e);
}
}
}
} | [
"private",
"void",
"init",
"(",
"Reader",
"reader",
")",
"{",
"names",
"=",
"new",
"TreeSet",
"<",
"String",
">",
"(",
")",
";",
"failedLines",
"=",
"new",
"LinkedHashMap",
"<",
"Integer",
",",
"String",
">",
"(",
")",
";",
"BufferedReader",
"br",
"=",... | Parses the FASTA file opened by reader. | [
"Parses",
"the",
"FASTA",
"file",
"opened",
"by",
"reader",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/scop/Astral.java#L205-L249 |
32,118 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/Grid.java | Grid.getAtomContacts | public AtomContactSet getAtomContacts() {
AtomContactSet contacts = new AtomContactSet(cutoff);
List<Contact> list = getIndicesContacts();
if (jAtomObjects == null) {
for (Contact cont : list) {
contacts.add(new AtomContact(new Pair<Atom>(iAtomObjects[cont.getI()],iAtomObjects[cont.getJ()]),cont.getDistance()));
}
} else {
for (Contact cont : list) {
contacts.add(new AtomContact(new Pair<Atom>(iAtomObjects[cont.getI()],jAtomObjects[cont.getJ()]),cont.getDistance()));
}
}
return contacts;
} | java | public AtomContactSet getAtomContacts() {
AtomContactSet contacts = new AtomContactSet(cutoff);
List<Contact> list = getIndicesContacts();
if (jAtomObjects == null) {
for (Contact cont : list) {
contacts.add(new AtomContact(new Pair<Atom>(iAtomObjects[cont.getI()],iAtomObjects[cont.getJ()]),cont.getDistance()));
}
} else {
for (Contact cont : list) {
contacts.add(new AtomContact(new Pair<Atom>(iAtomObjects[cont.getI()],jAtomObjects[cont.getJ()]),cont.getDistance()));
}
}
return contacts;
} | [
"public",
"AtomContactSet",
"getAtomContacts",
"(",
")",
"{",
"AtomContactSet",
"contacts",
"=",
"new",
"AtomContactSet",
"(",
"cutoff",
")",
";",
"List",
"<",
"Contact",
">",
"list",
"=",
"getIndicesContacts",
"(",
")",
";",
"if",
"(",
"jAtomObjects",
"==",
... | Returns all contacts, i.e. all atoms that are within the cutoff distance.
If both iAtoms and jAtoms are defined then contacts are between iAtoms and jAtoms,
if jAtoms is null, then contacts are within the iAtoms.
@return | [
"Returns",
"all",
"contacts",
"i",
".",
"e",
".",
"all",
"atoms",
"that",
"are",
"within",
"the",
"cutoff",
"distance",
".",
"If",
"both",
"iAtoms",
"and",
"jAtoms",
"are",
"defined",
"then",
"contacts",
"are",
"between",
"iAtoms",
"and",
"jAtoms",
"if",
... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/Grid.java#L381-L399 |
32,119 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/Grid.java | Grid.getIndicesContacts | public List<Contact> getIndicesContacts() {
List<Contact> list = new ArrayList<>();
// if the 2 sets of atoms are not overlapping they are too far away and no need to calculate anything
// this won't apply if there's only one set of atoms (iAtoms), where we would want all-to-all contacts
if (noOverlap) return list;
for (int xind=0;xind<cells.length;xind++) {
for (int yind=0;yind<cells[xind].length;yind++) {
for (int zind=0;zind<cells[xind][yind].length;zind++) {
// distances of points within this cell
GridCell thisCell = cells[xind][yind][zind];
if (thisCell==null) continue;
list.addAll(thisCell.getContactsWithinCell());
// distances of points from this box to all neighbouring boxes: 26 iterations (26 neighbouring boxes)
for (int x=xind-1;x<=xind+1;x++) {
for (int y=yind-1;y<=yind+1;y++) {
for (int z=zind-1;z<=zind+1;z++) {
if (x==xind && y==yind && z==zind) continue;
if (x>=0 && x<cells.length && y>=0 && y<cells[x].length && z>=0 && z<cells[x][y].length) {
if (cells[x][y][z] == null) continue;
list.addAll(thisCell.getContactsToOtherCell(cells[x][y][z]));
}
}
}
}
}
}
}
return list;
} | java | public List<Contact> getIndicesContacts() {
List<Contact> list = new ArrayList<>();
// if the 2 sets of atoms are not overlapping they are too far away and no need to calculate anything
// this won't apply if there's only one set of atoms (iAtoms), where we would want all-to-all contacts
if (noOverlap) return list;
for (int xind=0;xind<cells.length;xind++) {
for (int yind=0;yind<cells[xind].length;yind++) {
for (int zind=0;zind<cells[xind][yind].length;zind++) {
// distances of points within this cell
GridCell thisCell = cells[xind][yind][zind];
if (thisCell==null) continue;
list.addAll(thisCell.getContactsWithinCell());
// distances of points from this box to all neighbouring boxes: 26 iterations (26 neighbouring boxes)
for (int x=xind-1;x<=xind+1;x++) {
for (int y=yind-1;y<=yind+1;y++) {
for (int z=zind-1;z<=zind+1;z++) {
if (x==xind && y==yind && z==zind) continue;
if (x>=0 && x<cells.length && y>=0 && y<cells[x].length && z>=0 && z<cells[x][y].length) {
if (cells[x][y][z] == null) continue;
list.addAll(thisCell.getContactsToOtherCell(cells[x][y][z]));
}
}
}
}
}
}
}
return list;
} | [
"public",
"List",
"<",
"Contact",
">",
"getIndicesContacts",
"(",
")",
"{",
"List",
"<",
"Contact",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// if the 2 sets of atoms are not overlapping they are too far away and no need to calculate anything",
"// this... | Returns all contacts, i.e. all atoms that are within the cutoff distance, as simple Contact objects containing the atom indices pairs and the distance.
If both iAtoms and jAtoms are defined then contacts are between iAtoms and jAtoms,
if jAtoms is null, then contacts are within the iAtoms.
@return | [
"Returns",
"all",
"contacts",
"i",
".",
"e",
".",
"all",
"atoms",
"that",
"are",
"within",
"the",
"cutoff",
"distance",
"as",
"simple",
"Contact",
"objects",
"containing",
"the",
"atom",
"indices",
"pairs",
"and",
"the",
"distance",
".",
"If",
"both",
"iAt... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/Grid.java#L419-L456 |
32,120 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/AFPTwister.java | AFPTwister.twistOptimized | public static Group[] twistOptimized(AFPChain afpChain, Atom[] ca1,
Atom[] ca2) throws StructureException {
Atom[] optTwistPdb = new Atom[ca2.length];
int gPos = -1;
for (Atom a : ca2) {
gPos++;
optTwistPdb[gPos] = a;
}
int blockNum = afpChain.getBlockNum();
int b2 = 0;
int e2 = 0;
int focusResn = 0;
int[] focusRes1 = afpChain.getFocusRes1();
int[] focusRes2 = afpChain.getFocusRes2();
if (focusRes1 == null) {
focusRes1 = new int[afpChain.getCa1Length()];
afpChain.setFocusRes1(focusRes1);
}
if (focusRes2 == null) {
focusRes2 = new int[afpChain.getCa2Length()];
afpChain.setFocusRes2(focusRes2);
}
int[] optLen = afpChain.getOptLen();
int[][][] optAln = afpChain.getOptAln();
for (int bk = 0; bk < blockNum; bk++) {
// THIS IS TRANSFORMING THE ORIGINAL ca2 COORDINATES, NO CLONING...
// copies the atoms over to iniTwistPdb later on in modifyCod
transformOrigPDB(optLen[bk], optAln[bk][0], optAln[bk][1], ca1,
ca2, afpChain, bk);
// transform pro2 according to comparison of pro1 and pro2 at give
// residues
if (bk > 0) {
b2 = e2;
}
if (bk < blockNum - 1) { // bend at the middle of two consecutive
// blocks
e2 = optAln[bk][1][optLen[bk] - 1];
e2 = (optAln[bk + 1][1][0] - e2) / 2 + e2;
} else {
e2 = ca2.length;
}
cloneAtomRange(optTwistPdb, ca2, b2, e2);
for (int i = 0; i < optLen[bk]; i++) {
focusRes1[focusResn] = optAln[bk][0][i];
focusRes2[focusResn] = optAln[bk][1][i];
focusResn++;
}
}
int totalLenOpt = focusResn;
logger.debug("calrmsdopt for {} residues", focusResn);
double totalRmsdOpt = calCaRmsd(ca1, optTwistPdb, focusResn, focusRes1,
focusRes2);
logger.debug("got opt RMSD: {}", totalRmsdOpt);
int optLength = afpChain.getOptLength();
if (totalLenOpt != optLength) {
logger.warn("Final alignment length is different {} {}",
totalLenOpt, optLength);
}
logger.debug("final alignment length {}, rmsd {}", focusResn,
totalRmsdOpt);
afpChain.setTotalLenOpt(totalLenOpt);
afpChain.setTotalRmsdOpt(totalRmsdOpt);
return StructureTools.cloneGroups(optTwistPdb);
} | java | public static Group[] twistOptimized(AFPChain afpChain, Atom[] ca1,
Atom[] ca2) throws StructureException {
Atom[] optTwistPdb = new Atom[ca2.length];
int gPos = -1;
for (Atom a : ca2) {
gPos++;
optTwistPdb[gPos] = a;
}
int blockNum = afpChain.getBlockNum();
int b2 = 0;
int e2 = 0;
int focusResn = 0;
int[] focusRes1 = afpChain.getFocusRes1();
int[] focusRes2 = afpChain.getFocusRes2();
if (focusRes1 == null) {
focusRes1 = new int[afpChain.getCa1Length()];
afpChain.setFocusRes1(focusRes1);
}
if (focusRes2 == null) {
focusRes2 = new int[afpChain.getCa2Length()];
afpChain.setFocusRes2(focusRes2);
}
int[] optLen = afpChain.getOptLen();
int[][][] optAln = afpChain.getOptAln();
for (int bk = 0; bk < blockNum; bk++) {
// THIS IS TRANSFORMING THE ORIGINAL ca2 COORDINATES, NO CLONING...
// copies the atoms over to iniTwistPdb later on in modifyCod
transformOrigPDB(optLen[bk], optAln[bk][0], optAln[bk][1], ca1,
ca2, afpChain, bk);
// transform pro2 according to comparison of pro1 and pro2 at give
// residues
if (bk > 0) {
b2 = e2;
}
if (bk < blockNum - 1) { // bend at the middle of two consecutive
// blocks
e2 = optAln[bk][1][optLen[bk] - 1];
e2 = (optAln[bk + 1][1][0] - e2) / 2 + e2;
} else {
e2 = ca2.length;
}
cloneAtomRange(optTwistPdb, ca2, b2, e2);
for (int i = 0; i < optLen[bk]; i++) {
focusRes1[focusResn] = optAln[bk][0][i];
focusRes2[focusResn] = optAln[bk][1][i];
focusResn++;
}
}
int totalLenOpt = focusResn;
logger.debug("calrmsdopt for {} residues", focusResn);
double totalRmsdOpt = calCaRmsd(ca1, optTwistPdb, focusResn, focusRes1,
focusRes2);
logger.debug("got opt RMSD: {}", totalRmsdOpt);
int optLength = afpChain.getOptLength();
if (totalLenOpt != optLength) {
logger.warn("Final alignment length is different {} {}",
totalLenOpt, optLength);
}
logger.debug("final alignment length {}, rmsd {}", focusResn,
totalRmsdOpt);
afpChain.setTotalLenOpt(totalLenOpt);
afpChain.setTotalRmsdOpt(totalRmsdOpt);
return StructureTools.cloneGroups(optTwistPdb);
} | [
"public",
"static",
"Group",
"[",
"]",
"twistOptimized",
"(",
"AFPChain",
"afpChain",
",",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"ca2",
")",
"throws",
"StructureException",
"{",
"Atom",
"[",
"]",
"optTwistPdb",
"=",
"new",
"Atom",
"[",
"ca2",
... | superimposing according to the optimized alignment
@param afpChain
@param ca1
@param ca2
@return Group array twisted.
@throws StructureException | [
"superimposing",
"according",
"to",
"the",
"optimized",
"alignment"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/AFPTwister.java#L170-L245 |
32,121 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/AFPTwister.java | AFPTwister.getAtoms | private static Atom[] getAtoms(Atom[] ca, int[] positions, int length,
boolean clone) {
List<Atom> atoms = new ArrayList<Atom>();
for (int i = 0; i < length; i++) {
int p = positions[i];
Atom a;
if (clone) {
a = (Atom) ca[p].clone();
a.setGroup((Group) ca[p].getGroup().clone());
} else {
a = ca[p];
}
atoms.add(a);
}
return atoms.toArray(new Atom[atoms.size()]);
} | java | private static Atom[] getAtoms(Atom[] ca, int[] positions, int length,
boolean clone) {
List<Atom> atoms = new ArrayList<Atom>();
for (int i = 0; i < length; i++) {
int p = positions[i];
Atom a;
if (clone) {
a = (Atom) ca[p].clone();
a.setGroup((Group) ca[p].getGroup().clone());
} else {
a = ca[p];
}
atoms.add(a);
}
return atoms.toArray(new Atom[atoms.size()]);
} | [
"private",
"static",
"Atom",
"[",
"]",
"getAtoms",
"(",
"Atom",
"[",
"]",
"ca",
",",
"int",
"[",
"]",
"positions",
",",
"int",
"length",
",",
"boolean",
"clone",
")",
"{",
"List",
"<",
"Atom",
">",
"atoms",
"=",
"new",
"ArrayList",
"<",
"Atom",
">"... | most likely the clone flag is not needed | [
"most",
"likely",
"the",
"clone",
"flag",
"is",
"not",
"needed"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/AFPTwister.java#L297-L313 |
32,122 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/AFPTwister.java | AFPTwister.calCaRmsd | private static double calCaRmsd(Atom[] ca1, Atom[] pro, int resn,
int[] res1, int[] res2) throws StructureException {
Atom[] cod1 = getAtoms(ca1, res1, resn, false);
Atom[] cod2 = getAtoms(pro, res2, resn, false);
if (cod1.length == 0 || cod2.length == 0) {
logger.info("length of atoms == 0!");
return 99;
}
Matrix4d transform = SuperPositions.superpose(Calc.atomsToPoints(cod1),
Calc.atomsToPoints(cod2));
for (Atom a : cod2)
Calc.transform(a.getGroup(), transform);
return Calc.rmsd(cod1, cod2);
} | java | private static double calCaRmsd(Atom[] ca1, Atom[] pro, int resn,
int[] res1, int[] res2) throws StructureException {
Atom[] cod1 = getAtoms(ca1, res1, resn, false);
Atom[] cod2 = getAtoms(pro, res2, resn, false);
if (cod1.length == 0 || cod2.length == 0) {
logger.info("length of atoms == 0!");
return 99;
}
Matrix4d transform = SuperPositions.superpose(Calc.atomsToPoints(cod1),
Calc.atomsToPoints(cod2));
for (Atom a : cod2)
Calc.transform(a.getGroup(), transform);
return Calc.rmsd(cod1, cod2);
} | [
"private",
"static",
"double",
"calCaRmsd",
"(",
"Atom",
"[",
"]",
"ca1",
",",
"Atom",
"[",
"]",
"pro",
",",
"int",
"resn",
",",
"int",
"[",
"]",
"res1",
",",
"int",
"[",
"]",
"res2",
")",
"throws",
"StructureException",
"{",
"Atom",
"[",
"]",
"cod... | Return the rmsd of the CAs between the input pro and this protein, at
given positions. quite similar to transPdb but while that one transforms
the whole ca2, this one only works on the res1 and res2 positions.
Modifies the coordinates in the second set of Atoms (pro).
@return rmsd of CAs | [
"Return",
"the",
"rmsd",
"of",
"the",
"CAs",
"between",
"the",
"input",
"pro",
"and",
"this",
"protein",
"at",
"given",
"positions",
".",
"quite",
"similar",
"to",
"transPdb",
"but",
"while",
"that",
"one",
"transforms",
"the",
"whole",
"ca2",
"this",
"one... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/AFPTwister.java#L371-L389 |
32,123 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/AFPTwister.java | AFPTwister.afp2Res | public static int afp2Res(AFPChain afpChain, int afpn, int[] afpPositions,
int listStart) {
int[] res1 = afpChain.getFocusRes1();
int[] res2 = afpChain.getFocusRes2();
int minLen = afpChain.getMinLen();
int n = 0;
List<AFP> afpSet = afpChain.getAfpSet();
for (int i = listStart; i < listStart + afpn; i++) {
int a = afpPositions[i];
for (int j = 0; j < afpSet.get(a).getFragLen(); j++) {
if (n >= minLen) {
throw new RuntimeException(
"Error: too many residues in AFPChainer.afp2Res!");
}
res1[n] = afpSet.get(a).getP1() + j;
res2[n] = afpSet.get(a).getP2() + j;
n++;
}
}
afpChain.setFocusRes1(res1);
afpChain.setFocusRes2(res2);
afpChain.setFocusResn(n);
if (n == 0) {
logger.warn("n=0!!! + " + afpn + " " + listStart + " "
+ afpPositions.length);
}
return n;
} | java | public static int afp2Res(AFPChain afpChain, int afpn, int[] afpPositions,
int listStart) {
int[] res1 = afpChain.getFocusRes1();
int[] res2 = afpChain.getFocusRes2();
int minLen = afpChain.getMinLen();
int n = 0;
List<AFP> afpSet = afpChain.getAfpSet();
for (int i = listStart; i < listStart + afpn; i++) {
int a = afpPositions[i];
for (int j = 0; j < afpSet.get(a).getFragLen(); j++) {
if (n >= minLen) {
throw new RuntimeException(
"Error: too many residues in AFPChainer.afp2Res!");
}
res1[n] = afpSet.get(a).getP1() + j;
res2[n] = afpSet.get(a).getP2() + j;
n++;
}
}
afpChain.setFocusRes1(res1);
afpChain.setFocusRes2(res2);
afpChain.setFocusResn(n);
if (n == 0) {
logger.warn("n=0!!! + " + afpn + " " + listStart + " "
+ afpPositions.length);
}
return n;
} | [
"public",
"static",
"int",
"afp2Res",
"(",
"AFPChain",
"afpChain",
",",
"int",
"afpn",
",",
"int",
"[",
"]",
"afpPositions",
",",
"int",
"listStart",
")",
"{",
"int",
"[",
"]",
"res1",
"=",
"afpChain",
".",
"getFocusRes1",
"(",
")",
";",
"int",
"[",
... | Set the list of equivalent residues in the two proteins given a list of
AFPs
WARNING: changes the values for FocusRes1, focusRes2 and FocusResn in
afpChain!
@param afpChain
the AFPChain to store resuts
@param afpn
nr of afp
@param afpPositions
@param listStart
@return nr of eq residues | [
"Set",
"the",
"list",
"of",
"equivalent",
"residues",
"in",
"the",
"two",
"proteins",
"given",
"a",
"list",
"of",
"AFPs"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/AFPTwister.java#L407-L439 |
32,124 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/autosuggest/JAutoSuggest.java | JAutoSuggest.updateLocation | private void updateLocation() {
try {
location = getLocationOnScreen();
location.y += getHeight();
dialog.setLocation(location);
} catch (IllegalComponentStateException e) {
return; // might happen on window creation
}
} | java | private void updateLocation() {
try {
location = getLocationOnScreen();
location.y += getHeight();
dialog.setLocation(location);
} catch (IllegalComponentStateException e) {
return; // might happen on window creation
}
} | [
"private",
"void",
"updateLocation",
"(",
")",
"{",
"try",
"{",
"location",
"=",
"getLocationOnScreen",
"(",
")",
";",
"location",
".",
"y",
"+=",
"getHeight",
"(",
")",
";",
"dialog",
".",
"setLocation",
"(",
"location",
")",
";",
"}",
"catch",
"(",
"... | Place the suggestion window under the JTextField. | [
"Place",
"the",
"suggestion",
"window",
"under",
"the",
"JTextField",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/autosuggest/JAutoSuggest.java#L325-L333 |
32,125 | biojava/biojava | biojava-survival/src/main/java/org/biojava/nbio/survival/cox/matrix/StdArrayIO.java | StdArrayIO.print | public static void print(double[] a) {
int N = a.length;
System.out.println(N);
for (int i = 0; i < N; i++) {
// System.out.printf("%9.5f ", a[i]);
System.out.print(a[i] + " ");
}
System.out.println();
} | java | public static void print(double[] a) {
int N = a.length;
System.out.println(N);
for (int i = 0; i < N; i++) {
// System.out.printf("%9.5f ", a[i]);
System.out.print(a[i] + " ");
}
System.out.println();
} | [
"public",
"static",
"void",
"print",
"(",
"double",
"[",
"]",
"a",
")",
"{",
"int",
"N",
"=",
"a",
".",
"length",
";",
"System",
".",
"out",
".",
"println",
"(",
"N",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",... | Print an array of doubles to standard output.
@param a | [
"Print",
"an",
"array",
"of",
"doubles",
"to",
"standard",
"output",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-survival/src/main/java/org/biojava/nbio/survival/cox/matrix/StdArrayIO.java#L86-L94 |
32,126 | biojava/biojava | biojava-ontology/src/main/java/org/biojava/nbio/ontology/utils/SmallMap.java | SmallMap.removeMapping | private void removeMapping(int num) {
if (num < numMappings) {
System.arraycopy(mappings, num * 2, mappings, (num - 1) * 2, (numMappings - num) * 2);
}
mappings[numMappings * 2 - 1] = null;
mappings[numMappings * 2 - 2] = null;
numMappings--;
} | java | private void removeMapping(int num) {
if (num < numMappings) {
System.arraycopy(mappings, num * 2, mappings, (num - 1) * 2, (numMappings - num) * 2);
}
mappings[numMappings * 2 - 1] = null;
mappings[numMappings * 2 - 2] = null;
numMappings--;
} | [
"private",
"void",
"removeMapping",
"(",
"int",
"num",
")",
"{",
"if",
"(",
"num",
"<",
"numMappings",
")",
"{",
"System",
".",
"arraycopy",
"(",
"mappings",
",",
"num",
"*",
"2",
",",
"mappings",
",",
"(",
"num",
"-",
"1",
")",
"*",
"2",
",",
"(... | num ranges from 1 to numMappings | [
"num",
"ranges",
"from",
"1",
"to",
"numMappings"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-ontology/src/main/java/org/biojava/nbio/ontology/utils/SmallMap.java#L141-L148 |
32,127 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/alignment/matrices/SimpleSubstitutionMatrix.java | SimpleSubstitutionMatrix.getIndexOfCompound | private static <C extends Compound> int getIndexOfCompound(List<C> list, C compound) {
int index = list.indexOf(compound);
if (index == -1) {
for (int i = 0; i < list.size(); i++) {
if (compound.equalsIgnoreCase(list.get(i))) {
index = i;
break;
}
}
}
return index;
} | java | private static <C extends Compound> int getIndexOfCompound(List<C> list, C compound) {
int index = list.indexOf(compound);
if (index == -1) {
for (int i = 0; i < list.size(); i++) {
if (compound.equalsIgnoreCase(list.get(i))) {
index = i;
break;
}
}
}
return index;
} | [
"private",
"static",
"<",
"C",
"extends",
"Compound",
">",
"int",
"getIndexOfCompound",
"(",
"List",
"<",
"C",
">",
"list",
",",
"C",
"compound",
")",
"{",
"int",
"index",
"=",
"list",
".",
"indexOf",
"(",
"compound",
")",
";",
"if",
"(",
"index",
"=... | Returns the index of the first occurrence of the specified element in the list.
If the list does not contain the given compound, the index of the first occurrence
of the element according to case-insensitive equality.
If no such elements exist, -1 is returned.
@param list list of compounds to search
@param compound compound to search for
@return Returns the index of the first match to the specified element in this list, or -1 if there is no such index. | [
"Returns",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"of",
"the",
"specified",
"element",
"in",
"the",
"list",
".",
"If",
"the",
"list",
"does",
"not",
"contain",
"the",
"given",
"compound",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"of... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/alignment/matrices/SimpleSubstitutionMatrix.java#L229-L240 |
32,128 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java | SymmetryAxes.addAxis | public void addAxis(Matrix4d axis, int order, SymmetryType type) {
axes.add(new Axis(axis,order,type,axes.size(),0));
} | java | public void addAxis(Matrix4d axis, int order, SymmetryType type) {
axes.add(new Axis(axis,order,type,axes.size(),0));
} | [
"public",
"void",
"addAxis",
"(",
"Matrix4d",
"axis",
",",
"int",
"order",
",",
"SymmetryType",
"type",
")",
"{",
"axes",
".",
"add",
"(",
"new",
"Axis",
"(",
"axis",
",",
"order",
",",
"type",
",",
"axes",
".",
"size",
"(",
")",
",",
"0",
")",
"... | Adds a new axis of symmetry to the bottom level of the tree
@param axis the new axis of symmetry found
@param order number of parts that this axis divides the structure in
@param type indicates whether the axis has OPEN or CLOSED symmetry | [
"Adds",
"a",
"new",
"axis",
"of",
"symmetry",
"to",
"the",
"bottom",
"level",
"of",
"the",
"tree"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java#L205-L207 |
32,129 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java | SymmetryAxes.updateAxis | public void updateAxis(Integer index, Matrix4d newAxis){
axes.get(index).setOperator(newAxis);
} | java | public void updateAxis(Integer index, Matrix4d newAxis){
axes.get(index).setOperator(newAxis);
} | [
"public",
"void",
"updateAxis",
"(",
"Integer",
"index",
",",
"Matrix4d",
"newAxis",
")",
"{",
"axes",
".",
"get",
"(",
"index",
")",
".",
"setOperator",
"(",
"newAxis",
")",
";",
"}"
] | Updates an axis of symmetry, after the superposition changed.
@param index old axis index
@param newAxis | [
"Updates",
"an",
"axis",
"of",
"symmetry",
"after",
"the",
"superposition",
"changed",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java#L252-L254 |
32,130 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java | SymmetryAxes.getElementaryAxes | public List<Matrix4d> getElementaryAxes(){
List<Matrix4d> ops = new ArrayList<Matrix4d>(getNumLevels());
for(Axis axis : axes) {
ops.add(axis.getOperator());
}
return ops;
} | java | public List<Matrix4d> getElementaryAxes(){
List<Matrix4d> ops = new ArrayList<Matrix4d>(getNumLevels());
for(Axis axis : axes) {
ops.add(axis.getOperator());
}
return ops;
} | [
"public",
"List",
"<",
"Matrix4d",
">",
"getElementaryAxes",
"(",
")",
"{",
"List",
"<",
"Matrix4d",
">",
"ops",
"=",
"new",
"ArrayList",
"<",
"Matrix4d",
">",
"(",
"getNumLevels",
"(",
")",
")",
";",
"for",
"(",
"Axis",
"axis",
":",
"axes",
")",
"{"... | Return the operator for all elementary axes of symmetry of the structure, that is,
the axes stored in the List as unique and from which all the symmetry
axes are constructed.
@return axes elementary axes of symmetry. | [
"Return",
"the",
"operator",
"for",
"all",
"elementary",
"axes",
"of",
"symmetry",
"of",
"the",
"structure",
"that",
"is",
"the",
"axes",
"stored",
"in",
"the",
"List",
"as",
"unique",
"and",
"from",
"which",
"all",
"the",
"symmetry",
"axes",
"are",
"const... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java#L263-L269 |
32,131 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java | SymmetryAxes.getRepeatTransform | public Matrix4d getRepeatTransform(int repeat){
Matrix4d transform = new Matrix4d();
transform.setIdentity();
int[] counts = getAxisCounts(repeat);
for(int t = counts.length-1; t>=0; t--) {
if( counts[t] == 0 )
continue;
Matrix4d axis = new Matrix4d(axes.get(t).getOperator());
for(int i=0;i<counts[t];i++) {
transform.mul(axis);
}
}
return transform;
} | java | public Matrix4d getRepeatTransform(int repeat){
Matrix4d transform = new Matrix4d();
transform.setIdentity();
int[] counts = getAxisCounts(repeat);
for(int t = counts.length-1; t>=0; t--) {
if( counts[t] == 0 )
continue;
Matrix4d axis = new Matrix4d(axes.get(t).getOperator());
for(int i=0;i<counts[t];i++) {
transform.mul(axis);
}
}
return transform;
} | [
"public",
"Matrix4d",
"getRepeatTransform",
"(",
"int",
"repeat",
")",
"{",
"Matrix4d",
"transform",
"=",
"new",
"Matrix4d",
"(",
")",
";",
"transform",
".",
"setIdentity",
"(",
")",
";",
"int",
"[",
"]",
"counts",
"=",
"getAxisCounts",
"(",
"repeat",
")",... | Return the transformation that needs to be applied to a
repeat in order to superimpose onto repeat 0.
@param repeat the repeat index
@return transformation matrix for the repeat | [
"Return",
"the",
"transformation",
"that",
"needs",
"to",
"be",
"applied",
"to",
"a",
"repeat",
"in",
"order",
"to",
"superimpose",
"onto",
"repeat",
"0",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java#L389-L405 |
32,132 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java | SymmetryAxes.getRepeatTransform | public Matrix4d getRepeatTransform(int x, int y){
Matrix4d transform = new Matrix4d();
transform.setIdentity();
int[] iCounts = getAxisCounts(x);
int[] jCounts = getAxisCounts(y);
int[] counts = new int[iCounts.length];
for (int k = 0; k < iCounts.length; k++)
counts[k] = iCounts[k] - jCounts[k];
for(int t = counts.length-1; t>=0; t--) {
if(counts[t] == 0)
continue;
if (counts[t] > 0) {
Matrix4d axis = new Matrix4d(axes.get(t).getOperator());
for(int i=0;i<counts[t];i++)
transform.mul(axis);
} else if (counts[t] < 0) {
Matrix4d axis = new Matrix4d(axes.get(t).getOperator());
axis.invert();
for(int i=0;i<counts[t];i++)
transform.mul(axis);
}
}
return transform;
} | java | public Matrix4d getRepeatTransform(int x, int y){
Matrix4d transform = new Matrix4d();
transform.setIdentity();
int[] iCounts = getAxisCounts(x);
int[] jCounts = getAxisCounts(y);
int[] counts = new int[iCounts.length];
for (int k = 0; k < iCounts.length; k++)
counts[k] = iCounts[k] - jCounts[k];
for(int t = counts.length-1; t>=0; t--) {
if(counts[t] == 0)
continue;
if (counts[t] > 0) {
Matrix4d axis = new Matrix4d(axes.get(t).getOperator());
for(int i=0;i<counts[t];i++)
transform.mul(axis);
} else if (counts[t] < 0) {
Matrix4d axis = new Matrix4d(axes.get(t).getOperator());
axis.invert();
for(int i=0;i<counts[t];i++)
transform.mul(axis);
}
}
return transform;
} | [
"public",
"Matrix4d",
"getRepeatTransform",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"Matrix4d",
"transform",
"=",
"new",
"Matrix4d",
"(",
")",
";",
"transform",
".",
"setIdentity",
"(",
")",
";",
"int",
"[",
"]",
"iCounts",
"=",
"getAxisCounts",
"(",... | Return the transformation that needs to be applied to
repeat x in order to superimpose onto repeat y.
@param x the first repeat index (transformed)
@param y the second repeat index (fixed)
@return transformation matrix for the repeat x | [
"Return",
"the",
"transformation",
"that",
"needs",
"to",
"be",
"applied",
"to",
"repeat",
"x",
"in",
"order",
"to",
"superimpose",
"onto",
"repeat",
"y",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java#L415-L442 |
32,133 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java | SymmetryAxes.getNumRepeats | private int getNumRepeats(int level) {
int size = 1;
// Return 1 for illegally high level
if(level < getNumLevels()) {
for(Axis axis : axes.subList(level, getNumLevels())) {
size *= axis.getOrder();
}
}
return size;
} | java | private int getNumRepeats(int level) {
int size = 1;
// Return 1 for illegally high level
if(level < getNumLevels()) {
for(Axis axis : axes.subList(level, getNumLevels())) {
size *= axis.getOrder();
}
}
return size;
} | [
"private",
"int",
"getNumRepeats",
"(",
"int",
"level",
")",
"{",
"int",
"size",
"=",
"1",
";",
"// Return 1 for illegally high level",
"if",
"(",
"level",
"<",
"getNumLevels",
"(",
")",
")",
"{",
"for",
"(",
"Axis",
"axis",
":",
"axes",
".",
"subList",
... | Get the number of leaves from a node at the specified level. This is
equal to the product of all degrees at or below the level.
@param level level of the tree to cut at
@return Number of repeats (leaves of the tree). | [
"Get",
"the",
"number",
"of",
"leaves",
"from",
"a",
"node",
"at",
"the",
"specified",
"level",
".",
"This",
"is",
"equal",
"to",
"the",
"product",
"of",
"all",
"degrees",
"at",
"or",
"below",
"the",
"level",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java#L527-L536 |
32,134 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java | SymmetryAxes.getFirstRepeats | public List<Integer> getFirstRepeats(int level) {
List<Integer> firstRepeats = new ArrayList<Integer>();
int m = getNumRepeats(level+1); //size of the level
int d = axes.get(level).getOrder(); //degree of this level
int n = m*d; // number of repeats included in each axis
for (int firstRepeat = 0; firstRepeat < getNumRepeats(); firstRepeat+=n)
firstRepeats.add(firstRepeat);
return firstRepeats;
} | java | public List<Integer> getFirstRepeats(int level) {
List<Integer> firstRepeats = new ArrayList<Integer>();
int m = getNumRepeats(level+1); //size of the level
int d = axes.get(level).getOrder(); //degree of this level
int n = m*d; // number of repeats included in each axis
for (int firstRepeat = 0; firstRepeat < getNumRepeats(); firstRepeat+=n)
firstRepeats.add(firstRepeat);
return firstRepeats;
} | [
"public",
"List",
"<",
"Integer",
">",
"getFirstRepeats",
"(",
"int",
"level",
")",
"{",
"List",
"<",
"Integer",
">",
"firstRepeats",
"=",
"new",
"ArrayList",
"<",
"Integer",
">",
"(",
")",
";",
"int",
"m",
"=",
"getNumRepeats",
"(",
"level",
"+",
"1",... | Get the first repeat index of each axis of a specified level.
@param level level of the tree to cut at
@return List of first Repeats of each index, sorted in ascending order | [
"Get",
"the",
"first",
"repeat",
"index",
"of",
"each",
"axis",
"of",
"a",
"specified",
"level",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java#L543-L551 |
32,135 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java | StructureInterface.setAsas | void setAsas(double[] asas1, double[] asas2, int nSpherePoints, int nThreads, int cofactorSizeToUse) {
Atom[] atoms = getAtomsForAsa(cofactorSizeToUse);
AsaCalculator asaCalc = new AsaCalculator(atoms,
AsaCalculator.DEFAULT_PROBE_SIZE, nSpherePoints, nThreads);
double[] complexAsas = asaCalc.calculateAsas();
if (complexAsas.length!=asas1.length+asas2.length)
throw new IllegalArgumentException("The size of ASAs of complex doesn't match that of ASAs 1 + ASAs 2");
groupAsas1 = new TreeMap<>();
groupAsas2 = new TreeMap<>();
this.totalArea = 0;
for (int i=0;i<asas1.length;i++) {
Group g = atoms[i].getGroup();
if (!g.getType().equals(GroupType.HETATM) ||
isInChain(g)) {
// interface area should be only for protein/nucleotide but not hetatoms that are not part of the chain
this.totalArea += (asas1[i] - complexAsas[i]);
}
if (!groupAsas1.containsKey(g.getResidueNumber())) {
GroupAsa groupAsa = new GroupAsa(g);
groupAsa.addAtomAsaU(asas1[i]);
groupAsa.addAtomAsaC(complexAsas[i]);
groupAsas1.put(g.getResidueNumber(), groupAsa);
} else {
GroupAsa groupAsa = groupAsas1.get(g.getResidueNumber());
groupAsa.addAtomAsaU(asas1[i]);
groupAsa.addAtomAsaC(complexAsas[i]);
}
}
for (int i=0;i<asas2.length;i++) {
Group g = atoms[i+asas1.length].getGroup();
if (!g.getType().equals(GroupType.HETATM) ||
isInChain(g)) {
// interface area should be only for protein/nucleotide but not hetatoms that are not part of the chain
this.totalArea += (asas2[i] - complexAsas[i+asas1.length]);
}
if (!groupAsas2.containsKey(g.getResidueNumber())) {
GroupAsa groupAsa = new GroupAsa(g);
groupAsa.addAtomAsaU(asas2[i]);
groupAsa.addAtomAsaC(complexAsas[i+asas1.length]);
groupAsas2.put(g.getResidueNumber(), groupAsa);
} else {
GroupAsa groupAsa = groupAsas2.get(g.getResidueNumber());
groupAsa.addAtomAsaU(asas2[i]);
groupAsa.addAtomAsaC(complexAsas[i+asas1.length]);
}
}
// our interface area definition: average of bsa of both molecules
this.totalArea = this.totalArea/2.0;
} | java | void setAsas(double[] asas1, double[] asas2, int nSpherePoints, int nThreads, int cofactorSizeToUse) {
Atom[] atoms = getAtomsForAsa(cofactorSizeToUse);
AsaCalculator asaCalc = new AsaCalculator(atoms,
AsaCalculator.DEFAULT_PROBE_SIZE, nSpherePoints, nThreads);
double[] complexAsas = asaCalc.calculateAsas();
if (complexAsas.length!=asas1.length+asas2.length)
throw new IllegalArgumentException("The size of ASAs of complex doesn't match that of ASAs 1 + ASAs 2");
groupAsas1 = new TreeMap<>();
groupAsas2 = new TreeMap<>();
this.totalArea = 0;
for (int i=0;i<asas1.length;i++) {
Group g = atoms[i].getGroup();
if (!g.getType().equals(GroupType.HETATM) ||
isInChain(g)) {
// interface area should be only for protein/nucleotide but not hetatoms that are not part of the chain
this.totalArea += (asas1[i] - complexAsas[i]);
}
if (!groupAsas1.containsKey(g.getResidueNumber())) {
GroupAsa groupAsa = new GroupAsa(g);
groupAsa.addAtomAsaU(asas1[i]);
groupAsa.addAtomAsaC(complexAsas[i]);
groupAsas1.put(g.getResidueNumber(), groupAsa);
} else {
GroupAsa groupAsa = groupAsas1.get(g.getResidueNumber());
groupAsa.addAtomAsaU(asas1[i]);
groupAsa.addAtomAsaC(complexAsas[i]);
}
}
for (int i=0;i<asas2.length;i++) {
Group g = atoms[i+asas1.length].getGroup();
if (!g.getType().equals(GroupType.HETATM) ||
isInChain(g)) {
// interface area should be only for protein/nucleotide but not hetatoms that are not part of the chain
this.totalArea += (asas2[i] - complexAsas[i+asas1.length]);
}
if (!groupAsas2.containsKey(g.getResidueNumber())) {
GroupAsa groupAsa = new GroupAsa(g);
groupAsa.addAtomAsaU(asas2[i]);
groupAsa.addAtomAsaC(complexAsas[i+asas1.length]);
groupAsas2.put(g.getResidueNumber(), groupAsa);
} else {
GroupAsa groupAsa = groupAsas2.get(g.getResidueNumber());
groupAsa.addAtomAsaU(asas2[i]);
groupAsa.addAtomAsaC(complexAsas[i+asas1.length]);
}
}
// our interface area definition: average of bsa of both molecules
this.totalArea = this.totalArea/2.0;
} | [
"void",
"setAsas",
"(",
"double",
"[",
"]",
"asas1",
",",
"double",
"[",
"]",
"asas2",
",",
"int",
"nSpherePoints",
",",
"int",
"nThreads",
",",
"int",
"cofactorSizeToUse",
")",
"{",
"Atom",
"[",
"]",
"atoms",
"=",
"getAtomsForAsa",
"(",
"cofactorSizeToUse... | Set ASA annotations by passing the uncomplexed ASA values of the 2 partners.
This will calculate complexed ASA and set the ASA values in the member variables.
@param asas1 ASA values for atoms of partner 1
@param asas2 ASA values for atoms of partner 2
@param nSpherePoints the number of sphere points to be used for complexed ASA calculation
@param nThreads the number of threads to be used for complexed ASA calculation
@param cofactorSizeToUse the minimum size of cofactor molecule (non-chain HET atoms) that will be used in ASA calculation | [
"Set",
"ASA",
"annotations",
"by",
"passing",
"the",
"uncomplexed",
"ASA",
"values",
"of",
"the",
"2",
"partners",
".",
"This",
"will",
"calculate",
"complexed",
"ASA",
"and",
"set",
"the",
"ASA",
"values",
"in",
"the",
"member",
"variables",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java#L209-L271 |
32,136 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java | StructureInterface.getAllNonHAtomArray | private static final Atom[] getAllNonHAtomArray(Atom[] m, int minSizeHetAtomToInclude) {
List<Atom> atoms = new ArrayList<>();
for (Atom a:m){
if (a.getElement()==Element.H) continue;
Group g = a.getGroup();
if (g.getType().equals(GroupType.HETATM) &&
!isInChain(g) &&
getSizeNoH(g)<minSizeHetAtomToInclude) {
continue;
}
atoms.add(a);
}
return atoms.toArray(new Atom[atoms.size()]);
} | java | private static final Atom[] getAllNonHAtomArray(Atom[] m, int minSizeHetAtomToInclude) {
List<Atom> atoms = new ArrayList<>();
for (Atom a:m){
if (a.getElement()==Element.H) continue;
Group g = a.getGroup();
if (g.getType().equals(GroupType.HETATM) &&
!isInChain(g) &&
getSizeNoH(g)<minSizeHetAtomToInclude) {
continue;
}
atoms.add(a);
}
return atoms.toArray(new Atom[atoms.size()]);
} | [
"private",
"static",
"final",
"Atom",
"[",
"]",
"getAllNonHAtomArray",
"(",
"Atom",
"[",
"]",
"m",
",",
"int",
"minSizeHetAtomToInclude",
")",
"{",
"List",
"<",
"Atom",
">",
"atoms",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Atom",
"a"... | Returns and array of all non-Hydrogen atoms in the given molecule, including all
main chain HETATOM groups. Non main-chain HETATOM groups with fewer than minSizeHetAtomToInclude
non-Hydrogen atoms are not included.
@param m
@param minSizeHetAtomToInclude HETATOM groups (non main-chain) with fewer number of
non-Hydrogen atoms are not included
@return | [
"Returns",
"and",
"array",
"of",
"all",
"non",
"-",
"Hydrogen",
"atoms",
"in",
"the",
"given",
"molecule",
"including",
"all",
"main",
"chain",
"HETATOM",
"groups",
".",
"Non",
"main",
"-",
"chain",
"HETATOM",
"groups",
"with",
"fewer",
"than",
"minSizeHetAt... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java#L307-L325 |
32,137 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java | StructureInterface.getSizeNoH | private static int getSizeNoH(Group g) {
int size = 0;
for (Atom a:g.getAtoms()) {
if (a.getElement()!=Element.H)
size++;
}
return size;
} | java | private static int getSizeNoH(Group g) {
int size = 0;
for (Atom a:g.getAtoms()) {
if (a.getElement()!=Element.H)
size++;
}
return size;
} | [
"private",
"static",
"int",
"getSizeNoH",
"(",
"Group",
"g",
")",
"{",
"int",
"size",
"=",
"0",
";",
"for",
"(",
"Atom",
"a",
":",
"g",
".",
"getAtoms",
"(",
")",
")",
"{",
"if",
"(",
"a",
".",
"getElement",
"(",
")",
"!=",
"Element",
".",
"H",... | Calculates the number of non-Hydrogen atoms in the given group
@param g
@return | [
"Calculates",
"the",
"number",
"of",
"non",
"-",
"Hydrogen",
"atoms",
"in",
"the",
"given",
"group"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java#L332-L339 |
32,138 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java | StructureInterface.isInChain | private static boolean isInChain(Group g) {
ChemComp chemComp = g.getChemComp();
if (chemComp==null) {
logger.warn("Warning: can't determine PolymerType for group "+g.getResidueNumber()+" ("+g.getPDBName()+"). Will consider it as non-nucleotide/non-protein type.");
return false;
}
PolymerType polyType = chemComp.getPolymerType();
for (PolymerType protOnlyType: PolymerType.PROTEIN_ONLY) {
if (polyType==protOnlyType) return true;
}
for (PolymerType protOnlyType: PolymerType.POLYNUCLEOTIDE_ONLY) {
if (polyType==protOnlyType) return true;
}
return false;
} | java | private static boolean isInChain(Group g) {
ChemComp chemComp = g.getChemComp();
if (chemComp==null) {
logger.warn("Warning: can't determine PolymerType for group "+g.getResidueNumber()+" ("+g.getPDBName()+"). Will consider it as non-nucleotide/non-protein type.");
return false;
}
PolymerType polyType = chemComp.getPolymerType();
for (PolymerType protOnlyType: PolymerType.PROTEIN_ONLY) {
if (polyType==protOnlyType) return true;
}
for (PolymerType protOnlyType: PolymerType.POLYNUCLEOTIDE_ONLY) {
if (polyType==protOnlyType) return true;
}
return false;
} | [
"private",
"static",
"boolean",
"isInChain",
"(",
"Group",
"g",
")",
"{",
"ChemComp",
"chemComp",
"=",
"g",
".",
"getChemComp",
"(",
")",
";",
"if",
"(",
"chemComp",
"==",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Warning: can't determine PolymerType ... | Returns true if the given group is part of the main chain, i.e. if it is
a peptide-linked group or a nucleotide
@param g
@return | [
"Returns",
"true",
"if",
"the",
"given",
"group",
"is",
"part",
"of",
"the",
"main",
"chain",
"i",
".",
"e",
".",
"if",
"it",
"is",
"a",
"peptide",
"-",
"linked",
"group",
"or",
"a",
"nucleotide"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java#L347-L364 |
32,139 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java | StructureInterface.getInterfacingResidues | public Pair<List<Group>> getInterfacingResidues(double minAsaForSurface) {
List<Group> interf1 = new ArrayList<Group>();
List<Group> interf2 = new ArrayList<Group>();
for (GroupAsa groupAsa:groupAsas1.values()) {
if (groupAsa.getAsaU()>minAsaForSurface && groupAsa.getBsa()>0) {
interf1.add(groupAsa.getGroup());
}
}
for (GroupAsa groupAsa:groupAsas2.values()) {
if (groupAsa.getAsaU()>minAsaForSurface && groupAsa.getBsa()>0) {
interf2.add(groupAsa.getGroup());
}
}
return new Pair<List<Group>>(interf1, interf2);
} | java | public Pair<List<Group>> getInterfacingResidues(double minAsaForSurface) {
List<Group> interf1 = new ArrayList<Group>();
List<Group> interf2 = new ArrayList<Group>();
for (GroupAsa groupAsa:groupAsas1.values()) {
if (groupAsa.getAsaU()>minAsaForSurface && groupAsa.getBsa()>0) {
interf1.add(groupAsa.getGroup());
}
}
for (GroupAsa groupAsa:groupAsas2.values()) {
if (groupAsa.getAsaU()>minAsaForSurface && groupAsa.getBsa()>0) {
interf2.add(groupAsa.getGroup());
}
}
return new Pair<List<Group>>(interf1, interf2);
} | [
"public",
"Pair",
"<",
"List",
"<",
"Group",
">",
">",
"getInterfacingResidues",
"(",
"double",
"minAsaForSurface",
")",
"{",
"List",
"<",
"Group",
">",
"interf1",
"=",
"new",
"ArrayList",
"<",
"Group",
">",
"(",
")",
";",
"List",
"<",
"Group",
">",
"i... | Returns the residues belonging to the interface, i.e. the residues
at the surface with BSA>0
@param minAsaForSurface the minimum ASA to consider a residue on the surface
@return | [
"Returns",
"the",
"residues",
"belonging",
"to",
"the",
"interface",
"i",
".",
"e",
".",
"the",
"residues",
"at",
"the",
"surface",
"with",
"BSA",
">",
"0"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java#L530-L549 |
32,140 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java | StructureInterface.getSurfaceResidues | public Pair<List<Group>> getSurfaceResidues(double minAsaForSurface) {
List<Group> surf1 = new ArrayList<Group>();
List<Group> surf2 = new ArrayList<Group>();
for (GroupAsa groupAsa:groupAsas1.values()) {
if (groupAsa.getAsaU()>minAsaForSurface) {
surf1.add(groupAsa.getGroup());
}
}
for (GroupAsa groupAsa:groupAsas2.values()) {
if (groupAsa.getAsaU()>minAsaForSurface) {
surf2.add(groupAsa.getGroup());
}
}
return new Pair<List<Group>>(surf1, surf2);
} | java | public Pair<List<Group>> getSurfaceResidues(double minAsaForSurface) {
List<Group> surf1 = new ArrayList<Group>();
List<Group> surf2 = new ArrayList<Group>();
for (GroupAsa groupAsa:groupAsas1.values()) {
if (groupAsa.getAsaU()>minAsaForSurface) {
surf1.add(groupAsa.getGroup());
}
}
for (GroupAsa groupAsa:groupAsas2.values()) {
if (groupAsa.getAsaU()>minAsaForSurface) {
surf2.add(groupAsa.getGroup());
}
}
return new Pair<List<Group>>(surf1, surf2);
} | [
"public",
"Pair",
"<",
"List",
"<",
"Group",
">",
">",
"getSurfaceResidues",
"(",
"double",
"minAsaForSurface",
")",
"{",
"List",
"<",
"Group",
">",
"surf1",
"=",
"new",
"ArrayList",
"<",
"Group",
">",
"(",
")",
";",
"List",
"<",
"Group",
">",
"surf2",... | Returns the residues belonging to the surface
@param minAsaForSurface the minimum ASA to consider a residue on the surface
@return | [
"Returns",
"the",
"residues",
"belonging",
"to",
"the",
"surface"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java#L556-L574 |
32,141 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java | StructureInterface.isIsologous | public boolean isIsologous() {
double scoreInverse = this.getContactOverlapScore(this, true);
logger.debug("Interface {} contact overlap score with itself inverted: {}",
getId(), scoreInverse);
return (scoreInverse>SELF_SCORE_FOR_ISOLOGOUS);
} | java | public boolean isIsologous() {
double scoreInverse = this.getContactOverlapScore(this, true);
logger.debug("Interface {} contact overlap score with itself inverted: {}",
getId(), scoreInverse);
return (scoreInverse>SELF_SCORE_FOR_ISOLOGOUS);
} | [
"public",
"boolean",
"isIsologous",
"(",
")",
"{",
"double",
"scoreInverse",
"=",
"this",
".",
"getContactOverlapScore",
"(",
"this",
",",
"true",
")",
";",
"logger",
".",
"debug",
"(",
"\"Interface {} contact overlap score with itself inverted: {}\"",
",",
"getId",
... | Tell whether the interface is isologous, i.e. it is formed
by the same patches of same Compound on both sides.
@return true if isologous, false if heterologous | [
"Tell",
"whether",
"the",
"interface",
"is",
"isologous",
"i",
".",
"e",
".",
"it",
"is",
"formed",
"by",
"the",
"same",
"patches",
"of",
"same",
"Compound",
"on",
"both",
"sides",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java#L675-L680 |
32,142 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java | StructureInterface.getParentChains | public Pair<Chain> getParentChains() {
Atom[] firstMol = this.molecules.getFirst();
Atom[] secondMol = this.molecules.getSecond();
if (firstMol.length==0 || secondMol.length==0) {
logger.warn("No atoms found in first or second molecule, can't get parent Chains");
return null;
}
return new Pair<Chain>(firstMol[0].getGroup().getChain(), secondMol[0].getGroup().getChain());
} | java | public Pair<Chain> getParentChains() {
Atom[] firstMol = this.molecules.getFirst();
Atom[] secondMol = this.molecules.getSecond();
if (firstMol.length==0 || secondMol.length==0) {
logger.warn("No atoms found in first or second molecule, can't get parent Chains");
return null;
}
return new Pair<Chain>(firstMol[0].getGroup().getChain(), secondMol[0].getGroup().getChain());
} | [
"public",
"Pair",
"<",
"Chain",
">",
"getParentChains",
"(",
")",
"{",
"Atom",
"[",
"]",
"firstMol",
"=",
"this",
".",
"molecules",
".",
"getFirst",
"(",
")",
";",
"Atom",
"[",
"]",
"secondMol",
"=",
"this",
".",
"molecules",
".",
"getSecond",
"(",
"... | Finds the parent chains by looking up the references of first atom of each side of this interface
@return | [
"Finds",
"the",
"parent",
"chains",
"by",
"looking",
"up",
"the",
"references",
"of",
"first",
"atom",
"of",
"each",
"side",
"of",
"this",
"interface"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java#L686-L695 |
32,143 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java | StructureInterface.getParentCompounds | public Pair<EntityInfo> getParentCompounds() {
Pair<Chain> chains = getParentChains();
if (chains == null) {
logger.warn("Could not find parents chains, compounds will be null");
return null;
}
return new Pair<EntityInfo>(chains.getFirst().getEntityInfo(), chains.getSecond().getEntityInfo());
} | java | public Pair<EntityInfo> getParentCompounds() {
Pair<Chain> chains = getParentChains();
if (chains == null) {
logger.warn("Could not find parents chains, compounds will be null");
return null;
}
return new Pair<EntityInfo>(chains.getFirst().getEntityInfo(), chains.getSecond().getEntityInfo());
} | [
"public",
"Pair",
"<",
"EntityInfo",
">",
"getParentCompounds",
"(",
")",
"{",
"Pair",
"<",
"Chain",
">",
"chains",
"=",
"getParentChains",
"(",
")",
";",
"if",
"(",
"chains",
"==",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Could not find parents ch... | Finds the parent compounds by looking up the references of first atom of each side of this interface
@return | [
"Finds",
"the",
"parent",
"compounds",
"by",
"looking",
"up",
"the",
"references",
"of",
"first",
"atom",
"of",
"each",
"side",
"of",
"this",
"interface"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java#L701-L708 |
32,144 | biojava/biojava | biojava-structure/src/main/java/demo/DemoMMCIFReader.java | DemoMMCIFReader.loadSimple | public void loadSimple(){
String pdbId = "4hhb";
AtomCache cache = new AtomCache();
cache.setUseMmCif(true);
StructureIO.setAtomCache(cache);
try {
Structure s = StructureIO.getStructure(pdbId);
System.out.println(pdbId + " has nr atoms: " + StructureTools.getNrAtoms(s));
} catch (Exception e){
e.printStackTrace();
}
} | java | public void loadSimple(){
String pdbId = "4hhb";
AtomCache cache = new AtomCache();
cache.setUseMmCif(true);
StructureIO.setAtomCache(cache);
try {
Structure s = StructureIO.getStructure(pdbId);
System.out.println(pdbId + " has nr atoms: " + StructureTools.getNrAtoms(s));
} catch (Exception e){
e.printStackTrace();
}
} | [
"public",
"void",
"loadSimple",
"(",
")",
"{",
"String",
"pdbId",
"=",
"\"4hhb\"",
";",
"AtomCache",
"cache",
"=",
"new",
"AtomCache",
"(",
")",
";",
"cache",
".",
"setUseMmCif",
"(",
"true",
")",
";",
"StructureIO",
".",
"setAtomCache",
"(",
"cache",
")... | A basic example how to load an mmCif file and get a Structure object | [
"A",
"basic",
"example",
"how",
"to",
"load",
"an",
"mmCif",
"file",
"and",
"get",
"a",
"Structure",
"object"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/demo/DemoMMCIFReader.java#L56-L72 |
32,145 | biojava/biojava | biojava-structure/src/main/java/demo/DemoMMCIFReader.java | DemoMMCIFReader.loadFromDirectAccess | public void loadFromDirectAccess(){
String pdbId = "1A4W";
StructureProvider pdbreader = new MMCIFFileReader();
try {
Structure s = pdbreader.getStructureById(pdbId);
System.out.println("Getting chain H of 1A4W");
List<Chain> hs = s.getNonPolyChainsByPDB("H");
Chain h = hs.get(0);
List<Group> ligands = h.getAtomGroups();
System.out.println("These ligands have been found in chain " + h.getName());
for (Group l:ligands){
System.out.println(l);
}
System.out.println("Accessing QWE directly: ");
Group qwe = s.getNonPolyChainsByPDB("H").get(2).getGroupByPDB(new ResidueNumber("H",373,null));
System.out.println(qwe.getChemComp());
System.out.println(h.getSeqResSequence());
System.out.println(h.getAtomSequence());
System.out.println(h.getAtomGroups(GroupType.HETATM));
System.out.println("Entities: " + s.getEntityInfos());
} catch (Exception e) {
e.printStackTrace();
}
} | java | public void loadFromDirectAccess(){
String pdbId = "1A4W";
StructureProvider pdbreader = new MMCIFFileReader();
try {
Structure s = pdbreader.getStructureById(pdbId);
System.out.println("Getting chain H of 1A4W");
List<Chain> hs = s.getNonPolyChainsByPDB("H");
Chain h = hs.get(0);
List<Group> ligands = h.getAtomGroups();
System.out.println("These ligands have been found in chain " + h.getName());
for (Group l:ligands){
System.out.println(l);
}
System.out.println("Accessing QWE directly: ");
Group qwe = s.getNonPolyChainsByPDB("H").get(2).getGroupByPDB(new ResidueNumber("H",373,null));
System.out.println(qwe.getChemComp());
System.out.println(h.getSeqResSequence());
System.out.println(h.getAtomSequence());
System.out.println(h.getAtomGroups(GroupType.HETATM));
System.out.println("Entities: " + s.getEntityInfos());
} catch (Exception e) {
e.printStackTrace();
}
} | [
"public",
"void",
"loadFromDirectAccess",
"(",
")",
"{",
"String",
"pdbId",
"=",
"\"1A4W\"",
";",
"StructureProvider",
"pdbreader",
"=",
"new",
"MMCIFFileReader",
"(",
")",
";",
"try",
"{",
"Structure",
"s",
"=",
"pdbreader",
".",
"getStructureById",
"(",
"pdb... | An example demonstrating how to directly use the mmCif file parsing classes. This could potentially be used
to use the parser to populate a data-structure that is different from the biojava-structure data model. | [
"An",
"example",
"demonstrating",
"how",
"to",
"directly",
"use",
"the",
"mmCif",
"file",
"parsing",
"classes",
".",
"This",
"could",
"potentially",
"be",
"used",
"to",
"use",
"the",
"parser",
"to",
"populate",
"a",
"data",
"-",
"structure",
"that",
"is",
... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/demo/DemoMMCIFReader.java#L80-L117 |
32,146 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/AFPCalculator.java | AFPCalculator.getFragment | private static final Atom[] getFragment(Atom[] caall, int pos, int fragmentLength ,
boolean clone){
if ( pos+fragmentLength > caall.length)
return null;
Atom[] tmp = new Atom[fragmentLength];
for (int i=0;i< fragmentLength;i++){
if (clone){
tmp[i] = (Atom)caall[i+pos].clone();
} else {
tmp[i] = caall[i+pos];
}
}
return tmp;
} | java | private static final Atom[] getFragment(Atom[] caall, int pos, int fragmentLength ,
boolean clone){
if ( pos+fragmentLength > caall.length)
return null;
Atom[] tmp = new Atom[fragmentLength];
for (int i=0;i< fragmentLength;i++){
if (clone){
tmp[i] = (Atom)caall[i+pos].clone();
} else {
tmp[i] = caall[i+pos];
}
}
return tmp;
} | [
"private",
"static",
"final",
"Atom",
"[",
"]",
"getFragment",
"(",
"Atom",
"[",
"]",
"caall",
",",
"int",
"pos",
",",
"int",
"fragmentLength",
",",
"boolean",
"clone",
")",
"{",
"if",
"(",
"pos",
"+",
"fragmentLength",
">",
"caall",
".",
"length",
")"... | get a continue subset of Atoms based by the starting position and the length
@param caall
@param pos ... the start position
@param fragmentLength .. the length of the subset to extract.
@param clone: returns a copy of the atom (in case the coordinate get manipulated...)
@return an Atom[] array | [
"get",
"a",
"continue",
"subset",
"of",
"Atoms",
"based",
"by",
"the",
"starting",
"position",
"and",
"the",
"length"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/AFPCalculator.java#L214-L231 |
32,147 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/AFPCalculator.java | AFPCalculator.scoreAfp | private static final double scoreAfp(AFP afp, double badRmsd, double fragScore)
{
//longer AFP with low rmsd is better
double s, w;
//s = (rmsdCut - afptmp.rmsd) * afptmp.len; //the same scroing strategy as that in the post-processing
w = afp.getRmsd() / badRmsd;
w = w * w;
s = fragScore * (1.0 - w);
return s;
} | java | private static final double scoreAfp(AFP afp, double badRmsd, double fragScore)
{
//longer AFP with low rmsd is better
double s, w;
//s = (rmsdCut - afptmp.rmsd) * afptmp.len; //the same scroing strategy as that in the post-processing
w = afp.getRmsd() / badRmsd;
w = w * w;
s = fragScore * (1.0 - w);
return s;
} | [
"private",
"static",
"final",
"double",
"scoreAfp",
"(",
"AFP",
"afp",
",",
"double",
"badRmsd",
",",
"double",
"fragScore",
")",
"{",
"//longer AFP with low rmsd is better",
"double",
"s",
",",
"w",
";",
"//s = (rmsdCut - afptmp.rmsd) * afptmp.len; //the same scroing str... | Assign score to each AFP | [
"Assign",
"score",
"to",
"each",
"AFP"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/AFPCalculator.java#L238-L247 |
32,148 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/MenuCreator.java | MenuCreator.getAlignmentPanelMenu | public static JMenuBar getAlignmentPanelMenu(JFrame frame,
ActionListener actionListener, AFPChain afpChain,
MultipleAlignment msa){
JMenuBar menu = new JMenuBar();
JMenu file= new JMenu("File");
file.getAccessibleContext().setAccessibleDescription("File Menu");
menu.add(file);
ImageIcon saveicon = createImageIcon("/icons/filesave.png");
JMenuItem saveF = null;
if (saveicon != null)
saveF = new JMenuItem("Save text display", saveicon);
else
saveF = new JMenuItem("Save text display");
saveF.setMnemonic(KeyEvent.VK_S);
MySaveFileListener listener = new MySaveFileListener(afpChain, msa);
listener.setTextOutput(true);
saveF.addActionListener(listener);
file.add(saveF);
file.addSeparator();
JMenuItem print = getPrintMenuItem();
print.addActionListener(actionListener);
file.add(print);
file.addSeparator();
JMenuItem closeI = MenuCreator.getCloseMenuItem(frame);
file.add(closeI);
JMenuItem exitI = MenuCreator.getExitMenuItem();
file.add(exitI);
JMenu edit = new JMenu("Edit");
edit.setMnemonic(KeyEvent.VK_E);
menu.add(edit);
JMenuItem eqrI = MenuCreator.getIcon(actionListener,SELECT_EQR);
edit.add(eqrI);
JMenuItem eqrcI = MenuCreator.getIcon(actionListener,EQR_COLOR);
edit.add(eqrcI);
JMenuItem simI = MenuCreator.getIcon(actionListener, SIMILARITY_COLOR);
edit.add(simI);
JMenuItem fatcatI = MenuCreator.getIcon(actionListener, FATCAT_BLOCK );
edit.add(fatcatI);
JMenu view= new JMenu("View");
view.getAccessibleContext().setAccessibleDescription("View Menu");
view.setMnemonic(KeyEvent.VK_V);
menu.add(view);
JMenuItem textI = MenuCreator.getIcon(actionListener,TEXT_ONLY);
view.add(textI);
JMenuItem fastaI = MenuCreator.getIcon(actionListener,FASTA_FORMAT);
view.add(fastaI);
JMenuItem pairsI = MenuCreator.getIcon(actionListener,PAIRS_ONLY);
view.add(pairsI);
JMenuItem textF = MenuCreator.getIcon(actionListener,FATCAT_TEXT);
view.add(textF);
JMenu about = new JMenu("Help");
about.setMnemonic(KeyEvent.VK_A);
JMenuItem helpM = MenuCreator.getHelpMenuItem();
about.add(helpM);
JMenuItem aboutM = MenuCreator.getAboutMenuItem();
about.add(aboutM);
menu.add(Box.createGlue());
menu.add(about);
return menu;
} | java | public static JMenuBar getAlignmentPanelMenu(JFrame frame,
ActionListener actionListener, AFPChain afpChain,
MultipleAlignment msa){
JMenuBar menu = new JMenuBar();
JMenu file= new JMenu("File");
file.getAccessibleContext().setAccessibleDescription("File Menu");
menu.add(file);
ImageIcon saveicon = createImageIcon("/icons/filesave.png");
JMenuItem saveF = null;
if (saveicon != null)
saveF = new JMenuItem("Save text display", saveicon);
else
saveF = new JMenuItem("Save text display");
saveF.setMnemonic(KeyEvent.VK_S);
MySaveFileListener listener = new MySaveFileListener(afpChain, msa);
listener.setTextOutput(true);
saveF.addActionListener(listener);
file.add(saveF);
file.addSeparator();
JMenuItem print = getPrintMenuItem();
print.addActionListener(actionListener);
file.add(print);
file.addSeparator();
JMenuItem closeI = MenuCreator.getCloseMenuItem(frame);
file.add(closeI);
JMenuItem exitI = MenuCreator.getExitMenuItem();
file.add(exitI);
JMenu edit = new JMenu("Edit");
edit.setMnemonic(KeyEvent.VK_E);
menu.add(edit);
JMenuItem eqrI = MenuCreator.getIcon(actionListener,SELECT_EQR);
edit.add(eqrI);
JMenuItem eqrcI = MenuCreator.getIcon(actionListener,EQR_COLOR);
edit.add(eqrcI);
JMenuItem simI = MenuCreator.getIcon(actionListener, SIMILARITY_COLOR);
edit.add(simI);
JMenuItem fatcatI = MenuCreator.getIcon(actionListener, FATCAT_BLOCK );
edit.add(fatcatI);
JMenu view= new JMenu("View");
view.getAccessibleContext().setAccessibleDescription("View Menu");
view.setMnemonic(KeyEvent.VK_V);
menu.add(view);
JMenuItem textI = MenuCreator.getIcon(actionListener,TEXT_ONLY);
view.add(textI);
JMenuItem fastaI = MenuCreator.getIcon(actionListener,FASTA_FORMAT);
view.add(fastaI);
JMenuItem pairsI = MenuCreator.getIcon(actionListener,PAIRS_ONLY);
view.add(pairsI);
JMenuItem textF = MenuCreator.getIcon(actionListener,FATCAT_TEXT);
view.add(textF);
JMenu about = new JMenu("Help");
about.setMnemonic(KeyEvent.VK_A);
JMenuItem helpM = MenuCreator.getHelpMenuItem();
about.add(helpM);
JMenuItem aboutM = MenuCreator.getAboutMenuItem();
about.add(aboutM);
menu.add(Box.createGlue());
menu.add(about);
return menu;
} | [
"public",
"static",
"JMenuBar",
"getAlignmentPanelMenu",
"(",
"JFrame",
"frame",
",",
"ActionListener",
"actionListener",
",",
"AFPChain",
"afpChain",
",",
"MultipleAlignment",
"msa",
")",
"{",
"JMenuBar",
"menu",
"=",
"new",
"JMenuBar",
"(",
")",
";",
"JMenu",
... | Create the menu for the Alignment Panel representation of
Structural Alignments. The alignment can be in AFPChain format
or in the MultipleAlignment format.
@param frame
@param actionListener
@param afpChain
@param MultipleAlignment
@return a JMenuBar | [
"Create",
"the",
"menu",
"for",
"the",
"Alignment",
"Panel",
"representation",
"of",
"Structural",
"Alignments",
".",
"The",
"alignment",
"can",
"be",
"in",
"AFPChain",
"format",
"or",
"in",
"the",
"MultipleAlignment",
"format",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/MenuCreator.java#L296-L381 |
32,149 | biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java | FeatureList.add | @Override
public boolean add(FeatureI feature) {
if (mLocation == null) {
mLocation = feature.location().plus();
} else if (null != feature.location()) {
mLocation = mLocation.union(feature.location().plus());
}
for (Entry<String, String> entry : feature.getAttributes().entrySet()){
if (featindex.containsKey(entry.getKey())){
Map<String,List<FeatureI>> feat = featindex.get(entry.getKey());
if (feat==null){
feat= new HashMap<String,List<FeatureI>>();
}
List<FeatureI> features = feat.get(entry.getValue());
if (features==null){
features = new ArrayList<FeatureI>();
}
features.add(feature);
feat.put(entry.getValue(), features);
featindex.put(entry.getKey(), feat);
//featindex.put(key, value)
}
}
return super.add(feature);
} | java | @Override
public boolean add(FeatureI feature) {
if (mLocation == null) {
mLocation = feature.location().plus();
} else if (null != feature.location()) {
mLocation = mLocation.union(feature.location().plus());
}
for (Entry<String, String> entry : feature.getAttributes().entrySet()){
if (featindex.containsKey(entry.getKey())){
Map<String,List<FeatureI>> feat = featindex.get(entry.getKey());
if (feat==null){
feat= new HashMap<String,List<FeatureI>>();
}
List<FeatureI> features = feat.get(entry.getValue());
if (features==null){
features = new ArrayList<FeatureI>();
}
features.add(feature);
feat.put(entry.getValue(), features);
featindex.put(entry.getKey(), feat);
//featindex.put(key, value)
}
}
return super.add(feature);
} | [
"@",
"Override",
"public",
"boolean",
"add",
"(",
"FeatureI",
"feature",
")",
"{",
"if",
"(",
"mLocation",
"==",
"null",
")",
"{",
"mLocation",
"=",
"feature",
".",
"location",
"(",
")",
".",
"plus",
"(",
")",
";",
"}",
"else",
"if",
"(",
"null",
"... | Add specified feature to the end of the list. Updates the bounding location of the
feature list, if needed.
@param feature The FeatureI object to add.
@return True if the feature was added. | [
"Add",
"specified",
"feature",
"to",
"the",
"end",
"of",
"the",
"list",
".",
"Updates",
"the",
"bounding",
"location",
"of",
"the",
"feature",
"list",
"if",
"needed",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java#L73-L98 |
32,150 | biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java | FeatureList.hasGaps | public boolean hasGaps(int gapLength) {
Location last = null;
for (FeatureI f : this) {
if (last != null && gapLength <= f.location().distance(last)) {
return true;
} else {
last = f.location();
}
}
return false;
} | java | public boolean hasGaps(int gapLength) {
Location last = null;
for (FeatureI f : this) {
if (last != null && gapLength <= f.location().distance(last)) {
return true;
} else {
last = f.location();
}
}
return false;
} | [
"public",
"boolean",
"hasGaps",
"(",
"int",
"gapLength",
")",
"{",
"Location",
"last",
"=",
"null",
";",
"for",
"(",
"FeatureI",
"f",
":",
"this",
")",
"{",
"if",
"(",
"last",
"!=",
"null",
"&&",
"gapLength",
"<=",
"f",
".",
"location",
"(",
")",
"... | Check size of gaps between successive features in list. The features in
the list are assumed to be appropriately ordered.
@param gapLength The minimum gap length to consider. Use a gapLength
of 0 to check if features are contiguous.
@return True if list has any gaps equal to or greater than gapLength. | [
"Check",
"size",
"of",
"gaps",
"between",
"successive",
"features",
"in",
"list",
".",
"The",
"features",
"in",
"the",
"list",
"are",
"assumed",
"to",
"be",
"appropriately",
"ordered",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java#L132-L143 |
32,151 | biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java | FeatureList.splice | public String splice(DNASequence sequence) {
StringBuilder subData = new StringBuilder();
Location last = null;
for (FeatureI f : this) {
Location loc = f.location();
if (last == null || loc.startsAfter(last)) {
subData.append(sequence.getSubSequence(loc.start(), loc.end()).toString());
last = loc;
} else {
throw new IllegalStateException("Splice: Feature locations should not overlap.");
}
}
return subData.toString();
} | java | public String splice(DNASequence sequence) {
StringBuilder subData = new StringBuilder();
Location last = null;
for (FeatureI f : this) {
Location loc = f.location();
if (last == null || loc.startsAfter(last)) {
subData.append(sequence.getSubSequence(loc.start(), loc.end()).toString());
last = loc;
} else {
throw new IllegalStateException("Splice: Feature locations should not overlap.");
}
}
return subData.toString();
} | [
"public",
"String",
"splice",
"(",
"DNASequence",
"sequence",
")",
"{",
"StringBuilder",
"subData",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Location",
"last",
"=",
"null",
";",
"for",
"(",
"FeatureI",
"f",
":",
"this",
")",
"{",
"Location",
"loc",
"... | Concatenate successive portions of the specified sequence
using the feature locations in the list. The list is assumed to be appropriately
ordered.
@param sequence The source sequence from which portions should be selected.
@return The spliced data.
@throws IllegalStateException Out of order or overlapping FeatureI locations detected. | [
"Concatenate",
"successive",
"portions",
"of",
"the",
"specified",
"sequence",
"using",
"the",
"feature",
"locations",
"in",
"the",
"list",
".",
"The",
"list",
"is",
"assumed",
"to",
"be",
"appropriately",
"ordered",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java#L158-L175 |
32,152 | biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java | FeatureList.selectByAttribute | public FeatureList selectByAttribute(String key) {
FeatureList list = new FeatureList();
if (featindex.containsKey(key)){
Map<String, List<FeatureI>> featsmap =featindex.get(key);
if(null != featsmap) {
for (List<FeatureI> feats: featsmap.values()){
list.addAll(Collections.unmodifiableCollection(feats));
}
return list;
}
}
for (FeatureI f : this) {
if (f.hasAttribute(key)) {
list.add(f);
}
}
return list;
} | java | public FeatureList selectByAttribute(String key) {
FeatureList list = new FeatureList();
if (featindex.containsKey(key)){
Map<String, List<FeatureI>> featsmap =featindex.get(key);
if(null != featsmap) {
for (List<FeatureI> feats: featsmap.values()){
list.addAll(Collections.unmodifiableCollection(feats));
}
return list;
}
}
for (FeatureI f : this) {
if (f.hasAttribute(key)) {
list.add(f);
}
}
return list;
} | [
"public",
"FeatureList",
"selectByAttribute",
"(",
"String",
"key",
")",
"{",
"FeatureList",
"list",
"=",
"new",
"FeatureList",
"(",
")",
";",
"if",
"(",
"featindex",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
... | Create a list of all features that include the specified attribute key.
@param key The key to consider.
@return A list of features that include the key. | [
"Create",
"a",
"list",
"of",
"all",
"features",
"that",
"include",
"the",
"specified",
"attribute",
"key",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java#L292-L310 |
32,153 | biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java | FeatureList.selectOverlapping | public FeatureList selectOverlapping(String seqname, Location location, boolean useBothStrands)
throws Exception {
FeatureList list = new FeatureList();
for (FeatureI feature : this) {
boolean overlaps = false;
if (feature.seqname().equals(seqname)) {
if (location.isSameStrand(feature.location())) {
overlaps = feature.location().overlaps(location);
} else if (useBothStrands) {
overlaps = feature.location().overlaps(location.opposite());
}
}
if (overlaps) {
list.add(feature);
}
}
return list;
} | java | public FeatureList selectOverlapping(String seqname, Location location, boolean useBothStrands)
throws Exception {
FeatureList list = new FeatureList();
for (FeatureI feature : this) {
boolean overlaps = false;
if (feature.seqname().equals(seqname)) {
if (location.isSameStrand(feature.location())) {
overlaps = feature.location().overlaps(location);
} else if (useBothStrands) {
overlaps = feature.location().overlaps(location.opposite());
}
}
if (overlaps) {
list.add(feature);
}
}
return list;
} | [
"public",
"FeatureList",
"selectOverlapping",
"(",
"String",
"seqname",
",",
"Location",
"location",
",",
"boolean",
"useBothStrands",
")",
"throws",
"Exception",
"{",
"FeatureList",
"list",
"=",
"new",
"FeatureList",
"(",
")",
";",
"for",
"(",
"FeatureI",
"feat... | Create a list of all features that overlap the specified location on the specified
sequence.
@param seqname The sequence name. Only features with this sequence name will be checked for overlap.
@param location The location to check.
@param useBothStrands If true, locations are mapped to their positive strand image
before being checked for overlap. If false, only features whose locations are
on the same strand as the specified location will be considered for inclusion.
@return The new list of features that overlap the location. | [
"Create",
"a",
"list",
"of",
"all",
"features",
"that",
"overlap",
"the",
"specified",
"location",
"on",
"the",
"specified",
"sequence",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java#L356-L374 |
32,154 | biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java | FeatureList.hasAttribute | public boolean hasAttribute(String key) {
if (featindex.containsKey(key)){
Map<String, List<FeatureI>> mappa = featindex.get(key);
if (mappa!= null && mappa.size()>0)return true;
return false;
}
for (FeatureI f : this) {
if (f.hasAttribute(key)) {
return true;
}
}
return false;
} | java | public boolean hasAttribute(String key) {
if (featindex.containsKey(key)){
Map<String, List<FeatureI>> mappa = featindex.get(key);
if (mappa!= null && mappa.size()>0)return true;
return false;
}
for (FeatureI f : this) {
if (f.hasAttribute(key)) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"hasAttribute",
"(",
"String",
"key",
")",
"{",
"if",
"(",
"featindex",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"Map",
"<",
"String",
",",
"List",
"<",
"FeatureI",
">",
">",
"mappa",
"=",
"featindex",
".",
"get",
"(",
"key... | Check if any feature in list has the specified attribute key.
@param key The attribute key to consider.
@return True if at least one feature has the attribute key. | [
"Check",
"if",
"any",
"feature",
"in",
"list",
"has",
"the",
"specified",
"attribute",
"key",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java#L413-L426 |
32,155 | biojava/biojava | biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java | FeatureList.sortByStart | public FeatureList sortByStart() {
FeatureI[] array = toArray(new FeatureI[1]);
Arrays.sort(array, new FeatureComparator());
return new FeatureList(Arrays.asList(array));
} | java | public FeatureList sortByStart() {
FeatureI[] array = toArray(new FeatureI[1]);
Arrays.sort(array, new FeatureComparator());
return new FeatureList(Arrays.asList(array));
} | [
"public",
"FeatureList",
"sortByStart",
"(",
")",
"{",
"FeatureI",
"[",
"]",
"array",
"=",
"toArray",
"(",
"new",
"FeatureI",
"[",
"1",
"]",
")",
";",
"Arrays",
".",
"sort",
"(",
"array",
",",
"new",
"FeatureComparator",
"(",
")",
")",
";",
"return",
... | Create a new list that is ordered by the starting index of the features' locations. All locations
must be on the same strand of the same sequence.
@return An ordered list.
@throws IndexOutOfBoundsException Cannot compare/sort features whose locations are on opposite strands, or
whose seqnames differ. | [
"Create",
"a",
"new",
"list",
"that",
"is",
"ordered",
"by",
"the",
"starting",
"index",
"of",
"the",
"features",
"locations",
".",
"All",
"locations",
"must",
"be",
"on",
"the",
"same",
"strand",
"of",
"the",
"same",
"sequence",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/FeatureList.java#L492-L498 |
32,156 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifParser.java | SimpleMMcifParser.processLine | private List<String> processLine(String line,
BufferedReader buf,
int fieldLength)
throws IOException{
//System.out.println("XX processLine " + fieldLength + " " + line);
// go through the line and process each character
List<String> lineData = new ArrayList<String>();
boolean inString = false;
StringBuilder bigWord = null;
while ( true ){
if ( line.startsWith(STRING_LIMIT)){
if (! inString){
inString = true;
if ( line.length() > 1)
bigWord = new StringBuilder(line.substring(1));
else
bigWord = new StringBuilder("");
} else {
// the end of a word
lineData.add(bigWord.toString());
bigWord = null;
inString = false;
}
} else {
if ( inString )
bigWord.append(line);
else {
List<String> dat = processSingleLine(line);
for (String d : dat){
lineData.add(d);
}
}
}
//System.out.println("in process line : " + lineData.size() + " " + fieldLength);
if ( lineData.size() > fieldLength){
logger.warn("wrong data length ("+lineData.size()+
") should be ("+fieldLength+") at line " + line + " got lineData: " + lineData);
return lineData;
}
if ( lineData.size() == fieldLength)
return lineData;
line = buf.readLine();
if ( line == null)
break;
}
return lineData;
} | java | private List<String> processLine(String line,
BufferedReader buf,
int fieldLength)
throws IOException{
//System.out.println("XX processLine " + fieldLength + " " + line);
// go through the line and process each character
List<String> lineData = new ArrayList<String>();
boolean inString = false;
StringBuilder bigWord = null;
while ( true ){
if ( line.startsWith(STRING_LIMIT)){
if (! inString){
inString = true;
if ( line.length() > 1)
bigWord = new StringBuilder(line.substring(1));
else
bigWord = new StringBuilder("");
} else {
// the end of a word
lineData.add(bigWord.toString());
bigWord = null;
inString = false;
}
} else {
if ( inString )
bigWord.append(line);
else {
List<String> dat = processSingleLine(line);
for (String d : dat){
lineData.add(d);
}
}
}
//System.out.println("in process line : " + lineData.size() + " " + fieldLength);
if ( lineData.size() > fieldLength){
logger.warn("wrong data length ("+lineData.size()+
") should be ("+fieldLength+") at line " + line + " got lineData: " + lineData);
return lineData;
}
if ( lineData.size() == fieldLength)
return lineData;
line = buf.readLine();
if ( line == null)
break;
}
return lineData;
} | [
"private",
"List",
"<",
"String",
">",
"processLine",
"(",
"String",
"line",
",",
"BufferedReader",
"buf",
",",
"int",
"fieldLength",
")",
"throws",
"IOException",
"{",
"//System.out.println(\"XX processLine \" + fieldLength + \" \" + line);",
"// go through the line and proc... | Get the content of a cif entry
@param line
@param buf
@return | [
"Get",
"the",
"content",
"of",
"a",
"cif",
"entry"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifParser.java#L535-L599 |
32,157 | biojava/biojava | biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/BiojavaJmol.java | BiojavaJmol.jmolInClassPath | public static boolean jmolInClassPath(){
try {
Class.forName(viewer);
} catch (ClassNotFoundException e){
e.printStackTrace();
return false;
}
return true;
} | java | public static boolean jmolInClassPath(){
try {
Class.forName(viewer);
} catch (ClassNotFoundException e){
e.printStackTrace();
return false;
}
return true;
} | [
"public",
"static",
"boolean",
"jmolInClassPath",
"(",
")",
"{",
"try",
"{",
"Class",
".",
"forName",
"(",
"viewer",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"false",
";",... | returns true if Jmol can be found in the classpath, otherwise false.
@return true/false depending if Jmol can be found | [
"returns",
"true",
"if",
"Jmol",
"can",
"be",
"found",
"in",
"the",
"classpath",
"otherwise",
"false",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/BiojavaJmol.java#L204-L212 |
32,158 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/util/InputStreamProvider.java | InputStreamProvider.getInputStream | public InputStream getInputStream(String pathToFile)
throws IOException
{
File f = new File(pathToFile);
return getInputStream(f);
} | java | public InputStream getInputStream(String pathToFile)
throws IOException
{
File f = new File(pathToFile);
return getInputStream(f);
} | [
"public",
"InputStream",
"getInputStream",
"(",
"String",
"pathToFile",
")",
"throws",
"IOException",
"{",
"File",
"f",
"=",
"new",
"File",
"(",
"pathToFile",
")",
";",
"return",
"getInputStream",
"(",
"f",
")",
";",
"}"
] | Get an InputStream for given file path.
The caller is responsible for closing the stream or otherwise
a resource leak can occur.
@param pathToFile the path of the file.
@return an InputStream for the file located at the path.
@throws IOException | [
"Get",
"an",
"InputStream",
"for",
"given",
"file",
"path",
".",
"The",
"caller",
"is",
"responsible",
"for",
"closing",
"the",
"stream",
"or",
"otherwise",
"a",
"resource",
"leak",
"can",
"occur",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/util/InputStreamProvider.java#L88-L93 |
32,159 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/util/InputStreamProvider.java | InputStreamProvider.getMagicNumber | private int getMagicNumber(InputStream in)
throws IOException {
int t = in.read();
if (t < 0) throw new EOFException("Failed to read magic number");
int magic = (t & 0xff) << 8;
t = in.read();
if (t < 0) throw new EOFException("Failed to read magic number");
magic += t & 0xff;
return magic;
} | java | private int getMagicNumber(InputStream in)
throws IOException {
int t = in.read();
if (t < 0) throw new EOFException("Failed to read magic number");
int magic = (t & 0xff) << 8;
t = in.read();
if (t < 0) throw new EOFException("Failed to read magic number");
magic += t & 0xff;
return magic;
} | [
"private",
"int",
"getMagicNumber",
"(",
"InputStream",
"in",
")",
"throws",
"IOException",
"{",
"int",
"t",
"=",
"in",
".",
"read",
"(",
")",
";",
"if",
"(",
"t",
"<",
"0",
")",
"throw",
"new",
"EOFException",
"(",
"\"Failed to read magic number\"",
")",
... | open the file and read the magic number from the beginning
this is used to determine the compression type
@param in an input stream to read from
@return the magic number
@throws IOException | [
"open",
"the",
"file",
"and",
"read",
"the",
"magic",
"number",
"from",
"the",
"beginning",
"this",
"is",
"used",
"to",
"determine",
"the",
"compression",
"type"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/util/InputStreamProvider.java#L103-L115 |
32,160 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/util/InputStreamProvider.java | InputStreamProvider.getInputStream | public InputStream getInputStream(File f)
throws IOException
{
// use the magic numbers to determine the compression type,
// use file extension only as 2nd choice
int magic = 0;
InputStream test = getInputStreamFromFile(f);
magic = getMagicNumber(test);
test.close();
InputStream inputStream = null;
String fileName = f.getName();
if (magic == UncompressInputStream.LZW_MAGIC ) {
// a Z compressed file
return openCompressedFile(f);
}
else if (magic == GZIP_MAGIC ) {
return openGZIPFile(f);
}
else if ( fileName.endsWith(".gz")) {
return openGZIPFile(f);
}
else if ( fileName.endsWith(".zip")){
ZipFile zipfile = new ZipFile(f);
// stream to first entry is returned ...
ZipEntry entry;
Enumeration<? extends ZipEntry> e = zipfile.entries();
if ( e.hasMoreElements()){
entry = e.nextElement();
inputStream = zipfile.getInputStream(entry);
} else {
throw new IOException ("Zip file has no entries");
}
}
else if ( fileName.endsWith(".jar")) {
JarFile jarFile = new JarFile(f);
// stream to first entry is returned
JarEntry entry;
Enumeration<JarEntry> e = jarFile.entries();
if ( e.hasMoreElements()){
entry = e.nextElement();
inputStream = jarFile.getInputStream(entry);
} else {
throw new IOException ("Jar file has no entries");
}
}
else if ( fileName.endsWith(".Z")) {
// unix compressed
return openCompressedFile(f);
}
else {
// no particular extension found, assume that it is an uncompressed file
inputStream = getInputStreamFromFile(f);
}
return inputStream;
} | java | public InputStream getInputStream(File f)
throws IOException
{
// use the magic numbers to determine the compression type,
// use file extension only as 2nd choice
int magic = 0;
InputStream test = getInputStreamFromFile(f);
magic = getMagicNumber(test);
test.close();
InputStream inputStream = null;
String fileName = f.getName();
if (magic == UncompressInputStream.LZW_MAGIC ) {
// a Z compressed file
return openCompressedFile(f);
}
else if (magic == GZIP_MAGIC ) {
return openGZIPFile(f);
}
else if ( fileName.endsWith(".gz")) {
return openGZIPFile(f);
}
else if ( fileName.endsWith(".zip")){
ZipFile zipfile = new ZipFile(f);
// stream to first entry is returned ...
ZipEntry entry;
Enumeration<? extends ZipEntry> e = zipfile.entries();
if ( e.hasMoreElements()){
entry = e.nextElement();
inputStream = zipfile.getInputStream(entry);
} else {
throw new IOException ("Zip file has no entries");
}
}
else if ( fileName.endsWith(".jar")) {
JarFile jarFile = new JarFile(f);
// stream to first entry is returned
JarEntry entry;
Enumeration<JarEntry> e = jarFile.entries();
if ( e.hasMoreElements()){
entry = e.nextElement();
inputStream = jarFile.getInputStream(entry);
} else {
throw new IOException ("Jar file has no entries");
}
}
else if ( fileName.endsWith(".Z")) {
// unix compressed
return openCompressedFile(f);
}
else {
// no particular extension found, assume that it is an uncompressed file
inputStream = getInputStreamFromFile(f);
}
return inputStream;
} | [
"public",
"InputStream",
"getInputStream",
"(",
"File",
"f",
")",
"throws",
"IOException",
"{",
"// use the magic numbers to determine the compression type,",
"// use file extension only as 2nd choice",
"int",
"magic",
"=",
"0",
";",
"InputStream",
"test",
"=",
"getInputStrea... | Get an InputStream for the file.
The caller is responsible for closing the stream or otherwise
a resource leak can occur.
@param f a File
@return an InputStream for the file
@throws IOException | [
"Get",
"an",
"InputStream",
"for",
"the",
"file",
".",
"The",
"caller",
"is",
"responsible",
"for",
"closing",
"the",
"stream",
"or",
"otherwise",
"a",
"resource",
"leak",
"can",
"occur",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/util/InputStreamProvider.java#L156-L232 |
32,161 | biojava/biojava | biojava-core/src/main/java/org/biojava/nbio/core/util/InputStreamProvider.java | InputStreamProvider.getInputStreamFromFile | private InputStream getInputStreamFromFile(File f) throws FileNotFoundException{
InputStream stream = null;
if ( cacheRawFiles ){
stream = FlatFileCache.getInputStream(f.getAbsolutePath());
if ( stream == null){
FlatFileCache.addToCache(f.getAbsolutePath(),f);
stream = FlatFileCache.getInputStream(f.getAbsolutePath());
}
}
if ( stream == null)
stream = new FileInputStream(f);
return stream;
} | java | private InputStream getInputStreamFromFile(File f) throws FileNotFoundException{
InputStream stream = null;
if ( cacheRawFiles ){
stream = FlatFileCache.getInputStream(f.getAbsolutePath());
if ( stream == null){
FlatFileCache.addToCache(f.getAbsolutePath(),f);
stream = FlatFileCache.getInputStream(f.getAbsolutePath());
}
}
if ( stream == null)
stream = new FileInputStream(f);
return stream;
} | [
"private",
"InputStream",
"getInputStreamFromFile",
"(",
"File",
"f",
")",
"throws",
"FileNotFoundException",
"{",
"InputStream",
"stream",
"=",
"null",
";",
"if",
"(",
"cacheRawFiles",
")",
"{",
"stream",
"=",
"FlatFileCache",
".",
"getInputStream",
"(",
"f",
"... | Wrapper for new FileInputStream. if System.property biojava.cache.files is set, will try to load files from memory cache.
@param f
@return
@throws FileNotFoundException | [
"Wrapper",
"for",
"new",
"FileInputStream",
".",
"if",
"System",
".",
"property",
"biojava",
".",
"cache",
".",
"files",
"is",
"set",
"will",
"try",
"to",
"load",
"files",
"from",
"memory",
"cache",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/util/InputStreamProvider.java#L242-L260 |
32,162 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/model/AFPChain.java | AFPChain.getNrEQR | public int getNrEQR(){
if (myResultsEQR < 0){
if ( optLen == null) {
myResultsEQR = 0;
return 0;
}
int nrEqr = 0;
for(int bk = 0; bk < blockNum; bk ++) {
for ( int i=0;i< optLen[bk];i++){
nrEqr++;
}
}
myResultsEQR = nrEqr;
}
return myResultsEQR;
} | java | public int getNrEQR(){
if (myResultsEQR < 0){
if ( optLen == null) {
myResultsEQR = 0;
return 0;
}
int nrEqr = 0;
for(int bk = 0; bk < blockNum; bk ++) {
for ( int i=0;i< optLen[bk];i++){
nrEqr++;
}
}
myResultsEQR = nrEqr;
}
return myResultsEQR;
} | [
"public",
"int",
"getNrEQR",
"(",
")",
"{",
"if",
"(",
"myResultsEQR",
"<",
"0",
")",
"{",
"if",
"(",
"optLen",
"==",
"null",
")",
"{",
"myResultsEQR",
"=",
"0",
";",
"return",
"0",
";",
"}",
"int",
"nrEqr",
"=",
"0",
";",
"for",
"(",
"int",
"b... | Get the number of structurally equivalent residues
@return nr of EQR | [
"Get",
"the",
"number",
"of",
"structurally",
"equivalent",
"residues"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/model/AFPChain.java#L302-L320 |
32,163 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/model/AFPChain.java | AFPChain.getCoverage1 | public int getCoverage1(){
if ( myResultsSimilarity1 < 0 ) {
int distance = ca1Length + ca2Length - 2 * getNrEQR();
int similarity = (ca1Length + ca2Length - distance ) / 2;
myResultsSimilarity1 = Math.round(similarity /(float) ca1Length * 100);
}
return myResultsSimilarity1;
} | java | public int getCoverage1(){
if ( myResultsSimilarity1 < 0 ) {
int distance = ca1Length + ca2Length - 2 * getNrEQR();
int similarity = (ca1Length + ca2Length - distance ) / 2;
myResultsSimilarity1 = Math.round(similarity /(float) ca1Length * 100);
}
return myResultsSimilarity1;
} | [
"public",
"int",
"getCoverage1",
"(",
")",
"{",
"if",
"(",
"myResultsSimilarity1",
"<",
"0",
")",
"{",
"int",
"distance",
"=",
"ca1Length",
"+",
"ca2Length",
"-",
"2",
"*",
"getNrEQR",
"(",
")",
";",
"int",
"similarity",
"=",
"(",
"ca1Length",
"+",
"ca... | Get the coverage of protein 1 with the alignment
@return percentage of coverage, between 0 and 100. | [
"Get",
"the",
"coverage",
"of",
"protein",
"1",
"with",
"the",
"alignment"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/model/AFPChain.java#L326-L335 |
32,164 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/align/model/AFPChain.java | AFPChain.getCoverage2 | public int getCoverage2(){
if ( myResultsSimilarity2 < 0 ) {
int distance = ca1Length + ca2Length - 2 * getNrEQR();
int similarity = (ca1Length + ca2Length - distance ) / 2;
myResultsSimilarity2 = Math.round(similarity /(float) ca2Length * 100);
}
return myResultsSimilarity2;
} | java | public int getCoverage2(){
if ( myResultsSimilarity2 < 0 ) {
int distance = ca1Length + ca2Length - 2 * getNrEQR();
int similarity = (ca1Length + ca2Length - distance ) / 2;
myResultsSimilarity2 = Math.round(similarity /(float) ca2Length * 100);
}
return myResultsSimilarity2;
} | [
"public",
"int",
"getCoverage2",
"(",
")",
"{",
"if",
"(",
"myResultsSimilarity2",
"<",
"0",
")",
"{",
"int",
"distance",
"=",
"ca1Length",
"+",
"ca2Length",
"-",
"2",
"*",
"getNrEQR",
"(",
")",
";",
"int",
"similarity",
"=",
"(",
"ca1Length",
"+",
"ca... | Get the coverage of protein 2 with the alignment
@return percentage of coverage, between 0 and 100. | [
"Get",
"the",
"coverage",
"of",
"protein",
"2",
"with",
"the",
"alignment"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/model/AFPChain.java#L341-L352 |
32,165 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java | PDBStatus.getStatus | public static Status getStatus(String pdbId) {
Status[] statuses = getStatus(new String[] {pdbId});
if(statuses != null) {
assert(statuses.length == 1);
return statuses[0];
} else {
return null;
}
} | java | public static Status getStatus(String pdbId) {
Status[] statuses = getStatus(new String[] {pdbId});
if(statuses != null) {
assert(statuses.length == 1);
return statuses[0];
} else {
return null;
}
} | [
"public",
"static",
"Status",
"getStatus",
"(",
"String",
"pdbId",
")",
"{",
"Status",
"[",
"]",
"statuses",
"=",
"getStatus",
"(",
"new",
"String",
"[",
"]",
"{",
"pdbId",
"}",
")",
";",
"if",
"(",
"statuses",
"!=",
"null",
")",
"{",
"assert",
"(",
... | Get the status of the PDB in question.
@param pdbId
@return The status, or null if an error occurred. | [
"Get",
"the",
"status",
"of",
"the",
"PDB",
"in",
"question",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java#L162-L170 |
32,166 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java | PDBStatus.getStatus | public static Status[] getStatus(String[] pdbIds) {
Status[] statuses = new Status[pdbIds.length];
List<Map<String,String>> attrList = getStatusIdRecords(pdbIds);
//Expect a single record
if(attrList == null || attrList.size() != pdbIds.length) {
logger.error("Error getting Status for {} from the PDB website.", Arrays.toString(pdbIds));
return null;
}
for(int pdbNum = 0;pdbNum<pdbIds.length;pdbNum++) {
//Locate first element of attrList with matching structureId.
//attrList is usually short, so don't worry about performance
boolean foundAttr = false;
for( Map<String,String> attrs : attrList) {
//Check that the record matches pdbId
String id = attrs.get("structureId");
if(id == null || !id.equalsIgnoreCase(pdbIds[pdbNum])) {
continue;
}
//Check that the status is given
String statusStr = attrs.get("status");
Status status = null;
if(statusStr == null ) {
logger.error("No status returned for {}", pdbIds[pdbNum]);
statuses[pdbNum] = null;
} else {
status = Status.fromString(statusStr);
}
if(status == null) {
logger.error("Unknown status '{}'", statusStr);
statuses[pdbNum] = null;
}
statuses[pdbNum] = status;
foundAttr = true;
}
if(!foundAttr) {
logger.error("No result found for {}", pdbIds[pdbNum]);
statuses[pdbNum] = null;
}
}
return statuses;
} | java | public static Status[] getStatus(String[] pdbIds) {
Status[] statuses = new Status[pdbIds.length];
List<Map<String,String>> attrList = getStatusIdRecords(pdbIds);
//Expect a single record
if(attrList == null || attrList.size() != pdbIds.length) {
logger.error("Error getting Status for {} from the PDB website.", Arrays.toString(pdbIds));
return null;
}
for(int pdbNum = 0;pdbNum<pdbIds.length;pdbNum++) {
//Locate first element of attrList with matching structureId.
//attrList is usually short, so don't worry about performance
boolean foundAttr = false;
for( Map<String,String> attrs : attrList) {
//Check that the record matches pdbId
String id = attrs.get("structureId");
if(id == null || !id.equalsIgnoreCase(pdbIds[pdbNum])) {
continue;
}
//Check that the status is given
String statusStr = attrs.get("status");
Status status = null;
if(statusStr == null ) {
logger.error("No status returned for {}", pdbIds[pdbNum]);
statuses[pdbNum] = null;
} else {
status = Status.fromString(statusStr);
}
if(status == null) {
logger.error("Unknown status '{}'", statusStr);
statuses[pdbNum] = null;
}
statuses[pdbNum] = status;
foundAttr = true;
}
if(!foundAttr) {
logger.error("No result found for {}", pdbIds[pdbNum]);
statuses[pdbNum] = null;
}
}
return statuses;
} | [
"public",
"static",
"Status",
"[",
"]",
"getStatus",
"(",
"String",
"[",
"]",
"pdbIds",
")",
"{",
"Status",
"[",
"]",
"statuses",
"=",
"new",
"Status",
"[",
"pdbIds",
".",
"length",
"]",
";",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
"... | Get the status of the a collection of PDBs in question in a single query.
@see #getStatus(String)
@param pdbIds
@return The status array, or null if an error occurred. | [
"Get",
"the",
"status",
"of",
"the",
"a",
"collection",
"of",
"PDBs",
"in",
"question",
"in",
"a",
"single",
"query",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java#L179-L227 |
32,167 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java | PDBStatus.mergeReversed | private static void mergeReversed(List<String> merged,
final List<String> other) {
if(other.isEmpty())
return;
if(merged.isEmpty()) {
merged.addAll(other);
return;
}
ListIterator<String> m = merged.listIterator();
ListIterator<String> o = other.listIterator();
String nextM, prevO;
prevO = o.next();
while(m.hasNext()) {
// peek at m
nextM = m.next();
m.previous();
//insert from O until exhausted or occurs after nextM
while(prevO.compareTo(nextM) > 0) {
m.add(prevO);
if(!o.hasNext()) {
return;
}
prevO = o.next();
}
//remove duplicates
if(prevO.equals(nextM)) {
if(!o.hasNext()) {
return;
}
prevO = o.next();
}
m.next();
}
m.add(prevO);
while(o.hasNext()) {
m.add(o.next());
}
} | java | private static void mergeReversed(List<String> merged,
final List<String> other) {
if(other.isEmpty())
return;
if(merged.isEmpty()) {
merged.addAll(other);
return;
}
ListIterator<String> m = merged.listIterator();
ListIterator<String> o = other.listIterator();
String nextM, prevO;
prevO = o.next();
while(m.hasNext()) {
// peek at m
nextM = m.next();
m.previous();
//insert from O until exhausted or occurs after nextM
while(prevO.compareTo(nextM) > 0) {
m.add(prevO);
if(!o.hasNext()) {
return;
}
prevO = o.next();
}
//remove duplicates
if(prevO.equals(nextM)) {
if(!o.hasNext()) {
return;
}
prevO = o.next();
}
m.next();
}
m.add(prevO);
while(o.hasNext()) {
m.add(o.next());
}
} | [
"private",
"static",
"void",
"mergeReversed",
"(",
"List",
"<",
"String",
">",
"merged",
",",
"final",
"List",
"<",
"String",
">",
"other",
")",
"{",
"if",
"(",
"other",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"if",
"(",
"merged",
".",
"isEmpty... | Takes two reverse sorted lists of strings and merges the second into the
first. Duplicates are removed.
@param merged A reverse sorted list. Modified by this method to contain
the contents of other.
@param other A reverse sorted list. Not modified. | [
"Takes",
"two",
"reverse",
"sorted",
"lists",
"of",
"strings",
"and",
"merges",
"the",
"second",
"into",
"the",
"first",
".",
"Duplicates",
"are",
"removed",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java#L406-L450 |
32,168 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java | PDBStatus.getReplaces | public static List<String> getReplaces(String newPdbId, boolean recurse) {
List<Map<String,String>> attrList = getStatusIdRecords(new String[] {newPdbId});
//Expect a single record
if(attrList == null || attrList.size() != 1) {
//TODO Is it possible to have multiple record per ID?
// They seem to be combined into one record with space-delimited 'replaces'
logger.error("Error getting Status for {} from the PDB website.", newPdbId);
return null;
}
Map<String,String> attrs = attrList.get(0);
//Check that the record matches pdbId
String id = attrs.get("structureId");
if(id == null || !id.equals(newPdbId)) {
logger.error("Results returned from the query don't match {}", newPdbId);
return null;
}
String replacedList = attrs.get("replaces"); //space-delimited list
if(replacedList == null) {
// no replaces value; assume root
return new ArrayList<String>();
}
String[] directDescendents = replacedList.split("\\s");
// Not the root! Return the replaced PDB.
if(recurse) {
// Note: Assumes a proper directed acyclic graph of revisions
// Cycles will cause infinite loops.
List<String> allDescendents = new LinkedList<String>();
for(String replaced : directDescendents) {
List<String> roots = PDBStatus.getReplaces(replaced, recurse);
mergeReversed(allDescendents,roots);
}
mergeReversed(allDescendents,Arrays.asList(directDescendents));
return allDescendents;
} else {
return Arrays.asList(directDescendents);
}
} | java | public static List<String> getReplaces(String newPdbId, boolean recurse) {
List<Map<String,String>> attrList = getStatusIdRecords(new String[] {newPdbId});
//Expect a single record
if(attrList == null || attrList.size() != 1) {
//TODO Is it possible to have multiple record per ID?
// They seem to be combined into one record with space-delimited 'replaces'
logger.error("Error getting Status for {} from the PDB website.", newPdbId);
return null;
}
Map<String,String> attrs = attrList.get(0);
//Check that the record matches pdbId
String id = attrs.get("structureId");
if(id == null || !id.equals(newPdbId)) {
logger.error("Results returned from the query don't match {}", newPdbId);
return null;
}
String replacedList = attrs.get("replaces"); //space-delimited list
if(replacedList == null) {
// no replaces value; assume root
return new ArrayList<String>();
}
String[] directDescendents = replacedList.split("\\s");
// Not the root! Return the replaced PDB.
if(recurse) {
// Note: Assumes a proper directed acyclic graph of revisions
// Cycles will cause infinite loops.
List<String> allDescendents = new LinkedList<String>();
for(String replaced : directDescendents) {
List<String> roots = PDBStatus.getReplaces(replaced, recurse);
mergeReversed(allDescendents,roots);
}
mergeReversed(allDescendents,Arrays.asList(directDescendents));
return allDescendents;
} else {
return Arrays.asList(directDescendents);
}
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getReplaces",
"(",
"String",
"newPdbId",
",",
"boolean",
"recurse",
")",
"{",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"attrList",
"=",
"getStatusIdRecords",
"(",
"new",
"String",
"[",
"... | Get the ID of the protein which was made obsolete by newPdbId.
@param newPdbId PDB ID of the newer structure
@param recurse If true, return all ancestors of newPdbId.
Otherwise, just go one step newer than oldPdbId.
@return A (possibly empty) list of ID(s) of the ancestor(s) of
newPdbId, or <tt>null</tt> if an error occurred. | [
"Get",
"the",
"ID",
"of",
"the",
"protein",
"which",
"was",
"made",
"obsolete",
"by",
"newPdbId",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java#L462-L504 |
32,169 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java | PDBStatus.getStatusIdRecords | private static List<Map<String, String>> getStatusIdRecords(String[] pdbIDs) {
List<Map<String,String>> result = new ArrayList<Map<String,String>>(pdbIDs.length);
String serverName = System.getProperty(PDB_SERVER_PROPERTY);
if ( serverName == null)
serverName = DEFAULT_PDB_SERVER;
else
logger.info(String.format("Got System property %s=%s",PDB_SERVER_PROPERTY,serverName));
// Build REST query URL
if(pdbIDs.length < 1) {
throw new IllegalArgumentException("No pdbIDs specified");
}
String urlStr = String.format("http://%s/pdb/rest/idStatus?structureId=",serverName);
for(String pdbId : pdbIDs) {
pdbId = pdbId.toUpperCase();
//check the cache
if (recordsCache.containsKey(pdbId)) {
//logger.debug("Fetching "+pdbId+" from Cache");
result.add( recordsCache.get(pdbId) );
} else {
urlStr += pdbId + ",";
}
}
// check if any ids still need fetching
if(urlStr.charAt(urlStr.length()-1) == '=') {
return result;
}
try {
logger.info("Fetching {}", urlStr);
URL url = new URL(urlStr);
InputStream uStream = url.openStream();
InputSource source = new InputSource(uStream);
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
SAXParser parser = parserFactory.newSAXParser();
XMLReader reader = parser.getXMLReader();
PDBStatusXMLHandler handler = new PDBStatusXMLHandler();
reader.setContentHandler(handler);
reader.parse(source);
// Fetch results of SAX parsing
List<Map<String,String>> records = handler.getRecords();
//add to cache
for(Map<String,String> record : records) {
String pdbId = record.get("structureId").toUpperCase();
if(pdbId != null) {
recordsCache.put(pdbId, record);
}
}
// return results
result.addAll(handler.getRecords());
// TODO should throw these forward and let the caller log
} catch (IOException e){
logger.error("Problem getting status for {} from PDB server. Error: {}", Arrays.toString(pdbIDs), e.getMessage());
return null;
} catch (SAXException e) {
logger.error("Problem getting status for {} from PDB server. Error: {}", Arrays.toString(pdbIDs), e.getMessage());
return null;
} catch (ParserConfigurationException e) {
logger.error("Problem getting status for {} from PDB server. Error: {}", Arrays.toString(pdbIDs), e.getMessage());
return null;
}
return result;
} | java | private static List<Map<String, String>> getStatusIdRecords(String[] pdbIDs) {
List<Map<String,String>> result = new ArrayList<Map<String,String>>(pdbIDs.length);
String serverName = System.getProperty(PDB_SERVER_PROPERTY);
if ( serverName == null)
serverName = DEFAULT_PDB_SERVER;
else
logger.info(String.format("Got System property %s=%s",PDB_SERVER_PROPERTY,serverName));
// Build REST query URL
if(pdbIDs.length < 1) {
throw new IllegalArgumentException("No pdbIDs specified");
}
String urlStr = String.format("http://%s/pdb/rest/idStatus?structureId=",serverName);
for(String pdbId : pdbIDs) {
pdbId = pdbId.toUpperCase();
//check the cache
if (recordsCache.containsKey(pdbId)) {
//logger.debug("Fetching "+pdbId+" from Cache");
result.add( recordsCache.get(pdbId) );
} else {
urlStr += pdbId + ",";
}
}
// check if any ids still need fetching
if(urlStr.charAt(urlStr.length()-1) == '=') {
return result;
}
try {
logger.info("Fetching {}", urlStr);
URL url = new URL(urlStr);
InputStream uStream = url.openStream();
InputSource source = new InputSource(uStream);
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
SAXParser parser = parserFactory.newSAXParser();
XMLReader reader = parser.getXMLReader();
PDBStatusXMLHandler handler = new PDBStatusXMLHandler();
reader.setContentHandler(handler);
reader.parse(source);
// Fetch results of SAX parsing
List<Map<String,String>> records = handler.getRecords();
//add to cache
for(Map<String,String> record : records) {
String pdbId = record.get("structureId").toUpperCase();
if(pdbId != null) {
recordsCache.put(pdbId, record);
}
}
// return results
result.addAll(handler.getRecords());
// TODO should throw these forward and let the caller log
} catch (IOException e){
logger.error("Problem getting status for {} from PDB server. Error: {}", Arrays.toString(pdbIDs), e.getMessage());
return null;
} catch (SAXException e) {
logger.error("Problem getting status for {} from PDB server. Error: {}", Arrays.toString(pdbIDs), e.getMessage());
return null;
} catch (ParserConfigurationException e) {
logger.error("Problem getting status for {} from PDB server. Error: {}", Arrays.toString(pdbIDs), e.getMessage());
return null;
}
return result;
} | [
"private",
"static",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"getStatusIdRecords",
"(",
"String",
"[",
"]",
"pdbIDs",
")",
"{",
"List",
"<",
"Map",
"<",
"String",
",",
"String",
">",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"M... | Fetches the status of one or more pdbIDs from the server.
<p>Returns the results as a list of Attributes.
Each attribute should contain "structureId" and "status" attributes, and
possibly more.
<p>Example:</br>
<tt>http://www.rcsb.org/pdb/rest/idStatus?structureID=1HHB,4HHB</tt></br>
<pre><idStatus>
<record structureId="1HHB" status="OBSOLETE" replacedBy="4HHB"/>
<record structureId="4HHB" status="CURRENT" replaces="1HHB"/>
</idStatus>
</pre>
<p>Results are not guaranteed to be returned in the same order as pdbIDs.
Refer to the structureId property to match them.
@param pdbIDs
@return A map between attributes and values | [
"Fetches",
"the",
"status",
"of",
"one",
"or",
"more",
"pdbIDs",
"from",
"the",
"server",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java#L537-L613 |
32,170 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java | PDBStatus.getCurrentPDBIds | public static SortedSet<String> getCurrentPDBIds() throws IOException {
SortedSet<String> allPDBs = new TreeSet<String>();
String serverName = System.getProperty(PDB_SERVER_PROPERTY);
if ( serverName == null)
serverName = DEFAULT_PDB_SERVER;
else
logger.info(String.format("Got System property %s=%s",PDB_SERVER_PROPERTY,serverName));
// Build REST query URL
String urlStr = String.format("http://%s/pdb/rest/getCurrent",serverName);
URL u = new URL(urlStr);
InputStream stream = URLConnectionTools.getInputStream(u, 60000);
if (stream != null) {
BufferedReader reader = new BufferedReader(
new InputStreamReader(stream));
String line = null;
while ((line = reader.readLine()) != null) {
int index = line.lastIndexOf("structureId=");
if (index > 0) {
allPDBs.add(line.substring(index + 13, index + 17));
}
}
}
return allPDBs;
} | java | public static SortedSet<String> getCurrentPDBIds() throws IOException {
SortedSet<String> allPDBs = new TreeSet<String>();
String serverName = System.getProperty(PDB_SERVER_PROPERTY);
if ( serverName == null)
serverName = DEFAULT_PDB_SERVER;
else
logger.info(String.format("Got System property %s=%s",PDB_SERVER_PROPERTY,serverName));
// Build REST query URL
String urlStr = String.format("http://%s/pdb/rest/getCurrent",serverName);
URL u = new URL(urlStr);
InputStream stream = URLConnectionTools.getInputStream(u, 60000);
if (stream != null) {
BufferedReader reader = new BufferedReader(
new InputStreamReader(stream));
String line = null;
while ((line = reader.readLine()) != null) {
int index = line.lastIndexOf("structureId=");
if (index > 0) {
allPDBs.add(line.substring(index + 13, index + 17));
}
}
}
return allPDBs;
} | [
"public",
"static",
"SortedSet",
"<",
"String",
">",
"getCurrentPDBIds",
"(",
")",
"throws",
"IOException",
"{",
"SortedSet",
"<",
"String",
">",
"allPDBs",
"=",
"new",
"TreeSet",
"<",
"String",
">",
"(",
")",
";",
"String",
"serverName",
"=",
"System",
".... | Returns a list of current PDB IDs
@return a list of PDB IDs, or null if a problem occurred | [
"Returns",
"a",
"list",
"of",
"current",
"PDB",
"IDs"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBStatus.java#L674-L706 |
32,171 | biojava/biojava | biojava-protein-disorder/src/main/java/org/biojava/nbio/data/sequence/FastaSequence.java | FastaSequence.getFormatedSequence | public String getFormatedSequence(final int width) {
if (sequence == null) {
return "";
}
assert width >= 0 : "Wrong width parameter ";
final StringBuilder sb = new StringBuilder(sequence);
int nchunks = sequence.length() / width;
// add up inserted new line chars
nchunks = (nchunks + sequence.length()) / width;
int nlineCharcounter = 0;
for (int i = 1; i <= nchunks; i++) {
final int insPos = width * i + nlineCharcounter;
// to prevent inserting new line in the very end of a sequence then
// it would have failed.
// Also covers the case when the sequences shorter than width
if (sb.length() <= insPos) {
break;
}
sb.insert(insPos, "\n");
nlineCharcounter++;
}
return sb.toString();
} | java | public String getFormatedSequence(final int width) {
if (sequence == null) {
return "";
}
assert width >= 0 : "Wrong width parameter ";
final StringBuilder sb = new StringBuilder(sequence);
int nchunks = sequence.length() / width;
// add up inserted new line chars
nchunks = (nchunks + sequence.length()) / width;
int nlineCharcounter = 0;
for (int i = 1; i <= nchunks; i++) {
final int insPos = width * i + nlineCharcounter;
// to prevent inserting new line in the very end of a sequence then
// it would have failed.
// Also covers the case when the sequences shorter than width
if (sb.length() <= insPos) {
break;
}
sb.insert(insPos, "\n");
nlineCharcounter++;
}
return sb.toString();
} | [
"public",
"String",
"getFormatedSequence",
"(",
"final",
"int",
"width",
")",
"{",
"if",
"(",
"sequence",
"==",
"null",
")",
"{",
"return",
"\"\"",
";",
"}",
"assert",
"width",
">=",
"0",
":",
"\"Wrong width parameter \"",
";",
"final",
"StringBuilder",
"sb"... | Format sequence per width letter in one string. Without spaces.
@return multiple line formated sequence, one line width letters length | [
"Format",
"sequence",
"per",
"width",
"letter",
"in",
"one",
"string",
".",
"Without",
"spaces",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/data/sequence/FastaSequence.java#L124-L148 |
32,172 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/PermutationGroup.java | PermutationGroup.completeGroup | public void completeGroup() {
// Copy initial set to allow permutations to grow
List<List<Integer>> gens = new ArrayList<List<Integer>>(permutations);
// Keep HashSet version of permutations for fast lookup.
Set<List<Integer>> known = new HashSet<List<Integer>>(permutations);
//breadth-first search through the map of all members
List<List<Integer>> currentLevel = new ArrayList<List<Integer>>(permutations);
while( currentLevel.size() > 0) {
List<List<Integer>> nextLevel = new ArrayList<List<Integer>>();
for( List<Integer> p : currentLevel) {
for(List<Integer> gen : gens) {
List<Integer> y = combine(p,gen);
if(!known.contains(y)) {
nextLevel.add(y);
//bypass addPermutation(y) for performance
permutations.add(y);
known.add(y);
}
}
}
currentLevel = nextLevel;
}
} | java | public void completeGroup() {
// Copy initial set to allow permutations to grow
List<List<Integer>> gens = new ArrayList<List<Integer>>(permutations);
// Keep HashSet version of permutations for fast lookup.
Set<List<Integer>> known = new HashSet<List<Integer>>(permutations);
//breadth-first search through the map of all members
List<List<Integer>> currentLevel = new ArrayList<List<Integer>>(permutations);
while( currentLevel.size() > 0) {
List<List<Integer>> nextLevel = new ArrayList<List<Integer>>();
for( List<Integer> p : currentLevel) {
for(List<Integer> gen : gens) {
List<Integer> y = combine(p,gen);
if(!known.contains(y)) {
nextLevel.add(y);
//bypass addPermutation(y) for performance
permutations.add(y);
known.add(y);
}
}
}
currentLevel = nextLevel;
}
} | [
"public",
"void",
"completeGroup",
"(",
")",
"{",
"// Copy initial set to allow permutations to grow",
"List",
"<",
"List",
"<",
"Integer",
">>",
"gens",
"=",
"new",
"ArrayList",
"<",
"List",
"<",
"Integer",
">",
">",
"(",
"permutations",
")",
";",
"// Keep Hash... | Starts with an incomplete set of group generators in `permutations` and
expands it to include all possible combinations.
Ways to complete group:
- combinations of permutations pi x pj
- combinations with itself p^k | [
"Starts",
"with",
"an",
"incomplete",
"set",
"of",
"group",
"generators",
"in",
"permutations",
"and",
"expands",
"it",
"to",
"include",
"all",
"possible",
"combinations",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/PermutationGroup.java#L61-L83 |
32,173 | biojava/biojava | biojava-alignment/src/main/java/org/biojava/nbio/alignment/GuideTree.java | GuideTree.getDistanceMatrix | public double[][] getDistanceMatrix() {
double[][] matrix = new double[distances.getSize()][distances.getSize()];
for (int i = 0; i < matrix.length; i++) {
for (int j = i+1; j < matrix.length; j++) {
matrix[i][j] = matrix[j][i] = distances.getValue(i, j);
}
}
return matrix;
} | java | public double[][] getDistanceMatrix() {
double[][] matrix = new double[distances.getSize()][distances.getSize()];
for (int i = 0; i < matrix.length; i++) {
for (int j = i+1; j < matrix.length; j++) {
matrix[i][j] = matrix[j][i] = distances.getValue(i, j);
}
}
return matrix;
} | [
"public",
"double",
"[",
"]",
"[",
"]",
"getDistanceMatrix",
"(",
")",
"{",
"double",
"[",
"]",
"[",
"]",
"matrix",
"=",
"new",
"double",
"[",
"distances",
".",
"getSize",
"(",
")",
"]",
"[",
"distances",
".",
"getSize",
"(",
")",
"]",
";",
"for",
... | Returns the distance matrix used to construct this guide tree. The scores have been normalized.
@return the distance matrix used to construct this guide tree | [
"Returns",
"the",
"distance",
"matrix",
"used",
"to",
"construct",
"this",
"guide",
"tree",
".",
"The",
"scores",
"have",
"been",
"normalized",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-alignment/src/main/java/org/biojava/nbio/alignment/GuideTree.java#L107-L115 |
32,174 | biojava/biojava | biojava-alignment/src/main/java/org/biojava/nbio/alignment/GuideTree.java | GuideTree.getScoreMatrix | public double[][] getScoreMatrix() {
double[][] matrix = new double[sequences.size()][sequences.size()];
for (int i = 0, n = 0; i < matrix.length; i++) {
matrix[i][i] = scorers.get(i).getMaxScore();
for (int j = i+1; j < matrix.length; j++) {
matrix[i][j] = matrix[j][i] = scorers.get(n++).getScore();
}
}
return matrix;
} | java | public double[][] getScoreMatrix() {
double[][] matrix = new double[sequences.size()][sequences.size()];
for (int i = 0, n = 0; i < matrix.length; i++) {
matrix[i][i] = scorers.get(i).getMaxScore();
for (int j = i+1; j < matrix.length; j++) {
matrix[i][j] = matrix[j][i] = scorers.get(n++).getScore();
}
}
return matrix;
} | [
"public",
"double",
"[",
"]",
"[",
"]",
"getScoreMatrix",
"(",
")",
"{",
"double",
"[",
"]",
"[",
"]",
"matrix",
"=",
"new",
"double",
"[",
"sequences",
".",
"size",
"(",
")",
"]",
"[",
"sequences",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
... | Returns the similarity matrix used to construct this guide tree. The scores have not been normalized.
@return the similarity matrix used to construct this guide tree | [
"Returns",
"the",
"similarity",
"matrix",
"used",
"to",
"construct",
"this",
"guide",
"tree",
".",
"The",
"scores",
"have",
"not",
"been",
"normalized",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-alignment/src/main/java/org/biojava/nbio/alignment/GuideTree.java#L131-L140 |
32,175 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyBuilder.java | BiologicalAssemblyBuilder.orderTransformationsByChainId | private void orderTransformationsByChainId(Structure asymUnit, List<BiologicalAssemblyTransformation> transformations) {
final List<String> chainIds = getChainIds(asymUnit);
Collections.sort(transformations, new Comparator<BiologicalAssemblyTransformation>() {
@Override
public int compare(BiologicalAssemblyTransformation t1, BiologicalAssemblyTransformation t2) {
// set sort order only if the two ids are identical
if (t1.getId().equals(t2.getId())) {
return chainIds.indexOf(t1.getChainId()) - chainIds.indexOf(t2.getChainId());
} else {
return t1.getId().compareTo(t2.getId());
}
}
});
} | java | private void orderTransformationsByChainId(Structure asymUnit, List<BiologicalAssemblyTransformation> transformations) {
final List<String> chainIds = getChainIds(asymUnit);
Collections.sort(transformations, new Comparator<BiologicalAssemblyTransformation>() {
@Override
public int compare(BiologicalAssemblyTransformation t1, BiologicalAssemblyTransformation t2) {
// set sort order only if the two ids are identical
if (t1.getId().equals(t2.getId())) {
return chainIds.indexOf(t1.getChainId()) - chainIds.indexOf(t2.getChainId());
} else {
return t1.getId().compareTo(t2.getId());
}
}
});
} | [
"private",
"void",
"orderTransformationsByChainId",
"(",
"Structure",
"asymUnit",
",",
"List",
"<",
"BiologicalAssemblyTransformation",
">",
"transformations",
")",
"{",
"final",
"List",
"<",
"String",
">",
"chainIds",
"=",
"getChainIds",
"(",
"asymUnit",
")",
";",
... | Orders model transformations by chain ids in the same order as in the asymmetric unit
@param asymUnit
@param transformations | [
"Orders",
"model",
"transformations",
"by",
"chain",
"ids",
"in",
"the",
"same",
"order",
"as",
"in",
"the",
"asymmetric",
"unit"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyBuilder.java#L165-L178 |
32,176 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyBuilder.java | BiologicalAssemblyBuilder.getChainIds | private List<String> getChainIds(Structure asymUnit) {
List<String> chainIds = new ArrayList<String>();
for ( Chain c : asymUnit.getChains()){
String intChainID = c.getId();
chainIds.add(intChainID);
}
return chainIds;
} | java | private List<String> getChainIds(Structure asymUnit) {
List<String> chainIds = new ArrayList<String>();
for ( Chain c : asymUnit.getChains()){
String intChainID = c.getId();
chainIds.add(intChainID);
}
return chainIds;
} | [
"private",
"List",
"<",
"String",
">",
"getChainIds",
"(",
"Structure",
"asymUnit",
")",
"{",
"List",
"<",
"String",
">",
"chainIds",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"Chain",
"c",
":",
"asymUnit",
".",
"getChains... | Returns a list of chain ids in the order they are specified in the ATOM
records in the asymmetric unit
@param asymUnit
@return | [
"Returns",
"a",
"list",
"of",
"chain",
"ids",
"in",
"the",
"order",
"they",
"are",
"specified",
"in",
"the",
"ATOM",
"records",
"in",
"the",
"asymmetric",
"unit"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyBuilder.java#L186-L193 |
32,177 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyBuilder.java | BiologicalAssemblyBuilder.addChainMultiModel | private void addChainMultiModel(Structure s, Chain newChain, String transformId) {
// multi-model bioassembly
if ( modelIndex.size() == 0)
modelIndex.add("PLACEHOLDER FOR ASYM UNIT");
int modelCount = modelIndex.indexOf(transformId);
if ( modelCount == -1) {
modelIndex.add(transformId);
modelCount = modelIndex.indexOf(transformId);
}
if (modelCount == 0) {
s.addChain(newChain);
} else if (modelCount > s.nrModels()) {
List<Chain> newModel = new ArrayList<>();
newModel.add(newChain);
s.addModel(newModel);
} else {
s.addChain(newChain, modelCount-1);
}
} | java | private void addChainMultiModel(Structure s, Chain newChain, String transformId) {
// multi-model bioassembly
if ( modelIndex.size() == 0)
modelIndex.add("PLACEHOLDER FOR ASYM UNIT");
int modelCount = modelIndex.indexOf(transformId);
if ( modelCount == -1) {
modelIndex.add(transformId);
modelCount = modelIndex.indexOf(transformId);
}
if (modelCount == 0) {
s.addChain(newChain);
} else if (modelCount > s.nrModels()) {
List<Chain> newModel = new ArrayList<>();
newModel.add(newChain);
s.addModel(newModel);
} else {
s.addChain(newChain, modelCount-1);
}
} | [
"private",
"void",
"addChainMultiModel",
"(",
"Structure",
"s",
",",
"Chain",
"newChain",
",",
"String",
"transformId",
")",
"{",
"// multi-model bioassembly",
"if",
"(",
"modelIndex",
".",
"size",
"(",
")",
"==",
"0",
")",
"modelIndex",
".",
"add",
"(",
"\"... | Adds a chain to the given structure to form a biological assembly,
adding the symmetry expanded chains as new models per transformId.
@param s
@param newChain
@param transformId | [
"Adds",
"a",
"chain",
"to",
"the",
"given",
"structure",
"to",
"form",
"a",
"biological",
"assembly",
"adding",
"the",
"symmetry",
"expanded",
"chains",
"as",
"new",
"models",
"per",
"transformId",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyBuilder.java#L202-L225 |
32,178 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyBuilder.java | BiologicalAssemblyBuilder.getBioUnitTransformationList | public ArrayList<BiologicalAssemblyTransformation> getBioUnitTransformationList(PdbxStructAssembly psa, List<PdbxStructAssemblyGen> psags, List<PdbxStructOperList> operators) {
init();
// first we populate the list of all operators from pdbx_struct_oper_list so that we can then
// get them from getBioUnitTransformationsListUnaryOperators() and getBioUnitTransformationsListBinaryOperators()
for (PdbxStructOperList oper: operators){
try {
Matrix4d m = new Matrix4d();
m.m00 = Double.parseDouble(oper.getMatrix11());
m.m01 = Double.parseDouble(oper.getMatrix12());
m.m02 = Double.parseDouble(oper.getMatrix13());
m.m10 = Double.parseDouble(oper.getMatrix21());
m.m11 = Double.parseDouble(oper.getMatrix22());
m.m12 = Double.parseDouble(oper.getMatrix23());
m.m20 = Double.parseDouble(oper.getMatrix31());
m.m21 = Double.parseDouble(oper.getMatrix32());
m.m22 = Double.parseDouble(oper.getMatrix33());
m.m03 = Double.parseDouble(oper.getVector1());
m.m13 = Double.parseDouble(oper.getVector2());
m.m23 = Double.parseDouble(oper.getVector3());
m.m30 = 0;
m.m31 = 0;
m.m32 = 0;
m.m33 = 1;
allTransformations.put(oper.getId(), m);
} catch (NumberFormatException e) {
logger.warn("Could not parse a matrix value from pdbx_struct_oper_list for id {}. The operator id will be ignored. Error: {}", oper.getId(), e.getMessage());
}
}
ArrayList<BiologicalAssemblyTransformation> transformations = getBioUnitTransformationsListUnaryOperators(psa.getId(), psags);
transformations.addAll(getBioUnitTransformationsListBinaryOperators(psa.getId(), psags));
transformations.trimToSize();
return transformations;
} | java | public ArrayList<BiologicalAssemblyTransformation> getBioUnitTransformationList(PdbxStructAssembly psa, List<PdbxStructAssemblyGen> psags, List<PdbxStructOperList> operators) {
init();
// first we populate the list of all operators from pdbx_struct_oper_list so that we can then
// get them from getBioUnitTransformationsListUnaryOperators() and getBioUnitTransformationsListBinaryOperators()
for (PdbxStructOperList oper: operators){
try {
Matrix4d m = new Matrix4d();
m.m00 = Double.parseDouble(oper.getMatrix11());
m.m01 = Double.parseDouble(oper.getMatrix12());
m.m02 = Double.parseDouble(oper.getMatrix13());
m.m10 = Double.parseDouble(oper.getMatrix21());
m.m11 = Double.parseDouble(oper.getMatrix22());
m.m12 = Double.parseDouble(oper.getMatrix23());
m.m20 = Double.parseDouble(oper.getMatrix31());
m.m21 = Double.parseDouble(oper.getMatrix32());
m.m22 = Double.parseDouble(oper.getMatrix33());
m.m03 = Double.parseDouble(oper.getVector1());
m.m13 = Double.parseDouble(oper.getVector2());
m.m23 = Double.parseDouble(oper.getVector3());
m.m30 = 0;
m.m31 = 0;
m.m32 = 0;
m.m33 = 1;
allTransformations.put(oper.getId(), m);
} catch (NumberFormatException e) {
logger.warn("Could not parse a matrix value from pdbx_struct_oper_list for id {}. The operator id will be ignored. Error: {}", oper.getId(), e.getMessage());
}
}
ArrayList<BiologicalAssemblyTransformation> transformations = getBioUnitTransformationsListUnaryOperators(psa.getId(), psags);
transformations.addAll(getBioUnitTransformationsListBinaryOperators(psa.getId(), psags));
transformations.trimToSize();
return transformations;
} | [
"public",
"ArrayList",
"<",
"BiologicalAssemblyTransformation",
">",
"getBioUnitTransformationList",
"(",
"PdbxStructAssembly",
"psa",
",",
"List",
"<",
"PdbxStructAssemblyGen",
">",
"psags",
",",
"List",
"<",
"PdbxStructOperList",
">",
"operators",
")",
"{",
"init",
... | Returns a list of transformation matrices for the generation of a macromolecular
assembly for the specified assembly Id.
@param psa
@param psags
@param operators
@return list of transformation matrices to generate macromolecular assembly | [
"Returns",
"a",
"list",
"of",
"transformation",
"matrices",
"for",
"the",
"generation",
"of",
"a",
"macromolecular",
"assembly",
"for",
"the",
"specified",
"assembly",
"Id",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyBuilder.java#L250-L290 |
32,179 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getNrAtoms | public static final int getNrAtoms(Structure s) {
int nrAtoms = 0;
Iterator<Group> iter = new GroupIterator(s);
while (iter.hasNext()) {
Group g = iter.next();
nrAtoms += g.size();
}
return nrAtoms;
} | java | public static final int getNrAtoms(Structure s) {
int nrAtoms = 0;
Iterator<Group> iter = new GroupIterator(s);
while (iter.hasNext()) {
Group g = iter.next();
nrAtoms += g.size();
}
return nrAtoms;
} | [
"public",
"static",
"final",
"int",
"getNrAtoms",
"(",
"Structure",
"s",
")",
"{",
"int",
"nrAtoms",
"=",
"0",
";",
"Iterator",
"<",
"Group",
">",
"iter",
"=",
"new",
"GroupIterator",
"(",
"s",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")"... | Count how many Atoms are contained within a Structure object.
@param s
the structure object
@return the number of Atoms in this Structure | [
"Count",
"how",
"many",
"Atoms",
"are",
"contained",
"within",
"a",
"Structure",
"object",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L268-L280 |
32,180 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getNrGroups | public static final int getNrGroups(Structure s) {
int nrGroups = 0;
List<Chain> chains = s.getChains(0);
for (Chain c : chains) {
nrGroups += c.getAtomLength();
}
return nrGroups;
} | java | public static final int getNrGroups(Structure s) {
int nrGroups = 0;
List<Chain> chains = s.getChains(0);
for (Chain c : chains) {
nrGroups += c.getAtomLength();
}
return nrGroups;
} | [
"public",
"static",
"final",
"int",
"getNrGroups",
"(",
"Structure",
"s",
")",
"{",
"int",
"nrGroups",
"=",
"0",
";",
"List",
"<",
"Chain",
">",
"chains",
"=",
"s",
".",
"getChains",
"(",
"0",
")",
";",
"for",
"(",
"Chain",
"c",
":",
"chains",
")",... | Count how many groups are contained within a structure object.
@param s
the structure object
@return the number of groups in the structure | [
"Count",
"how",
"many",
"groups",
"are",
"contained",
"within",
"a",
"structure",
"object",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L289-L297 |
32,181 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getLigandsByProximity | public static List<Group> getLigandsByProximity(Collection<Group> target, Atom[] query, double cutoff) {
// Geometric hashing of the reduced structure
Grid grid = new Grid(cutoff);
grid.addAtoms(query);
List<Group> ligands = new ArrayList<>();
for(Group g :target ) {
// don't worry about waters
if(g.isWater()) {
continue;
}
if(g.isPolymeric() ) {
// Polymers aren't ligands
continue;
}
// It is a ligand!
// Check that it's within cutoff of something in reduced
List<Atom> groupAtoms = g.getAtoms();
if( ! grid.hasAnyContact(Calc.atomsToPoints(groupAtoms))) {
continue;
}
ligands.add(g);
}
return ligands;
} | java | public static List<Group> getLigandsByProximity(Collection<Group> target, Atom[] query, double cutoff) {
// Geometric hashing of the reduced structure
Grid grid = new Grid(cutoff);
grid.addAtoms(query);
List<Group> ligands = new ArrayList<>();
for(Group g :target ) {
// don't worry about waters
if(g.isWater()) {
continue;
}
if(g.isPolymeric() ) {
// Polymers aren't ligands
continue;
}
// It is a ligand!
// Check that it's within cutoff of something in reduced
List<Atom> groupAtoms = g.getAtoms();
if( ! grid.hasAnyContact(Calc.atomsToPoints(groupAtoms))) {
continue;
}
ligands.add(g);
}
return ligands;
} | [
"public",
"static",
"List",
"<",
"Group",
">",
"getLigandsByProximity",
"(",
"Collection",
"<",
"Group",
">",
"target",
",",
"Atom",
"[",
"]",
"query",
",",
"double",
"cutoff",
")",
"{",
"// Geometric hashing of the reduced structure",
"Grid",
"grid",
"=",
"new"... | Finds all ligand groups from the target which fall within the cutoff distance
of some atom from the query set.
@param target Set of groups including the ligands
@param query Atom selection
@param cutoff Distance from query atoms to consider, in angstroms
@return All groups from the target with at least one atom within cutoff of a query atom
@see StructureTools#DEFAULT_LIGAND_PROXIMITY_CUTOFF | [
"Finds",
"all",
"ligand",
"groups",
"from",
"the",
"target",
"which",
"fall",
"within",
"the",
"cutoff",
"distance",
"of",
"some",
"atom",
"from",
"the",
"query",
"set",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L476-L504 |
32,182 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.addGroupToStructure | public static Chain addGroupToStructure(Structure s, Group g, int model, Chain chainGuess, boolean clone ) {
synchronized(s) {
// Find or create the chain
String chainId = g.getChainId();
assert !chainId.isEmpty();
Chain chain;
if(chainGuess != null && chainGuess.getId() == chainId) {
// previously guessed chain
chain = chainGuess;
} else {
// Try to guess
chain = s.getChain(chainId, model);
if(chain == null) {
// no chain found
chain = new ChainImpl();
chain.setId(chainId);
Chain oldChain = g.getChain();
chain.setName(oldChain.getName());
EntityInfo oldEntityInfo = oldChain.getEntityInfo();
EntityInfo newEntityInfo;
if(oldEntityInfo == null) {
newEntityInfo = new EntityInfo();
s.addEntityInfo(newEntityInfo);
} else {
newEntityInfo = s.getEntityById(oldEntityInfo.getMolId());
if( newEntityInfo == null ) {
newEntityInfo = new EntityInfo(oldEntityInfo);
s.addEntityInfo(newEntityInfo);
}
}
newEntityInfo.addChain(chain);
chain.setEntityInfo(newEntityInfo);
// TODO Do the seqres need to be cloned too? -SB 2016-10-7
chain.setSeqResGroups(oldChain.getSeqResGroups());
chain.setSeqMisMatches(oldChain.getSeqMisMatches());
s.addChain(chain,model);
}
}
// Add cloned group
if(clone) {
g = (Group)g.clone();
}
chain.addGroup(g);
return chain;
}
} | java | public static Chain addGroupToStructure(Structure s, Group g, int model, Chain chainGuess, boolean clone ) {
synchronized(s) {
// Find or create the chain
String chainId = g.getChainId();
assert !chainId.isEmpty();
Chain chain;
if(chainGuess != null && chainGuess.getId() == chainId) {
// previously guessed chain
chain = chainGuess;
} else {
// Try to guess
chain = s.getChain(chainId, model);
if(chain == null) {
// no chain found
chain = new ChainImpl();
chain.setId(chainId);
Chain oldChain = g.getChain();
chain.setName(oldChain.getName());
EntityInfo oldEntityInfo = oldChain.getEntityInfo();
EntityInfo newEntityInfo;
if(oldEntityInfo == null) {
newEntityInfo = new EntityInfo();
s.addEntityInfo(newEntityInfo);
} else {
newEntityInfo = s.getEntityById(oldEntityInfo.getMolId());
if( newEntityInfo == null ) {
newEntityInfo = new EntityInfo(oldEntityInfo);
s.addEntityInfo(newEntityInfo);
}
}
newEntityInfo.addChain(chain);
chain.setEntityInfo(newEntityInfo);
// TODO Do the seqres need to be cloned too? -SB 2016-10-7
chain.setSeqResGroups(oldChain.getSeqResGroups());
chain.setSeqMisMatches(oldChain.getSeqMisMatches());
s.addChain(chain,model);
}
}
// Add cloned group
if(clone) {
g = (Group)g.clone();
}
chain.addGroup(g);
return chain;
}
} | [
"public",
"static",
"Chain",
"addGroupToStructure",
"(",
"Structure",
"s",
",",
"Group",
"g",
",",
"int",
"model",
",",
"Chain",
"chainGuess",
",",
"boolean",
"clone",
")",
"{",
"synchronized",
"(",
"s",
")",
"{",
"// Find or create the chain",
"String",
"chai... | Adds a particular group to a structure. A new chain will be created if necessary.
<p>When adding multiple groups, pass the return value of one call as the
chainGuess parameter of the next call for efficiency.
<pre>
Chain guess = null;
for(Group g : groups) {
guess = addGroupToStructure(s, g, guess );
}
</pre>
@param s structure to receive the group
@param g group to add
@param chainGuess (optional) If not null, should be a chain from s. Used
to improve performance when adding many groups from the same chain
@param clone Indicates whether the input group should be cloned before
being added to the new chain
@return the chain g was added to | [
"Adds",
"a",
"particular",
"group",
"to",
"a",
"structure",
".",
"A",
"new",
"chain",
"will",
"be",
"created",
"if",
"necessary",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L525-L577 |
32,183 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.addGroupsToStructure | public static void addGroupsToStructure(Structure s, Collection<Group> groups, int model, boolean clone) {
Chain chainGuess = null;
for(Group g : groups) {
chainGuess = addGroupToStructure(s, g, model, chainGuess, clone);
}
} | java | public static void addGroupsToStructure(Structure s, Collection<Group> groups, int model, boolean clone) {
Chain chainGuess = null;
for(Group g : groups) {
chainGuess = addGroupToStructure(s, g, model, chainGuess, clone);
}
} | [
"public",
"static",
"void",
"addGroupsToStructure",
"(",
"Structure",
"s",
",",
"Collection",
"<",
"Group",
">",
"groups",
",",
"int",
"model",
",",
"boolean",
"clone",
")",
"{",
"Chain",
"chainGuess",
"=",
"null",
";",
"for",
"(",
"Group",
"g",
":",
"gr... | Add a list of groups to a new structure. Chains will be automatically
created in the new structure as needed.
@param s structure to receive the group
@param g group to add
@param clone Indicates whether the input groups should be cloned before
being added to the new chain | [
"Add",
"a",
"list",
"of",
"groups",
"to",
"a",
"new",
"structure",
".",
"Chains",
"will",
"be",
"automatically",
"created",
"in",
"the",
"new",
"structure",
"as",
"needed",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L587-L592 |
32,184 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getAllGroupsFromSubset | public static Set<Group> getAllGroupsFromSubset(Atom[] atoms,GroupType types) {
// Get the full structure
Structure s = null;
if (atoms.length > 0) {
Group g = atoms[0].getGroup();
if (g != null) {
Chain c = g.getChain();
if (c != null) {
s = c.getStructure();
}
}
}
// Collect all groups from the structure
Set<Chain> allChains = new HashSet<>();
if( s != null ) {
allChains.addAll(s.getChains());
}
// In case the structure wasn't set, need to use ca chains too
for(Atom a : atoms) {
Group g = a.getGroup();
if(g != null) {
Chain c = g.getChain();
if( c != null ) {
allChains.add(c);
}
}
}
if(allChains.isEmpty() ) {
return Collections.emptySet();
}
// Extract all ligand groups
Set<Group> full = new HashSet<>();
for(Chain c : allChains) {
if(types == null) {
full.addAll(c.getAtomGroups());
} else {
full.addAll(c.getAtomGroups(types));
}
}
return full;
} | java | public static Set<Group> getAllGroupsFromSubset(Atom[] atoms,GroupType types) {
// Get the full structure
Structure s = null;
if (atoms.length > 0) {
Group g = atoms[0].getGroup();
if (g != null) {
Chain c = g.getChain();
if (c != null) {
s = c.getStructure();
}
}
}
// Collect all groups from the structure
Set<Chain> allChains = new HashSet<>();
if( s != null ) {
allChains.addAll(s.getChains());
}
// In case the structure wasn't set, need to use ca chains too
for(Atom a : atoms) {
Group g = a.getGroup();
if(g != null) {
Chain c = g.getChain();
if( c != null ) {
allChains.add(c);
}
}
}
if(allChains.isEmpty() ) {
return Collections.emptySet();
}
// Extract all ligand groups
Set<Group> full = new HashSet<>();
for(Chain c : allChains) {
if(types == null) {
full.addAll(c.getAtomGroups());
} else {
full.addAll(c.getAtomGroups(types));
}
}
return full;
} | [
"public",
"static",
"Set",
"<",
"Group",
">",
"getAllGroupsFromSubset",
"(",
"Atom",
"[",
"]",
"atoms",
",",
"GroupType",
"types",
")",
"{",
"// Get the full structure",
"Structure",
"s",
"=",
"null",
";",
"if",
"(",
"atoms",
".",
"length",
">",
"0",
")",
... | Expand a set of atoms into all groups from the same structure.
If the structure is set, only the first atom is used (assuming all
atoms come from the same original structure).
If the atoms aren't linked to a structure (for instance, for cloned atoms),
searches all chains of all atoms for groups.
@param atoms Sample of atoms
@param types Type of groups to return (useful for getting only ligands, for instance).
Null gets all groups.
@return All groups from all chains accessible from the input atoms | [
"Expand",
"a",
"set",
"of",
"atoms",
"into",
"all",
"groups",
"from",
"the",
"same",
"structure",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L619-L662 |
32,185 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getAllNonHAtomArray | public static final Atom[] getAllNonHAtomArray(Structure s, boolean hetAtoms) {
AtomIterator iter = new AtomIterator(s);
return getAllNonHAtomArray(s, hetAtoms, iter);
} | java | public static final Atom[] getAllNonHAtomArray(Structure s, boolean hetAtoms) {
AtomIterator iter = new AtomIterator(s);
return getAllNonHAtomArray(s, hetAtoms, iter);
} | [
"public",
"static",
"final",
"Atom",
"[",
"]",
"getAllNonHAtomArray",
"(",
"Structure",
"s",
",",
"boolean",
"hetAtoms",
")",
"{",
"AtomIterator",
"iter",
"=",
"new",
"AtomIterator",
"(",
"s",
")",
";",
"return",
"getAllNonHAtomArray",
"(",
"s",
",",
"hetAto... | Returns and array of all non-Hydrogen atoms in the given Structure,
optionally including HET atoms or not. Waters are not included.
@param s
@param hetAtoms
if true HET atoms are included in array, if false they are not
@return | [
"Returns",
"and",
"array",
"of",
"all",
"non",
"-",
"Hydrogen",
"atoms",
"in",
"the",
"given",
"Structure",
"optionally",
"including",
"HET",
"atoms",
"or",
"not",
".",
"Waters",
"are",
"not",
"included",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L674-L677 |
32,186 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getAllNonHAtomArray | public static final Atom[] getAllNonHAtomArray(Chain c, boolean hetAtoms) {
List<Atom> atoms = new ArrayList<Atom>();
for (Group g : c.getAtomGroups()) {
if (g.isWater())
continue;
for (Atom a : g.getAtoms()) {
if (a.getElement() == Element.H)
continue;
if (!hetAtoms && g.getType().equals(GroupType.HETATM))
continue;
atoms.add(a);
}
}
return atoms.toArray(new Atom[atoms.size()]);
} | java | public static final Atom[] getAllNonHAtomArray(Chain c, boolean hetAtoms) {
List<Atom> atoms = new ArrayList<Atom>();
for (Group g : c.getAtomGroups()) {
if (g.isWater())
continue;
for (Atom a : g.getAtoms()) {
if (a.getElement() == Element.H)
continue;
if (!hetAtoms && g.getType().equals(GroupType.HETATM))
continue;
atoms.add(a);
}
}
return atoms.toArray(new Atom[atoms.size()]);
} | [
"public",
"static",
"final",
"Atom",
"[",
"]",
"getAllNonHAtomArray",
"(",
"Chain",
"c",
",",
"boolean",
"hetAtoms",
")",
"{",
"List",
"<",
"Atom",
">",
"atoms",
"=",
"new",
"ArrayList",
"<",
"Atom",
">",
"(",
")",
";",
"for",
"(",
"Group",
"g",
":",... | Returns and array of all non-Hydrogen atoms in the given Chain,
optionally including HET atoms or not Waters are not included.
@param c
@param hetAtoms
if true HET atoms are included in array, if false they are not
@return | [
"Returns",
"and",
"array",
"of",
"all",
"non",
"-",
"Hydrogen",
"atoms",
"in",
"the",
"given",
"Chain",
"optionally",
"including",
"HET",
"atoms",
"or",
"not",
"Waters",
"are",
"not",
"included",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L722-L740 |
32,187 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.extractAtoms | private static void extractAtoms(String[] atomNames, List<Chain> chains,
List<Atom> atoms) {
for (Chain c : chains) {
for (Group g : c.getAtomGroups()) {
// a temp container for the atoms of this group
List<Atom> thisGroupAtoms = new ArrayList<Atom>();
// flag to check if this group contains all the requested atoms.
boolean thisGroupAllAtoms = true;
for (String atomName : atomNames) {
Atom a = g.getAtom(atomName);
if (a == null) {
// this group does not have a required atom, skip it...
thisGroupAllAtoms = false;
break;
}
thisGroupAtoms.add(a);
}
if (thisGroupAllAtoms) {
// add the atoms of this group to the array.
for (Atom a : thisGroupAtoms) {
atoms.add(a);
}
}
}
}
} | java | private static void extractAtoms(String[] atomNames, List<Chain> chains,
List<Atom> atoms) {
for (Chain c : chains) {
for (Group g : c.getAtomGroups()) {
// a temp container for the atoms of this group
List<Atom> thisGroupAtoms = new ArrayList<Atom>();
// flag to check if this group contains all the requested atoms.
boolean thisGroupAllAtoms = true;
for (String atomName : atomNames) {
Atom a = g.getAtom(atomName);
if (a == null) {
// this group does not have a required atom, skip it...
thisGroupAllAtoms = false;
break;
}
thisGroupAtoms.add(a);
}
if (thisGroupAllAtoms) {
// add the atoms of this group to the array.
for (Atom a : thisGroupAtoms) {
atoms.add(a);
}
}
}
}
} | [
"private",
"static",
"void",
"extractAtoms",
"(",
"String",
"[",
"]",
"atomNames",
",",
"List",
"<",
"Chain",
">",
"chains",
",",
"List",
"<",
"Atom",
">",
"atoms",
")",
"{",
"for",
"(",
"Chain",
"c",
":",
"chains",
")",
"{",
"for",
"(",
"Group",
"... | Adds to the given atoms list, all atoms of groups that contained all
requested atomNames, i.e. if a group does not contain all of the
requested atom names, its atoms won't be added.
@param atomNames
@param chains
@param atoms | [
"Adds",
"to",
"the",
"given",
"atoms",
"list",
"all",
"atoms",
"of",
"groups",
"that",
"contained",
"all",
"requested",
"atomNames",
"i",
".",
"e",
".",
"if",
"a",
"group",
"does",
"not",
"contain",
"all",
"of",
"the",
"requested",
"atom",
"names",
"its"... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L780-L810 |
32,188 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getAtomArray | public static final Atom[] getAtomArray(Chain c, String[] atomNames) {
List<Atom> atoms = new ArrayList<Atom>();
for (Group g : c.getAtomGroups()) {
// a temp container for the atoms of this group
List<Atom> thisGroupAtoms = new ArrayList<Atom>();
// flag to check if this group contains all the requested atoms.
boolean thisGroupAllAtoms = true;
for (String atomName : atomNames) {
Atom a = g.getAtom(atomName);
if (a == null) {
logger.debug("Group " + g.getResidueNumber() + " ("
+ g.getPDBName()
+ ") does not have the required atom '" + atomName
+ "'");
// this group does not have a required atom, skip it...
thisGroupAllAtoms = false;
break;
}
thisGroupAtoms.add(a);
}
if (thisGroupAllAtoms) {
// add the atoms of this group to the array.
for (Atom a : thisGroupAtoms) {
atoms.add(a);
}
}
}
return atoms.toArray(new Atom[atoms.size()]);
} | java | public static final Atom[] getAtomArray(Chain c, String[] atomNames) {
List<Atom> atoms = new ArrayList<Atom>();
for (Group g : c.getAtomGroups()) {
// a temp container for the atoms of this group
List<Atom> thisGroupAtoms = new ArrayList<Atom>();
// flag to check if this group contains all the requested atoms.
boolean thisGroupAllAtoms = true;
for (String atomName : atomNames) {
Atom a = g.getAtom(atomName);
if (a == null) {
logger.debug("Group " + g.getResidueNumber() + " ("
+ g.getPDBName()
+ ") does not have the required atom '" + atomName
+ "'");
// this group does not have a required atom, skip it...
thisGroupAllAtoms = false;
break;
}
thisGroupAtoms.add(a);
}
if (thisGroupAllAtoms) {
// add the atoms of this group to the array.
for (Atom a : thisGroupAtoms) {
atoms.add(a);
}
}
}
return atoms.toArray(new Atom[atoms.size()]);
} | [
"public",
"static",
"final",
"Atom",
"[",
"]",
"getAtomArray",
"(",
"Chain",
"c",
",",
"String",
"[",
"]",
"atomNames",
")",
"{",
"List",
"<",
"Atom",
">",
"atoms",
"=",
"new",
"ArrayList",
"<",
"Atom",
">",
"(",
")",
";",
"for",
"(",
"Group",
"g",... | Returns an array of the requested Atoms from the Chain object. Iterates
over all groups and checks if the requested atoms are in this group, no
matter if this is a AminoAcid or Hetatom group. If the group does not
contain all requested atoms then no atoms are added for that group.
@param c
the Chain to get the atoms from
@param atomNames
contains the atom names to be used.
@return an Atom[] array | [
"Returns",
"an",
"array",
"of",
"the",
"requested",
"Atoms",
"from",
"the",
"Chain",
"object",
".",
"Iterates",
"over",
"all",
"groups",
"and",
"checks",
"if",
"the",
"requested",
"atoms",
"are",
"in",
"this",
"group",
"no",
"matter",
"if",
"this",
"is",
... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L825-L859 |
32,189 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.cloneAtomArray | public static final Atom[] cloneAtomArray(Atom[] ca) {
Atom[] newCA = new Atom[ca.length];
List<Chain> model = new ArrayList<Chain>();
int apos = -1;
for (Atom a : ca) {
apos++;
Group parentG = a.getGroup();
Chain parentC = parentG.getChain();
Chain newChain = null;
for (Chain c : model) {
if (c.getName().equals(parentC.getName())) {
newChain = c;
break;
}
}
if (newChain == null) {
newChain = new ChainImpl();
newChain.setId(parentC.getId());
newChain.setName(parentC.getName());
model.add(newChain);
}
Group parentN = (Group) parentG.clone();
newCA[apos] = parentN.getAtom(a.getName());
try {
// if the group doesn't exist yet, this produces a StructureException
newChain.getGroupByPDB(parentN.getResidueNumber());
} catch (StructureException e) {
// the group doesn't exist yet in the newChain, let's add it
newChain.addGroup(parentN);
}
}
return newCA;
} | java | public static final Atom[] cloneAtomArray(Atom[] ca) {
Atom[] newCA = new Atom[ca.length];
List<Chain> model = new ArrayList<Chain>();
int apos = -1;
for (Atom a : ca) {
apos++;
Group parentG = a.getGroup();
Chain parentC = parentG.getChain();
Chain newChain = null;
for (Chain c : model) {
if (c.getName().equals(parentC.getName())) {
newChain = c;
break;
}
}
if (newChain == null) {
newChain = new ChainImpl();
newChain.setId(parentC.getId());
newChain.setName(parentC.getName());
model.add(newChain);
}
Group parentN = (Group) parentG.clone();
newCA[apos] = parentN.getAtom(a.getName());
try {
// if the group doesn't exist yet, this produces a StructureException
newChain.getGroupByPDB(parentN.getResidueNumber());
} catch (StructureException e) {
// the group doesn't exist yet in the newChain, let's add it
newChain.addGroup(parentN);
}
}
return newCA;
} | [
"public",
"static",
"final",
"Atom",
"[",
"]",
"cloneAtomArray",
"(",
"Atom",
"[",
"]",
"ca",
")",
"{",
"Atom",
"[",
"]",
"newCA",
"=",
"new",
"Atom",
"[",
"ca",
".",
"length",
"]",
";",
"List",
"<",
"Chain",
">",
"model",
"=",
"new",
"ArrayList",
... | Provides an equivalent copy of Atoms in a new array. Clones everything,
starting with parent groups and chains. The chain will only contain
groups that are part of the input array.
@param ca
array of representative atoms, e.g. CA atoms
@return Atom array
@since Biojava 4.1.0 | [
"Provides",
"an",
"equivalent",
"copy",
"of",
"Atoms",
"in",
"a",
"new",
"array",
".",
"Clones",
"everything",
"starting",
"with",
"parent",
"groups",
"and",
"chains",
".",
"The",
"chain",
"will",
"only",
"contain",
"groups",
"that",
"are",
"part",
"of",
"... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L933-L970 |
32,190 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.cloneGroups | public static Group[] cloneGroups(Atom[] ca) {
Group[] newGroup = new Group[ca.length];
List<Chain> model = new ArrayList<Chain>();
int apos = -1;
for (Atom a : ca) {
apos++;
Group parentG = a.getGroup();
Chain parentC = parentG.getChain();
Chain newChain = null;
for (Chain c : model) {
if (c.getName().equals(parentC.getName())) {
newChain = c;
break;
}
}
if (newChain == null) {
newChain = new ChainImpl();
newChain.setName(parentC.getName());
model.add(newChain);
}
Group ng = (Group) parentG.clone();
newGroup[apos] = ng;
newChain.addGroup(ng);
}
return newGroup;
} | java | public static Group[] cloneGroups(Atom[] ca) {
Group[] newGroup = new Group[ca.length];
List<Chain> model = new ArrayList<Chain>();
int apos = -1;
for (Atom a : ca) {
apos++;
Group parentG = a.getGroup();
Chain parentC = parentG.getChain();
Chain newChain = null;
for (Chain c : model) {
if (c.getName().equals(parentC.getName())) {
newChain = c;
break;
}
}
if (newChain == null) {
newChain = new ChainImpl();
newChain.setName(parentC.getName());
model.add(newChain);
}
Group ng = (Group) parentG.clone();
newGroup[apos] = ng;
newChain.addGroup(ng);
}
return newGroup;
} | [
"public",
"static",
"Group",
"[",
"]",
"cloneGroups",
"(",
"Atom",
"[",
"]",
"ca",
")",
"{",
"Group",
"[",
"]",
"newGroup",
"=",
"new",
"Group",
"[",
"ca",
".",
"length",
"]",
";",
"List",
"<",
"Chain",
">",
"model",
"=",
"new",
"ArrayList",
"<",
... | Clone a set of representative Atoms, but returns the parent groups
@param ca
Atom array
@return Group array | [
"Clone",
"a",
"set",
"of",
"representative",
"Atoms",
"but",
"returns",
"the",
"parent",
"groups"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L979-L1007 |
32,191 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.duplicateCA2 | public static Atom[] duplicateCA2(Atom[] ca2) {
// we don't want to rotate input atoms, do we?
Atom[] ca2clone = new Atom[ca2.length * 2];
int pos = 0;
Chain c = null;
String prevChainId = "";
for (Atom a : ca2) {
Group g = (Group) a.getGroup().clone(); // works because each group
// has only a single atom
if (c == null) {
c = new ChainImpl();
Chain orig = a.getGroup().getChain();
c.setId(orig.getId());
c.setName(orig.getName());
} else {
Chain orig = a.getGroup().getChain();
if (!orig.getId().equals(prevChainId)) {
c = new ChainImpl();
c.setId(orig.getId());
c.setName(orig.getName());
}
}
c.addGroup(g);
ca2clone[pos] = g.getAtom(a.getName());
pos++;
}
// Duplicate ca2!
c = null;
prevChainId = "";
for (Atom a : ca2) {
Group g = (Group) a.getGroup().clone();
if (c == null) {
c = new ChainImpl();
Chain orig = a.getGroup().getChain();
c.setId(orig.getId());
c.setName(orig.getName());
} else {
Chain orig = a.getGroup().getChain();
if (!orig.getId().equals(prevChainId)) {
c = new ChainImpl();
c.setId(orig.getId());
c.setName(orig.getName());
}
}
c.addGroup(g);
ca2clone[pos] = g.getAtom(a.getName());
pos++;
}
return ca2clone;
} | java | public static Atom[] duplicateCA2(Atom[] ca2) {
// we don't want to rotate input atoms, do we?
Atom[] ca2clone = new Atom[ca2.length * 2];
int pos = 0;
Chain c = null;
String prevChainId = "";
for (Atom a : ca2) {
Group g = (Group) a.getGroup().clone(); // works because each group
// has only a single atom
if (c == null) {
c = new ChainImpl();
Chain orig = a.getGroup().getChain();
c.setId(orig.getId());
c.setName(orig.getName());
} else {
Chain orig = a.getGroup().getChain();
if (!orig.getId().equals(prevChainId)) {
c = new ChainImpl();
c.setId(orig.getId());
c.setName(orig.getName());
}
}
c.addGroup(g);
ca2clone[pos] = g.getAtom(a.getName());
pos++;
}
// Duplicate ca2!
c = null;
prevChainId = "";
for (Atom a : ca2) {
Group g = (Group) a.getGroup().clone();
if (c == null) {
c = new ChainImpl();
Chain orig = a.getGroup().getChain();
c.setId(orig.getId());
c.setName(orig.getName());
} else {
Chain orig = a.getGroup().getChain();
if (!orig.getId().equals(prevChainId)) {
c = new ChainImpl();
c.setId(orig.getId());
c.setName(orig.getName());
}
}
c.addGroup(g);
ca2clone[pos] = g.getAtom(a.getName());
pos++;
}
return ca2clone;
} | [
"public",
"static",
"Atom",
"[",
"]",
"duplicateCA2",
"(",
"Atom",
"[",
"]",
"ca2",
")",
"{",
"// we don't want to rotate input atoms, do we?",
"Atom",
"[",
"]",
"ca2clone",
"=",
"new",
"Atom",
"[",
"ca2",
".",
"length",
"*",
"2",
"]",
";",
"int",
"pos",
... | Utility method for working with circular permutations. Creates a
duplicated and cloned set of Calpha atoms from the input array.
@param ca2
atom array
@return cloned and duplicated set of input array | [
"Utility",
"method",
"for",
"working",
"with",
"circular",
"permutations",
".",
"Creates",
"a",
"duplicated",
"and",
"cloned",
"set",
"of",
"Calpha",
"atoms",
"from",
"the",
"input",
"array",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L1017-L1077 |
32,192 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getAtomCAArray | public static Atom[] getAtomCAArray(Structure s) {
List<Atom> atoms = new ArrayList<Atom>();
for (Chain c : s.getChains()) {
for (Group g : c.getAtomGroups()) {
if (g.hasAtom(CA_ATOM_NAME)
&& g.getAtom(CA_ATOM_NAME).getElement() == Element.C) {
atoms.add(g.getAtom(CA_ATOM_NAME));
}
}
}
return atoms.toArray(new Atom[atoms.size()]);
} | java | public static Atom[] getAtomCAArray(Structure s) {
List<Atom> atoms = new ArrayList<Atom>();
for (Chain c : s.getChains()) {
for (Group g : c.getAtomGroups()) {
if (g.hasAtom(CA_ATOM_NAME)
&& g.getAtom(CA_ATOM_NAME).getElement() == Element.C) {
atoms.add(g.getAtom(CA_ATOM_NAME));
}
}
}
return atoms.toArray(new Atom[atoms.size()]);
} | [
"public",
"static",
"Atom",
"[",
"]",
"getAtomCAArray",
"(",
"Structure",
"s",
")",
"{",
"List",
"<",
"Atom",
">",
"atoms",
"=",
"new",
"ArrayList",
"<",
"Atom",
">",
"(",
")",
";",
"for",
"(",
"Chain",
"c",
":",
"s",
".",
"getChains",
"(",
")",
... | Return an Atom array of the C-alpha atoms. Any atom that is a carbon and
has CA name will be returned.
@param s
the structure object
@return an Atom[] array
@see #getRepresentativeAtomArray(Structure) | [
"Return",
"an",
"Atom",
"array",
"of",
"the",
"C",
"-",
"alpha",
"atoms",
".",
"Any",
"atom",
"that",
"is",
"a",
"carbon",
"and",
"has",
"CA",
"name",
"will",
"be",
"returned",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L1088-L1102 |
32,193 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.isNucleotide | public static final boolean isNucleotide(String groupCode3) {
String code = groupCode3.trim();
return nucleotides30.containsKey(code)
|| nucleotides23.containsKey(code);
} | java | public static final boolean isNucleotide(String groupCode3) {
String code = groupCode3.trim();
return nucleotides30.containsKey(code)
|| nucleotides23.containsKey(code);
} | [
"public",
"static",
"final",
"boolean",
"isNucleotide",
"(",
"String",
"groupCode3",
")",
"{",
"String",
"code",
"=",
"groupCode3",
".",
"trim",
"(",
")",
";",
"return",
"nucleotides30",
".",
"containsKey",
"(",
"code",
")",
"||",
"nucleotides23",
".",
"cont... | Test if the three-letter code of an ATOM entry corresponds to a
nucleotide or to an aminoacid.
@param groupCode3
3-character code for a group. | [
"Test",
"if",
"the",
"three",
"-",
"letter",
"code",
"of",
"an",
"ATOM",
"entry",
"corresponds",
"to",
"a",
"nucleotide",
"or",
"to",
"an",
"aminoacid",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L1267-L1271 |
32,194 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getReducedStructure | @Deprecated
public static final Structure getReducedStructure(Structure s,
String chainId) throws StructureException {
// since we deal here with structure alignments,
// only use Model 1...
Structure newS = new StructureImpl();
newS.setPDBCode(s.getPDBCode());
newS.setPDBHeader(s.getPDBHeader());
newS.setName(s.getName());
newS.setSSBonds(s.getSSBonds());
newS.setDBRefs(s.getDBRefs());
newS.setSites(s.getSites());
newS.setBiologicalAssembly(s.isBiologicalAssembly());
newS.setEntityInfos(s.getEntityInfos());
newS.setSSBonds(s.getSSBonds());
newS.setSites(s.getSites());
if (chainId != null)
chainId = chainId.trim();
if (chainId == null || chainId.equals("")) {
// only get model 0
List<Chain> model0 = s.getModel(0);
for (Chain c : model0) {
newS.addChain(c);
}
return newS;
}
Chain c = null;
try {
c = s.getChainByPDB(chainId);
} catch (StructureException e) {
logger.warn(e.getMessage() + ". Chain id " + chainId
+ " did not match, trying upper case Chain id.");
c = s.getChainByPDB(chainId.toUpperCase());
}
if (c != null) {
newS.addChain(c);
for (EntityInfo comp : s.getEntityInfos()) {
if (comp.getChainIds() != null
&& comp.getChainIds().contains(c.getChainID())) {
// found matching entity info. set description...
newS.getPDBHeader().setDescription(
"Chain " + c.getChainID() + " of " + s.getPDBCode()
+ " " + comp.getDescription());
}
}
}
return newS;
} | java | @Deprecated
public static final Structure getReducedStructure(Structure s,
String chainId) throws StructureException {
// since we deal here with structure alignments,
// only use Model 1...
Structure newS = new StructureImpl();
newS.setPDBCode(s.getPDBCode());
newS.setPDBHeader(s.getPDBHeader());
newS.setName(s.getName());
newS.setSSBonds(s.getSSBonds());
newS.setDBRefs(s.getDBRefs());
newS.setSites(s.getSites());
newS.setBiologicalAssembly(s.isBiologicalAssembly());
newS.setEntityInfos(s.getEntityInfos());
newS.setSSBonds(s.getSSBonds());
newS.setSites(s.getSites());
if (chainId != null)
chainId = chainId.trim();
if (chainId == null || chainId.equals("")) {
// only get model 0
List<Chain> model0 = s.getModel(0);
for (Chain c : model0) {
newS.addChain(c);
}
return newS;
}
Chain c = null;
try {
c = s.getChainByPDB(chainId);
} catch (StructureException e) {
logger.warn(e.getMessage() + ". Chain id " + chainId
+ " did not match, trying upper case Chain id.");
c = s.getChainByPDB(chainId.toUpperCase());
}
if (c != null) {
newS.addChain(c);
for (EntityInfo comp : s.getEntityInfos()) {
if (comp.getChainIds() != null
&& comp.getChainIds().contains(c.getChainID())) {
// found matching entity info. set description...
newS.getPDBHeader().setDescription(
"Chain " + c.getChainID() + " of " + s.getPDBCode()
+ " " + comp.getDescription());
}
}
}
return newS;
} | [
"@",
"Deprecated",
"public",
"static",
"final",
"Structure",
"getReducedStructure",
"(",
"Structure",
"s",
",",
"String",
"chainId",
")",
"throws",
"StructureException",
"{",
"// since we deal here with structure alignments,",
"// only use Model 1...",
"Structure",
"newS",
... | Reduce a structure to provide a smaller representation . Only takes the
first model of the structure. If chainName is provided only return a
structure containing that Chain ID. Converts lower case chain IDs to
upper case if structure does not contain a chain with that ID.
@param s
@param chainId
@return Structure
@since 3.0
@deprecated Use {@link StructureIdentifier#reduce(Structure)} instead (v. 4.2.0) | [
"Reduce",
"a",
"structure",
"to",
"provide",
"a",
"smaller",
"representation",
".",
"Only",
"takes",
"the",
"first",
"model",
"of",
"the",
"structure",
".",
"If",
"chainName",
"is",
"provided",
"only",
"return",
"a",
"structure",
"containing",
"that",
"Chain",... | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L1285-L1339 |
32,195 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.getGroupByPDBResidueNumber | public static final Group getGroupByPDBResidueNumber(Structure struc,
ResidueNumber pdbResNum) throws StructureException {
if (struc == null || pdbResNum == null) {
throw new IllegalArgumentException("Null argument(s).");
}
Chain chain = struc.getPolyChainByPDB(pdbResNum.getChainName());
return chain.getGroupByPDB(pdbResNum);
} | java | public static final Group getGroupByPDBResidueNumber(Structure struc,
ResidueNumber pdbResNum) throws StructureException {
if (struc == null || pdbResNum == null) {
throw new IllegalArgumentException("Null argument(s).");
}
Chain chain = struc.getPolyChainByPDB(pdbResNum.getChainName());
return chain.getGroupByPDB(pdbResNum);
} | [
"public",
"static",
"final",
"Group",
"getGroupByPDBResidueNumber",
"(",
"Structure",
"struc",
",",
"ResidueNumber",
"pdbResNum",
")",
"throws",
"StructureException",
"{",
"if",
"(",
"struc",
"==",
"null",
"||",
"pdbResNum",
"==",
"null",
")",
"{",
"throw",
"new... | Get a group represented by a ResidueNumber.
@param struc
a {@link Structure}
@param pdbResNum
a {@link ResidueNumber}
@return a group in the structure that is represented by the pdbResNum.
@throws StructureException
if the group cannot be found. | [
"Get",
"a",
"group",
"represented",
"by",
"a",
"ResidueNumber",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L1377-L1386 |
32,196 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.removeModels | public static Structure removeModels(Structure s) {
if (s.nrModels() == 1)
return s;
Structure n = new StructureImpl();
// go through whole substructure and clone ...
// copy structure data
n.setPDBCode(s.getPDBCode());
n.setName(s.getName());
// TODO: do deep copying of data!
n.setPDBHeader(s.getPDBHeader());
n.setDBRefs(s.getDBRefs());
n.setSites(s.getSites());
n.setChains(s.getModel(0));
return n;
} | java | public static Structure removeModels(Structure s) {
if (s.nrModels() == 1)
return s;
Structure n = new StructureImpl();
// go through whole substructure and clone ...
// copy structure data
n.setPDBCode(s.getPDBCode());
n.setName(s.getName());
// TODO: do deep copying of data!
n.setPDBHeader(s.getPDBHeader());
n.setDBRefs(s.getDBRefs());
n.setSites(s.getSites());
n.setChains(s.getModel(0));
return n;
} | [
"public",
"static",
"Structure",
"removeModels",
"(",
"Structure",
"s",
")",
"{",
"if",
"(",
"s",
".",
"nrModels",
"(",
")",
"==",
"1",
")",
"return",
"s",
";",
"Structure",
"n",
"=",
"new",
"StructureImpl",
"(",
")",
";",
"// go through whole substructure... | Remove all models from a Structure and keep only the first
@param s
original Structure
@return a structure that contains only the first model
@since 3.0.5 | [
"Remove",
"all",
"models",
"from",
"a",
"Structure",
"and",
"keep",
"only",
"the",
"first"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L1715-L1737 |
32,197 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.filterLigands | public static List<Group> filterLigands(List<Group> allGroups) {
List<Group> groups = new ArrayList<Group>();
for (Group g : allGroups) {
if ( g.isPolymeric())
continue;
if (!g.isWater()) {
groups.add(g);
}
}
return groups;
} | java | public static List<Group> filterLigands(List<Group> allGroups) {
List<Group> groups = new ArrayList<Group>();
for (Group g : allGroups) {
if ( g.isPolymeric())
continue;
if (!g.isWater()) {
groups.add(g);
}
}
return groups;
} | [
"public",
"static",
"List",
"<",
"Group",
">",
"filterLigands",
"(",
"List",
"<",
"Group",
">",
"allGroups",
")",
"{",
"List",
"<",
"Group",
">",
"groups",
"=",
"new",
"ArrayList",
"<",
"Group",
">",
"(",
")",
";",
"for",
"(",
"Group",
"g",
":",
"a... | Removes all polymeric and solvent groups from a list of groups | [
"Removes",
"all",
"polymeric",
"and",
"solvent",
"groups",
"from",
"a",
"list",
"of",
"groups"
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L1743-L1757 |
32,198 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.hasNonDeuteratedEquiv | public static boolean hasNonDeuteratedEquiv(Atom atom, Group currentGroup) {
if(atom.getElement()==Element.D && currentGroup.hasAtom(replaceFirstChar(atom.getName(),'D', 'H'))) {
// If it's deuterated and has a non-deuterated brother
return true;
}
return false;
} | java | public static boolean hasNonDeuteratedEquiv(Atom atom, Group currentGroup) {
if(atom.getElement()==Element.D && currentGroup.hasAtom(replaceFirstChar(atom.getName(),'D', 'H'))) {
// If it's deuterated and has a non-deuterated brother
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"hasNonDeuteratedEquiv",
"(",
"Atom",
"atom",
",",
"Group",
"currentGroup",
")",
"{",
"if",
"(",
"atom",
".",
"getElement",
"(",
")",
"==",
"Element",
".",
"D",
"&&",
"currentGroup",
".",
"hasAtom",
"(",
"replaceFirstChar",
"("... | Check to see if an Deuterated atom has a non deuterated brother in the group.
@param atom the input atom that is putatively deuterium
@param currentGroup the group the atom is in
@return true if the atom is deuterated and it's hydrogen equive exists. | [
"Check",
"to",
"see",
"if",
"an",
"Deuterated",
"atom",
"has",
"a",
"non",
"deuterated",
"brother",
"in",
"the",
"group",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L1895-L1901 |
32,199 | biojava/biojava | biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java | StructureTools.hasDeuteratedEquiv | public static boolean hasDeuteratedEquiv(Atom atom, Group currentGroup) {
if(atom.getElement()==Element.H && currentGroup.hasAtom(replaceFirstChar(atom.getName(),'H', 'D'))) {
// If it's hydrogen and has a deuterated brother
return true;
}
return false;
} | java | public static boolean hasDeuteratedEquiv(Atom atom, Group currentGroup) {
if(atom.getElement()==Element.H && currentGroup.hasAtom(replaceFirstChar(atom.getName(),'H', 'D'))) {
// If it's hydrogen and has a deuterated brother
return true;
}
return false;
} | [
"public",
"static",
"boolean",
"hasDeuteratedEquiv",
"(",
"Atom",
"atom",
",",
"Group",
"currentGroup",
")",
"{",
"if",
"(",
"atom",
".",
"getElement",
"(",
")",
"==",
"Element",
".",
"H",
"&&",
"currentGroup",
".",
"hasAtom",
"(",
"replaceFirstChar",
"(",
... | Check to see if a Hydrogen has a Deuterated brother in the group.
@param atom the input atom that is putatively hydorgen
@param currentGroup the group the atom is in
@return true if the atom is hydrogen and it's Deuterium equiv exists. | [
"Check",
"to",
"see",
"if",
"a",
"Hydrogen",
"has",
"a",
"Deuterated",
"brother",
"in",
"the",
"group",
"."
] | a1c71a8e3d40cc32104b1d387a3d3b560b43356e | https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java#L1909-L1915 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.