idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
24,200 | public Point getLegendPosition ( int lineNr , int chainNr ) { int x = DEFAULT_X_SPACE ; int y = lineNr * DEFAULT_Y_STEP + DEFAULT_Y_SPACE ; y += chainNr * DEFAULT_LINE_SEPARATION ; Point p = new Point ( x , y ) ; return p ; } | provide the coordinates for where to draw the legend for line X and if it is chain 1 or 2 |
24,201 | public static void writeProteinSequence ( File file , Collection < ProteinSequence > proteinSequences ) throws Exception { FileOutputStream outputStream = new FileOutputStream ( file ) ; BufferedOutputStream bo = new BufferedOutputStream ( outputStream ) ; writeProteinSequence ( bo , proteinSequences ) ; bo . close ( ) ; outputStream . close ( ) ; } | Write collection of protein sequences to a file |
24,202 | public static void writeSequence ( File file , Sequence < ? > sequence ) throws Exception { FileOutputStream outputStream = new FileOutputStream ( file ) ; BufferedOutputStream bo = new BufferedOutputStream ( outputStream ) ; writeSequences ( bo , singleSeqToCollection ( sequence ) ) ; bo . close ( ) ; outputStream . close ( ) ; } | Write a sequence to a file |
24,203 | public static void writeSequence ( OutputStream outputStream , Sequence < ? > sequence ) throws Exception { writeSequences ( outputStream , singleSeqToCollection ( sequence ) ) ; } | Write a sequence to OutputStream |
24,204 | public SequenceView < C > get ( int index ) { int start = toStartIndex ( index ) ; int end = index + ( getWindowSize ( ) - 1 ) ; return getBackingSequence ( ) . getSubSequence ( start , end ) ; } | Returns the window specified at the given index in offsets i . e . asking for position 2 in a moving window sequence of size 3 will get you the window starting at position 4 . |
24,205 | private Color4f getPolyhedronColor ( ) { Color4f [ ] colors = getSymmetryColors ( 5 ) ; Color4f strongestColor = colors [ 4 ] ; Color4f complement = new Color4f ( Color . WHITE ) ; complement . sub ( strongestColor ) ; return complement ; } | Return a color that is complementary to the symmetry color |
24,206 | public static < C extends Compound > int countCompounds ( Sequence < C > sequence , C ... compounds ) { int count = 0 ; Map < C , Integer > compositon = getComposition ( sequence ) ; for ( C compound : compounds ) { if ( compositon . containsKey ( compound ) ) { count = compositon . get ( compound ) + count ; } } return count ; } | For the given vargs of compounds this method counts the number of times those compounds appear in the given sequence |
24,207 | public static int countGC ( Sequence < NucleotideCompound > sequence ) { CompoundSet < NucleotideCompound > cs = sequence . getCompoundSet ( ) ; NucleotideCompound G = cs . getCompoundForString ( "G" ) ; NucleotideCompound C = cs . getCompoundForString ( "C" ) ; NucleotideCompound g = cs . getCompoundForString ( "g" ) ; NucleotideCompound c = cs . getCompoundForString ( "c" ) ; return countCompounds ( sequence , G , C , g , c ) ; } | Returns the count of GC in the given sequence |
24,208 | public static int countAT ( Sequence < NucleotideCompound > sequence ) { CompoundSet < NucleotideCompound > cs = sequence . getCompoundSet ( ) ; NucleotideCompound A = cs . getCompoundForString ( "A" ) ; NucleotideCompound T = cs . getCompoundForString ( "T" ) ; NucleotideCompound a = cs . getCompoundForString ( "a" ) ; NucleotideCompound t = cs . getCompoundForString ( "t" ) ; return countCompounds ( sequence , A , T , a , t ) ; } | Returns the count of AT in the given sequence |
24,209 | public static < C extends Compound > Map < C , Integer > getComposition ( Sequence < C > sequence ) { Map < C , Integer > results = new HashMap < C , Integer > ( ) ; for ( C currentCompound : sequence ) { Integer currentInteger = results . get ( currentCompound ) ; if ( currentInteger == null ) currentInteger = 0 ; currentInteger ++ ; results . put ( currentCompound , currentInteger ) ; } return results ; } | Does a linear scan over the given Sequence and records the number of times each base appears . The returned map will return 0 if a compound is asked for and the Map has no record of it . |
24,210 | public static < C extends Compound > void write ( Appendable appendable , Sequence < C > sequence ) throws IOException { for ( C compound : sequence ) { appendable . append ( compound . toString ( ) ) ; } } | Used as a way of sending a Sequence to a writer without the cost of converting to a full length String and then writing the data out |
24,211 | public static < C extends Compound > int indexOf ( Sequence < C > sequence , C compound ) { int index = 1 ; for ( C currentCompound : sequence ) { if ( currentCompound . equals ( compound ) ) { return index ; } index ++ ; } return 0 ; } | Performs a linear search of the given Sequence for the given compound . Once we find the compound we return the position . |
24,212 | public static < C extends Compound > Iterator < C > createIterator ( Sequence < C > sequence ) { return new SequenceIterator < C > ( sequence ) ; } | Creates a simple sequence iterator which moves through a sequence going from 1 to the length of the Sequence . Modification of the Sequence is not allowed . |
24,213 | public static < C extends Compound > SequenceView < C > createSubSequence ( Sequence < C > sequence , int start , int end ) { return new SequenceProxyView < C > ( sequence , start , end ) ; } | Creates a simple sub sequence view delimited by the given start and end . |
24,214 | public static < C extends Compound > String checksum ( Sequence < C > sequence ) { CRC64Checksum checksum = new CRC64Checksum ( ) ; for ( C compound : sequence ) { checksum . update ( compound . getShortName ( ) ) ; } return checksum . toString ( ) ; } | Performs a simple CRC64 checksum on any given sequence . |
24,215 | public static < C extends Compound > List < SequenceView < C > > overlappingKmers ( Sequence < C > sequence , int kmer ) { List < SequenceView < C > > l = new ArrayList < SequenceView < C > > ( ) ; List < Iterator < SequenceView < C > > > windows = new ArrayList < Iterator < SequenceView < C > > > ( ) ; for ( int i = 1 ; i <= kmer ; i ++ ) { if ( i == 1 ) { windows . add ( new WindowedSequence < C > ( sequence , kmer ) . iterator ( ) ) ; } else { SequenceView < C > sv = sequence . getSubSequence ( i , sequence . getLength ( ) ) ; windows . add ( new WindowedSequence < C > ( sv , kmer ) . iterator ( ) ) ; } } OUTER : while ( true ) { for ( int i = 0 ; i < kmer ; i ++ ) { Iterator < SequenceView < C > > iterator = windows . get ( i ) ; boolean breakLoop = true ; if ( iterator . hasNext ( ) ) { l . add ( iterator . next ( ) ) ; breakLoop = false ; } if ( breakLoop ) { break OUTER ; } } } return l ; } | Used to generate overlapping k - mers such i . e . ATGTA will give rise to ATG TGT & GTA |
24,216 | public static < C extends Compound > boolean sequenceEqualityIgnoreCase ( Sequence < C > source , Sequence < C > target ) { return baseSequenceEquality ( source , target , true ) ; } | A case - insensitive manner of comparing two sequence objects together . We will throw out any compounds which fail to match on their sequence length & compound sets used . The code will also bail out the moment we find something is wrong with a Sequence . Cost to run is linear to the length of the Sequence . |
24,217 | public static < C extends Compound > boolean sequenceEquality ( Sequence < C > source , Sequence < C > target ) { return baseSequenceEquality ( source , target , false ) ; } | A case - sensitive manner of comparing two sequence objects together . We will throw out any compounds which fail to match on their sequence length & compound sets used . The code will also bail out the moment we find something is wrong with a Sequence . Cost to run is linear to the length of the Sequence . |
24,218 | public boolean hasNext ( int windowSize , int increment ) { if ( windowSize <= 0 ) { throw new IllegalArgumentException ( "Window size must be positive." ) ; } try { if ( increment > 0 ) { return windowSize == mBounds . suffix ( mPosition ) . prefix ( windowSize ) . length ( ) ; } else { if ( mPosition == 0 ) { return windowSize == mBounds . suffix ( - windowSize ) . length ( ) ; } else { return windowSize == mBounds . prefix ( mPosition ) . suffix ( - windowSize ) . length ( ) ; } } } catch ( Exception e ) { return false ; } } | Check if next window of specified size is available . |
24,219 | public Location next ( int windowSize , int increment ) { if ( windowSize <= 0 ) { throw new IllegalArgumentException ( "Window size must be positive." ) ; } if ( increment == 0 ) { throw new IllegalArgumentException ( "Increment must be non-zero." ) ; } Location r ; try { if ( increment > 0 ) { r = mBounds . suffix ( mPosition ) . prefix ( windowSize ) ; } else { if ( mPosition == 0 ) { r = mBounds . suffix ( - windowSize ) ; } else { r = mBounds . prefix ( mPosition ) . suffix ( - windowSize ) ; } } mPosition += increment ; } catch ( Exception e ) { throw new IndexOutOfBoundsException ( e . toString ( ) ) ; } return r ; } | Get next window of specified size then increment position by specified amount . |
24,220 | public void setProxySequenceReader ( SequenceReader < C > proxyLoader ) { this . sequenceStorage = proxyLoader ; if ( proxyLoader instanceof FeaturesKeyWordInterface ) { this . setFeaturesKeyWord ( ( FeaturesKeyWordInterface ) sequenceStorage ) ; } if ( proxyLoader instanceof DatabaseReferenceInterface ) { this . setDatabaseReferences ( ( DatabaseReferenceInterface ) sequenceStorage ) ; } if ( proxyLoader instanceof FeatureRetriever ) { this . setFeatureRetriever ( ( FeatureRetriever ) sequenceStorage ) ; HashMap < String , ArrayList < AbstractFeature > > ff = getFeatureRetriever ( ) . getFeatures ( ) ; for ( String k : ff . keySet ( ) ) { for ( AbstractFeature f : ff . get ( k ) ) { this . addFeature ( f ) ; } } ArrayList < DBReferenceInfo > dbQualifiers = ( ArrayList ) ff . get ( "source" ) . get ( 0 ) . getQualifiers ( ) . get ( "db_xref" ) ; DBReferenceInfo dbQualifier = dbQualifiers . get ( 0 ) ; if ( dbQualifier != null ) this . setTaxonomy ( new TaxonomyID ( dbQualifier . getDatabase ( ) + ":" + dbQualifier . getId ( ) , DataSource . UNKNOWN ) ) ; } if ( getAccession ( ) == null && proxyLoader instanceof UniprotProxySequenceReader ) { this . setAccession ( proxyLoader . getAccession ( ) ) ; } } | Very important method that allows external mappings of sequence data and features . This method will gain additional interface inspection that allows external data sources with knowledge of features for a sequence to be supported . |
24,221 | public String getSource ( ) { if ( source != null ) { return source ; } if ( parentSequence != null ) { return parentSequence . getSource ( ) ; } return null ; } | Added support for the source of this sequence for GFF3 export If a sub sequence doesn t have source then check for parent source |
24,222 | public List < FeatureInterface < AbstractSequence < C > , C > > getFeatures ( int bioSequencePosition ) { ArrayList < FeatureInterface < AbstractSequence < C > , C > > featureHits = new ArrayList < FeatureInterface < AbstractSequence < C > , C > > ( ) ; if ( features != null ) { for ( FeatureInterface < AbstractSequence < C > , C > feature : features ) { if ( bioSequencePosition >= feature . getLocations ( ) . getStart ( ) . getPosition ( ) && bioSequencePosition <= feature . getLocations ( ) . getEnd ( ) . getPosition ( ) ) { featureHits . add ( feature ) ; } } } return featureHits ; } | Return features at a sequence position |
24,223 | public void addFeature ( int bioStart , int bioEnd , FeatureInterface < AbstractSequence < C > , C > feature ) { SequenceLocation < AbstractSequence < C > , C > sequenceLocation = new SequenceLocation < AbstractSequence < C > , C > ( bioStart , bioEnd , this ) ; feature . setLocation ( sequenceLocation ) ; addFeature ( feature ) ; } | Method to help set the proper details for a feature as it relates to a sequence where the feature needs to have a location on the sequence |
24,224 | public void addFeature ( FeatureInterface < AbstractSequence < C > , C > feature ) { features . add ( feature ) ; ArrayList < FeatureInterface < AbstractSequence < C > , C > > featureList = groupedFeatures . get ( feature . getType ( ) ) ; if ( featureList == null ) { featureList = new ArrayList < FeatureInterface < AbstractSequence < C > , C > > ( ) ; groupedFeatures . put ( feature . getType ( ) , featureList ) ; } featureList . add ( feature ) ; Collections . sort ( features , AbstractFeature . LOCATION_LENGTH ) ; Collections . sort ( featureList , AbstractFeature . LOCATION_LENGTH ) ; } | Add a feature to this sequence . The feature will be added to the collection where the order is start position and if more than one feature at the same start position then longest is added first . This helps on doing feature layout for displaying features in SequenceFeaturePanel |
24,225 | public void removeFeature ( FeatureInterface < AbstractSequence < C > , C > feature ) { features . remove ( feature ) ; ArrayList < FeatureInterface < AbstractSequence < C > , C > > featureList = groupedFeatures . get ( feature . getType ( ) ) ; if ( featureList != null ) { featureList . remove ( feature ) ; if ( featureList . isEmpty ( ) ) { groupedFeatures . remove ( feature . getType ( ) ) ; } } } | Remove a feature from the sequence |
24,226 | public Point3i getCellIndices ( Tuple3d pt ) { Point3d p = new Point3d ( pt ) ; this . transfToCrystal ( p ) ; int x = ( int ) Math . floor ( p . x ) ; int y = ( int ) Math . floor ( p . y ) ; int z = ( int ) Math . floor ( p . z ) ; return new Point3i ( x , y , z ) ; } | Get the index of a unit cell to which the query point belongs . |
24,227 | public void transfToOriginCell ( Tuple3d [ ] points , Tuple3d reference ) { reference = new Point3d ( reference ) ; transfToCrystal ( reference ) ; int x = ( int ) Math . floor ( reference . x ) ; int y = ( int ) Math . floor ( reference . y ) ; int z = ( int ) Math . floor ( reference . z ) ; for ( Tuple3d point : points ) { transfToCrystal ( point ) ; point . x -= x ; point . y -= y ; point . z -= z ; transfToOrthonormal ( point ) ; } } | Converts a set of points so that the reference point falls in the unit cell . |
24,228 | public double getMaxDimension ( ) { if ( maxDimension != 0 ) { return maxDimension ; } Point3d vert0 = new Point3d ( 0 , 0 , 0 ) ; Point3d vert1 = new Point3d ( 1 , 0 , 0 ) ; transfToOrthonormal ( vert1 ) ; Point3d vert2 = new Point3d ( 0 , 1 , 0 ) ; transfToOrthonormal ( vert2 ) ; Point3d vert3 = new Point3d ( 0 , 0 , 1 ) ; transfToOrthonormal ( vert3 ) ; Point3d vert4 = new Point3d ( 1 , 1 , 0 ) ; transfToOrthonormal ( vert4 ) ; Point3d vert5 = new Point3d ( 1 , 0 , 1 ) ; transfToOrthonormal ( vert5 ) ; Point3d vert6 = new Point3d ( 0 , 1 , 1 ) ; transfToOrthonormal ( vert6 ) ; Point3d vert7 = new Point3d ( 1 , 1 , 1 ) ; transfToOrthonormal ( vert7 ) ; ArrayList < Double > vertDists = new ArrayList < Double > ( ) ; vertDists . add ( vert0 . distance ( vert7 ) ) ; vertDists . add ( vert3 . distance ( vert4 ) ) ; vertDists . add ( vert1 . distance ( vert6 ) ) ; vertDists . add ( vert2 . distance ( vert5 ) ) ; maxDimension = Collections . max ( vertDists ) ; return maxDimension ; } | Gets the maximum dimension of the unit cell . |
24,229 | private SiftsSegment getSiftsSegment ( Element el ) { String segId = el . getAttribute ( "segId" ) ; String start = el . getAttribute ( "start" ) ; String end = el . getAttribute ( "end" ) ; SiftsSegment seg = new SiftsSegment ( segId , start , end ) ; if ( debug ) System . out . println ( "parsed " + seg ) ; NodeList nl = el . getElementsByTagName ( "listResidue" ) ; if ( nl != null && nl . getLength ( ) > 0 ) { for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Element listResidueEl = ( Element ) nl . item ( i ) ; NodeList residueNodes = listResidueEl . getElementsByTagName ( "residue" ) ; if ( residueNodes != null && residueNodes . getLength ( ) > 0 ) { for ( int j = 0 ; j < residueNodes . getLength ( ) ; j ++ ) { Element residue = ( Element ) residueNodes . item ( j ) ; SiftsResidue pos = getResidue ( residue ) ; seg . addResidue ( pos ) ; } } } } return seg ; } | segId = 4hhb_A_1_140 start = 1 end = 140 |
24,230 | public static Color rotateHue ( Color color , float fraction ) { float [ ] af = Color . RGBtoHSB ( color . getRed ( ) , color . getGreen ( ) , color . getBlue ( ) , null ) ; float hue = af [ 0 ] ; float saturation = af [ 1 ] ; float brightness = af [ 2 ] ; float hueNew = hue + fraction ; Color hsb = Color . getHSBColor ( hueNew , saturation , brightness ) ; return new Color ( hsb . getRed ( ) , hsb . getGreen ( ) , hsb . getBlue ( ) , color . getAlpha ( ) ) ; } | Rotate a color through HSB space |
24,231 | protected PdbPairsMessage getAlignmentPairsFromServer ( ) { String url = params . getServer ( ) ; int nrPairs = params . getStepSize ( ) ; if ( maxNrAlignments < nrPairs ) nrPairs = maxNrAlignments ; SortedSet < PdbPair > allPairs = new TreeSet < PdbPair > ( ) ; PdbPairsMessage msg = null ; try { if ( progressListeners != null ) notifyRequestingAlignments ( nrPairs ) ; if ( ! waitForAlignments ) { msg = JFatCatClient . getPdbPairs ( url , nrPairs , userName ) ; allPairs = msg . getPairs ( ) ; } else { while ( allPairs . isEmpty ( ) ) { msg = JFatCatClient . getPdbPairs ( url , nrPairs , userName ) ; allPairs = msg . getPairs ( ) ; if ( allPairs . isEmpty ( ) ) { randomSleep ( ) ; } } } } catch ( JobKillException k ) { logger . debug ( "Terminating job" , k ) ; terminate ( ) ; } catch ( Exception e ) { logger . error ( "Error while requesting alignment pairs" , e ) ; randomSleep ( ) ; } return msg ; } | talk to centralized server and fetch all alignments to run . |
24,232 | public static Map < Integer , Integer > alignmentAsMap ( AFPChain afpChain ) throws StructureException { Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; if ( afpChain . getAlnLength ( ) < 1 ) { return map ; } int [ ] [ ] [ ] optAln = afpChain . getOptAln ( ) ; int [ ] optLen = afpChain . getOptLen ( ) ; for ( int block = 0 ; block < afpChain . getBlockNum ( ) ; block ++ ) { for ( int pos = 0 ; pos < optLen [ block ] ; pos ++ ) { int res1 = optAln [ block ] [ 0 ] [ pos ] ; int res2 = optAln [ block ] [ 1 ] [ pos ] ; if ( map . containsKey ( res1 ) ) { throw new StructureException ( String . format ( "Residue %d aligned to both %d and %d." , res1 , map . get ( res1 ) , res2 ) ) ; } map . put ( res1 , res2 ) ; } } return map ; } | Creates a Map specifying the alignment as a mapping between residue indices of protein 1 and residue indices of protein 2 . |
24,233 | public static int getSymmetryOrder ( Map < Integer , Integer > alignment , Map < Integer , Integer > identity , final int maxSymmetry , final float minimumMetricChange ) { List < Integer > preimage = new ArrayList < Integer > ( alignment . keySet ( ) ) ; List < Integer > image = new ArrayList < Integer > ( preimage ) ; int bestSymmetry = 1 ; double bestMetric = Double . POSITIVE_INFINITY ; boolean foundSymmetry = false ; if ( debug ) { logger . trace ( "Symm\tPos\tDelta" ) ; } for ( int n = 1 ; n <= maxSymmetry ; n ++ ) { int deltasSq = 0 ; int numDeltas = 0 ; for ( int i = 0 ; i < image . size ( ) ; i ++ ) { Integer pre = image . get ( i ) ; Integer intermediate = ( pre == null ? null : alignment . get ( pre ) ) ; Integer post = ( intermediate == null ? null : identity . get ( intermediate ) ) ; image . set ( i , post ) ; if ( post != null ) { int delta = post - preimage . get ( i ) ; deltasSq += delta * delta ; numDeltas ++ ; if ( debug ) { logger . debug ( "%d\t%d\t%d\n" , n , preimage . get ( i ) , delta ) ; } } } double metric = Math . sqrt ( ( double ) deltasSq / numDeltas ) ; if ( ! foundSymmetry && metric < bestMetric * minimumMetricChange ) { if ( bestMetric < Double . POSITIVE_INFINITY ) { foundSymmetry = true ; } bestSymmetry = n ; bestMetric = metric ; } if ( ! debug && foundSymmetry ) { break ; } } if ( foundSymmetry ) { return bestSymmetry ; } else { return 1 ; } } | Tries to detect symmetry in an alignment . |
24,234 | public static int getSymmetryOrder ( AFPChain afpChain , int maxSymmetry , float minimumMetricChange ) throws StructureException { Map < Integer , Integer > alignment = AlignmentTools . alignmentAsMap ( afpChain ) ; Map < Integer , Integer > identity = guessSequentialAlignment ( alignment , true ) ; return AlignmentTools . getSymmetryOrder ( alignment , identity , maxSymmetry , minimumMetricChange ) ; } | Guesses the order of symmetry in an alignment |
24,235 | public static Map < Integer , Integer > guessSequentialAlignment ( Map < Integer , Integer > alignment , boolean inverseAlignment ) { Map < Integer , Integer > identity = new HashMap < Integer , Integer > ( ) ; SortedSet < Integer > aligned1 = new TreeSet < Integer > ( ) ; SortedSet < Integer > aligned2 = new TreeSet < Integer > ( ) ; for ( Entry < Integer , Integer > pair : alignment . entrySet ( ) ) { aligned1 . add ( pair . getKey ( ) ) ; if ( ! aligned2 . add ( pair . getValue ( ) ) ) throw new IllegalArgumentException ( "Alignment is not one-to-one for residue " + pair . getValue ( ) + " of the second structure." ) ; } Iterator < Integer > it1 = aligned1 . iterator ( ) ; Iterator < Integer > it2 = aligned2 . iterator ( ) ; while ( it1 . hasNext ( ) ) { if ( inverseAlignment ) { identity . put ( it2 . next ( ) , it1 . next ( ) ) ; } else { identity . put ( it1 . next ( ) , it2 . next ( ) ) ; } } return identity ; } | Takes a potentially non - sequential alignment and guesses a sequential version of it . Residues from each structure are sorted sequentially and then compared directly . |
24,236 | public static AFPChain createAFPChain ( Atom [ ] ca1 , Atom [ ] ca2 , ResidueNumber [ ] aligned1 , ResidueNumber [ ] aligned2 ) throws StructureException { int alnLen = aligned1 . length ; if ( alnLen != aligned2 . length ) { throw new IllegalArgumentException ( "Alignment lengths are not equal" ) ; } AFPChain a = new AFPChain ( AFPChain . UNKNOWN_ALGORITHM ) ; try { a . setName1 ( ca1 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) . getName ( ) ) ; if ( ca2 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) != null ) { a . setName2 ( ca2 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) . getName ( ) ) ; } } catch ( Exception e ) { } a . setBlockNum ( 1 ) ; a . setCa1Length ( ca1 . length ) ; a . setCa2Length ( ca2 . length ) ; a . setOptLength ( alnLen ) ; a . setOptLen ( new int [ ] { alnLen } ) ; Matrix [ ] ms = new Matrix [ a . getBlockNum ( ) ] ; a . setBlockRotationMatrix ( ms ) ; Atom [ ] blockShiftVector = new Atom [ a . getBlockNum ( ) ] ; a . setBlockShiftVector ( blockShiftVector ) ; String [ ] [ ] [ ] pdbAln = new String [ 1 ] [ 2 ] [ alnLen ] ; for ( int i = 0 ; i < alnLen ; i ++ ) { pdbAln [ 0 ] [ 0 ] [ i ] = aligned1 [ i ] . getChainName ( ) + ":" + aligned1 [ i ] ; pdbAln [ 0 ] [ 1 ] [ i ] = aligned2 [ i ] . getChainName ( ) + ":" + aligned2 [ i ] ; } a . setPdbAln ( pdbAln ) ; AFPChainXMLParser . rebuildAFPChain ( a , ca1 , ca2 ) ; return a ; } | Fundamentally an alignment is just a list of aligned residues in each protein . This method converts two lists of ResidueNumbers into an AFPChain . |
24,237 | public static AFPChain replaceOptAln ( int [ ] [ ] [ ] newAlgn , AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 ) throws StructureException { int order = newAlgn . length ; int [ ] optLens = new int [ order ] ; for ( int s = 0 ; s < order ; s ++ ) { optLens [ s ] = newAlgn [ s ] [ 0 ] . length ; } int optLength = 0 ; for ( int s = 0 ; s < order ; s ++ ) { optLength += optLens [ s ] ; } AFPChain copyAFP = ( AFPChain ) afpChain . clone ( ) ; copyAFP . setOptLength ( optLength ) ; copyAFP . setOptLen ( optLens ) ; copyAFP . setOptAln ( newAlgn ) ; copyAFP . setBlockNum ( order ) ; copyAFP . setBlockSize ( optLens ) ; copyAFP . setBlockResList ( newAlgn ) ; copyAFP . setBlockResSize ( optLens ) ; copyAFP . setBlockGap ( calculateBlockGap ( newAlgn ) ) ; Atom [ ] ca2clone = StructureTools . cloneAtomArray ( ca2 ) ; AlignmentTools . updateSuperposition ( copyAFP , ca1 , ca2clone ) ; copyAFP . setAlnsymb ( null ) ; AFPAlignmentDisplay . getAlign ( copyAFP , ca1 , ca2clone ) ; return copyAFP ; } | It replaces an optimal alignment of an AFPChain and calculates all the new alignment scores and variables . |
24,238 | public static AFPChain replaceOptAln ( AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 , Map < Integer , Integer > alignment ) throws StructureException { Integer [ ] res1 = alignment . keySet ( ) . toArray ( new Integer [ 0 ] ) ; Arrays . sort ( res1 ) ; List < Integer > blockLens = new ArrayList < Integer > ( 2 ) ; int optLength = 0 ; Integer lastRes = alignment . get ( res1 [ 0 ] ) ; int blkLen = lastRes == null ? 0 : 1 ; for ( int i = 1 ; i < res1 . length ; i ++ ) { Integer currRes = alignment . get ( res1 [ i ] ) ; assert ( currRes != null ) ; if ( lastRes < currRes ) { blkLen ++ ; } else { blockLens . add ( blkLen ) ; optLength += blkLen ; blkLen = 1 ; } lastRes = currRes ; } blockLens . add ( blkLen ) ; optLength += blkLen ; int [ ] [ ] [ ] optAln = new int [ blockLens . size ( ) ] [ ] [ ] ; int pos1 = 0 ; for ( int blk = 0 ; blk < blockLens . size ( ) ; blk ++ ) { optAln [ blk ] = new int [ 2 ] [ ] ; blkLen = blockLens . get ( blk ) ; optAln [ blk ] [ 0 ] = new int [ blkLen ] ; optAln [ blk ] [ 1 ] = new int [ blkLen ] ; int pos = 0 ; while ( pos < blkLen ) { optAln [ blk ] [ 0 ] [ pos ] = res1 [ pos1 ] ; Integer currRes = alignment . get ( res1 [ pos1 ] ) ; optAln [ blk ] [ 1 ] [ pos ] = currRes ; pos ++ ; pos1 ++ ; } } assert ( pos1 == optLength ) ; int [ ] optLens = new int [ blockLens . size ( ) ] ; for ( int i = 0 ; i < blockLens . size ( ) ; i ++ ) { optLens [ i ] = blockLens . get ( i ) ; } return replaceOptAln ( afpChain , ca1 , ca2 , blockLens . size ( ) , optLens , optAln ) ; } | Takes an AFPChain and replaces the optimal alignment based on an alignment map |
24,239 | public static < S , T > String toConciseAlignmentString ( Map < S , T > alignment , Map < T , S > identity ) { Map < S , T > alig = new HashMap < S , T > ( alignment ) ; Map < S , List < S > > inverse = new HashMap < S , List < S > > ( ) ; for ( Entry < S , T > e : alig . entrySet ( ) ) { S val = identity . get ( e . getValue ( ) ) ; if ( inverse . containsKey ( val ) ) { List < S > l = inverse . get ( val ) ; l . add ( e . getKey ( ) ) ; } else { List < S > l = new ArrayList < S > ( ) ; l . add ( e . getKey ( ) ) ; inverse . put ( val , l ) ; } } StringBuilder str = new StringBuilder ( ) ; while ( ! alig . isEmpty ( ) ) { S seedNode = alig . keySet ( ) . iterator ( ) . next ( ) ; S node = seedNode ; if ( inverse . containsKey ( seedNode ) ) { node = inverse . get ( seedNode ) . iterator ( ) . next ( ) ; while ( node != seedNode && inverse . containsKey ( node ) ) { node = inverse . get ( node ) . iterator ( ) . next ( ) ; } } seedNode = node ; str . append ( node ) ; while ( alig . containsKey ( node ) ) { S lastNode = node ; node = identity . get ( alig . get ( lastNode ) ) ; str . append ( '>' ) ; str . append ( node ) ; alig . remove ( lastNode ) ; List < S > inv = inverse . get ( node ) ; if ( inv . size ( ) > 1 ) { inv . remove ( node ) ; } else { inverse . remove ( node ) ; } } if ( ! alig . isEmpty ( ) ) { str . append ( ' ' ) ; } } return str . toString ( ) ; } | Print an alignment map in a concise representation . Edges are given as two numbers separated by > . They are chained together where possible or separated by spaces where disjoint or branched . |
24,240 | public static int [ ] calculateBlockGap ( int [ ] [ ] [ ] optAln ) { int [ ] blockGap = new int [ optAln . length ] ; for ( int i = 0 ; i < optAln . length ; i ++ ) { int gaps = 0 ; int last1 = 0 ; int last2 = 0 ; for ( int j = 0 ; j < optAln [ i ] [ 0 ] . length ; j ++ ) { if ( j == 0 ) { last1 = optAln [ i ] [ 0 ] [ j ] ; last2 = optAln [ i ] [ 1 ] [ j ] ; } else { if ( optAln [ i ] [ 0 ] [ j ] > last1 + 1 || optAln [ i ] [ 1 ] [ j ] > last2 + 1 ) { gaps ++ ; last1 = optAln [ i ] [ 0 ] [ j ] ; last2 = optAln [ i ] [ 1 ] [ j ] ; } else { last1 = optAln [ i ] [ 0 ] [ j ] ; last2 = optAln [ i ] [ 1 ] [ j ] ; } } } blockGap [ i ] = gaps ; } return blockGap ; } | Method that calculates the number of gaps in each subunit block of an optimal AFP alignment . |
24,241 | public static final List < Chain > getAlignedModel ( Atom [ ] ca ) { List < Chain > model = new ArrayList < Chain > ( ) ; for ( Atom a : ca ) { Group g = a . getGroup ( ) ; Chain parentC = g . getChain ( ) ; Chain newChain = null ; for ( Chain c : model ) { if ( c . getId ( ) . equals ( parentC . getId ( ) ) ) { newChain = c ; break ; } } if ( newChain == null ) { newChain = new ChainImpl ( ) ; newChain . setId ( parentC . getId ( ) ) ; model . add ( newChain ) ; } newChain . addGroup ( g ) ; } return model ; } | get an artificial List of chains containing the Atoms and groups . Does NOT rotate anything . |
24,242 | public static final Structure getAlignedStructure ( Atom [ ] ca1 , Atom [ ] ca2 ) throws StructureException { Structure s = new StructureImpl ( ) ; List < Chain > model1 = getAlignedModel ( ca1 ) ; s . addModel ( model1 ) ; List < Chain > model2 = getAlignedModel ( ca2 ) ; s . addModel ( model2 ) ; return s ; } | Get an artifical Structure containing both chains . Does NOT rotate anything |
24,243 | public static void shiftCA2 ( AFPChain afpChain , Atom [ ] ca2 , Matrix m , Atom shift , Group [ ] twistedGroups ) { int i = - 1 ; for ( Atom a : ca2 ) { i ++ ; Group g = a . getGroup ( ) ; Calc . rotate ( g , m ) ; Calc . shift ( g , shift ) ; if ( g . hasAltLoc ( ) ) { for ( Group alt : g . getAltLocs ( ) ) { for ( Atom alta : alt . getAtoms ( ) ) { if ( g . getAtoms ( ) . contains ( alta ) ) continue ; Calc . rotate ( alta , m ) ; Calc . shift ( alta , shift ) ; } } } twistedGroups [ i ] = g ; } } | only shift CA positions . |
24,244 | public static void fillAlignedAtomArrays ( AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 , Atom [ ] ca1aligned , Atom [ ] ca2aligned ) { int pos = 0 ; int [ ] blockLens = afpChain . getOptLen ( ) ; int [ ] [ ] [ ] optAln = afpChain . getOptAln ( ) ; assert ( afpChain . getBlockNum ( ) <= optAln . length ) ; for ( int block = 0 ; block < afpChain . getBlockNum ( ) ; block ++ ) { for ( int i = 0 ; i < blockLens [ block ] ; i ++ ) { int pos1 = optAln [ block ] [ 0 ] [ i ] ; int pos2 = optAln [ block ] [ 1 ] [ i ] ; Atom a1 = ca1 [ pos1 ] ; Atom a2 = ( Atom ) ca2 [ pos2 ] . clone ( ) ; ca1aligned [ pos ] = a1 ; ca2aligned [ pos ] = a2 ; pos ++ ; } } if ( pos != afpChain . getOptLength ( ) ) { logger . warn ( "AFPChainScorer getTMScore: Problems reconstructing alignment! nr of loaded atoms is " + pos + " but should be " + afpChain . getOptLength ( ) ) ; ca1aligned = ( Atom [ ] ) resizeArray ( ca1aligned , pos ) ; ca2aligned = ( Atom [ ] ) resizeArray ( ca2aligned , pos ) ; } } | Fill the aligned Atom arrays with the equivalent residues in the afpChain . |
24,245 | public static AFPChain deleteHighestDistanceColumn ( AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 ) throws StructureException { int [ ] [ ] [ ] optAln = afpChain . getOptAln ( ) ; int maxBlock = 0 ; int maxPos = 0 ; double maxDistance = Double . MIN_VALUE ; for ( int b = 0 ; b < optAln . length ; b ++ ) { for ( int p = 0 ; p < optAln [ b ] [ 0 ] . length ; p ++ ) { Atom ca2clone = ca2 [ optAln [ b ] [ 1 ] [ p ] ] ; Calc . rotate ( ca2clone , afpChain . getBlockRotationMatrix ( ) [ b ] ) ; Calc . shift ( ca2clone , afpChain . getBlockShiftVector ( ) [ b ] ) ; double distance = Calc . getDistance ( ca1 [ optAln [ b ] [ 0 ] [ p ] ] , ca2clone ) ; if ( distance > maxDistance ) { maxBlock = b ; maxPos = p ; maxDistance = distance ; } } } return deleteColumn ( afpChain , ca1 , ca2 , maxBlock , maxPos ) ; } | Find the alignment position with the highest atomic distance between the equivalent atomic positions of the arrays and remove it from the alignment . |
24,246 | public static AFPChain deleteColumn ( AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 , int block , int pos ) throws StructureException { if ( afpChain . getBlockNum ( ) <= block ) { throw new IndexOutOfBoundsException ( String . format ( "Block index requested (%d) is higher than the total number of AFPChain blocks (%d)." , block , afpChain . getBlockNum ( ) ) ) ; } if ( afpChain . getOptAln ( ) [ block ] [ 0 ] . length <= pos ) { throw new IndexOutOfBoundsException ( String . format ( "Position index requested (%d) is higher than the total number of aligned position in the AFPChain block (%d)." , block , afpChain . getBlockSize ( ) [ block ] ) ) ; } int [ ] [ ] [ ] optAln = afpChain . getOptAln ( ) ; int [ ] newPos0 = new int [ optAln [ block ] [ 0 ] . length - 1 ] ; int [ ] newPos1 = new int [ optAln [ block ] [ 1 ] . length - 1 ] ; int position = 0 ; for ( int p = 0 ; p < optAln [ block ] [ 0 ] . length ; p ++ ) { if ( p == pos ) continue ; newPos0 [ position ] = optAln [ block ] [ 0 ] [ p ] ; newPos1 [ position ] = optAln [ block ] [ 1 ] [ p ] ; position ++ ; } optAln [ block ] [ 0 ] = newPos0 ; optAln [ block ] [ 1 ] = newPos1 ; return AlignmentTools . replaceOptAln ( optAln , afpChain , ca1 , ca2 ) ; } | Delete an alignment position from the original alignment object . |
24,247 | public void identify ( final Structure structure , final Set < ProteinModification > potentialModifications ) { if ( structure == null ) { throw new IllegalArgumentException ( "Null structure." ) ; } identify ( structure . getChains ( ) , potentialModifications ) ; } | Identify a set of modifications in a structure . |
24,248 | public void identify ( final Chain chain , final Set < ProteinModification > potentialModifications ) { identify ( Collections . singletonList ( chain ) , potentialModifications ) ; } | Identify a set of modifications in a a chains . |
24,249 | public void identify ( final List < Chain > chains , final Set < ProteinModification > potentialModifications ) { if ( chains == null ) { throw new IllegalArgumentException ( "Null structure." ) ; } if ( potentialModifications == null ) { throw new IllegalArgumentException ( "Null potentialModifications." ) ; } reset ( ) ; if ( potentialModifications . isEmpty ( ) ) { return ; } residues = new ArrayList < Group > ( ) ; List < Group > ligands = new ArrayList < Group > ( ) ; Map < Component , Set < Group > > mapCompGroups = new HashMap < Component , Set < Group > > ( ) ; for ( Chain chain : chains ) { List < Group > ress = StructureUtil . getAminoAcids ( chain ) ; List < Group > ligs = StructureTools . filterLigands ( chain . getAtomGroups ( ) ) ; residues . addAll ( ress ) ; residues . removeAll ( ligs ) ; ligands . addAll ( ligs ) ; addModificationGroups ( potentialModifications , ress , ligs , mapCompGroups ) ; } if ( residues . isEmpty ( ) ) { String pdbId = "?" ; if ( chains . size ( ) > 0 ) { Structure struc = chains . get ( 0 ) . getStructure ( ) ; if ( struc != null ) pdbId = struc . getPDBCode ( ) ; } logger . warn ( "No amino acids found for {}. Either you did not parse the PDB file with alignSEQRES records, or this record does not contain any amino acids." , pdbId ) ; } List < ModifiedCompound > modComps = new ArrayList < ModifiedCompound > ( ) ; for ( ProteinModification mod : potentialModifications ) { ModificationCondition condition = mod . getCondition ( ) ; List < Component > components = condition . getComponents ( ) ; if ( ! mapCompGroups . keySet ( ) . containsAll ( components ) ) { continue ; } int sizeComps = components . size ( ) ; if ( sizeComps == 1 ) { processCrosslink1 ( mapCompGroups , modComps , mod , components ) ; } else { processMultiCrosslink ( mapCompGroups , modComps , mod , condition ) ; } } if ( recordAdditionalAttachments ) { for ( ModifiedCompound mc : modComps ) { identifyAdditionalAttachments ( mc , ligands , chains ) ; } } mergeModComps ( modComps ) ; identifiedModifiedCompounds . addAll ( modComps ) ; if ( recordUnidentifiableModifiedCompounds ) { recordUnidentifiableAtomLinkages ( modComps , ligands ) ; recordUnidentifiableModifiedResidues ( modComps ) ; } } | Identify a set of modifications in a a list of chains . |
24,250 | private void identifyAdditionalAttachments ( ModifiedCompound mc , List < Group > ligands , List < Chain > chains ) { if ( ligands . isEmpty ( ) ) { return ; } List < Group > identifiedGroups = new ArrayList < Group > ( ) ; for ( StructureGroup num : mc . getGroups ( false ) ) { Group group ; try { ResidueNumber resNum = new ResidueNumber ( ) ; resNum . setChainName ( num . getChainId ( ) ) ; resNum . setSeqNum ( num . getResidueNumber ( ) ) ; resNum . setInsCode ( num . getInsCode ( ) ) ; group = getGroup ( num , chains ) ; } catch ( StructureException e ) { logger . error ( "Exception: " , e ) ; continue ; } identifiedGroups . add ( group ) ; } int start = 0 ; int n = identifiedGroups . size ( ) ; while ( n > start ) { for ( Group group1 : ligands ) { for ( int i = start ; i < n ; i ++ ) { Group group2 = identifiedGroups . get ( i ) ; if ( ! identifiedGroups . contains ( group1 ) ) { List < Atom [ ] > linkedAtoms = StructureUtil . findAtomLinkages ( group1 , group2 , false , bondLengthTolerance ) ; if ( ! linkedAtoms . isEmpty ( ) ) { for ( Atom [ ] atoms : linkedAtoms ) { mc . addAtomLinkage ( StructureUtil . getStructureAtomLinkage ( atoms [ 0 ] , false , atoms [ 1 ] , false ) ) ; } identifiedGroups . add ( group1 ) ; break ; } } } } start = n ; n = identifiedGroups . size ( ) ; } } | identify additional groups that are not directly attached to amino acids . |
24,251 | private void mergeModComps ( List < ModifiedCompound > modComps ) { TreeSet < Integer > remove = new TreeSet < Integer > ( ) ; int n = modComps . size ( ) ; for ( int icurr = 1 ; icurr < n ; icurr ++ ) { ModifiedCompound curr = modComps . get ( icurr ) ; String id = curr . getModification ( ) . getId ( ) ; if ( ProteinModificationRegistry . getById ( id ) . getCategory ( ) != ModificationCategory . UNDEFINED ) continue ; int ipre = 0 ; for ( ; ipre < icurr ; ipre ++ ) { if ( remove . contains ( ipre ) ) continue ; ModifiedCompound pre = modComps . get ( ipre ) ; if ( ! Collections . disjoint ( pre . getGroups ( false ) , curr . getGroups ( false ) ) ) { break ; } } if ( ipre < icurr ) { ModifiedCompound mcKeep = modComps . get ( ipre ) ; if ( mcKeep . getModification ( ) . getId ( ) . equals ( id ) ) { mcKeep . addAtomLinkages ( curr . getAtomLinkages ( ) ) ; remove . add ( icurr ) ; } } } Iterator < Integer > it = remove . descendingIterator ( ) ; while ( it . hasNext ( ) ) { modComps . remove ( it . next ( ) . intValue ( ) ) ; } } | Merge identified modified compounds if linked . |
24,252 | private void recordUnidentifiableAtomLinkages ( List < ModifiedCompound > modComps , List < Group > ligands ) { Set < StructureAtomLinkage > identifiedLinkages = new HashSet < StructureAtomLinkage > ( ) ; for ( ModifiedCompound mc : modComps ) { identifiedLinkages . addAll ( mc . getAtomLinkages ( ) ) ; } int nRes = residues . size ( ) ; for ( int i = 0 ; i < nRes - 1 ; i ++ ) { Group group1 = residues . get ( i ) ; for ( int j = i + 1 ; j < nRes ; j ++ ) { Group group2 = residues . get ( j ) ; List < Atom [ ] > linkages = StructureUtil . findAtomLinkages ( group1 , group2 , true , bondLengthTolerance ) ; for ( Atom [ ] atoms : linkages ) { StructureAtomLinkage link = StructureUtil . getStructureAtomLinkage ( atoms [ 0 ] , true , atoms [ 1 ] , true ) ; unidentifiableAtomLinkages . add ( link ) ; } } } int nLig = ligands . size ( ) ; for ( int i = 0 ; i < nRes ; i ++ ) { Group group1 = residues . get ( i ) ; for ( int j = 0 ; j < nLig ; j ++ ) { Group group2 = ligands . get ( j ) ; if ( group1 . equals ( group2 ) ) { continue ; } List < Atom [ ] > linkages = StructureUtil . findAtomLinkages ( group1 , group2 , false , bondLengthTolerance ) ; for ( Atom [ ] atoms : linkages ) { StructureAtomLinkage link = StructureUtil . getStructureAtomLinkage ( atoms [ 0 ] , true , atoms [ 1 ] , false ) ; unidentifiableAtomLinkages . add ( link ) ; } } } } | Record unidentifiable atom linkages in a chain . Only linkages between two residues or one residue and one ligand will be recorded . |
24,253 | private List < List < Atom [ ] > > getMatchedAtomsOfLinkages ( ModificationCondition condition , Map < Component , Set < Group > > mapCompGroups ) { List < ModificationLinkage > linkages = condition . getLinkages ( ) ; int nLink = linkages . size ( ) ; List < List < Atom [ ] > > matchedAtomsOfLinkages = new ArrayList < List < Atom [ ] > > ( nLink ) ; for ( int iLink = 0 ; iLink < nLink ; iLink ++ ) { ModificationLinkage linkage = linkages . get ( iLink ) ; Component comp1 = linkage . getComponent1 ( ) ; Component comp2 = linkage . getComponent2 ( ) ; Set < Group > groups1 = mapCompGroups . get ( comp1 ) ; Set < Group > groups2 = mapCompGroups . get ( comp2 ) ; List < Atom [ ] > list = new ArrayList < Atom [ ] > ( ) ; List < String > potentialNamesOfAtomOnGroup1 = linkage . getPDBNameOfPotentialAtomsOnComponent1 ( ) ; for ( String name : potentialNamesOfAtomOnGroup1 ) { if ( name . equals ( "*" ) ) { potentialNamesOfAtomOnGroup1 = null ; break ; } } List < String > potentialNamesOfAtomOnGroup2 = linkage . getPDBNameOfPotentialAtomsOnComponent2 ( ) ; for ( String name : potentialNamesOfAtomOnGroup2 ) { if ( name . equals ( "*" ) ) { potentialNamesOfAtomOnGroup2 = null ; break ; } } for ( Group g1 : groups1 ) { for ( Group g2 : groups2 ) { if ( g1 . equals ( g2 ) ) { continue ; } boolean ignoreNCLinkage = potentialNamesOfAtomOnGroup1 == null && potentialNamesOfAtomOnGroup2 == null && residues . contains ( g1 ) && residues . contains ( g2 ) ; Atom [ ] atoms = StructureUtil . findNearestAtomLinkage ( g1 , g2 , potentialNamesOfAtomOnGroup1 , potentialNamesOfAtomOnGroup2 , ignoreNCLinkage , bondLengthTolerance ) ; if ( atoms != null ) { list . add ( atoms ) ; } } } if ( list . isEmpty ( ) ) { break ; } matchedAtomsOfLinkages . add ( list ) ; } return matchedAtomsOfLinkages ; } | Get matched atoms for all linkages . |
24,254 | private void assembleLinkages ( List < List < Atom [ ] > > matchedAtomsOfLinkages , ProteinModification mod , List < ModifiedCompound > ret ) { ModificationCondition condition = mod . getCondition ( ) ; List < ModificationLinkage > modLinks = condition . getLinkages ( ) ; int nLink = matchedAtomsOfLinkages . size ( ) ; int [ ] indices = new int [ nLink ] ; Set < ModifiedCompound > identifiedCompounds = new HashSet < ModifiedCompound > ( ) ; while ( indices [ 0 ] < matchedAtomsOfLinkages . get ( 0 ) . size ( ) ) { List < Atom [ ] > atomLinkages = new ArrayList < Atom [ ] > ( nLink ) ; for ( int iLink = 0 ; iLink < nLink ; iLink ++ ) { Atom [ ] atoms = matchedAtomsOfLinkages . get ( iLink ) . get ( indices [ iLink ] ) ; atomLinkages . add ( atoms ) ; } if ( matchLinkages ( modLinks , atomLinkages ) ) { int n = atomLinkages . size ( ) ; List < StructureAtomLinkage > linkages = new ArrayList < StructureAtomLinkage > ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { Atom [ ] linkage = atomLinkages . get ( i ) ; StructureAtomLinkage link = StructureUtil . getStructureAtomLinkage ( linkage [ 0 ] , residues . contains ( linkage [ 0 ] . getGroup ( ) ) , linkage [ 1 ] , residues . contains ( linkage [ 1 ] . getGroup ( ) ) ) ; linkages . add ( link ) ; } ModifiedCompound mc = new ModifiedCompoundImpl ( mod , linkages ) ; if ( ! identifiedCompounds . contains ( mc ) ) { ret . add ( mc ) ; identifiedCompounds . add ( mc ) ; } } int i = nLink - 1 ; while ( i >= 0 ) { if ( i == 0 || indices [ i ] < matchedAtomsOfLinkages . get ( i ) . size ( ) - 1 ) { indices [ i ] ++ ; break ; } else { indices [ i ] = 0 ; i -- ; } } } } | Assembly the matched linkages |
24,255 | protected int getSeqPos ( int panelPos ) { int seqPos = Math . round ( ( panelPos - SequenceScalePanel . DEFAULT_X_START ) / scale ) ; if ( seqPos < 0 ) seqPos = 0 ; return seqPos ; } | start counting at 0 ... |
24,256 | public String getOrientationName ( int index ) { if ( getAxisTransformation ( ) . getRotationGroup ( ) . getPointGroup ( ) . equals ( "C2" ) ) { if ( index == 0 ) { return "Front C2 axis" ; } else if ( index == 2 ) { return "Back C2 axis" ; } } return getPolyhedron ( ) . getViewName ( index ) ; } | Returns the name of a specific orientation |
24,257 | public XMLWriter toXML ( PrintWriter pw ) throws IOException { XMLWriter xw = new PrettyXMLWriter ( pw ) ; toXML ( xw ) ; return xw ; } | convert Configuration to an XML file so it can be serialized |
24,258 | public XMLWriter toXML ( XMLWriter xw ) throws IOException { xw . printRaw ( "<?xml version='1.0' standalone='no' ?>" ) ; xw . openTag ( "JFatCatConfig" ) ; xw . openTag ( "PDBFILEPATH" ) ; String tempdir = System . getProperty ( TMP_DIR ) ; if ( ! pdbFilePath . equals ( tempdir ) ) xw . attribute ( "path" , pdbFilePath ) ; xw . attribute ( "fetchBehavior" , fetchBehavior + "" ) ; xw . attribute ( "obsoleteBehavior" , obsoleteBehavior + "" ) ; xw . attribute ( "fileFormat" , fileFormat ) ; xw . closeTag ( "PDBFILEPATH" ) ; xw . closeTag ( "JFatCatConfig" ) ; return xw ; } | convert Configuration to an XML file so it can be serialized add to an already existing xml file . |
24,259 | private void mapIds ( ) { if ( queryReferences != null ) { queryReferencesMap = new HashMap < String , Sequence > ( queryReferences . size ( ) ) ; for ( int counter = 0 ; counter < queryReferences . size ( ) ; counter ++ ) { String id = "Query_" + ( counter + 1 ) ; queryReferencesMap . put ( id , queryReferences . get ( counter ) ) ; } } if ( databaseReferences != null ) { databaseReferencesMap = new HashMap < String , Sequence > ( databaseReferences . size ( ) ) ; for ( int counter = 0 ; counter < databaseReferences . size ( ) ; counter ++ ) { String id = "gnl|BL_ORD_ID|" + ( counter ) ; databaseReferencesMap . put ( id , databaseReferences . get ( counter ) ) ; } } } | fill the map association between sequences an a unique id |
24,260 | public void sort ( ) { Collections . sort ( list ) ; int i = 1 ; for ( StructureInterface interf : list ) { interf . setId ( i ) ; i ++ ; } } | Sorts the interface list and reassigns ids based on new sorting |
24,261 | public void addNcsEquivalent ( StructureInterface interfaceNew , StructureInterface interfaceRef ) { this . add ( interfaceNew ) ; if ( clustersNcs == null ) { clustersNcs = new ArrayList < > ( ) ; } if ( interfaceRef == null ) { StructureInterfaceCluster newCluster = new StructureInterfaceCluster ( ) ; newCluster . addMember ( interfaceNew ) ; clustersNcs . add ( newCluster ) ; return ; } Optional < StructureInterfaceCluster > clusterRef = clustersNcs . stream ( ) . filter ( r -> r . getMembers ( ) . stream ( ) . anyMatch ( c -> c . equals ( interfaceRef ) ) ) . findFirst ( ) ; if ( clusterRef . isPresent ( ) ) { clusterRef . get ( ) . addMember ( interfaceNew ) ; return ; } logger . warn ( "The specified reference interface, if not null, should have been added to this set previously. " + "Creating new cluster and adding both interfaces. This is likely a bug." ) ; this . add ( interfaceRef ) ; StructureInterfaceCluster newCluster = new StructureInterfaceCluster ( ) ; newCluster . addMember ( interfaceRef ) ; newCluster . addMember ( interfaceNew ) ; clustersNcs . add ( newCluster ) ; } | Add an interface to the list possibly defining it as NCS - equivalent to an interface already in the list . Used to build up the NCS clustering . |
24,262 | public static StructureInterfaceList calculateInterfaces ( Structure struc ) { CrystalBuilder builder = new CrystalBuilder ( struc ) ; StructureInterfaceList interfaces = builder . getUniqueInterfaces ( ) ; logger . debug ( "Calculating ASA for " + interfaces . size ( ) + " potential interfaces" ) ; interfaces . calcAsas ( StructureInterfaceList . DEFAULT_ASA_SPHERE_POINTS , Runtime . getRuntime ( ) . availableProcessors ( ) , StructureInterfaceList . DEFAULT_MIN_COFACTOR_SIZE ) ; interfaces . removeInterfacesBelowArea ( ) ; interfaces . getClusters ( ) ; logger . debug ( "Found " + interfaces . size ( ) + " interfaces" ) ; return interfaces ; } | Calculates the interfaces for a structure using default parameters |
24,263 | public static String getNewickString ( Phylogeny phylo , boolean writeDistances ) throws IOException { PhylogenyWriter w = new PhylogenyWriter ( ) ; StringBuffer newickString = w . toNewHampshire ( phylo , writeDistances ) ; return newickString . toString ( ) ; } | Convert a Phylogenetic tree to its Newick representation so that it can be exported to an external application . |
24,264 | public static BasicSymmetricalDistanceMatrix cloneDM ( BasicSymmetricalDistanceMatrix distM ) { int n = distM . getSize ( ) ; BasicSymmetricalDistanceMatrix cloneDM = new BasicSymmetricalDistanceMatrix ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { cloneDM . setIdentifier ( i , distM . getIdentifier ( i ) ) ; for ( int j = i + 1 ; j < n ; j ++ ) { cloneDM . setValue ( i , j , distM . getValue ( i , j ) ) ; } } return cloneDM ; } | Helper function to clone a forester symmetrical DistanceMatrix . |
24,265 | public List < AtomContact > getContactsWithinDistance ( double distance ) { List < AtomContact > list = new ArrayList < AtomContact > ( ) ; for ( AtomContact contact : this . atomContacts ) { if ( contact . getDistance ( ) < distance ) { list . add ( contact ) ; } } return list ; } | Returns the list of atom contacts in this GroupContact that are within the given distance . |
24,266 | public void computeMolecularWeight ( ElementTable eTable ) { this . aaSymbol2MolecularWeight = new HashMap < Character , Double > ( ) ; for ( AminoAcidComposition a : aminoacid ) { if ( a . getSymbol ( ) . length ( ) != 1 ) { throw new Error ( a . getSymbol ( ) + " is not allowed. Symbols must be single character.\r\nPlease check AminoAcidComposition XML file" ) ; } char c = a . getSymbol ( ) . charAt ( 0 ) ; if ( this . aaSymbol2MolecularWeight . keySet ( ) . contains ( c ) ) { throw new Error ( "Symbol " + c + " is repeated.\r\n" + "Please check AminoAcidComposition XML file to ensure there are no repeated symbols. Note that this is case-insensitive.\r\n" + "This means that having 'A' and 'a' would be repeating." ) ; } double total = 0.0 ; if ( a . getElementList ( ) != null ) { for ( Name2Count element : a . getElementList ( ) ) { element . getName ( ) ; if ( eTable . getElement ( element . getName ( ) ) == null ) { throw new Error ( "Element " + element . getName ( ) + " could not be found. " + "\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml." ) ; } eTable . getElement ( element . getName ( ) ) . getMass ( ) ; total += eTable . getElement ( element . getName ( ) ) . getMass ( ) * element . getCount ( ) ; } } if ( a . getIsotopeList ( ) != null ) { for ( Name2Count isotope : a . getIsotopeList ( ) ) { isotope . getName ( ) ; if ( eTable . getIsotope ( isotope . getName ( ) ) == null ) { throw new Error ( "Isotope " + isotope . getName ( ) + " could not be found. " + "\r\nPlease ensure that its name is correct in AminoAcidComposition.xml and is defined in ElementMass.xml." ) ; } eTable . getIsotope ( isotope . getName ( ) ) . getMass ( ) ; total += eTable . getIsotope ( isotope . getName ( ) ) . getMass ( ) * isotope . getCount ( ) ; } } c = a . getSymbol ( ) . charAt ( 0 ) ; this . aaSymbol2MolecularWeight . put ( c , total ) ; } generatesAminoAcidCompoundSet ( ) ; } | Computes and store the molecular weight of each amino acid by its symbol in aaSymbol2MolecularWeight . |
24,267 | public boolean hasContact ( Group group1 , Group group2 ) { return hasContact ( group1 . getResidueNumber ( ) , group2 . getResidueNumber ( ) ) ; } | Tell whether the given group pair is a contact in this GroupContactSet the comparison is done by matching residue numbers and chain identifiers |
24,268 | public boolean hasContact ( ResidueNumber resNumber1 , ResidueNumber resNumber2 ) { return contacts . containsKey ( new Pair < ResidueNumber > ( resNumber1 , resNumber2 ) ) ; } | Tell whether the given pair is a contact in this GroupContactSet the comparison is done by matching residue numbers and chain identifiers |
24,269 | public GroupContact getContact ( Group group1 , Group group2 ) { return contacts . get ( new Pair < ResidueNumber > ( group1 . getResidueNumber ( ) , group2 . getResidueNumber ( ) ) ) ; } | Returns the corresponding GroupContact or null if no contact exists between the 2 given groups |
24,270 | public Structure mutate ( Structure struc , String chainId , String pdbResnum , String newType ) throws PDBParseException { Structure newstruc = new StructureImpl ( ) ; List < Chain > chains = struc . getChains ( 0 ) ; for ( Chain c : chains ) { if ( c . getName ( ) . equals ( chainId ) ) { Chain newchain = new ChainImpl ( ) ; newchain . setName ( c . getName ( ) ) ; List < Group > groups = c . getAtomGroups ( ) ; for ( Group g : groups ) { String rnum = g . getResidueNumber ( ) . toString ( ) ; if ( rnum . equals ( pdbResnum ) && ( g . getType ( ) == GroupType . AMINOACID ) ) { AminoAcid newgroup = mutateResidue ( ( AminoAcid ) g , newType ) ; newchain . addGroup ( newgroup ) ; } else { newchain . addGroup ( g ) ; } } newstruc . addChain ( newchain ) ; } else { newstruc . addChain ( c ) ; } } return newstruc ; } | creates a new structure which is identical with the original one . only one amino acid will be different . |
24,271 | public AminoAcid mutateResidue ( AminoAcid oldAmino , String newType ) throws PDBParseException { AminoAcid newgroup = new AminoAcidImpl ( ) ; newgroup . setResidueNumber ( oldAmino . getResidueNumber ( ) ) ; newgroup . setPDBName ( newType ) ; AtomIterator aiter = new AtomIterator ( oldAmino ) ; while ( aiter . hasNext ( ) ) { Atom a = aiter . next ( ) ; if ( supportedAtoms . contains ( a . getName ( ) ) ) { newgroup . addAtom ( a ) ; } } return newgroup ; } | create a new residue which is of the new type . Only the atoms N Ca C O Cb will be considered . |
24,272 | public final static float PID ( String seq1 , String seq2 ) { return PID ( seq1 , seq2 , 0 , seq1 . length ( ) ) ; } | this is a gapped PID calculation |
24,273 | public final static float PID ( String seq1 , String seq2 , int start , int end ) { int s1len = seq1 . length ( ) ; int s2len = seq2 . length ( ) ; int len = Math . min ( s1len , s2len ) ; if ( end < len ) { len = end ; } if ( len < start ) { start = len - 1 ; } int bad = 0 ; char chr1 ; char chr2 ; for ( int i = start ; i < len ; i ++ ) { chr1 = seq1 . charAt ( i ) ; chr2 = seq2 . charAt ( i ) ; if ( 'a' <= chr1 && chr1 <= 'z' ) { chr1 -= caseShift ; } if ( 'a' <= chr2 && chr2 <= 'z' ) { chr2 -= caseShift ; } if ( chr1 != chr2 && ! isGap ( chr1 ) && ! isGap ( chr2 ) ) { bad ++ ; } } return ( ( float ) 100 * ( len - bad ) ) / len ; } | Another pid with region specification |
24,274 | private boolean completeRotationGroup ( Rotation ... additionalRots ) { PermutationGroup g = new PermutationGroup ( ) ; for ( Rotation s : rotations ) { g . addPermutation ( s . getPermutation ( ) ) ; } for ( Rotation s : additionalRots ) { g . addPermutation ( s . getPermutation ( ) ) ; assert evaluatedPermutations . get ( s . getPermutation ( ) ) == null ; } g . completeGroup ( ) ; if ( g . getOrder ( ) == rotations . getOrder ( ) + additionalRots . length ) { for ( Rotation s : additionalRots ) { addRotation ( s ) ; } return true ; } List < Rotation > newRots = new ArrayList < > ( g . getOrder ( ) ) ; for ( List < Integer > permutation : g ) { if ( evaluatedPermutations . containsKey ( permutation ) ) { Rotation rot = evaluatedPermutations . get ( permutation ) ; if ( rot == null ) { return false ; } } else { if ( ! isAllowedPermutation ( permutation ) ) { return false ; } } } for ( List < Integer > permutation : g ) { Rotation rot ; if ( evaluatedPermutations . containsKey ( permutation ) ) { rot = evaluatedPermutations . get ( permutation ) ; } else { rot = isValidPermutation ( permutation ) ; } if ( rot == null ) { return false ; } if ( ! evaluatedPermutations . containsKey ( permutation ) ) { newRots . add ( rot ) ; } } for ( Rotation rot : newRots ) { addRotation ( rot ) ; } return true ; } | Combine current rotations to make all possible permutations . If these are all valid add them to the rotations |
24,275 | private List < Double > getAngles ( ) { int n = subunits . getSubunitCount ( ) ; if ( n % 60 == 0 && isSpherical ( ) ) { n = 60 ; } List < Integer > folds = subunits . getFolds ( ) ; List < Double > angles = new ArrayList < Double > ( folds . size ( ) - 1 ) ; for ( int fold : folds ) { if ( fold > 0 && fold <= n ) { angles . add ( 2 * Math . PI / fold ) ; } } return angles ; } | Get valid rotation angles given the number of subunits |
24,276 | private Rotation isValidPermutation ( List < Integer > permutation ) { if ( permutation . size ( ) == 0 ) { return null ; } if ( evaluatedPermutations . containsKey ( permutation ) ) { return evaluatedPermutations . get ( permutation ) ; } if ( ! isAllowedPermutation ( permutation ) ) { evaluatedPermutations . put ( permutation , null ) ; return null ; } Rotation rot = superimposePermutation ( permutation ) ; return rot ; } | Checks if a particular permutation is allowed and superimposes well . Caches results . |
24,277 | private boolean isAllowedPermutation ( List < Integer > permutation ) { List < Integer > seqClusterId = subunits . getClusterIds ( ) ; int selfaligned = 0 ; for ( int i = 0 ; i < permutation . size ( ) ; i ++ ) { int j = permutation . get ( i ) ; if ( seqClusterId . get ( i ) != seqClusterId . get ( j ) ) { return false ; } if ( i == j ) { selfaligned ++ ; } } return selfaligned == 0 || selfaligned == permutation . size ( ) ; } | The permutation must map all subunits onto an equivalent subunit and no subunit onto itself |
24,278 | private List < Integer > getPermutation ( ) { List < Integer > permutation = new ArrayList < Integer > ( transformedCoords . length ) ; double sum = 0.0f ; for ( Point3d t : transformedCoords ) { List < Integer > neighbors = box . getNeighborsWithCache ( t ) ; int closest = - 1 ; double minDist = Double . MAX_VALUE ; for ( int j : neighbors ) { double dist = t . distanceSquared ( originalCoords [ j ] ) ; if ( dist < minDist ) { closest = j ; minDist = dist ; } } sum += minDist ; if ( closest == - 1 ) { break ; } permutation . add ( closest ) ; } double rmsd = Math . sqrt ( sum / transformedCoords . length ) ; if ( rmsd > distanceThreshold || permutation . size ( ) != transformedCoords . length ) { permutation . clear ( ) ; return permutation ; } Set < Integer > set = new HashSet < Integer > ( permutation ) ; if ( set . size ( ) != originalCoords . length ) { permutation . clear ( ) ; } return permutation ; } | Compare this . transformedCoords with the original coords . For each subunit return the transformed subunit with the closest position . |
24,279 | public static Structure readStructure ( String pdbId , int bioAssemblyId ) { pdbId = pdbId . toLowerCase ( ) ; AtomCache cache = new AtomCache ( ) ; cache . setUseMmCif ( true ) ; FileParsingParameters p = cache . getFileParsingParams ( ) ; p . setAtomCaThreshold ( Integer . MAX_VALUE ) ; p . setParseBioAssembly ( true ) ; Structure structure = null ; try { structure = StructureIO . getBiologicalAssembly ( pdbId , bioAssemblyId ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return null ; } return structure ; } | Load a specific biological assembly for a PDB entry |
24,280 | public List < SecStrucState > calculate ( Structure s , boolean assign ) throws StructureException { List < SecStrucState > secstruc = new ArrayList < SecStrucState > ( ) ; for ( int i = 0 ; i < s . nrModels ( ) ; i ++ ) { ladders = new ArrayList < Ladder > ( ) ; bridges = new ArrayList < BetaBridge > ( ) ; groups = initGroupArray ( s , i ) ; initContactSet ( ) ; if ( groups . length < 5 ) { throw new StructureException ( "Not enough backbone groups in the" + " Structure to calculate the secondary structure (" + groups . length + " given, minimum 5)" ) ; } calculateHAtoms ( ) ; calculateHBonds ( ) ; calculateDihedralAngles ( ) ; calculateTurns ( ) ; buildHelices ( ) ; detectBends ( ) ; detectStrands ( ) ; for ( SecStrucGroup sg : groups ) { SecStrucState ss = ( SecStrucState ) sg . getProperty ( Group . SEC_STRUC ) ; secstruc . add ( ss ) ; if ( assign ) sg . getOriginal ( ) . setProperty ( Group . SEC_STRUC , ss ) ; } } return secstruc ; } | Predicts the secondary structure of this Structure object using a DSSP implementation . |
24,281 | private void initContactSet ( ) { atoms = new Atom [ groups . length ] ; indResMap = new HashMap < > ( ) ; for ( int i = 0 ; i < groups . length ; i ++ ) { SecStrucGroup one = groups [ i ] ; indResMap . put ( one . getResidueNumber ( ) , i ) ; atoms [ i ] = one . getCA ( ) ; } Grid grid = new Grid ( CA_MIN_DIST ) ; if ( atoms . length == 0 ) { contactSet = new AtomContactSet ( CA_MIN_DIST ) ; } else { grid . addAtoms ( atoms ) ; contactSet = grid . getAtomContacts ( ) ; } } | Function to generate the contact sets |
24,282 | public String printDSSP ( ) { StringBuffer buf = new StringBuffer ( ) ; String nl = System . getProperty ( "line.separator" ) ; buf . append ( "==== Secondary Structure Definition by BioJava" + " DSSP implementation, Version October 2015 ====" + nl ) ; buf . append ( " # RESIDUE AA STRUCTURE BP1 BP2 ACC " + "N-H + "TCO KAPPA ALPHA PHI PSI " + "X-CA Y-CA Z-CA " ) ; for ( int i = 0 ; i < groups . length ; i ++ ) { buf . append ( nl ) ; SecStrucState ss = getSecStrucState ( i ) ; buf . append ( ss . printDSSPline ( i ) ) ; } return buf . toString ( ) ; } | Generate a DSSP file format ouput String of this SS prediction . |
24,283 | public String printFASTA ( ) { StringBuffer buf = new StringBuffer ( ) ; String nl = System . getProperty ( "line.separator" ) ; buf . append ( ">" + groups [ 0 ] . getChain ( ) . getStructure ( ) . getIdentifier ( ) + nl ) ; for ( int g = 0 ; g < groups . length ; g ++ ) { buf . append ( getSecStrucState ( g ) . getType ( ) ) ; } return buf . toString ( ) ; } | Generate a FASTA sequence with the SS annotation letters in the aminoacid sequence order . |
24,284 | private void calculateHAtoms ( ) throws StructureException { for ( int i = 0 ; i < groups . length - 1 ; i ++ ) { SecStrucGroup a = groups [ i ] ; SecStrucGroup b = groups [ i + 1 ] ; if ( ! b . hasAtom ( "H" ) ) { Atom H = calcSimple_H ( a . getC ( ) , a . getO ( ) , b . getN ( ) ) ; b . setH ( H ) ; } } } | Calculate the coordinates of the H atoms . They are usually missing in the PDB files as only few experimental methods allow to resolve their location . |
24,285 | private void calculateHBonds ( ) { if ( groups . length < 5 ) return ; Iterator < AtomContact > otu = contactSet . iterator ( ) ; while ( otu . hasNext ( ) ) { AtomContact ac = otu . next ( ) ; Pair < Atom > pair = ac . getPair ( ) ; Group g1 = pair . getFirst ( ) . getGroup ( ) ; Group g2 = pair . getSecond ( ) . getGroup ( ) ; int i = indResMap . get ( g1 . getResidueNumber ( ) ) ; int j = indResMap . get ( g2 . getResidueNumber ( ) ) ; checkAddHBond ( i , j ) ; if ( j != ( i + 1 ) ) checkAddHBond ( j , i ) ; } } | Calculate the HBonds between different groups . see Creighton page 147 f Modified to use only the contact map |
24,286 | private void trackHBondEnergy ( int i , int j , double energy ) { if ( groups [ i ] . getPDBName ( ) . equals ( "PRO" ) ) { logger . debug ( "Ignore: PRO {}" , groups [ i ] . getResidueNumber ( ) ) ; return ; } SecStrucState stateOne = getSecStrucState ( i ) ; SecStrucState stateTwo = getSecStrucState ( j ) ; double acc1e = stateOne . getAccept1 ( ) . getEnergy ( ) ; double acc2e = stateOne . getAccept2 ( ) . getEnergy ( ) ; double don1e = stateTwo . getDonor1 ( ) . getEnergy ( ) ; double don2e = stateTwo . getDonor2 ( ) . getEnergy ( ) ; if ( energy < acc1e ) { logger . debug ( "{} < {}" , energy , acc1e ) ; stateOne . setAccept2 ( stateOne . getAccept1 ( ) ) ; HBond bond = new HBond ( ) ; bond . setEnergy ( energy ) ; bond . setPartner ( j ) ; stateOne . setAccept1 ( bond ) ; } else if ( energy < acc2e ) { logger . debug ( "{} < {}" , energy , acc2e ) ; HBond bond = new HBond ( ) ; bond . setEnergy ( energy ) ; bond . setPartner ( j ) ; stateOne . setAccept2 ( bond ) ; } if ( energy < don1e ) { logger . debug ( "{} < {}" , energy , don1e ) ; stateTwo . setDonor2 ( stateTwo . getDonor1 ( ) ) ; HBond bond = new HBond ( ) ; bond . setEnergy ( energy ) ; bond . setPartner ( i ) ; stateTwo . setDonor1 ( bond ) ; } else if ( energy < don2e ) { logger . debug ( "{} < {}" , energy , don2e ) ; HBond bond = new HBond ( ) ; bond . setEnergy ( energy ) ; bond . setPartner ( i ) ; stateTwo . setDonor2 ( bond ) ; } } | Store Hbonds in the Groups . DSSP allows two HBonds per aminoacids to allow bifurcated bonds . |
24,287 | private void calculateTurns ( ) { for ( int i = 0 ; i < groups . length ; i ++ ) { for ( int turn = 3 ; turn <= 5 ; turn ++ ) { if ( i + turn >= groups . length ) continue ; if ( isBonded ( i , i + turn ) ) { logger . debug ( "Turn at ({},{}) turn {}" , i , ( i + turn ) , turn ) ; getSecStrucState ( i ) . setTurn ( '>' , turn ) ; getSecStrucState ( i + turn ) . setTurn ( '<' , turn ) ; for ( int j = i + 1 ; j < i + turn ; j ++ ) { Integer t = turn ; char helix = t . toString ( ) . charAt ( 0 ) ; getSecStrucState ( j ) . setTurn ( helix , turn ) ; } } } } } | Detect helical turn patterns . |
24,288 | @ SuppressWarnings ( "unused" ) private static Atom calc_H ( Atom C , Atom N , Atom CA ) throws StructureException { Atom nc = Calc . subtract ( N , C ) ; Atom nca = Calc . subtract ( N , CA ) ; Atom u_nc = Calc . unitVector ( nc ) ; Atom u_nca = Calc . unitVector ( nca ) ; Atom added = Calc . add ( u_nc , u_nca ) ; Atom U = Calc . unitVector ( added ) ; Atom H = Calc . add ( N , U ) ; H . setName ( "H" ) ; return H ; } | Use unit vectors NC and NCalpha Add them . Calc unit vector and substract it from N . C coordinates are from amino acid i - 1 N CA atoms from amino acid i |
24,289 | private void setSecStrucType ( int pos , SecStrucType type ) { SecStrucState ss = getSecStrucState ( pos ) ; if ( type . compareTo ( ss . getType ( ) ) < 0 ) ss . setType ( type ) ; } | Set the new type only if it has more preference than the current residue SS type . |
24,290 | public AFPChain align ( Atom [ ] ca1 , Atom [ ] ca2 , Object param ) throws StructureException { if ( ! ( param instanceof CeParameters ) ) throw new IllegalArgumentException ( "CE algorithm needs an object of call CeParameters as argument." ) ; params = ( CeParameters ) param ; ca2clone = new Atom [ ca2 . length ] ; int pos = 0 ; for ( Atom a : ca2 ) { Group g = ( Group ) a . getGroup ( ) . clone ( ) ; ca2clone [ pos ] = g . getAtom ( a . getName ( ) ) ; pos ++ ; } calculator = new CECalculator ( params ) ; AFPChain afpChain = new AFPChain ( algorithmName ) ; afpChain = calculator . extractFragments ( afpChain , ca1 , ca2clone ) ; calculator . traceFragmentMatrix ( afpChain , ca1 , ca2clone ) ; calculator . nextStep ( afpChain , ca1 , ca2clone ) ; afpChain . setAlgorithmName ( getAlgorithmName ( ) ) ; afpChain . setVersion ( version ) ; if ( ca1 . length != 0 && ca1 [ 0 ] . getGroup ( ) . getChain ( ) != null && ca1 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) != null ) afpChain . setName1 ( ca1 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) . getName ( ) ) ; if ( ca2 . length != 0 && ca2 [ 0 ] . getGroup ( ) . getChain ( ) != null && ca2 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) != null ) afpChain . setName2 ( ca2 [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) . getName ( ) ) ; if ( afpChain . getNrEQR ( ) == 0 ) return afpChain ; int winSize = params . getWinSize ( ) ; int winSizeComb1 = ( winSize - 1 ) * ( winSize - 2 ) / 2 ; double [ ] [ ] m = calculator . initSumOfDistances ( ca1 . length , ca2 . length , winSize , winSizeComb1 , ca1 , ca2clone ) ; afpChain . setDistanceMatrix ( new Matrix ( m ) ) ; afpChain . setSequentialAlignment ( true ) ; return afpChain ; } | Align ca2 onto ca1 . |
24,291 | public void remark800toPDB ( StringBuffer stringBuffer ) { stringBuffer . append ( String . format ( Locale . UK , "REMARK 800 SITE_IDENTIFIER: %-52s%s" , siteID , lineEnd ) ) ; stringBuffer . append ( String . format ( Locale . UK , "REMARK 800 EVIDENCE_CODE: %-54s%s" , evCode , lineEnd ) ) ; stringBuffer . append ( String . format ( Locale . UK , "REMARK 800 SITE_DESCRIPTION: %-51s%s" , description , lineEnd ) ) ; } | Appends the REMARK 800 section pertaining to the site onto the end of the StringBuffer provided . |
24,292 | private double normScore ( double score , double rmsd , int optLen , int r ) { double score1 = score ; if ( r > 0 ) score1 /= Math . sqrt ( r + 1 ) ; if ( rmsd < 0.5 ) score1 *= Math . sqrt ( ( optLen ) / 0.5 ) ; else score1 *= Math . sqrt ( ( optLen ) / rmsd ) ; return score1 ; } | the chaining score is normalized by rmsd twist and optimal alignment length |
24,293 | public static String cleanSequence ( String sequence ) { assert sequence != null ; final Matcher m = SequenceUtil . WHITE_SPACE . matcher ( sequence ) ; sequence = m . replaceAll ( "" ) . toUpperCase ( ) ; return sequence ; } | Removes all whitespace chars in the sequence string |
24,294 | public static String deepCleanSequence ( String sequence ) { sequence = SequenceUtil . cleanSequence ( sequence ) ; sequence = SequenceUtil . DIGIT . matcher ( sequence ) . replaceAll ( "" ) ; sequence = SequenceUtil . NONWORD . matcher ( sequence ) . replaceAll ( "" ) ; final Pattern othernonSeqChars = Pattern . compile ( "[_-]+" ) ; sequence = othernonSeqChars . matcher ( sequence ) . replaceAll ( "" ) ; return sequence ; } | Removes all special characters and digits as well as whitespace chars from the sequence |
24,295 | public static boolean isAmbiguosProtein ( String sequence ) { sequence = SequenceUtil . cleanSequence ( sequence ) ; if ( SequenceUtil . isNonAmbNucleotideSequence ( sequence ) ) { return false ; } if ( SequenceUtil . DIGIT . matcher ( sequence ) . find ( ) ) { return false ; } if ( SequenceUtil . NON_AA . matcher ( sequence ) . find ( ) ) { return false ; } if ( SequenceUtil . AA . matcher ( sequence ) . find ( ) ) { return false ; } final Matcher amb_prot = SequenceUtil . AMBIGUOUS_AA . matcher ( sequence ) ; return amb_prot . find ( ) ; } | Check whether the sequence confirms to amboguous protein sequence |
24,296 | public static void writeFasta ( final OutputStream outstream , final List < FastaSequence > sequences , final int width ) throws IOException { final OutputStreamWriter writer = new OutputStreamWriter ( outstream ) ; final BufferedWriter fastawriter = new BufferedWriter ( writer ) ; for ( final FastaSequence fs : sequences ) { fastawriter . write ( fs . getFormatedSequence ( width ) ) ; } outstream . flush ( ) ; fastawriter . close ( ) ; writer . close ( ) ; } | Writes list of FastaSequeces into the outstream formatting the sequence so that it contains width chars on each line |
24,297 | public static List < FastaSequence > readFasta ( final InputStream inStream ) throws IOException { final List < FastaSequence > seqs = new ArrayList < FastaSequence > ( ) ; final BufferedReader infasta = new BufferedReader ( new InputStreamReader ( inStream , "UTF8" ) , 16000 ) ; final Pattern pattern = Pattern . compile ( "//s+" ) ; String line ; String sname = "" , seqstr = null ; do { line = infasta . readLine ( ) ; if ( ( line == null ) || line . startsWith ( ">" ) ) { if ( seqstr != null ) { seqs . add ( new FastaSequence ( sname . substring ( 1 ) , seqstr ) ) ; } sname = line ; seqstr = "" ; } else { final String subseq = pattern . matcher ( line ) . replaceAll ( "" ) ; seqstr += subseq ; } } while ( line != null ) ; infasta . close ( ) ; return seqs ; } | Reads fasta sequences from inStream into the list of FastaSequence objects |
24,298 | public static void writeFasta ( final OutputStream os , final List < FastaSequence > sequences ) throws IOException { final OutputStreamWriter outWriter = new OutputStreamWriter ( os ) ; final BufferedWriter fasta_out = new BufferedWriter ( outWriter ) ; for ( final FastaSequence fs : sequences ) { fasta_out . write ( fs . getOnelineFasta ( ) ) ; } fasta_out . close ( ) ; outWriter . close ( ) ; } | Writes FastaSequence in the file each sequence will take one line only |
24,299 | @ SuppressWarnings ( "unused" ) private void reset ( ) { this . version = 0 ; this . versionSeen = false ; this . accession = null ; this . description = null ; this . identifier = null ; this . name = null ; this . comments . clear ( ) ; } | Sets the sequence info back to default values ie . in order to start constructing a new sequence from scratch . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.