idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
24,700
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 ) ; } } } } }
Populate the Maps for quick retrieval
24,701
public double [ ] getDimensions ( ) { double [ ] dim = new double [ 3 ] ; dim [ 0 ] = xmax - xmin ; dim [ 1 ] = ymax - ymin ; dim [ 2 ] = zmax - zmin ; return dim ; }
Returns the dimensions of this bounding box .
24,702
public boolean overlaps ( BoundingBox o , double cutoff ) { if ( this == o ) return true ; if ( ! areOverlapping ( xmin , xmax , o . xmin , o . xmax , cutoff ) ) { return false ; } if ( ! areOverlapping ( ymin , ymax , o . ymin , o . ymax , cutoff ) ) { return false ; } if ( ! areOverlapping ( zmin , zmax , o . zmin , o . zmax , cutoff ) ) { return false ; } return true ; }
Returns true if this bounding box overlaps given one i . e . they are within one cutoff distance in one of their 3 dimensions .
24,703
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 ; }
Check if a given point falls within this box
24,704
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 ; }
Returns an array of size 2 with min and max values of given double array
24,705
public double transform ( double value ) { double logValue = Math . log ( value > 0 ? value : 0 ) / Math . log ( base ) ; return logValue ; }
Apply log transform .
24,706
private static void registerCommonProteinModifications ( InputStream inStream ) { try { ProteinModificationXmlReader . registerProteinModificationFromXml ( inStream ) ; } catch ( Exception e ) { logger . error ( "Exception: " , e ) ; } }
register common protein modifications from XML file .
24,707
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 ) ; } }
Lazy Initialization the static variables and register common modifications .
24,708
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 ) ; } }
Register a new ProteinModification .
24,709
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 ) ; }
Remove a modification from registry .
24,710
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 ; } }
Get ProteinModifications that involves one or more components .
24,711
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 ( ) ; }
Get a list of representatives names for the specified ASTRAL cutoff .
24,712
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 ) ; } } } }
Parses the FASTA file opened by reader .
24,713
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 ; }
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 .
24,714
public List < Contact > getIndicesContacts ( ) { List < Contact > list = new ArrayList < > ( ) ; 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 ++ ) { GridCell thisCell = cells [ xind ] [ yind ] [ zind ] ; if ( thisCell == null ) continue ; list . addAll ( thisCell . getContactsWithinCell ( ) ) ; 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 ; }
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 .
24,715
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 ++ ) { transformOrigPDB ( optLen [ bk ] , optAln [ bk ] [ 0 ] , optAln [ bk ] [ 1 ] , ca1 , ca2 , afpChain , bk ) ; if ( bk > 0 ) { b2 = e2 ; } if ( bk < blockNum - 1 ) { 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 ) ; }
superimposing according to the optimized alignment
24,716
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 ( ) ] ) ; }
most likely the clone flag is not needed
24,717
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 ) ; }
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 .
24,718
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 ; }
Set the list of equivalent residues in the two proteins given a list of AFPs
24,719
private void updateLocation ( ) { try { location = getLocationOnScreen ( ) ; location . y += getHeight ( ) ; dialog . setLocation ( location ) ; } catch ( IllegalComponentStateException e ) { return ; } }
Place the suggestion window under the JTextField .
24,720
public static void print ( double [ ] a ) { int N = a . length ; System . out . println ( N ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } System . out . println ( ) ; }
Print an array of doubles to standard output .
24,721
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 -- ; }
num ranges from 1 to numMappings
24,722
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 ; }
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 .
24,723
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
24,724
public void updateAxis ( Integer index , Matrix4d newAxis ) { axes . get ( index ) . setOperator ( newAxis ) ; }
Updates an axis of symmetry after the superposition changed .
24,725
public List < Matrix4d > getElementaryAxes ( ) { List < Matrix4d > ops = new ArrayList < Matrix4d > ( getNumLevels ( ) ) ; for ( Axis axis : axes ) { ops . add ( axis . getOperator ( ) ) ; } return ops ; }
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 .
24,726
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 ; }
Return the transformation that needs to be applied to a repeat in order to superimpose onto repeat 0 .
24,727
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 ; }
Return the transformation that needs to be applied to repeat x in order to superimpose onto repeat y .
24,728
private int getNumRepeats ( int level ) { int size = 1 ; if ( level < getNumLevels ( ) ) { for ( Axis axis : axes . subList ( level , getNumLevels ( ) ) ) { size *= axis . getOrder ( ) ; } } return size ; }
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 .
24,729
public List < Integer > getFirstRepeats ( int level ) { List < Integer > firstRepeats = new ArrayList < Integer > ( ) ; int m = getNumRepeats ( level + 1 ) ; int d = axes . get ( level ) . getOrder ( ) ; int n = m * d ; for ( int firstRepeat = 0 ; firstRepeat < getNumRepeats ( ) ; firstRepeat += n ) firstRepeats . add ( firstRepeat ) ; return firstRepeats ; }
Get the first repeat index of each axis of a specified level .
24,730
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 ) ) { 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 ) ) { 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 ] ) ; } } this . totalArea = this . totalArea / 2.0 ; }
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 .
24,731
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 ( ) ] ) ; }
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 .
24,732
private static int getSizeNoH ( Group g ) { int size = 0 ; for ( Atom a : g . getAtoms ( ) ) { if ( a . getElement ( ) != Element . H ) size ++ ; } return size ; }
Calculates the number of non - Hydrogen atoms in the given group
24,733
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 ; }
Returns true if the given group is part of the main chain i . e . if it is a peptide - linked group or a nucleotide
24,734
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 ) ; }
Returns the residues belonging to the interface i . e . the residues at the surface with BSA > 0
24,735
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 ) ; }
Returns the residues belonging to the surface
24,736
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 ) ; }
Tell whether the interface is isologous i . e . it is formed by the same patches of same Compound on both sides .
24,737
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 ( ) ) ; }
Finds the parent chains by looking up the references of first atom of each side of this interface
24,738
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 ( ) ) ; }
Finds the parent compounds by looking up the references of first atom of each side of this interface
24,739
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 ( ) ; } }
A basic example how to load an mmCif file and get a Structure object
24,740
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 ( ) ; } }
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 .
24,741
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 ; }
get a continue subset of Atoms based by the starting position and the length
24,742
private static final double scoreAfp ( AFP afp , double badRmsd , double fragScore ) { double s , w ; w = afp . getRmsd ( ) / badRmsd ; w = w * w ; s = fragScore * ( 1.0 - w ) ; return s ; }
Assign score to each AFP
24,743
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 ; }
Create the menu for the Alignment Panel representation of Structural Alignments . The alignment can be in AFPChain format or in the MultipleAlignment format .
24,744
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 ) ; } } return super . add ( feature ) ; }
Add specified feature to the end of the list . Updates the bounding location of the feature list if needed .
24,745
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 ; }
Check size of gaps between successive features in list . The features in the list are assumed to be appropriately ordered .
24,746
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 ( ) ; }
Concatenate successive portions of the specified sequence using the feature locations in the list . The list is assumed to be appropriately ordered .
24,747
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 ; }
Create a list of all features that include the specified attribute key .
24,748
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 ; }
Create a list of all features that overlap the specified location on the specified sequence .
24,749
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 ; }
Check if any feature in list has the specified attribute key .
24,750
public FeatureList sortByStart ( ) { FeatureI [ ] array = toArray ( new FeatureI [ 1 ] ) ; Arrays . sort ( array , new FeatureComparator ( ) ) ; return new FeatureList ( Arrays . asList ( array ) ) ; }
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 .
24,751
private List < String > processLine ( String line , BufferedReader buf , int fieldLength ) throws IOException { 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 { 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 ) ; } } } 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 ; }
Get the content of a cif entry
24,752
public static boolean jmolInClassPath ( ) { try { Class . forName ( viewer ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; return false ; } return true ; }
returns true if Jmol can be found in the classpath otherwise false .
24,753
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 .
24,754
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 ; }
open the file and read the magic number from the beginning this is used to determine the compression type
24,755
public InputStream getInputStream ( File f ) throws IOException { int magic = 0 ; InputStream test = getInputStreamFromFile ( f ) ; magic = getMagicNumber ( test ) ; test . close ( ) ; InputStream inputStream = null ; String fileName = f . getName ( ) ; if ( magic == UncompressInputStream . LZW_MAGIC ) { 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 ) ; 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 ) ; 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" ) ) { return openCompressedFile ( f ) ; } else { inputStream = getInputStreamFromFile ( f ) ; } return inputStream ; }
Get an InputStream for the file . The caller is responsible for closing the stream or otherwise a resource leak can occur .
24,756
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 ; }
Wrapper for new FileInputStream . if System . property biojava . cache . files is set will try to load files from memory cache .
24,757
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 ; }
Get the number of structurally equivalent residues
24,758
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 ; }
Get the coverage of protein 1 with the alignment
24,759
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 ; }
Get the coverage of protein 2 with the alignment
24,760
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 ; } }
Get the status of the PDB in question .
24,761
public static Status [ ] getStatus ( String [ ] pdbIds ) { Status [ ] statuses = new Status [ pdbIds . length ] ; List < Map < String , String > > attrList = getStatusIdRecords ( pdbIds ) ; 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 ++ ) { boolean foundAttr = false ; for ( Map < String , String > attrs : attrList ) { String id = attrs . get ( "structureId" ) ; if ( id == null || ! id . equalsIgnoreCase ( pdbIds [ pdbNum ] ) ) { continue ; } 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 ; }
Get the status of the a collection of PDBs in question in a single query .
24,762
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 ( ) ) { nextM = m . next ( ) ; m . previous ( ) ; while ( prevO . compareTo ( nextM ) > 0 ) { m . add ( prevO ) ; if ( ! o . hasNext ( ) ) { return ; } prevO = o . next ( ) ; } if ( prevO . equals ( nextM ) ) { if ( ! o . hasNext ( ) ) { return ; } prevO = o . next ( ) ; } m . next ( ) ; } m . add ( prevO ) ; while ( o . hasNext ( ) ) { m . add ( o . next ( ) ) ; } }
Takes two reverse sorted lists of strings and merges the second into the first . Duplicates are removed .
24,763
public static List < String > getReplaces ( String newPdbId , boolean recurse ) { List < Map < String , String > > attrList = getStatusIdRecords ( new String [ ] { newPdbId } ) ; if ( attrList == null || attrList . size ( ) != 1 ) { logger . error ( "Error getting Status for {} from the PDB website." , newPdbId ) ; return null ; } Map < String , String > attrs = attrList . get ( 0 ) ; 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" ) ; if ( replacedList == null ) { return new ArrayList < String > ( ) ; } String [ ] directDescendents = replacedList . split ( "\\s" ) ; if ( recurse ) { 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 ) ; } }
Get the ID of the protein which was made obsolete by newPdbId .
24,764
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 ) ) ; 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 ( ) ; if ( recordsCache . containsKey ( pdbId ) ) { result . add ( recordsCache . get ( pdbId ) ) ; } else { urlStr += pdbId + "," ; } } 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 ) ; List < Map < String , String > > records = handler . getRecords ( ) ; for ( Map < String , String > record : records ) { String pdbId = record . get ( "structureId" ) . toUpperCase ( ) ; if ( pdbId != null ) { recordsCache . put ( pdbId , record ) ; } } result . addAll ( handler . getRecords ( ) ) ; } 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 ; }
Fetches the status of one or more pdbIDs from the server .
24,765
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 ) ) ; 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 ; }
Returns a list of current PDB IDs
24,766
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 ; nchunks = ( nchunks + sequence . length ( ) ) / width ; int nlineCharcounter = 0 ; for ( int i = 1 ; i <= nchunks ; i ++ ) { final int insPos = width * i + nlineCharcounter ; if ( sb . length ( ) <= insPos ) { break ; } sb . insert ( insPos , "\n" ) ; nlineCharcounter ++ ; } return sb . toString ( ) ; }
Format sequence per width letter in one string . Without spaces .
24,767
public void completeGroup ( ) { List < List < Integer > > gens = new ArrayList < List < Integer > > ( permutations ) ; Set < List < Integer > > known = new HashSet < List < Integer > > ( permutations ) ; 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 ) ; permutations . add ( y ) ; known . add ( y ) ; } } } currentLevel = nextLevel ; } }
Starts with an incomplete set of group generators in permutations and expands it to include all possible combinations .
24,768
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 ; }
Returns the distance matrix used to construct this guide tree . The scores have been normalized .
24,769
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 ; }
Returns the similarity matrix used to construct this guide tree . The scores have not been normalized .
24,770
private void orderTransformationsByChainId ( Structure asymUnit , List < BiologicalAssemblyTransformation > transformations ) { final List < String > chainIds = getChainIds ( asymUnit ) ; Collections . sort ( transformations , new Comparator < BiologicalAssemblyTransformation > ( ) { public int compare ( BiologicalAssemblyTransformation t1 , BiologicalAssemblyTransformation t2 ) { if ( t1 . getId ( ) . equals ( t2 . getId ( ) ) ) { return chainIds . indexOf ( t1 . getChainId ( ) ) - chainIds . indexOf ( t2 . getChainId ( ) ) ; } else { return t1 . getId ( ) . compareTo ( t2 . getId ( ) ) ; } } } ) ; }
Orders model transformations by chain ids in the same order as in the asymmetric unit
24,771
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 ; }
Returns a list of chain ids in the order they are specified in the ATOM records in the asymmetric unit
24,772
private void addChainMultiModel ( Structure s , Chain newChain , String transformId ) { 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 ) ; } }
Adds a chain to the given structure to form a biological assembly adding the symmetry expanded chains as new models per transformId .
24,773
public ArrayList < BiologicalAssemblyTransformation > getBioUnitTransformationList ( PdbxStructAssembly psa , List < PdbxStructAssemblyGen > psags , List < PdbxStructOperList > operators ) { init ( ) ; 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 ; }
Returns a list of transformation matrices for the generation of a macromolecular assembly for the specified assembly Id .
24,774
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 ; }
Count how many Atoms are contained within a Structure object .
24,775
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 ; }
Count how many groups are contained within a structure object .
24,776
public static List < Group > getLigandsByProximity ( Collection < Group > target , Atom [ ] query , double cutoff ) { Grid grid = new Grid ( cutoff ) ; grid . addAtoms ( query ) ; List < Group > ligands = new ArrayList < > ( ) ; for ( Group g : target ) { if ( g . isWater ( ) ) { continue ; } if ( g . isPolymeric ( ) ) { continue ; } List < Atom > groupAtoms = g . getAtoms ( ) ; if ( ! grid . hasAnyContact ( Calc . atomsToPoints ( groupAtoms ) ) ) { continue ; } ligands . add ( g ) ; } return ligands ; }
Finds all ligand groups from the target which fall within the cutoff distance of some atom from the query set .
24,777
public static Chain addGroupToStructure ( Structure s , Group g , int model , Chain chainGuess , boolean clone ) { synchronized ( s ) { String chainId = g . getChainId ( ) ; assert ! chainId . isEmpty ( ) ; Chain chain ; if ( chainGuess != null && chainGuess . getId ( ) == chainId ) { chain = chainGuess ; } else { chain = s . getChain ( chainId , model ) ; if ( chain == null ) { 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 ) ; chain . setSeqResGroups ( oldChain . getSeqResGroups ( ) ) ; chain . setSeqMisMatches ( oldChain . getSeqMisMatches ( ) ) ; s . addChain ( chain , model ) ; } } if ( clone ) { g = ( Group ) g . clone ( ) ; } chain . addGroup ( g ) ; return chain ; } }
Adds a particular group to a structure . A new chain will be created if necessary .
24,778
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 ) ; } }
Add a list of groups to a new structure . Chains will be automatically created in the new structure as needed .
24,779
public static Set < Group > getAllGroupsFromSubset ( Atom [ ] atoms , GroupType types ) { 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 ( ) ; } } } Set < Chain > allChains = new HashSet < > ( ) ; if ( s != null ) { allChains . addAll ( s . getChains ( ) ) ; } 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 ( ) ; } Set < Group > full = new HashSet < > ( ) ; for ( Chain c : allChains ) { if ( types == null ) { full . addAll ( c . getAtomGroups ( ) ) ; } else { full . addAll ( c . getAtomGroups ( types ) ) ; } } return full ; }
Expand a set of atoms into all groups from the same structure .
24,780
public static final Atom [ ] getAllNonHAtomArray ( Structure s , boolean hetAtoms ) { AtomIterator iter = new AtomIterator ( s ) ; return getAllNonHAtomArray ( s , hetAtoms , iter ) ; }
Returns and array of all non - Hydrogen atoms in the given Structure optionally including HET atoms or not . Waters are not included .
24,781
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 ( ) ] ) ; }
Returns and array of all non - Hydrogen atoms in the given Chain optionally including HET atoms or not Waters are not included .
24,782
private static void extractAtoms ( String [ ] atomNames , List < Chain > chains , List < Atom > atoms ) { for ( Chain c : chains ) { for ( Group g : c . getAtomGroups ( ) ) { List < Atom > thisGroupAtoms = new ArrayList < Atom > ( ) ; boolean thisGroupAllAtoms = true ; for ( String atomName : atomNames ) { Atom a = g . getAtom ( atomName ) ; if ( a == null ) { thisGroupAllAtoms = false ; break ; } thisGroupAtoms . add ( a ) ; } if ( thisGroupAllAtoms ) { for ( Atom a : thisGroupAtoms ) { atoms . add ( a ) ; } } } } }
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 .
24,783
public static final Atom [ ] getAtomArray ( Chain c , String [ ] atomNames ) { List < Atom > atoms = new ArrayList < Atom > ( ) ; for ( Group g : c . getAtomGroups ( ) ) { List < Atom > thisGroupAtoms = new ArrayList < Atom > ( ) ; 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 + "'" ) ; thisGroupAllAtoms = false ; break ; } thisGroupAtoms . add ( a ) ; } if ( thisGroupAllAtoms ) { for ( Atom a : thisGroupAtoms ) { atoms . add ( a ) ; } } } return atoms . toArray ( new Atom [ atoms . size ( ) ] ) ; }
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 .
24,784
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 { newChain . getGroupByPDB ( parentN . getResidueNumber ( ) ) ; } catch ( StructureException e ) { newChain . addGroup ( parentN ) ; } } return newCA ; }
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 .
24,785
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 ; }
Clone a set of representative Atoms but returns the parent groups
24,786
public static Atom [ ] duplicateCA2 ( Atom [ ] ca2 ) { 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 ( ) ; 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 ++ ; } 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 ; }
Utility method for working with circular permutations . Creates a duplicated and cloned set of Calpha atoms from the input array .
24,787
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 ( ) ] ) ; }
Return an Atom array of the C - alpha atoms . Any atom that is a carbon and has CA name will be returned .
24,788
public static final boolean isNucleotide ( String groupCode3 ) { String code = groupCode3 . trim ( ) ; return nucleotides30 . containsKey ( code ) || nucleotides23 . containsKey ( code ) ; }
Test if the three - letter code of an ATOM entry corresponds to a nucleotide or to an aminoacid .
24,789
public static final Structure getReducedStructure ( Structure s , String chainId ) throws StructureException { 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 ( "" ) ) { 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 ( ) ) ) { newS . getPDBHeader ( ) . setDescription ( "Chain " + c . getChainID ( ) + " of " + s . getPDBCode ( ) + " " + comp . getDescription ( ) ) ; } } } return 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 .
24,790
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 ) ; }
Get a group represented by a ResidueNumber .
24,791
public static Structure removeModels ( Structure s ) { if ( s . nrModels ( ) == 1 ) return s ; Structure n = new StructureImpl ( ) ; n . setPDBCode ( s . getPDBCode ( ) ) ; n . setName ( s . getName ( ) ) ; n . setPDBHeader ( s . getPDBHeader ( ) ) ; n . setDBRefs ( s . getDBRefs ( ) ) ; n . setSites ( s . getSites ( ) ) ; n . setChains ( s . getModel ( 0 ) ) ; return n ; }
Remove all models from a Structure and keep only the first
24,792
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 ; }
Removes all polymeric and solvent groups from a list of groups
24,793
public static boolean hasNonDeuteratedEquiv ( Atom atom , Group currentGroup ) { if ( atom . getElement ( ) == Element . D && currentGroup . hasAtom ( replaceFirstChar ( atom . getName ( ) , 'D' , 'H' ) ) ) { return true ; } return false ; }
Check to see if an Deuterated atom has a non deuterated brother in the group .
24,794
public static boolean hasDeuteratedEquiv ( Atom atom , Group currentGroup ) { if ( atom . getElement ( ) == Element . H && currentGroup . hasAtom ( replaceFirstChar ( atom . getName ( ) , 'H' , 'D' ) ) ) { return true ; } return false ; }
Check to see if a Hydrogen has a Deuterated brother in the group .
24,795
private Point3d getMidPoint ( Point3d p1 , Point3d p2 , Point3d p3 ) { Vector3d v1 = new Vector3d ( ) ; v1 . sub ( p1 , p2 ) ; Vector3d v2 = new Vector3d ( ) ; v2 . sub ( p3 , p2 ) ; Vector3d v3 = new Vector3d ( ) ; v3 . add ( v1 ) ; v3 . add ( v2 ) ; v3 . normalize ( ) ; double dTotal = v1 . length ( ) ; double rise = p2 . y - p1 . y ; double chord = Math . sqrt ( dTotal * dTotal - rise * rise ) ; double angle = helixLayers . getByLargestContacts ( ) . getAxisAngle ( ) . angle ; double radius = chord / Math . sin ( angle / 2 ) / 2 ; v3 . scale ( radius ) ; v3 . add ( p2 ) ; Point3d cor = new Point3d ( v3 ) ; return cor ; }
Return a midpoint of a helix calculated from three positions of three adjacent subunit centers .
24,796
private void calcBoundaries ( ) { minBoundary . x = Double . MAX_VALUE ; maxBoundary . x = Double . MIN_VALUE ; minBoundary . y = Double . MAX_VALUE ; maxBoundary . x = Double . MIN_VALUE ; minBoundary . z = Double . MAX_VALUE ; maxBoundary . z = Double . MIN_VALUE ; xzRadiusMax = Double . MIN_VALUE ; Point3d probe = new Point3d ( ) ; for ( Point3d [ ] list : subunits . getTraces ( ) ) { for ( Point3d p : list ) { probe . set ( p ) ; transformationMatrix . transform ( probe ) ; minBoundary . x = Math . min ( minBoundary . x , probe . x ) ; maxBoundary . x = Math . max ( maxBoundary . x , probe . x ) ; minBoundary . y = Math . min ( minBoundary . y , probe . y ) ; maxBoundary . y = Math . max ( maxBoundary . y , probe . y ) ; minBoundary . z = Math . min ( minBoundary . z , probe . z ) ; maxBoundary . z = Math . max ( maxBoundary . z , probe . z ) ; xzRadiusMax = Math . max ( xzRadiusMax , Math . sqrt ( probe . x * probe . x + probe . z * probe . z ) ) ; } } }
Calculates the min and max boundaries of the structure after it has been transformed into its canonical orientation .
24,797
public static String getJmolString ( MultipleAlignment multAln , List < Atom [ ] > transformedAtoms , ColorBrewer colorPalette , boolean colorByBlocks ) { if ( colorByBlocks ) return getMultiBlockJmolString ( multAln , transformedAtoms , colorPalette , colorByBlocks ) ; Color [ ] colors = colorPalette . getColorPalette ( multAln . size ( ) ) ; StringBuffer j = new StringBuffer ( ) ; j . append ( DEFAULT_SCRIPT ) ; StringBuffer sel = new StringBuffer ( ) ; sel . append ( "select *; color lightgrey; backbone 0.1; " ) ; List < List < String > > allPDB = new ArrayList < List < String > > ( ) ; for ( int i = 0 ; i < multAln . size ( ) ; i ++ ) { List < String > pdb = MultipleAlignmentJmolDisplay . getPDBresnum ( i , multAln , transformedAtoms . get ( i ) ) ; allPDB . add ( pdb ) ; sel . append ( "select " ) ; int pos = 0 ; for ( String res : pdb ) { if ( pos > 0 ) sel . append ( "," ) ; pos ++ ; sel . append ( res ) ; sel . append ( "/" + ( i + 1 ) ) ; } if ( pos == 0 ) sel . append ( "none" ) ; sel . append ( "; backbone 0.3 ; color [" + colors [ i ] . getRed ( ) + "," + colors [ i ] . getGreen ( ) + "," + colors [ i ] . getBlue ( ) + "]; " ) ; } j . append ( sel ) ; j . append ( "model 0; " ) ; j . append ( LIGAND_DISPLAY_SCRIPT ) ; return j . toString ( ) ; }
Generate a Jmol command String that colors the aligned residues of every structure .
24,798
public static String getMultiBlockJmolString ( MultipleAlignment multAln , List < Atom [ ] > transformedAtoms , ColorBrewer colorPalette , boolean colorByBlocks ) { StringWriter jmol = new StringWriter ( ) ; jmol . append ( DEFAULT_SCRIPT ) ; jmol . append ( "select *; color lightgrey; backbone 0.1; " ) ; int blockNum = multAln . getBlocks ( ) . size ( ) ; Color [ ] colors = colorPalette . getColorPalette ( blockNum ) ; for ( int str = 0 ; str < transformedAtoms . size ( ) ; str ++ ) { jmol . append ( "select */" + ( str + 1 ) + "; color lightgrey; model " + ( str + 1 ) + "; " ) ; int index = 0 ; for ( BlockSet bs : multAln . getBlockSets ( ) ) { for ( Block b : bs . getBlocks ( ) ) { List < List < Integer > > alignRes = b . getAlignRes ( ) ; printJmolScript4Block ( transformedAtoms . get ( str ) , alignRes , colors [ index ] , jmol , str , index , blockNum ) ; index ++ ; } } } jmol . append ( "model 0; " ) ; jmol . append ( LIGAND_DISPLAY_SCRIPT ) ; return jmol . toString ( ) ; }
Colors every Block of the structures with a different color following the palette . It colors each Block differently no matter if it is from the same or different BlockSet .
24,799
public List < Contact > getContactsWithinCell ( ) { List < Contact > contacts = new ArrayList < Contact > ( ) ; Point3d [ ] iAtoms = grid . getIAtoms ( ) ; Point3d [ ] jAtoms = grid . getJAtoms ( ) ; double cutoff = grid . getCutoff ( ) ; if ( jAtoms == null ) { for ( int i : iIndices ) { for ( int j : iIndices ) { if ( j > i ) { double distance = iAtoms [ i ] . distance ( iAtoms [ j ] ) ; if ( distance < cutoff ) contacts . add ( new Contact ( i , j , distance ) ) ; } } } } else { for ( int i : iIndices ) { for ( int j : jIndices ) { double distance = iAtoms [ i ] . distance ( jAtoms [ j ] ) ; if ( distance < cutoff ) contacts . add ( new Contact ( i , j , distance ) ) ; } } } return contacts ; }
Calculates all distances of atoms within this cell returning those that are within the given cutoff as a list of Contacts containing the indices of the pair and the calculated distance .