idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
24,100 | public Structure getDomain ( String pdpDomainName , AtomCache cache ) throws IOException , StructureException { return cache . getStructure ( getPDPDomain ( pdpDomainName ) ) ; } | Get the structure for a particular PDP domain |
24,101 | public PDPDomain getPDPDomain ( String pdpDomainName ) throws IOException { SortedSet < String > domainRanges = null ; if ( serializedCache != null ) { if ( serializedCache . containsKey ( pdpDomainName ) ) { domainRanges = serializedCache . get ( pdpDomainName ) ; } } boolean shouldRequestDomainRanges = checkDomainRanges ( domainRanges ) ; try { if ( shouldRequestDomainRanges ) { URL u = new URL ( server + "getPDPDomain?pdpId=" + pdpDomainName ) ; logger . info ( "Fetching {}" , u ) ; InputStream response = URLConnectionTools . getInputStream ( u ) ; String xml = JFatCatClient . convertStreamToString ( response ) ; domainRanges = XMLUtil . getDomainRangesFromXML ( xml ) ; if ( domainRanges != null ) cache ( pdpDomainName , domainRanges ) ; } } catch ( MalformedURLException e ) { logger . error ( "Problem generating PDP request URL for " + pdpDomainName , e ) ; throw new IllegalArgumentException ( "Invalid PDP name: " + pdpDomainName , e ) ; } String pdbId = null ; List < ResidueRange > ranges = new ArrayList < ResidueRange > ( ) ; for ( String domainRange : domainRanges ) { SubstructureIdentifier strucId = new SubstructureIdentifier ( domainRange ) ; if ( pdbId == null ) { pdbId = strucId . getPdbId ( ) ; } else if ( ! pdbId . equals ( strucId . getPdbId ( ) ) ) { throw new RuntimeException ( "Don't know how to take the union of domains from multiple PDB IDs." ) ; } ranges . addAll ( strucId . getResidueRanges ( ) ) ; } return new PDPDomain ( pdpDomainName , ranges ) ; } | Get a StructureIdentifier representing the specified PDP domain . |
24,102 | private boolean checkDomainRanges ( SortedSet < String > domainRanges ) { if ( ( domainRanges == null ) || ( domainRanges . size ( ) == 0 ) ) { return true ; } for ( String d : domainRanges ) { if ( ( d != null ) && ( d . length ( ) > 0 ) ) { return false ; } } return true ; } | returns true if client should fetch domain definitions from server |
24,103 | public SortedSet < String > getPDPDomainNamesForPDB ( String pdbId ) throws IOException { SortedSet < String > results = null ; try { URL u = new URL ( server + "getPDPDomainNamesForPDB?pdbId=" + pdbId ) ; logger . info ( "Fetching {}" , u ) ; InputStream response = URLConnectionTools . getInputStream ( u ) ; String xml = JFatCatClient . convertStreamToString ( response ) ; results = XMLUtil . getDomainRangesFromXML ( xml ) ; } catch ( MalformedURLException e ) { logger . error ( "Problem generating PDP request URL for " + pdbId , e ) ; throw new IllegalArgumentException ( "Invalid PDB name: " + pdbId , e ) ; } return results ; } | Get a list of all PDP domains for a given PDB entry |
24,104 | public static void blockInfo ( AFPChain afpChain ) { int i , j , k , a , n ; int blockNum = afpChain . getBlockNum ( ) ; int [ ] blockSize = afpChain . getBlockSize ( ) ; int [ ] afpChainList = afpChain . getAfpChainList ( ) ; int [ ] block2Afp = afpChain . getBlock2Afp ( ) ; int [ ] [ ] [ ] blockResList = afpChain . getBlockResList ( ) ; List < AFP > afpSet = afpChain . getAfpSet ( ) ; int [ ] blockResSize = afpChain . getBlockResSize ( ) ; for ( i = 0 ; i < blockNum ; i ++ ) { n = 0 ; for ( j = 0 ; j < blockSize [ i ] ; j ++ ) { a = afpChainList [ block2Afp [ i ] + j ] ; for ( k = 0 ; k < afpSet . get ( a ) . getFragLen ( ) ; k ++ ) { blockResList [ i ] [ 0 ] [ n ] = afpSet . get ( a ) . getP1 ( ) + k ; blockResList [ i ] [ 1 ] [ n ] = afpSet . get ( a ) . getP2 ( ) + k ; n ++ ; } } blockResSize [ i ] = n ; } afpChain . setBlockResSize ( blockResSize ) ; afpChain . setBlockSize ( blockSize ) ; afpChain . setAfpChainList ( afpChainList ) ; afpChain . setBlock2Afp ( block2Afp ) ; afpChain . setBlockResList ( blockResList ) ; } | get the afp list and residue list for each block |
24,105 | public static void updateScore ( FatCatParameters params , AFPChain afpChain ) { int i , j , bknow , bkold , g1 , g2 ; afpChain . setConn ( 0d ) ; afpChain . setDVar ( 0d ) ; int blockNum = afpChain . getBlockNum ( ) ; int alignScoreUpdate = 0 ; double [ ] blockScore = afpChain . getBlockScore ( ) ; int [ ] blockGap = afpChain . getBlockGap ( ) ; int [ ] blockSize = afpChain . getBlockSize ( ) ; int [ ] afpChainList = afpChain . getAfpChainList ( ) ; List < AFP > afpSet = afpChain . getAfpSet ( ) ; int [ ] block2Afp = afpChain . getBlock2Afp ( ) ; double torsionPenalty = params . getTorsionPenalty ( ) ; bkold = 0 ; for ( i = 0 ; i < blockNum ; i ++ ) { blockScore [ i ] = 0 ; blockGap [ i ] = 0 ; for ( j = 0 ; j < blockSize [ i ] ; j ++ ) { bknow = afpChainList [ block2Afp [ i ] + j ] ; if ( j == 0 ) { blockScore [ i ] = afpSet . get ( bknow ) . getScore ( ) ; } else { AFPChainer . afpPairConn ( bkold , bknow , params , afpChain ) ; Double conn = afpChain . getConn ( ) ; blockScore [ i ] += afpSet . get ( bknow ) . getScore ( ) + conn ; g1 = afpSet . get ( bknow ) . getP1 ( ) - afpSet . get ( bkold ) . getP1 ( ) - afpSet . get ( bkold ) . getFragLen ( ) ; g2 = afpSet . get ( bknow ) . getP2 ( ) - afpSet . get ( bkold ) . getP2 ( ) - afpSet . get ( bkold ) . getFragLen ( ) ; blockGap [ i ] += ( g1 > g2 ) ? g1 : g2 ; } bkold = bknow ; } alignScoreUpdate += blockScore [ i ] ; } if ( blockNum >= 2 ) { alignScoreUpdate += ( blockNum - 1 ) * torsionPenalty ; } afpChain . setBlockGap ( blockGap ) ; afpChain . setAlignScoreUpdate ( alignScoreUpdate ) ; afpChain . setBlockScore ( blockScore ) ; afpChain . setBlockSize ( blockSize ) ; afpChain . setAfpChainList ( afpChainList ) ; afpChain . setBlock2Afp ( block2Afp ) ; } | to update the chaining score after block delete and merge processed the blockScore value is important for significance evaluation |
24,106 | public static CeSymmResult analyze ( Atom [ ] atoms ) throws StructureException { CESymmParameters params = new CESymmParameters ( ) ; return analyze ( atoms , params ) ; } | Analyze the symmetries of the input Atom array using the DEFAULT parameters . |
24,107 | public static CeSymmResult analyze ( Atom [ ] atoms , CESymmParameters params ) throws StructureException { if ( atoms . length < 1 ) throw new IllegalArgumentException ( "Empty Atom array given." ) ; if ( params . getSSEThreshold ( ) > 0 ) { Structure s = atoms [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) ; if ( SecStrucTools . getSecStrucInfo ( s ) . isEmpty ( ) ) { logger . info ( "Calculating Secondary Structure..." ) ; SecStrucCalc ssp = new SecStrucCalc ( ) ; ssp . calculate ( s , true ) ; } } CeSymmIterative iter = new CeSymmIterative ( params ) ; CeSymmResult result = iter . execute ( atoms ) ; if ( result . isRefined ( ) ) { if ( params . getOptimization ( ) && result . getSymmLevels ( ) > 1 ) { try { SymmOptimizer optimizer = new SymmOptimizer ( result ) ; MultipleAlignment optimized = optimizer . optimize ( ) ; result . setMultipleAlignment ( optimized ) ; } catch ( RefinerFailedException e ) { logger . info ( "Final optimization failed:" + e . getMessage ( ) ) ; } } result . getMultipleAlignment ( ) . getEnsemble ( ) . setStructureIdentifiers ( result . getRepeatsID ( ) ) ; } return result ; } | Analyze the symmetries of the input Atom array using the provided parameters . |
24,108 | public static CeSymmResult analyzeLevel ( Atom [ ] atoms , CESymmParameters params ) throws StructureException { if ( atoms . length < 1 ) throw new IllegalArgumentException ( "Empty Atom array given." ) ; CeSymmResult result = align ( atoms , params ) ; if ( result . isRefined ( ) ) { if ( result . getParams ( ) . getOptimization ( ) ) { try { MultipleAlignment msa = result . getMultipleAlignment ( ) ; SymmOptimizer optimizer = new SymmOptimizer ( result ) ; msa = optimizer . optimize ( ) ; result . setMultipleAlignment ( msa ) ; } catch ( RefinerFailedException e ) { logger . debug ( "Optimization failed:" + e . getMessage ( ) ) ; } } } return result ; } | Analyze a single level of symmetry . |
24,109 | public int getLength ( int positionA , int positionB , String startingChain ) { int positionStart , positionEnd ; if ( positionA <= positionB ) { positionStart = positionA ; positionEnd = positionB ; } else { positionStart = positionB ; positionEnd = positionA ; } int count = 0 ; for ( Map . Entry < ResidueNumber , Integer > entry : treeMap . entrySet ( ) ) { if ( entry . getKey ( ) . getChainName ( ) . equals ( startingChain ) && positionStart <= entry . getValue ( ) && entry . getValue ( ) <= positionEnd ) { count ++ ; } } return count ; } | Calculates the number of residues of the specified chain in a given range inclusive . |
24,110 | public int getLengthDirectional ( int positionStart , int positionEnd , String startingChain ) { int count = getLength ( positionStart , positionEnd , startingChain ) ; if ( positionStart <= positionEnd ) { return count ; } else { return - count ; } } | Calculates the number of residues of the specified chain in a given range . Will return a negative value if the start is past the end . |
24,111 | public int getLength ( ResidueNumber start , ResidueNumber end ) { if ( ! start . getChainName ( ) . equals ( end . getChainName ( ) ) ) { throw new IllegalArgumentException ( String . format ( "Chains differ between %s and %s. Unable to calculate length." , start , end ) ) ; } Integer startPos = getPosition ( start ) ; Integer endPos = getPosition ( end ) ; if ( startPos == null ) { throw new IllegalArgumentException ( "Residue " + start + " was not found." ) ; } if ( endPos == null ) { throw new IllegalArgumentException ( "Residue " + start + " was not found." ) ; } return getLength ( startPos , endPos , start . getChainName ( ) ) ; } | Calculates the number of atoms between two ResidueNumbers inclusive . Both residues must belong to the same chain . |
24,112 | public ResidueRangeAndLength trimToValidResidues ( ResidueRange rr ) { ResidueNumber start = rr . getStart ( ) ; ResidueNumber end = rr . getEnd ( ) ; String chain = rr . getChainName ( ) ; if ( start . getChainName ( ) == null ) { start = new ResidueNumber ( chain , start . getSeqNum ( ) , start . getInsCode ( ) ) ; } if ( end . getChainName ( ) == null ) { end = new ResidueNumber ( chain , end . getSeqNum ( ) , end . getInsCode ( ) ) ; } Integer startIndex = getPosition ( start ) ; if ( startIndex == null ) { for ( ResidueNumber key : treeMap . keySet ( ) ) { if ( ! key . getChainName ( ) . equals ( chain ) ) continue ; if ( start . getSeqNum ( ) <= key . getSeqNum ( ) ) { start = key ; startIndex = getPosition ( key ) ; break ; } } if ( startIndex == null ) { logger . error ( "Unable to find Residue {} in AtomPositionMap, and no plausible substitute." , start ) ; return null ; } else { logger . warn ( "Unable to find Residue {}, so substituting {}." , rr . getStart ( ) , start ) ; } } Integer endIndex = getPosition ( end ) ; if ( endIndex == null ) { for ( ResidueNumber key : treeMap . descendingKeySet ( ) ) { if ( ! key . getChainName ( ) . equals ( chain ) ) continue ; Integer value = getPosition ( key ) ; if ( value < startIndex ) { break ; } if ( end . getSeqNum ( ) >= key . getSeqNum ( ) ) { end = key ; endIndex = value ; break ; } } if ( endIndex == null ) { logger . error ( "Unable to find Residue {} in AtomPositionMap, and no plausible substitute." , end ) ; return null ; } else { logger . warn ( "Unable to find Residue {}, so substituting {}." , rr . getEnd ( ) , end ) ; } } int length = getLength ( startIndex , endIndex , chain ) ; return new ResidueRangeAndLength ( chain , start , end , length ) ; } | Trims a residue range so that both endpoints are contained in this map . |
24,113 | public static Atom [ ] findNearestAtomLinkage ( final Group group1 , final Group group2 , List < String > potentialNamesOfAtomOnGroup1 , List < String > potentialNamesOfAtomOnGroup2 , final boolean ignoreNCLinkage , double bondLengthTolerance ) { List < Atom [ ] > linkages = findAtomLinkages ( group1 , group2 , potentialNamesOfAtomOnGroup1 , potentialNamesOfAtomOnGroup2 , ignoreNCLinkage , bondLengthTolerance ) ; Atom [ ] ret = null ; double minDistance = Double . POSITIVE_INFINITY ; for ( Atom [ ] linkage : linkages ) { double distance ; distance = Calc . getDistance ( linkage [ 0 ] , linkage [ 1 ] ) ; if ( distance < minDistance ) { minDistance = distance ; ret = linkage ; } } return ret ; } | Find a linkage between two groups within tolerance of bond length from potential atoms . |
24,114 | public static Atom [ ] findLinkage ( final Group group1 , final Group group2 , String nameOfAtomOnGroup1 , String nameOfAtomOnGroup2 , double bondLengthTolerance ) { Atom [ ] ret = new Atom [ 2 ] ; ret [ 0 ] = group1 . getAtom ( nameOfAtomOnGroup1 ) ; ret [ 1 ] = group2 . getAtom ( nameOfAtomOnGroup2 ) ; if ( ret [ 0 ] == null || ret [ 1 ] == null ) { return null ; } Atom a1 = ret [ 0 ] ; Atom a2 = ret [ 1 ] ; boolean hasBond = a1 . hasBond ( a2 ) ; if ( hasBond ) { return ret ; } if ( a1 . getElement ( ) . isMetal ( ) || a2 . getElement ( ) . isMetal ( ) ) { MetalBondDistance defined = getMetalDistanceCutoff ( a1 . getElement ( ) . name ( ) , a2 . getElement ( ) . name ( ) ) ; if ( defined != null ) { if ( hasMetalBond ( a1 , a2 , defined ) ) return ret ; else return null ; } } double distance = Calc . getDistance ( a1 , a2 ) ; float radiusOfAtom1 = ret [ 0 ] . getElement ( ) . getCovalentRadius ( ) ; float radiusOfAtom2 = ret [ 1 ] . getElement ( ) . getCovalentRadius ( ) ; if ( Math . abs ( distance - radiusOfAtom1 - radiusOfAtom2 ) > bondLengthTolerance ) { return null ; } return ret ; } | Find a linkage between two groups within tolerance of bond length . |
24,115 | public static List < Group > getAminoAcids ( Chain chain ) { List < Group > gs = new ArrayList < > ( ) ; for ( Group g : chain . getAtomGroups ( ) ) { if ( g . isAminoAcid ( ) ) gs . add ( g ) ; } return gs ; } | Get all amino acids in a chain . |
24,116 | public boolean isCrystallographic ( ) { if ( pdbHeader . getExperimentalTechniques ( ) != null ) { return ExperimentalTechnique . isCrystallographic ( pdbHeader . getExperimentalTechniques ( ) ) ; } else { if ( pdbHeader . getCrystallographicInfo ( ) . getSpaceGroup ( ) != null ) { return pdbHeader . getCrystallographicInfo ( ) . getCrystalCell ( ) != null && pdbHeader . getCrystallographicInfo ( ) . getCrystalCell ( ) . isCellReasonable ( ) ; } } return false ; } | Whether this Structure is a crystallographic structure or not . It will first check the experimental technique and if not present it will try to guess from the presence of a space group and sensible cell parameters |
24,117 | public boolean isNmr ( ) { if ( pdbHeader . getExperimentalTechniques ( ) != null ) { return ExperimentalTechnique . isNmr ( pdbHeader . getExperimentalTechniques ( ) ) ; } else { if ( nrModels ( ) > 1 ) { if ( pdbHeader . getCrystallographicInfo ( ) . getSpaceGroup ( ) != null ) { if ( pdbHeader . getCrystallographicInfo ( ) . getCrystalCell ( ) == null ) return true ; if ( ! pdbHeader . getCrystallographicInfo ( ) . getCrystalCell ( ) . isCellReasonable ( ) ) return true ; } else { return true ; } } } return false ; } | Whether this Structure is a NMR structure or not . It will first check the experimental technique and if not present it will try to guess from the presence of more than 1 model and from b - factors being 0 in first chain of first model |
24,118 | private SubstructureIdentifier toCanonical ( ) { StructureIdentifier real = getStructureIdentifier ( ) ; if ( real != null ) { try { return real . toCanonical ( ) ; } catch ( StructureException e ) { } } List < ResidueRange > range = new ArrayList < > ( ) ; for ( Chain chain : getChains ( ) ) { List < Group > groups = chain . getAtomGroups ( ) ; ListIterator < Group > groupsIt = groups . listIterator ( ) ; if ( ! groupsIt . hasNext ( ) ) { continue ; } Group g = groupsIt . next ( ) ; ResidueNumber first = g . getResidueNumber ( ) ; while ( groupsIt . hasNext ( ) ) { g = groupsIt . next ( ) ; } ResidueNumber last = g . getResidueNumber ( ) ; range . add ( new ResidueRange ( chain . getName ( ) , first , last ) ) ; } return new SubstructureIdentifier ( getPDBCode ( ) , range ) ; } | Creates a SubstructureIdentifier based on the residues in this Structure . |
24,119 | private Dimension layoutSize ( Container target , boolean preferred ) { synchronized ( target . getTreeLock ( ) ) { int targetWidth = target . getSize ( ) . width ; Container container = target ; while ( container . getSize ( ) . width == 0 && container . getParent ( ) != null ) { container = container . getParent ( ) ; } targetWidth = container . getSize ( ) . width ; if ( targetWidth == 0 ) targetWidth = Integer . MAX_VALUE ; int hgap = getHgap ( ) ; int vgap = getVgap ( ) ; Insets insets = target . getInsets ( ) ; int horizontalInsetsAndGap = insets . left + insets . right + ( hgap * 2 ) ; int maxWidth = targetWidth - horizontalInsetsAndGap ; Dimension dim = new Dimension ( 0 , 0 ) ; int rowWidth = 0 ; int rowHeight = 0 ; int nmembers = target . getComponentCount ( ) ; for ( int i = 0 ; i < nmembers ; i ++ ) { Component m = target . getComponent ( i ) ; if ( m . isVisible ( ) ) { Dimension d = preferred ? m . getPreferredSize ( ) : m . getMinimumSize ( ) ; if ( rowWidth + d . width > maxWidth ) { addRow ( dim , rowWidth , rowHeight ) ; rowWidth = 0 ; rowHeight = 0 ; } if ( rowWidth != 0 ) { rowWidth += hgap ; } rowWidth += d . width ; rowHeight = Math . max ( rowHeight , d . height ) ; } } addRow ( dim , rowWidth , rowHeight ) ; dim . width += horizontalInsetsAndGap ; dim . height += insets . top + insets . bottom + vgap * 2 ; Container scrollPane = SwingUtilities . getAncestorOfClass ( JScrollPane . class , target ) ; if ( scrollPane != null && target . isValid ( ) ) { dim . width -= ( hgap + 1 ) ; } return dim ; } } | Returns the minimum or preferred dimension needed to layout the target container . |
24,120 | public void setKaplanMeierFigure ( KaplanMeierFigure kmf ) { this . kmf = kmf ; int numRows = kmf . getSurvivalFitInfo ( ) . getStrataInfoHashMap ( ) . size ( ) ; int height = ( numRows + 1 ) * getFontMetrics ( getFont ( ) ) . getHeight ( ) ; int width = kmf . getWidth ( ) ; setPreferredSize ( new Dimension ( width , height ) ) ; this . setSize ( width , height ) ; } | Pick up needed info and details from the KM Figure |
24,121 | private static boolean isCategorical ( LinkedHashMap < String , Double > values ) { try { for ( String value : values . keySet ( ) ) { Double . parseDouble ( value ) ; } return false ; } catch ( Exception e ) { return true ; } } | If any not numeric value then categorical |
24,122 | public static void categorizeData ( ArrayList < SurvivalInfo > DataT ) { LinkedHashMap < String , LinkedHashMap < String , Double > > valueMap = new LinkedHashMap < String , LinkedHashMap < String , Double > > ( ) ; for ( SurvivalInfo si : DataT ) { for ( String key : si . unknownDataType . keySet ( ) ) { LinkedHashMap < String , Double > map = valueMap . get ( key ) ; if ( map == null ) { map = new LinkedHashMap < String , Double > ( ) ; valueMap . put ( key , map ) ; } map . put ( si . unknownDataType . get ( key ) , null ) ; } } for ( String variable : valueMap . keySet ( ) ) { LinkedHashMap < String , Double > values = valueMap . get ( variable ) ; if ( isCategorical ( values ) ) { ArrayList < String > categories = new ArrayList < String > ( values . keySet ( ) ) ; Collections . sort ( categories ) ; if ( categories . size ( ) == 2 ) { for ( String value : values . keySet ( ) ) { int index = categories . indexOf ( value ) ; values . put ( value , index + 0.0 ) ; } } else { for ( String value : values . keySet ( ) ) { int index = categories . indexOf ( value ) ; values . put ( value , index + 1.0 ) ; } } } else { for ( String value : values . keySet ( ) ) { Double d = Double . parseDouble ( value ) ; values . put ( value , d ) ; } } } for ( SurvivalInfo si : DataT ) { for ( String key : si . unknownDataType . keySet ( ) ) { LinkedHashMap < String , Double > map = valueMap . get ( key ) ; String value = si . unknownDataType . get ( key ) ; Double d = map . get ( value ) ; si . data . put ( key , d ) ; } } for ( SurvivalInfo si : DataT ) { si . unknownDataType . clear ( ) ; } } | Take a collection of categorical data and convert it to numeric to be used in cox calculations |
24,123 | public static ArrayList < String > addInteraction ( String variable1 , String variable2 , ArrayList < SurvivalInfo > survivalInfoList ) { ArrayList < String > variables = new ArrayList < String > ( ) ; variables . add ( variable1 ) ; variables . add ( variable2 ) ; variables . add ( variable1 + ":" + variable2 ) ; for ( SurvivalInfo si : survivalInfoList ) { Double value1 = si . getVariable ( variable1 ) ; Double value2 = si . getVariable ( variable2 ) ; Double value3 = value1 * value2 ; si . addContinuousVariable ( variable1 + ":" + variable2 , value3 ) ; } return variables ; } | To test for interactions use two variables and create a third variable where the two are multiplied together . |
24,124 | public static void groupByRange ( double [ ] range , String variable , String groupName , ArrayList < SurvivalInfo > survivalInfoList ) throws Exception { ArrayList < String > labels = new ArrayList < String > ( ) ; for ( int i = 0 ; i < range . length ; i ++ ) { String label = "" ; if ( i == 0 ) { label = "[<=" + range [ i ] + "]" ; } else if ( i == range . length - 1 ) { label = "[" + ( range [ i - 1 ] + 1 ) + "-" + range [ i ] + "]" ; labels . add ( label ) ; label = "[>" + range [ i ] + "]" ; } else { label = "[" + ( range [ i - 1 ] + 1 ) + "-" + range [ i ] + "]" ; } labels . add ( label ) ; } ArrayList < String > validLabels = new ArrayList < String > ( ) ; for ( SurvivalInfo si : survivalInfoList ) { Double value = si . getContinuousVariable ( variable ) ; if ( value == null ) { throw new Exception ( "Variable " + variable + " not found in " + si . toString ( ) ) ; } int rangeIndex = getRangeIndex ( range , value ) ; String label = labels . get ( rangeIndex ) ; if ( ! validLabels . contains ( groupName + "_" + label ) ) { validLabels . add ( groupName + "_" + label ) ; } } Collections . sort ( validLabels ) ; System . out . println ( "Valid Lables:" + validLabels ) ; for ( SurvivalInfo si : survivalInfoList ) { Double value = si . getContinuousVariable ( variable ) ; if ( value == null ) { throw new Exception ( "Variable " + variable + " not found in " + si . toString ( ) ) ; } int rangeIndex = getRangeIndex ( range , value ) ; String label = labels . get ( rangeIndex ) ; String inLable = groupName + "_" + label ; for ( String gl : validLabels ) { if ( gl . equals ( inLable ) ) { si . addContinuousVariable ( gl , 1.0 ) ; } else { si . addContinuousVariable ( gl , 0.0 ) ; } } } } | Need to allow a range of values similar to cut in R and a continuous c |
24,125 | public static Matrix grayOutCEOrig ( Atom [ ] ca2 , int rows , int cols , CECalculator calculator , Matrix origM , int blankWindowSize , double [ ] gradientPolyCoeff , double gradientExpCoeff ) { if ( origM == null ) { origM = new Matrix ( calculator . getMatMatrix ( ) ) ; } for ( int i = 0 ; i < rows ; i ++ ) { for ( int j = 0 ; j < cols ; j ++ ) { int diff = Math . abs ( i - j ) ; double resetVal = getResetVal ( origM . get ( i , j ) , diff , gradientPolyCoeff , gradientExpCoeff ) ; if ( diff < blankWindowSize ) { origM . set ( i , j , origM . get ( i , j ) + resetVal ) ; } int diff2 = Math . abs ( i - ( j - ca2 . length / 2 ) ) ; double resetVal2 = getResetVal ( origM . get ( i , j ) , diff2 , gradientPolyCoeff , gradientExpCoeff ) ; if ( diff2 < blankWindowSize ) { origM . set ( i , j , origM . get ( i , j ) + resetVal2 ) ; } } } return origM ; } | Grays out the main diagonal of a duplicated distance matrix . |
24,126 | public static List < List < Integer > > buildSymmetryGraph ( List < AFPChain > afps , Atom [ ] atoms , boolean undirected ) { List < List < Integer > > graph = new ArrayList < List < Integer > > ( ) ; for ( int n = 0 ; n < atoms . length ; n ++ ) { graph . add ( new ArrayList < Integer > ( ) ) ; } for ( int k = 0 ; k < afps . size ( ) ; k ++ ) { for ( int i = 0 ; i < afps . get ( k ) . getOptAln ( ) . length ; i ++ ) { for ( int j = 0 ; j < afps . get ( k ) . getOptAln ( ) [ i ] [ 0 ] . length ; j ++ ) { Integer res1 = afps . get ( k ) . getOptAln ( ) [ i ] [ 0 ] [ j ] ; Integer res2 = afps . get ( k ) . getOptAln ( ) [ i ] [ 1 ] [ j ] ; graph . get ( res1 ) . add ( res2 ) ; if ( undirected ) graph . get ( res2 ) . add ( res1 ) ; } } } return graph ; } | Converts a set of AFP alignments into a Graph of aligned residues where each vertex is a residue and each edge means the connection between the two residues in one of the alignments . |
24,127 | public static Graph < Integer , DefaultEdge > buildSymmetryGraph ( AFPChain selfAlignment ) { Graph < Integer , DefaultEdge > graph = new SimpleGraph < Integer , DefaultEdge > ( DefaultEdge . class ) ; for ( int i = 0 ; i < selfAlignment . getOptAln ( ) . length ; i ++ ) { for ( int j = 0 ; j < selfAlignment . getOptAln ( ) [ i ] [ 0 ] . length ; j ++ ) { Integer res1 = selfAlignment . getOptAln ( ) [ i ] [ 0 ] [ j ] ; Integer res2 = selfAlignment . getOptAln ( ) [ i ] [ 1 ] [ j ] ; graph . addVertex ( res1 ) ; graph . addVertex ( res2 ) ; graph . addEdge ( res1 , res2 ) ; } } return graph ; } | Converts a self alignment into a directed jGraphT of aligned residues where each vertex is a residue and each edge means the equivalence between the two residues in the self - alignment . |
24,128 | public static List < Structure > divideStructure ( CeSymmResult symmetry ) throws StructureException { if ( ! symmetry . isRefined ( ) ) throw new IllegalArgumentException ( "The symmetry result " + "is not refined, repeats cannot be defined" ) ; int order = symmetry . getMultipleAlignment ( ) . size ( ) ; Atom [ ] atoms = symmetry . getAtoms ( ) ; Set < Group > allGroups = StructureTools . getAllGroupsFromSubset ( atoms , GroupType . HETATM ) ; List < StructureIdentifier > repeatsId = symmetry . getRepeatsID ( ) ; List < Structure > repeats = new ArrayList < Structure > ( order ) ; for ( int i = 0 ; i < order ; i ++ ) { Structure s = new StructureImpl ( ) ; s . addModel ( new ArrayList < Chain > ( 1 ) ) ; s . setStructureIdentifier ( repeatsId . get ( i ) ) ; Block align = symmetry . getMultipleAlignment ( ) . getBlock ( 0 ) ; int res1 = align . getStartResidue ( i ) ; int res2 = align . getFinalResidue ( i ) ; List < Atom > repeat = new ArrayList < > ( Math . max ( 9 * ( res2 - res1 + 1 ) , 9 ) ) ; Chain prevChain = null ; for ( int k = res1 ; k <= res2 ; k ++ ) { Group g = atoms [ k ] . getGroup ( ) ; prevChain = StructureTools . addGroupToStructure ( s , g , 0 , prevChain , true ) ; repeat . addAll ( g . getAtoms ( ) ) ; } List < Group > ligands = StructureTools . getLigandsByProximity ( allGroups , repeat . toArray ( new Atom [ repeat . size ( ) ] ) , StructureTools . DEFAULT_LIGAND_PROXIMITY_CUTOFF ) ; logger . warn ( "Adding {} ligands to {}" , ligands . size ( ) , symmetry . getMultipleAlignment ( ) . getStructureIdentifier ( i ) ) ; for ( Group ligand : ligands ) { prevChain = StructureTools . addGroupToStructure ( s , ligand , 0 , prevChain , true ) ; } repeats . add ( s ) ; } return repeats ; } | Method that converts the symmetric units of a structure into different structures so that they can be individually visualized . |
24,129 | public static MultipleAlignment fromAFP ( AFPChain symm , Atom [ ] atoms ) throws StructureException { if ( ! symm . getAlgorithmName ( ) . contains ( "symm" ) ) { throw new IllegalArgumentException ( "The input alignment is not a symmetry alignment." ) ; } MultipleAlignmentEnsemble e = new MultipleAlignmentEnsembleImpl ( symm , atoms , atoms , false ) ; e . setAtomArrays ( new ArrayList < Atom [ ] > ( ) ) ; StructureIdentifier name = null ; if ( e . getStructureIdentifiers ( ) != null ) { if ( ! e . getStructureIdentifiers ( ) . isEmpty ( ) ) name = e . getStructureIdentifiers ( ) . get ( 0 ) ; } else name = atoms [ 0 ] . getGroup ( ) . getChain ( ) . getStructure ( ) . getStructureIdentifier ( ) ; e . setStructureIdentifiers ( new ArrayList < StructureIdentifier > ( ) ) ; MultipleAlignment result = new MultipleAlignmentImpl ( ) ; BlockSet bs = new BlockSetImpl ( result ) ; Block b = new BlockImpl ( bs ) ; b . setAlignRes ( new ArrayList < List < Integer > > ( ) ) ; int order = symm . getBlockNum ( ) ; for ( int su = 0 ; su < order ; su ++ ) { List < Integer > residues = e . getMultipleAlignment ( 0 ) . getBlock ( su ) . getAlignRes ( ) . get ( 0 ) ; b . getAlignRes ( ) . add ( residues ) ; e . getStructureIdentifiers ( ) . add ( name ) ; e . getAtomArrays ( ) . add ( atoms ) ; } e . getMultipleAlignments ( ) . set ( 0 , result ) ; result . setEnsemble ( e ) ; CoreSuperimposer imposer = new CoreSuperimposer ( ) ; imposer . superimpose ( result ) ; updateSymmetryScores ( result ) ; return result ; } | Converts a refined symmetry AFPChain alignment into the standard representation of symmetry in a MultipleAlignment that contains the entire Atom array of the strcuture and the symmetric repeats are orgaized in different rows in a single Block . |
24,130 | public static Atom [ ] getRepresentativeAtoms ( Structure structure ) { if ( structure . isNmr ( ) ) return StructureTools . getRepresentativeAtomArray ( structure ) ; else { List < Atom > atomList = new ArrayList < Atom > ( ) ; for ( int m = 0 ; m < structure . nrModels ( ) ; m ++ ) { for ( Chain c : structure . getModel ( m ) ) atomList . addAll ( Arrays . asList ( StructureTools . getRepresentativeAtomArray ( c ) ) ) ; } return atomList . toArray ( new Atom [ 0 ] ) ; } } | Returns the representative Atom Array of the first model if the structure is NMR or the Array for each model if it is a biological assembly with multiple models . |
24,131 | public static Alignable align_NPE ( Matrix sim , StrucAligParameters params ) { float gapOpen = params . getGapOpen ( ) ; float gapExtension = params . getGapExtension ( ) ; int rows = sim . getRowDimension ( ) ; int cols = sim . getColumnDimension ( ) ; Alignable al = new StrCompAlignment ( rows , cols ) ; al . setGapExtCol ( gapExtension ) ; al . setGapExtRow ( gapExtension ) ; al . setGapOpenCol ( gapOpen ) ; al . setGapOpenRow ( gapOpen ) ; AligMatEl [ ] [ ] aligmat = al . getAligMat ( ) ; for ( int i = 0 ; i < rows ; i ++ ) { for ( int j = 0 ; j < cols ; j ++ ) { int e = 0 ; e = ( int ) Math . round ( Gotoh . ALIGFACTOR * sim . get ( i , j ) ) ; AligMatEl am = new AligMatEl ( ) ; am . setValue ( e ) ; aligmat [ i + 1 ] [ j + 1 ] = am ; } } new Gotoh ( al ) ; return al ; } | Align without penalizing end - gaps . Return alignment and score |
24,132 | public static void calculateScores ( MultipleAlignment alignment ) throws StructureException { List < Atom [ ] > trans = MultipleAlignmentTools . transformAtoms ( alignment ) ; alignment . putScore ( RMSD , getRMSD ( trans ) ) ; List < Integer > lengths = new ArrayList < Integer > ( alignment . size ( ) ) ; for ( Atom [ ] atoms : alignment . getAtomArrays ( ) ) { lengths . add ( atoms . length ) ; } alignment . putScore ( AVGTM_SCORE , getAvgTMScore ( trans , lengths ) ) ; } | Calculates and puts the RMSD and the average TM - Score of the MultipleAlignment . |
24,133 | public Ontology parse ( BufferedReader in , OntologyFactory of ) throws IOException , OntologyException { String name = "" ; String description = "" ; Ontology onto = null ; for ( String line = in . readLine ( ) ; line != null ; line = in . readLine ( ) ) { line = line . trim ( ) ; if ( line . length ( ) > 0 ) { if ( line . startsWith ( "#" ) ) { if ( line . startsWith ( "#name:" ) ) { name = line . substring ( "#name:" . length ( ) ) . trim ( ) ; } else if ( line . startsWith ( "#description:" ) ) { description = line . substring ( "#description:" . length ( ) ) . trim ( ) ; } } else { try { if ( onto == null ) { onto = of . createOntology ( name , description ) ; } StringTokenizer toke = new StringTokenizer ( line ) ; String subject = toke . nextToken ( ) ; String predicate = toke . nextToken ( ) ; String object = toke . nextToken ( ) ; Term subT = resolveTerm ( subject , onto ) ; Term objT = resolveTerm ( object , onto ) ; Term relT = resolveTerm ( predicate , onto ) ; Triple trip = resolveTriple ( subT , objT , relT , onto ) ; trip = trip == null ? null : trip ; } catch ( StringIndexOutOfBoundsException e ) { throw new IOException ( "Could not parse line: " + line ) ; } } } } return onto ; } | Parse an ontology from a reader . The reader will be emptied of text . It is the caller s responsibility to close the reader . |
24,134 | public static AFPChain fromXML ( String xml , String name1 , String name2 , Atom [ ] ca1 , Atom [ ] ca2 ) throws IOException , StructureException { AFPChain [ ] afps = parseMultiXML ( xml ) ; if ( afps . length > 0 ) { AFPChain afpChain = afps [ 0 ] ; String n1 = afpChain . getName1 ( ) ; String n2 = afpChain . getName2 ( ) ; if ( n1 == null ) n1 = "" ; if ( n2 == null ) n2 = "" ; if ( n1 . equals ( name2 ) && n2 . equals ( name1 ) ) { afpChain = AFPChainFlipper . flipChain ( afpChain ) ; } rebuildAFPChain ( afpChain , ca1 , ca2 ) ; return afpChain ; } return null ; } | new utility method that checks that the order of the pair in the XML alignment is correct and flips the direction if needed |
24,135 | public static String flipAlignment ( String xml ) throws IOException , StructureException { AFPChain [ ] afps = parseMultiXML ( xml ) ; if ( afps . length < 1 ) return null ; if ( afps . length == 1 ) { AFPChain newChain = AFPChainFlipper . flipChain ( afps [ 0 ] ) ; if ( newChain . getAlgorithmName ( ) == null ) { newChain . setAlgorithmName ( DEFAULT_ALGORITHM_NAME ) ; } return AFPChainXMLConverter . toXML ( newChain ) ; } throw new StructureException ( "not Implemented yet!" ) ; } | Takes an XML representation of the alignment and flips the positions of name1 and name2 |
24,136 | private static int getPositionForPDBresunm ( String pdbresnum , String authId , Atom [ ] atoms ) { ResidueNumber residueNumber = ResidueNumber . fromString ( pdbresnum ) ; residueNumber . setChainName ( authId ) ; boolean blankChain = authId == null || authId . equalsIgnoreCase ( "null" ) || authId . equals ( "_" ) ; for ( int i = 0 ; i < atoms . length ; i ++ ) { Group g = atoms [ i ] . getGroup ( ) ; if ( blankChain ) { residueNumber . setChainName ( g . getChain ( ) . getName ( ) ) ; } if ( g . getResidueNumber ( ) . equals ( residueNumber ) ) { Chain c = g . getChain ( ) ; if ( blankChain || c . getName ( ) . equals ( authId ) ) { return i ; } } } return - 1 ; } | get the position of PDB residue nr X in the ato marray |
24,137 | public List < Matrix4d > getTransformations ( ) { List < Matrix4d > transfs = new ArrayList < Matrix4d > ( ) ; for ( int i = 1 ; i < this . transformations . size ( ) ; i ++ ) { transfs . add ( transformations . get ( i ) ) ; } return transfs ; } | Gets all transformations except for the identity in crystal axes basis . |
24,138 | private static Group [ ] rChainAfp ( FatCatParameters params , AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 ) throws StructureException { params . setMaxTra ( 0 ) ; afpChain . setMaxTra ( 0 ) ; return chainAfp ( params , afpChain , ca1 , ca2 ) ; } | runs rigid chaining process |
24,139 | private static Group [ ] chainAfp ( FatCatParameters params , AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 ) throws StructureException { Atom [ ] ca2clone = StructureTools . cloneAtomArray ( ca2 ) ; List < AFP > afpSet = afpChain . getAfpSet ( ) ; if ( debug ) System . out . println ( "entering chainAfp" ) ; int afpNum = afpSet . size ( ) ; if ( afpNum < 1 ) return new Group [ 0 ] ; long bgtime = System . currentTimeMillis ( ) ; if ( debug ) { System . out . println ( String . format ( "total AFP %d\n" , afpNum ) ) ; } AFPChainer . doChainAfp ( params , afpChain , ca1 , ca2 ) ; int afpChainLen = afpChain . getAfpChainLen ( ) ; if ( afpChainLen < 1 ) { afpChain . setShortAlign ( true ) ; return new Group [ 0 ] ; } long chaintime = System . currentTimeMillis ( ) ; if ( debug ) { System . out . println ( "Afp chaining: time " + ( chaintime - bgtime ) ) ; } AFPPostProcessor . postProcess ( params , afpChain , ca1 , ca2 ) ; AFPOptimizer . optimizeAln ( params , afpChain , ca1 , ca2 ) ; AFPOptimizer . blockInfo ( afpChain ) ; AFPOptimizer . updateScore ( params , afpChain ) ; AFPAlignmentDisplay . getAlign ( afpChain , ca1 , ca2 ) ; Group [ ] twistedPDB = AFPTwister . twistPDB ( afpChain , ca1 , ca2clone ) ; SigEva sig = new SigEva ( ) ; double probability = sig . calSigAll ( params , afpChain ) ; afpChain . setProbability ( probability ) ; double normAlignScore = sig . calNS ( params , afpChain ) ; afpChain . setNormAlignScore ( normAlignScore ) ; double tmScore = AFPChainScorer . getTMScore ( afpChain , ca1 , ca2 , false ) ; afpChain . setTMScore ( tmScore ) ; if ( debug ) { long nowtime = System . currentTimeMillis ( ) ; long diff = nowtime - chaintime ; System . out . println ( "Alignment optimization: time " + diff ) ; System . out . println ( "score: " + afpChain . getAlignScore ( ) ) ; System . out . println ( "opt length: " + afpChain . getOptLength ( ) ) ; System . out . println ( "opt rmsd: " + afpChain . getTotalRmsdOpt ( ) ) ; } return twistedPDB ; } | run AFP chaining allowing up to maxTra flexible regions . Input is original coordinates . |
24,140 | public void process ( ) throws Exception { PrintWriter writer = new PrintWriter ( os ) ; for ( S sequence : sequences ) { String header = headerFormat . getHeader ( sequence ) ; writer . format ( header ) ; writer . println ( ) ; String data = sequence . getSequenceAsString ( ) . toLowerCase ( ) ; int seq_len = data . length ( ) ; writer . println ( "ORIGIN" ) ; for ( int line_number = 0 ; line_number < seq_len ; line_number += lineLength ) { writer . print ( StringManipulationHelper . padLeft ( Integer . toString ( line_number + 1 ) , SEQUENCE_INDENT ) ) ; for ( int words = line_number ; words < Math . min ( line_number + lineLength , seq_len ) ; words += 10 ) { if ( ( words + 10 ) > data . length ( ) ) { writer . print ( ( " " + data . substring ( words ) ) ) ; } else { writer . print ( ( " " + data . substring ( words , words + 10 ) ) ) ; } } writer . println ( ) ; } writer . println ( "//" ) ; } writer . flush ( ) ; } | Allow an override of operating system line separator for programs that needs a specific CRLF or CR or LF option |
24,141 | public Set < String > getOutputOptions ( ) { Set < String > result = new HashSet < String > ( ) ; for ( BlastOutputParameterEnum parameter : param . keySet ( ) ) { result . add ( parameter . name ( ) ) ; } return result ; } | Gets output parameters which are currently set |
24,142 | public Chain getCurrentChain ( ) { if ( current_model_pos >= structure . nrModels ( ) ) { return null ; } List < Chain > model = structure . getModel ( current_model_pos ) ; if ( current_chain_pos >= model . size ( ) ) { return null ; } return model . get ( current_chain_pos ) ; } | Get the current Chain . Returns null if we are at the end of the iteration . |
24,143 | public final static double roundToDecimals ( double d , int c ) { if ( c < 0 ) return d ; double p = Math . pow ( 10 , c ) ; d = d * p ; double tmp = Math . round ( d ) ; return tmp / p ; } | Returns a value with the desired number of decimal places . |
24,144 | public final static boolean doesSequenceContainInvalidChar ( String sequence , Set < Character > cSet ) { for ( char c : sequence . toCharArray ( ) ) { if ( ! cSet . contains ( c ) ) return true ; } return false ; } | Checks if given sequence contains invalid characters . Returns true if invalid characters are found else return false . Note that any characters are deemed as valid only if it is found in cSet . |
24,145 | public final static int getNumberOfInvalidChar ( String sequence , Set < Character > cSet , boolean ignoreCase ) { int total = 0 ; char [ ] cArray ; if ( ignoreCase ) cArray = sequence . toUpperCase ( ) . toCharArray ( ) ; else cArray = sequence . toCharArray ( ) ; if ( cSet == null ) cSet = PeptideProperties . standardAASet ; for ( char c : cArray ) { if ( ! cSet . contains ( c ) ) total ++ ; } return total ; } | Return the number of invalid characters in sequence . |
24,146 | public final static String cleanSequence ( String sequence , Set < Character > cSet ) { Set < Character > invalidCharSet = new HashSet < Character > ( ) ; StringBuilder cleanSeq = new StringBuilder ( ) ; if ( cSet == null ) cSet = PeptideProperties . standardAASet ; for ( char c : sequence . toCharArray ( ) ) { if ( ! cSet . contains ( c ) ) { cleanSeq . append ( "-" ) ; invalidCharSet . add ( c ) ; } else { cleanSeq . append ( c ) ; } } StringBuilder stringBuilder = new StringBuilder ( ) ; for ( char c : invalidCharSet ) { stringBuilder . append ( "\'" + c + "\'" ) ; } stringBuilder . deleteCharAt ( stringBuilder . length ( ) - 1 ) ; stringBuilder . append ( " are being replaced with '-'" ) ; logger . warn ( stringBuilder . toString ( ) ) ; return cleanSeq . toString ( ) ; } | Returns a new sequence with all invalid characters being replaced by - . Note that any character outside of the 20 standard protein amino acid codes are considered as invalid . |
24,147 | public static final String checkSequence ( String sequence , Set < Character > cSet ) { boolean containInvalid = false ; if ( cSet != null ) { containInvalid = sequence != null && doesSequenceContainInvalidChar ( sequence , cSet ) ; } else { containInvalid = sequence != null && doesSequenceContainInvalidChar ( sequence , PeptideProperties . standardAASet ) ; } if ( containInvalid ) { String cSeq = cleanSequence ( sequence , cSet ) ; logger . warn ( "There exists invalid characters in the sequence. Computed results might not be precise." ) ; logger . warn ( "To remove this warning: Please use org.biojava.nbio.aaproperties.Utils.cleanSequence to clean sequence." ) ; return cSeq ; } else { return sequence ; } } | Checks if the sequence contains invalid characters . Note that any character outside of the 20 standard protein amino acid codes are considered as invalid . If yes it will return a new sequence where invalid characters are replaced with - . If no it will simply return the input sequence . |
24,148 | public static LinkedHashMap < String , ProteinSequence > readFastaProteinSequence ( File file ) throws IOException { FileInputStream inStream = new FileInputStream ( file ) ; LinkedHashMap < String , ProteinSequence > proteinSequences = readFastaProteinSequence ( inStream ) ; inStream . close ( ) ; return proteinSequences ; } | Read a fasta file containing amino acids with setup that would handle most cases . |
24,149 | public static LinkedHashMap < String , ProteinSequence > readFastaProteinSequence ( InputStream inStream ) throws IOException { FastaReader < ProteinSequence , AminoAcidCompound > fastaReader = new FastaReader < ProteinSequence , AminoAcidCompound > ( inStream , new GenericFastaHeaderParser < ProteinSequence , AminoAcidCompound > ( ) , new ProteinSequenceCreator ( AminoAcidCompoundSet . getAminoAcidCompoundSet ( ) ) ) ; return fastaReader . process ( ) ; } | Read a fasta file containing amino acids with setup that would handle most cases . User is responsible for closing InputStream because you opened it |
24,150 | public static LinkedHashMap < String , DNASequence > readFastaDNASequence ( InputStream inStream ) throws IOException { FastaReader < DNASequence , NucleotideCompound > fastaReader = new FastaReader < DNASequence , NucleotideCompound > ( inStream , new GenericFastaHeaderParser < DNASequence , NucleotideCompound > ( ) , new DNASequenceCreator ( DNACompoundSet . getDNACompoundSet ( ) ) ) ; return fastaReader . process ( ) ; } | Read a fasta DNA sequence |
24,151 | public static LinkedHashMap < String , RNASequence > readFastaRNASequence ( InputStream inStream ) throws IOException { FastaReader < RNASequence , NucleotideCompound > fastaReader = new FastaReader < RNASequence , NucleotideCompound > ( inStream , new GenericFastaHeaderParser < RNASequence , NucleotideCompound > ( ) , new RNASequenceCreator ( RNACompoundSet . getRNACompoundSet ( ) ) ) ; return fastaReader . process ( ) ; } | Read a fasta RNA sequence |
24,152 | public static void setThreadPoolCPUsFraction ( float fraction ) { setThreadPoolSize ( Math . max ( 1 , Math . round ( fraction * Runtime . getRuntime ( ) . availableProcessors ( ) ) ) ) ; } | Sets thread pool to a given fraction of the available processors . |
24,153 | public static void setThreadPoolSize ( int threads ) { setThreadPool ( new ThreadPoolExecutor ( threads , threads , 0L , TimeUnit . MILLISECONDS , new LinkedBlockingQueue < Runnable > ( ) ) ) ; } | Sets thread pool to given size . |
24,154 | public static void shutdownAndAwaitTermination ( ) { shutdown ( ) ; if ( pool != null ) { try { if ( ! pool . awaitTermination ( 60L , TimeUnit . SECONDS ) ) { pool . shutdownNow ( ) ; if ( ! pool . awaitTermination ( 60L , TimeUnit . SECONDS ) ) { logger . warn ( "BioJava ConcurrencyTools thread pool did not terminate" ) ; } } } catch ( InterruptedException ie ) { pool . shutdownNow ( ) ; Thread . currentThread ( ) . interrupt ( ) ; } } } | Closes the thread pool . Waits 1 minute for a clean exit ; if necessary waits another minute for cancellation . |
24,155 | public static < T > Future < T > submit ( Callable < T > task , String message ) { logger . debug ( "Task " + ( ++ tasks ) + " submitted to shared thread pool. " + message ) ; return getThreadPool ( ) . submit ( task ) ; } | Queues up a task and adds a log entry . |
24,156 | public void process ( String uniprotDatFileName , String fastaFileName ) throws Exception { FileReader fr = new FileReader ( uniprotDatFileName ) ; BufferedReader br = new BufferedReader ( fr ) ; String line = br . readLine ( ) ; String id = "" ; StringBuffer sequence = new StringBuffer ( ) ; ArrayList < ProteinSequence > seqCodingRegionsList = new ArrayList < ProteinSequence > ( ) ; int count = 0 ; HashMap < String , String > uniqueGenes = new HashMap < String , String > ( ) ; HashMap < String , String > uniqueSpecies = new HashMap < String , String > ( ) ; while ( line != null ) { if ( line . startsWith ( "ID" ) ) { String [ ] data = line . split ( " " ) ; id = data [ 3 ] ; } else if ( line . startsWith ( "SQ" ) ) { line = br . readLine ( ) ; while ( ! line . startsWith ( "//" ) ) { for ( int i = 0 ; i < line . length ( ) ; i ++ ) { char aa = line . charAt ( i ) ; if ( ( aa >= 'A' && aa <= 'Z' ) || ( aa >= 'a' && aa <= 'z' ) ) { sequence . append ( aa ) ; } } line = br . readLine ( ) ; } ProteinSequence seq = new ProteinSequence ( sequence . toString ( ) ) ; seq . setAccession ( new AccessionID ( id ) ) ; seqCodingRegionsList . add ( seq ) ; sequence = new StringBuffer ( ) ; count ++ ; if ( count % 100 == 0 ) logger . info ( "Count: " , count ) ; String [ ] parts = id . split ( "_" ) ; uniqueGenes . put ( parts [ 0 ] , "" ) ; uniqueSpecies . put ( parts [ 1 ] , "" ) ; } line = br . readLine ( ) ; } FastaWriterHelper . writeProteinSequence ( new File ( fastaFileName ) , seqCodingRegionsList ) ; br . close ( ) ; fr . close ( ) ; } | Convert a Uniprot sequence file to a fasta file . Allows you to download all sequence data for a species and convert to fasta to be used in a blast database |
24,157 | public boolean hasNext ( ) { if ( group == null ) return false ; if ( current_atom_pos < group . size ( ) - 1 ) { return true ; } else { if ( groupiter != null ) { GroupIterator tmp = ( GroupIterator ) groupiter . clone ( ) ; while ( tmp . hasNext ( ) ) { Group tmpg = tmp . next ( ) ; if ( tmpg . size ( ) > 0 ) { return true ; } } } else { return false ; } } return false ; } | Is there a next atom ? |
24,158 | public Atom next ( ) throws NoSuchElementException { current_atom_pos ++ ; if ( current_atom_pos >= group . size ( ) ) { if ( groupiter == null ) { throw new NoSuchElementException ( "no more atoms found in group!" ) ; } if ( groupiter . hasNext ( ) ) { group = groupiter . next ( ) ; current_atom_pos = - 1 ; return next ( ) ; } else { throw new NoSuchElementException ( "no more atoms found in structure!" ) ; } } Atom a ; a = group . getAtom ( current_atom_pos ) ; if ( a == null ) { logger . error ( "current_atom_pos {} group {} size: {}" , current_atom_pos , group , group . size ( ) ) ; throw new NoSuchElementException ( "error wile trying to retrieve atom" ) ; } return a ; } | Return next atom . |
24,159 | private static ProteinSequence getUniprot ( String uniProtID ) throws Exception { AminoAcidCompoundSet set = AminoAcidCompoundSet . getAminoAcidCompoundSet ( ) ; UniprotProxySequenceReader < AminoAcidCompound > uniprotSequence = new UniprotProxySequenceReader < AminoAcidCompound > ( uniProtID , set ) ; ProteinSequence seq = new ProteinSequence ( uniprotSequence ) ; return seq ; } | Fetch a protein sequence from the UniProt web site |
24,160 | public static boolean equalLengthSequences ( ProteinSequence [ ] sequences ) { for ( int i = 0 ; i < sequences . length - 1 ; i ++ ) { if ( sequences [ i ] == null ) continue ; for ( int j = i + 1 ; j < sequences . length ; j ++ ) { if ( sequences [ j ] == null ) continue ; if ( sequences [ i ] . getLength ( ) == sequences [ j ] . getLength ( ) ) return true ; } } return false ; } | A method to check whether an array of sequences contains at least two sequences having an equal length . |
24,161 | private void readResults ( ) throws IOException , ParseException { factory . setFile ( file ) ; results = factory . createObjects ( evalueThreshold ) ; } | This method is declared private because it is the default action of constructor when file exists |
24,162 | public static String formatExonStructure ( GeneChromosomePosition chromosomePosition ) { if ( chromosomePosition . getOrientation ( ) == '+' ) return formatExonStructureForward ( chromosomePosition ) ; return formatExonStructureReverse ( chromosomePosition ) ; } | Pretty print the details of a GeneChromosomePosition to a String |
24,163 | public static int getCDSLength ( GeneChromosomePosition chromPos ) { List < Integer > exonStarts = chromPos . getExonStarts ( ) ; List < Integer > exonEnds = chromPos . getExonEnds ( ) ; int cdsStart = chromPos . getCdsStart ( ) ; int cdsEnd = chromPos . getCdsEnd ( ) ; int codingLength ; if ( chromPos . getOrientation ( ) . equals ( '+' ) ) codingLength = ChromosomeMappingTools . getCDSLengthForward ( exonStarts , exonEnds , cdsStart , cdsEnd ) ; else codingLength = ChromosomeMappingTools . getCDSLengthReverse ( exonStarts , exonEnds , cdsStart , cdsEnd ) ; return codingLength ; } | Get the length of the CDS in nucleotides . |
24,164 | public static ChromPos getChromosomePosForCDScoordinate ( int cdsNucleotidePosition , GeneChromosomePosition chromPos ) { logger . debug ( " ? Checking chromosome position for CDS position " + cdsNucleotidePosition ) ; List < Integer > exonStarts = chromPos . getExonStarts ( ) ; List < Integer > exonEnds = chromPos . getExonEnds ( ) ; logger . debug ( " Exons:" + exonStarts . size ( ) ) ; int cdsStart = chromPos . getCdsStart ( ) ; int cdsEnd = chromPos . getCdsEnd ( ) ; ChromPos chromosomePos = null ; if ( chromPos . getOrientation ( ) . equals ( '+' ) ) chromosomePos = ChromosomeMappingTools . getChromPosForward ( cdsNucleotidePosition , exonStarts , exonEnds , cdsStart , cdsEnd ) ; else chromosomePos = ChromosomeMappingTools . getChromPosReverse ( cdsNucleotidePosition , exonStarts , exonEnds , cdsStart , cdsEnd ) ; logger . debug ( "=> CDS pos " + cdsNucleotidePosition + " for " + chromPos . getGeneName ( ) + " is on chromosome at " + chromosomePos ) ; return chromosomePos ; } | Maps the position of a CDS nucleotide back to the genome |
24,165 | public static List < Range < Integer > > getChromosomalRangesForCDS ( GeneChromosomePosition chromPos ) { if ( chromPos . getOrientation ( ) == '+' ) return getCDSExonRangesForward ( chromPos , CHROMOSOME ) ; return getCDSExonRangesReverse ( chromPos , CHROMOSOME ) ; } | Extracts the boundaries of the coding regions in chromosomal coordinates |
24,166 | public static int getCDSPosForChromosomeCoordinate ( int coordinate , GeneChromosomePosition chromosomePosition ) { if ( chromosomePosition . getOrientation ( ) == '+' ) return getCDSPosForward ( coordinate , chromosomePosition . getExonStarts ( ) , chromosomePosition . getExonEnds ( ) , chromosomePosition . getCdsStart ( ) , chromosomePosition . getCdsEnd ( ) ) ; return getCDSPosReverse ( coordinate , chromosomePosition . getExonStarts ( ) , chromosomePosition . getExonEnds ( ) , chromosomePosition . getCdsStart ( ) , chromosomePosition . getCdsEnd ( ) ) ; } | I have a genomic coordinate where is it on the mRNA |
24,167 | public static int getCDSPosForward ( int chromPos , List < Integer > exonStarts , List < Integer > exonEnds , int cdsStart , int cdsEnd ) { if ( ( chromPos < ( cdsStart + base ) ) || ( chromPos > ( cdsEnd + base ) ) ) { logger . debug ( "The " + format ( chromPos ) + " position is not in a coding region" ) ; return - 1 ; } logger . debug ( "looking for CDS position for " + format ( chromPos ) ) ; List < Range < Integer > > cdsRegions = getCDSRegions ( exonStarts , exonEnds , cdsStart , cdsEnd ) ; int codingLength = 0 ; int lengthExon = 0 ; for ( Range < Integer > range : cdsRegions ) { int start = range . lowerEndpoint ( ) ; int end = range . upperEndpoint ( ) ; lengthExon = end - start ; if ( start + base <= chromPos && end >= chromPos ) { return codingLength + ( chromPos - start ) ; } else { codingLength += lengthExon ; } } return - 1 ; } | Converts the genetic coordinate to the position of the nucleotide on the mRNA sequence for a gene living on the forward DNA strand . |
24,168 | public static int getCDSPosReverse ( int chromPos , List < Integer > exonStarts , List < Integer > exonEnds , int cdsStart , int cdsEnd ) { if ( ( chromPos < ( cdsStart + base ) ) || ( chromPos > ( cdsEnd + base ) ) ) { logger . debug ( "The " + format ( chromPos ) + " position is not in a coding region" ) ; return - 1 ; } logger . debug ( "looking for CDS position for " + format ( chromPos ) ) ; List < Range < Integer > > cdsRegions = getCDSRegions ( exonStarts , exonEnds , cdsStart , cdsEnd ) ; int codingLength = 0 ; int lengthExon = 0 ; for ( int i = cdsRegions . size ( ) - 1 ; i >= 0 ; i -- ) { int start = cdsRegions . get ( i ) . lowerEndpoint ( ) ; int end = cdsRegions . get ( i ) . upperEndpoint ( ) ; lengthExon = end - start ; if ( start + base <= chromPos && end >= chromPos ) { return codingLength + ( end - chromPos + 1 ) ; } else { codingLength += lengthExon ; } } return - 1 ; } | Converts the genetic coordinate to the position of the nucleotide on the mRNA sequence for a gene living on the reverse DNA strand . |
24,169 | public static List < Range < Integer > > getCDSRegions ( List < Integer > origExonStarts , List < Integer > origExonEnds , int cdsStart , int cdsEnd ) { List < Integer > exonStarts = new ArrayList < Integer > ( origExonStarts ) ; List < Integer > exonEnds = new ArrayList < Integer > ( origExonEnds ) ; int j = 0 ; for ( int i = 0 ; i < origExonStarts . size ( ) ; i ++ ) { if ( ( origExonEnds . get ( i ) < cdsStart ) || ( origExonStarts . get ( i ) > cdsEnd ) ) { exonStarts . remove ( j ) ; exonEnds . remove ( j ) ; } else { j ++ ; } } int nExons = exonStarts . size ( ) ; exonStarts . remove ( 0 ) ; exonStarts . add ( 0 , cdsStart ) ; exonEnds . remove ( nExons - 1 ) ; exonEnds . add ( cdsEnd ) ; List < Range < Integer > > cdsRegion = new ArrayList < Range < Integer > > ( ) ; for ( int i = 0 ; i < nExons ; i ++ ) { Range < Integer > r = Range . closed ( exonStarts . get ( i ) , exonEnds . get ( i ) ) ; cdsRegion . add ( r ) ; } return cdsRegion ; } | Extracts the exons boundaries in CDS coordinates corresponding to the forward DNA strand . |
24,170 | private int resetbuf ( int bit_pos ) { int pos = bit_pos >> 3 ; System . arraycopy ( data , pos , data , 0 , end - pos ) ; end -= pos ; return 0 ; } | Moves the unread data in the buffer to the beginning and resets the pointers . |
24,171 | public static CathDatabase getCathDatabase ( String version ) { if ( version == null ) version = DEFAULT_VERSION ; CathDatabase cath = versions . get ( version ) ; if ( cath == null ) { CathInstallation newCath = new CathInstallation ( ) ; newCath . setCathVersion ( version ) ; cath = newCath ; } return cath ; } | Returns a CATH database of the specified version . |
24,172 | public static QuatSymmetryScores calcScores ( QuatSymmetrySubunits subunits , Matrix4d transformation , List < Integer > permutation ) { QuatSymmetryScores scores = new QuatSymmetryScores ( ) ; double minTm = Double . MAX_VALUE ; double maxTm = Double . MIN_VALUE ; double minRmsd = Double . MAX_VALUE ; double maxRmsd = Double . MIN_VALUE ; double totalSumTm = 0 ; double totalSumDsq = 0 ; double totalLength = 0 ; Point3d t = new Point3d ( ) ; List < Point3d [ ] > traces = subunits . getTraces ( ) ; for ( int i = 0 ; i < traces . size ( ) ; i ++ ) { if ( permutation . get ( i ) == - 1 ) { continue ; } Point3d [ ] orig = traces . get ( i ) ; totalLength += orig . length ; Point3d [ ] perm = traces . get ( permutation . get ( i ) ) ; int tmLen = Math . max ( orig . length , 17 ) ; double d0 = 1.24 * Math . cbrt ( tmLen - 15.0 ) - 1.8 ; double d0Sq = d0 * d0 ; double sumTm = 0 ; double sumDsq = 0 ; for ( int j = 0 ; j < orig . length ; j ++ ) { t . set ( perm [ j ] ) ; transformation . transform ( t ) ; double dSq = orig [ j ] . distanceSquared ( t ) ; sumTm += 1.0 / ( 1.0 + dSq / d0Sq ) ; sumDsq += dSq ; } double sTm = sumTm / tmLen ; minTm = Math . min ( minTm , sTm ) ; maxTm = Math . max ( maxTm , sTm ) ; double sRmsd = Math . sqrt ( sumDsq / orig . length ) ; minRmsd = Math . min ( minRmsd , sRmsd ) ; maxRmsd = Math . max ( maxRmsd , sRmsd ) ; totalSumTm += sumTm ; totalSumDsq += sumDsq ; } scores . setMinRmsd ( minRmsd ) ; scores . setMaxRmsd ( maxRmsd ) ; scores . setMinTm ( minTm ) ; scores . setMaxTm ( maxTm ) ; scores . setTm ( totalSumTm / totalLength ) ; scores . setRmsd ( Math . sqrt ( totalSumDsq / totalLength ) ) ; calcIntrasubunitScores ( subunits , transformation , permutation , scores ) ; return scores ; } | Returns minimum mean and maximum RMSD and TM - Score for two superimposed sets of subunits |
24,173 | private static double combineRmsd ( int b1 , int b2 , AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 ) { int i ; int afpn = 0 ; int [ ] afpChainList = afpChain . getAfpChainList ( ) ; int [ ] block2Afp = afpChain . getBlock2Afp ( ) ; int [ ] blockSize = afpChain . getBlockSize ( ) ; int [ ] list = new int [ blockSize [ b1 ] + blockSize [ b2 ] ] ; for ( i = block2Afp [ b1 ] ; i < block2Afp [ b1 ] + blockSize [ b1 ] ; i ++ ) { list [ afpn ++ ] = afpChainList [ i ] ; } for ( i = block2Afp [ b2 ] ; i < block2Afp [ b2 ] + blockSize [ b2 ] ; i ++ ) { list [ afpn ++ ] = afpChainList [ i ] ; } double rmsd = AFPChainer . calAfpRmsd ( afpn , list , 0 , afpChain , ca1 , ca2 ) ; afpChain . setBlock2Afp ( block2Afp ) ; afpChain . setBlockSize ( blockSize ) ; afpChain . setAfpChainList ( afpChainList ) ; return rmsd ; } | return the rmsd of two blocks |
24,174 | private int getSubstitutionScore ( float [ ] qv , float [ ] tv ) { float score = 0.0f ; for ( int q = 0 ; q < qv . length ; q ++ ) { if ( qv [ q ] > 0.0f ) { for ( int t = 0 ; t < tv . length ; t ++ ) { if ( tv [ t ] > 0.0f ) { score += qv [ q ] * tv [ t ] * getSubstitutionMatrix ( ) . getValue ( cslist . get ( q ) , cslist . get ( t ) ) ; } } } } return Math . round ( score ) ; } | helper method that scores alignment of two column vectors |
24,175 | private static List < EntityInfo > findUniqueEntities ( TreeMap < String , EntityInfo > chainIds2entities ) { List < EntityInfo > list = new ArrayList < EntityInfo > ( ) ; for ( EntityInfo cluster : chainIds2entities . values ( ) ) { boolean present = false ; for ( EntityInfo cl : list ) { if ( cl == cluster ) { present = true ; break ; } } if ( ! present ) list . add ( cluster ) ; } return list ; } | Utility method to obtain a list of unique entities from the chainIds2entities map |
24,176 | public static void createPurelyNonPolyEntities ( List < List < Chain > > nonPolyModels , List < List < Chain > > waterModels , List < EntityInfo > entities ) { if ( nonPolyModels . isEmpty ( ) ) return ; int maxMolId = 0 ; if ( ! entities . isEmpty ( ) ) { maxMolId = Collections . max ( entities , new Comparator < EntityInfo > ( ) { public int compare ( EntityInfo o1 , EntityInfo o2 ) { return new Integer ( o1 . getMolId ( ) ) . compareTo ( o2 . getMolId ( ) ) ; } } ) . getMolId ( ) ; } int molId = maxMolId + 1 ; if ( ! nonPolyModels . get ( 0 ) . isEmpty ( ) ) { List < EntityInfo > nonPolyEntities = new ArrayList < > ( ) ; for ( List < Chain > model : nonPolyModels ) { for ( Chain c : model ) { String molecPdbName = c . getAtomGroup ( 0 ) . getPDBName ( ) ; EntityInfo nonPolyEntity = findNonPolyEntityWithDescription ( molecPdbName , nonPolyEntities ) ; if ( nonPolyEntity == null ) { nonPolyEntity = new EntityInfo ( ) ; nonPolyEntity . setDescription ( molecPdbName ) ; nonPolyEntity . setType ( EntityType . NONPOLYMER ) ; nonPolyEntity . setMolId ( molId ++ ) ; nonPolyEntities . add ( nonPolyEntity ) ; } nonPolyEntity . addChain ( c ) ; c . setEntityInfo ( nonPolyEntity ) ; } } entities . addAll ( nonPolyEntities ) ; } if ( ! waterModels . get ( 0 ) . isEmpty ( ) ) { EntityInfo waterEntity = new EntityInfo ( ) ; waterEntity . setType ( EntityType . WATER ) ; waterEntity . setDescription ( "water" ) ; waterEntity . setMolId ( molId ) ; for ( List < Chain > model : waterModels ) { for ( Chain waterChain : model ) { waterEntity . addChain ( waterChain ) ; waterChain . setEntityInfo ( waterEntity ) ; } } entities . add ( waterEntity ) ; } } | Given all chains of all models find entities for the nonpolymers and water chains within them assigning entity ids types and descriptions to them . The result is written back to the passed entities List . |
24,177 | private static ProteinSequence getProteinSequence ( String str ) { try { ProteinSequence s = new ProteinSequence ( str ) ; return s ; } catch ( CompoundNotFoundException e ) { logger . error ( "Unexpected error when creating ProteinSequence" , e ) ; } return null ; } | Returns the ProteinSequence or null if one can t be created |
24,178 | private static DNASequence getDNASequence ( String str ) { try { DNASequence s = new DNASequence ( str ) ; return s ; } catch ( CompoundNotFoundException e ) { logger . error ( "Unexpected error when creating DNASequence " , e ) ; } return null ; } | Returns the DNASequence or null if one can t be created |
24,179 | private static RNASequence getRNASequence ( String str ) { try { RNASequence s = new RNASequence ( str ) ; return s ; } catch ( CompoundNotFoundException e ) { logger . error ( "Unexpected error when creating RNASequence " , e ) ; } return null ; } | Returns the RNASequence or null if one can t be created |
24,180 | private void combineWithTranslation ( Matrix4d rotation ) { rotation . setTranslation ( centroid ) ; rotation . mul ( rotation , centroidInverse ) ; } | Adds translational component to rotation matrix |
24,181 | public AxisAngle4d getAxisAngle4d ( ) { return new AxisAngle4d ( rotationAxis . getX ( ) , rotationAxis . getY ( ) , rotationAxis . getZ ( ) , theta ) ; } | Returns the rotation axis and angle in a single javax . vecmath . AxisAngle4d object |
24,182 | public Matrix getRotationMatrix ( double theta ) { if ( rotationAxis == null ) { return Matrix . identity ( 3 , 3 ) ; } double x = rotationAxis . getX ( ) ; double y = rotationAxis . getY ( ) ; double z = rotationAxis . getZ ( ) ; double cos = Math . cos ( theta ) ; double sin = Math . sin ( theta ) ; double com = 1 - cos ; return new Matrix ( new double [ ] [ ] { { com * x * x + cos , com * x * y + sin * z , com * x * z + - sin * y } , { com * x * y - sin * z , com * y * y + cos , com * y * z + sin * x } , { com * x * z + sin * y , com * y * z - sin * x , com * z * z + cos } , } ) ; } | Get the rotation matrix corresponding to a rotation about this axis |
24,183 | private void calculateTranslationalAxis ( Matrix rotation , Atom translation ) { rotationAxis = Calc . scale ( translation , 1. / Calc . amount ( translation ) ) ; rotationPos = null ; screwTranslation = translation ; otherTranslation = new AtomImpl ( ) ; otherTranslation . setCoords ( new double [ ] { 0 , 0 , 0 } ) ; } | Handle cases with small angles of rotation |
24,184 | public Atom getProjectedPoint ( Atom point ) { if ( rotationPos == null ) { return null ; } Atom localPoint = Calc . subtract ( point , rotationPos ) ; double dot = Calc . scalarProduct ( localPoint , rotationAxis ) ; Atom localProjected = Calc . scale ( rotationAxis , dot ) ; Atom projected = Calc . add ( localProjected , rotationPos ) ; return projected ; } | Projects a given point onto the axis of rotation |
24,185 | public double getProjectedDistance ( Atom point ) { Atom projected = getProjectedPoint ( point ) ; if ( projected == null ) { return Double . NaN ; } return Calc . getDistance ( point , projected ) ; } | Get the distance from a point to the axis of rotation |
24,186 | public static double getAngle ( AFPChain afpChain ) throws StructureException { if ( afpChain . getBlockNum ( ) < 1 ) { throw new StructureException ( "No aligned residues" ) ; } Matrix rotation = afpChain . getBlockRotationMatrix ( ) [ 0 ] ; if ( rotation == null ) { throw new NullPointerException ( "AFPChain does not contain a rotation matrix" ) ; } return getAngle ( rotation ) ; } | Calculate the rotation angle for a structure |
24,187 | public static double getAngle ( Matrix rotation ) { double c = ( rotation . trace ( ) - 1 ) / 2.0 ; if ( - 1 - 1e-8 < c && c < - 1 ) c = - 1 ; if ( 1 + 1e-8 > c && c > 1 ) c = 1 ; if ( - 1 > c || c > 1 ) { throw new IllegalArgumentException ( "Input matrix is not a valid rotation matrix." ) ; } return Math . acos ( c ) ; } | Calculate the rotation angle for a given matrix |
24,188 | public static double getAngle ( Matrix4d transform ) { double c = ( transform . m00 + transform . m11 + transform . m22 - 1 ) / 2.0 ; if ( - 1 - 1e-8 < c && c < - 1 ) c = - 1 ; if ( 1 + 1e-8 > c && c > 1 ) c = 1 ; if ( - 1 > c || c > 1 ) { throw new IllegalArgumentException ( "Input matrix is not a valid rotation matrix." ) ; } return Math . acos ( c ) ; } | Quickly compute the rotation angle from a rotation matrix . |
24,189 | @ SuppressWarnings ( "unchecked" ) protected void calculateIndirectAmbiguities ( ) { Map < NucleotideCompound , List < NucleotideCompound > > equivalentsMap = new HashMap < NucleotideCompound , List < NucleotideCompound > > ( ) ; List < NucleotideCompound > ambiguousCompounds = new ArrayList < NucleotideCompound > ( ) ; for ( NucleotideCompound compound : getAllCompounds ( ) ) { if ( ! compound . isAmbiguous ( ) ) { continue ; } ambiguousCompounds . add ( compound ) ; } for ( NucleotideCompound sourceCompound : ambiguousCompounds ) { Set < NucleotideCompound > compoundConstituents = sourceCompound . getConstituents ( ) ; for ( NucleotideCompound targetCompound : ambiguousCompounds ) { Set < NucleotideCompound > targetConstituents = targetCompound . getConstituents ( ) ; if ( targetConstituents . containsAll ( compoundConstituents ) ) { NucleotideCompound lcSourceCompound = toLowerCase ( sourceCompound ) ; NucleotideCompound lcTargetCompound = toLowerCase ( targetCompound ) ; checkAdd ( equivalentsMap , sourceCompound , targetCompound ) ; checkAdd ( equivalentsMap , sourceCompound , lcTargetCompound ) ; checkAdd ( equivalentsMap , targetCompound , sourceCompound ) ; checkAdd ( equivalentsMap , lcTargetCompound , sourceCompound ) ; checkAdd ( equivalentsMap , lcSourceCompound , targetCompound ) ; checkAdd ( equivalentsMap , lcSourceCompound , lcTargetCompound ) ; } } } for ( NucleotideCompound key : equivalentsMap . keySet ( ) ) { List < NucleotideCompound > vals = equivalentsMap . get ( key ) ; for ( NucleotideCompound value : vals ) { addEquivalent ( ( C ) key , ( C ) value ) ; addEquivalent ( ( C ) value , ( C ) key ) ; } } } | Loops through all known nucleotides and attempts to find which are equivalent to each other . Also takes into account lower casing nucleotides as well as upper - cased ones . |
24,190 | public NucleotideCompound getAmbiguity ( NucleotideCompound ... compounds ) { Set < NucleotideCompound > settedCompounds = new HashSet < NucleotideCompound > ( ) ; for ( NucleotideCompound compound : compounds ) { for ( NucleotideCompound subCompound : compound . getConstituents ( ) ) { settedCompounds . add ( getCompoundForString ( subCompound . getBase ( ) . toUpperCase ( ) ) ) ; } } for ( NucleotideCompound compound : getAllCompounds ( ) ) { if ( compound . getConstituents ( ) . equals ( settedCompounds ) ) { return compound ; } } return null ; } | Calculates the best symbol for a collection of compounds . For example if you gave this method a AC it will return a M which is the ambiguity symbol for these compounds . |
24,191 | public static int getBlockNrForAlignPos ( AFPChain afpChain , int aligPos ) { int blockNum = afpChain . getBlockNum ( ) ; int [ ] optLen = afpChain . getOptLen ( ) ; int [ ] [ ] [ ] optAln = afpChain . getOptAln ( ) ; int len = 0 ; int p1b = 0 ; int p2b = 0 ; for ( int i = 0 ; i < blockNum ; i ++ ) { for ( int j = 0 ; j < optLen [ i ] ; j ++ ) { int p1 = optAln [ i ] [ 0 ] [ j ] ; int p2 = optAln [ i ] [ 1 ] [ j ] ; if ( len != 0 ) { int lmax = ( p1 - p1b - 1 ) > ( p2 - p2b - 1 ) ? ( p1 - p1b - 1 ) : ( p2 - p2b - 1 ) ; for ( int k = 0 ; k < lmax ; k ++ ) { len ++ ; } } p1b = p1 ; p2b = p2 ; if ( len >= aligPos ) { return i ; } len ++ ; } } return blockNum ; } | get the block number for an aligned position |
24,192 | public void apairs_from_seed ( int l , int i , int j ) { aligpath = new IndexPair [ l ] ; idx1 = new int [ l ] ; idx2 = new int [ l ] ; for ( int x = 0 ; x < l ; x ++ ) { idx1 [ x ] = i + x ; idx2 [ x ] = j + x ; aligpath [ x ] = new IndexPair ( ( short ) ( i + x ) , ( short ) ( j + x ) ) ; } } | Set apairs according to a seed position . |
24,193 | private void rotateShiftAtoms ( Atom [ ] ca ) { for ( int i = 0 ; i < ca . length ; i ++ ) { Atom c = ca [ i ] ; Calc . rotate ( c , currentRotMatrix ) ; Calc . shift ( c , currentTranMatrix ) ; ca [ i ] = c ; } } | rotate and shift atoms with currentRotMatrix and current Tranmatrix |
24,194 | private int count_gaps ( int [ ] i1 , int [ ] i2 ) { int i0 = i1 [ 0 ] ; int j0 = i2 [ 0 ] ; int gaps = 0 ; for ( int i = 1 ; i < i1 . length ; i ++ ) { if ( Math . abs ( i1 [ i ] - i0 ) != 1 || ( Math . abs ( i2 [ i ] - j0 ) != 1 ) ) { gaps += 1 ; } i0 = i1 [ i ] ; j0 = i2 [ i ] ; } return gaps ; } | Count the number of gaps in an alignment represented by idx1 idx2 . |
24,195 | private void super_pos_alig ( Atom [ ] ca1 , Atom [ ] ca2 , int [ ] idx1 , int [ ] idx2 , boolean getRMS ) throws StructureException { Atom [ ] ca1subset = new Atom [ idx1 . length ] ; Atom [ ] ca2subset = new Atom [ idx2 . length ] ; for ( int i = 0 ; i < idx1 . length ; i ++ ) { int pos1 = idx1 [ i ] ; int pos2 = idx2 [ i ] ; ca1subset [ i ] = ca1 [ pos1 ] ; ca2subset [ i ] = ( Atom ) ca2 [ pos2 ] . clone ( ) ; } Matrix4d trans = SuperPositions . superpose ( Calc . atomsToPoints ( ca1subset ) , Calc . atomsToPoints ( ca2subset ) ) ; this . currentRotMatrix = Matrices . getRotationJAMA ( trans ) ; this . currentTranMatrix = Calc . getTranslationVector ( trans ) ; if ( getRMS ) { rotateShiftAtoms ( ca2subset ) ; this . rms = Calc . rmsd ( ca1subset , ca2subset ) ; } } | Superimposes two molecules according to residue index list idx1 and idx2 . Does not change the original coordinates . as an internal result the rotation matrix and shift vectors for are set |
24,196 | public Structure getAlignedStructure ( Structure s1 , Structure s2 ) { Structure s3 = s2 . clone ( ) ; currentRotMatrix . print ( 3 , 3 ) ; Calc . rotate ( s3 , currentRotMatrix ) ; Calc . shift ( s3 , currentTranMatrix ) ; Structure newpdb = new StructureImpl ( ) ; newpdb . setPDBCode ( "Java" ) ; newpdb . setName ( "Aligned with BioJava" ) ; newpdb . addModel ( s1 . getChains ( 0 ) ) ; newpdb . addModel ( s3 . getChains ( 0 ) ) ; return newpdb ; } | create an artifical Structure object that contains the two structures superimposed onto each other . Each structure is in a separate model . Model 1 is structure 1 and Model 2 is structure 2 . |
24,197 | public String toPDB ( Structure s1 , Structure s2 ) { Structure newpdb = getAlignedStructure ( s1 , s2 ) ; return newpdb . toPDB ( ) ; } | converts the alignment to a PDB file each of the structures will be represented as a model . |
24,198 | public GeneSequence addGene ( AccessionID accession , int bioBegin , int bioEnd , Strand strand ) { GeneSequence geneSequence = new GeneSequence ( this , bioBegin , bioEnd , strand ) ; geneSequence . setAccession ( accession ) ; geneSequenceHashMap . put ( accession . toString ( ) , geneSequence ) ; return geneSequence ; } | Add a gene to the chromosome sequence using bioIndexing starts at 1 instead of 0 . The GeneSequence that is returned will have a reference to parent chromosome sequence which actually contains the sequence data . Strand is important for positive and negative direction where negative strand means we need reverse complement . If negative strand then bioBegin will be greater than bioEnd |
24,199 | public Point getPanelPos ( int aligSeq , int i ) { Point p = new Point ( ) ; int lineNr = i / DEFAULT_LINE_LENGTH ; int linePos = i % DEFAULT_LINE_LENGTH ; int x = linePos * DEFAULT_CHAR_SIZE + DEFAULT_X_SPACE + DEFAULT_LEGEND_SIZE ; int y = lineNr * DEFAULT_Y_STEP + DEFAULT_Y_SPACE ; y += DEFAULT_LINE_SEPARATION * aligSeq ; p . setLocation ( x , y ) ; return p ; } | get the position of the sequence position on the Panel |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.