idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
24,400 | private void checkWriteFile ( AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 , boolean dbsearch ) throws IOException , ClassNotFoundException , NoSuchMethodException , InvocationTargetException , IllegalAccessException , StructureException { String output = null ; if ( params . isOutputPDB ( ) ) { if ( ! GuiWrapper . isGuiModuleInstalled ( ) ) { System . err . println ( "The biojava-structure-gui module is not installed. Please install!" ) ; output = AFPChainXMLConverter . toXML ( afpChain , ca1 , ca2 ) ; } else { Structure tmp = AFPAlignmentDisplay . createArtificalStructure ( afpChain , ca1 , ca2 ) ; output = "TITLE " + afpChain . getAlgorithmName ( ) + " " + afpChain . getVersion ( ) + " " ; output += afpChain . getName1 ( ) + " vs. " + afpChain . getName2 ( ) ; output += newline ; output += tmp . toPDB ( ) ; } } else if ( params . getOutFile ( ) != null ) { output = AFPChainXMLConverter . toXML ( afpChain , ca1 , ca2 ) ; } else if ( params . getSaveOutputDir ( ) != null ) { output = AFPChainXMLConverter . toXML ( afpChain , ca1 , ca2 ) ; } if ( output == null ) return ; String fileName = null ; if ( dbsearch ) { if ( params . getSaveOutputDir ( ) != null ) { if ( afpChain . getName1 ( ) . startsWith ( "file:" ) || afpChain . getName2 ( ) . startsWith ( "file:" ) ) return ; fileName = params . getSaveOutputDir ( ) ; fileName += getAutoFileName ( afpChain ) ; } else { return ; } } else if ( params . getOutFile ( ) != null ) { fileName = params . getOutFile ( ) ; } if ( fileName == null ) { System . err . println ( "Can't write outputfile. Either provide a filename using -outFile or set -autoOutputFile to true ." ) ; System . exit ( 1 ) ; return ; } FileOutputStream out ; PrintStream p ; out = new FileOutputStream ( fileName ) ; p = new PrintStream ( out ) ; p . println ( output ) ; p . close ( ) ; } | check if the result should be written to the local file system |
24,401 | private Structure fixStructureName ( Structure s , String file ) { if ( s . getName ( ) != null && ( ! s . getName ( ) . equals ( "" ) ) ) return s ; s . setName ( s . getPDBCode ( ) ) ; if ( s . getName ( ) == null || s . getName ( ) . equals ( "" ) ) { File f = new File ( file ) ; s . setName ( f . getName ( ) ) ; } return s ; } | apply a number of rules to fix the name of the structure if it did not get set during loading . |
24,402 | public static void main ( String [ ] args ) throws IOException , StructureException { Structure structure = MmtfActions . readFromWeb ( "4cup" ) ; System . out . println ( structure . getChains ( ) . size ( ) ) ; } | Main function to run the demo |
24,403 | public void runOptimization ( int maxi ) throws StructureException { superimposeBySet ( ) ; if ( debug ) System . err . println ( " initial rmsd " + rmsd ) ; maxKeepStep = 4 ; keepStep = 0 ; optimize ( maxi ) ; } | run the optimization |
24,404 | private void superimposeBySet ( ) throws StructureException { Atom [ ] tmp1 = new Atom [ equLen ] ; Atom [ ] tmp2 = new Atom [ equLen ] ; int i , r1 , r2 ; for ( i = 0 ; i < equLen ; i ++ ) { r1 = equSet [ 0 ] [ i ] ; r2 = equSet [ 1 ] [ i ] ; tmp1 [ i ] = cod1 [ r1 ] ; tmp2 [ i ] = ( Atom ) cod2 [ r2 ] . clone ( ) ; } Matrix4d trans = SuperPositions . superpose ( Calc . atomsToPoints ( tmp1 ) , Calc . atomsToPoints ( tmp2 ) ) ; Calc . transform ( tmp2 , trans ) ; rmsd = Calc . rmsd ( tmp1 , tmp2 ) ; Calc . transform ( cod2 , trans ) ; } | superimpose two structures according to the equivalent residues |
24,405 | private void saveMatrix ( ) { for ( String chainId : currentChainIDs ) { BiologicalAssemblyTransformation transformation = new BiologicalAssemblyTransformation ( ) ; transformation . setRotationMatrix ( currentMatrix . getArray ( ) ) ; transformation . setTranslation ( shift ) ; transformation . setId ( String . valueOf ( modelNumber ) ) ; transformation . setChainId ( chainId ) ; transformations . add ( transformation ) ; } if ( ! transformationMap . containsKey ( currentBioMolecule ) ) { BioAssemblyInfo bioAssembly = new BioAssemblyInfo ( ) ; bioAssembly . setId ( currentBioMolecule ) ; bioAssembly . setTransforms ( transformations ) ; transformationMap . put ( currentBioMolecule , bioAssembly ) ; } } | Saves transformation matrix for the list of current chains |
24,406 | public void setMacromolecularSizes ( ) { for ( BioAssemblyInfo bioAssembly : transformationMap . values ( ) ) { bioAssembly . setMacromolecularSize ( bioAssembly . getTransforms ( ) . size ( ) ) ; } } | Set the macromolecularSize fields of the parsed bioassemblies . This can only be called after the full PDB file has been read so that all the info for all bioassemblies has been gathered . Note that an explicit method to set the field is necessary here because in PDB files the transformations contain only the author chain ids corresponding to polymeric chains whilst in mmCIF files the transformations contain all asym ids of both polymers and non - polymers . |
24,407 | public static < C extends Compound > UniprotProxySequenceReader < C > parseUniprotXMLString ( String xml , CompoundSet < C > compoundSet ) { try { Document document = XMLHelper . inputStreamToDocument ( new ByteArrayInputStream ( xml . getBytes ( ) ) ) ; return new UniprotProxySequenceReader < C > ( document , compoundSet ) ; } catch ( Exception e ) { logger . error ( "Exception on xml parse of: {}" , xml ) ; } return null ; } | The passed in xml is parsed as a DOM object so we know everything about the protein . If an error occurs throw an exception . We could have a bad uniprot id |
24,408 | public ArrayList < AccessionID > getAccessions ( ) throws XPathExpressionException { ArrayList < AccessionID > accessionList = new ArrayList < AccessionID > ( ) ; if ( uniprotDoc == null ) { return accessionList ; } Element uniprotElement = uniprotDoc . getDocumentElement ( ) ; Element entryElement = XMLHelper . selectSingleElement ( uniprotElement , "entry" ) ; ArrayList < Element > keyWordElementList = XMLHelper . selectElements ( entryElement , "accession" ) ; for ( Element element : keyWordElementList ) { AccessionID accessionID = new AccessionID ( element . getTextContent ( ) , DataSource . UNIPROT ) ; accessionList . add ( accessionID ) ; } return accessionList ; } | Pull uniprot accessions associated with this sequence |
24,409 | public ArrayList < String > getProteinAliases ( ) throws XPathExpressionException { ArrayList < String > aliasList = new ArrayList < String > ( ) ; if ( uniprotDoc == null ) { return aliasList ; } Element uniprotElement = uniprotDoc . getDocumentElement ( ) ; Element entryElement = XMLHelper . selectSingleElement ( uniprotElement , "entry" ) ; Element proteinElement = XMLHelper . selectSingleElement ( entryElement , "protein" ) ; ArrayList < Element > keyWordElementList = XMLHelper . selectElements ( proteinElement , "alternativeName" ) ; for ( Element element : keyWordElementList ) { Element fullNameElement = XMLHelper . selectSingleElement ( element , "fullName" ) ; aliasList . add ( fullNameElement . getTextContent ( ) ) ; ArrayList < Element > shortNameElements = XMLHelper . selectElements ( element , "shortName" ) ; for ( Element shortNameElement : shortNameElements ) { if ( null != shortNameElement ) { String shortName = shortNameElement . getTextContent ( ) ; if ( null != shortName && ! shortName . trim ( ) . isEmpty ( ) ) { aliasList . add ( shortName ) ; } } } } keyWordElementList = XMLHelper . selectElements ( proteinElement , "recommendedName" ) ; for ( Element element : keyWordElementList ) { Element fullNameElement = XMLHelper . selectSingleElement ( element , "fullName" ) ; aliasList . add ( fullNameElement . getTextContent ( ) ) ; ArrayList < Element > shortNameElements = XMLHelper . selectElements ( element , "shortName" ) ; for ( Element shortNameElement : shortNameElements ) { if ( null != shortNameElement ) { String shortName = shortNameElement . getTextContent ( ) ; if ( null != shortName && ! shortName . trim ( ) . isEmpty ( ) ) { aliasList . add ( shortName ) ; } } } } Element cdAntigen = XMLHelper . selectSingleElement ( proteinElement , "cdAntigenName" ) ; if ( null != cdAntigen ) { String cdAntigenName = cdAntigen . getTextContent ( ) ; if ( null != cdAntigenName && ! cdAntigenName . trim ( ) . isEmpty ( ) ) { aliasList . add ( cdAntigenName ) ; } } return aliasList ; } | Pull uniprot protein aliases associated with this sequence |
24,410 | public ArrayList < String > getGeneAliases ( ) throws XPathExpressionException { ArrayList < String > aliasList = new ArrayList < String > ( ) ; if ( uniprotDoc == null ) { return aliasList ; } Element uniprotElement = uniprotDoc . getDocumentElement ( ) ; Element entryElement = XMLHelper . selectSingleElement ( uniprotElement , "entry" ) ; ArrayList < Element > proteinElements = XMLHelper . selectElements ( entryElement , "gene" ) ; for ( Element proteinElement : proteinElements ) { ArrayList < Element > keyWordElementList = XMLHelper . selectElements ( proteinElement , "name" ) ; for ( Element element : keyWordElementList ) { aliasList . add ( element . getTextContent ( ) ) ; } } return aliasList ; } | Pull uniprot gene aliases associated with this sequence |
24,411 | private static HttpURLConnection openURLConnection ( URL url ) throws IOException { final int timeout = 5000 ; final String useragent = "BioJava" ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setRequestProperty ( "User-Agent" , useragent ) ; conn . setInstanceFollowRedirects ( true ) ; conn . setConnectTimeout ( timeout ) ; conn . setReadTimeout ( timeout ) ; int status = conn . getResponseCode ( ) ; while ( status == HttpURLConnection . HTTP_MOVED_TEMP || status == HttpURLConnection . HTTP_MOVED_PERM || status == HttpURLConnection . HTTP_SEE_OTHER ) { String newUrl = conn . getHeaderField ( "Location" ) ; if ( newUrl . equals ( url . toString ( ) ) ) { throw new IOException ( "Cyclic redirect detected at " + newUrl ) ; } String cookies = conn . getHeaderField ( "Set-Cookie" ) ; url = new URL ( newUrl ) ; conn . disconnect ( ) ; conn = ( HttpURLConnection ) url . openConnection ( ) ; if ( cookies != null ) { conn . setRequestProperty ( "Cookie" , cookies ) ; } conn . addRequestProperty ( "User-Agent" , useragent ) ; conn . setInstanceFollowRedirects ( true ) ; conn . setConnectTimeout ( timeout ) ; conn . setReadTimeout ( timeout ) ; conn . connect ( ) ; status = conn . getResponseCode ( ) ; logger . info ( "Redirecting from {} to {}" , url , newUrl ) ; } conn . connect ( ) ; return conn ; } | Open a URL connection . |
24,412 | public String getGeneName ( ) { if ( uniprotDoc == null ) { return "" ; } try { Element uniprotElement = uniprotDoc . getDocumentElement ( ) ; Element entryElement = XMLHelper . selectSingleElement ( uniprotElement , "entry" ) ; Element geneElement = XMLHelper . selectSingleElement ( entryElement , "gene" ) ; if ( geneElement == null ) { return "" ; } Element nameElement = XMLHelper . selectSingleElement ( geneElement , "name" ) ; if ( nameElement == null ) { return "" ; } return nameElement . getTextContent ( ) ; } catch ( XPathExpressionException e ) { logger . error ( "Problems while parsing gene name in UniProt XML: {}. Gene name will be blank." , e . getMessage ( ) ) ; return "" ; } } | Get the gene name associated with this sequence . |
24,413 | public ArrayList < String > getKeyWords ( ) { ArrayList < String > keyWordsList = new ArrayList < String > ( ) ; if ( uniprotDoc == null ) { return keyWordsList ; } try { Element uniprotElement = uniprotDoc . getDocumentElement ( ) ; Element entryElement = XMLHelper . selectSingleElement ( uniprotElement , "entry" ) ; ArrayList < Element > keyWordElementList = XMLHelper . selectElements ( entryElement , "keyword" ) ; for ( Element element : keyWordElementList ) { keyWordsList . add ( element . getTextContent ( ) ) ; } } catch ( XPathExpressionException e ) { logger . error ( "Problems while parsing keywords in UniProt XML: {}. No keywords will be available." , e . getMessage ( ) ) ; return new ArrayList < String > ( ) ; } return keyWordsList ; } | Pull UniProt key words which is a mixed bag of words associated with this sequence |
24,414 | public LinkedHashMap < String , ArrayList < DBReferenceInfo > > getDatabaseReferences ( ) { LinkedHashMap < String , ArrayList < DBReferenceInfo > > databaseReferencesHashMap = new LinkedHashMap < String , ArrayList < DBReferenceInfo > > ( ) ; if ( uniprotDoc == null ) { return databaseReferencesHashMap ; } try { Element uniprotElement = uniprotDoc . getDocumentElement ( ) ; Element entryElement = XMLHelper . selectSingleElement ( uniprotElement , "entry" ) ; ArrayList < Element > dbreferenceElementList = XMLHelper . selectElements ( entryElement , "dbReference" ) ; for ( Element element : dbreferenceElementList ) { String type = element . getAttribute ( "type" ) ; String id = element . getAttribute ( "id" ) ; ArrayList < DBReferenceInfo > idlist = databaseReferencesHashMap . get ( type ) ; if ( idlist == null ) { idlist = new ArrayList < DBReferenceInfo > ( ) ; databaseReferencesHashMap . put ( type , idlist ) ; } DBReferenceInfo dbreferenceInfo = new DBReferenceInfo ( type , id ) ; ArrayList < Element > propertyElementList = XMLHelper . selectElements ( element , "property" ) ; for ( Element propertyElement : propertyElementList ) { String propertyType = propertyElement . getAttribute ( "type" ) ; String propertyValue = propertyElement . getAttribute ( "value" ) ; dbreferenceInfo . addProperty ( propertyType , propertyValue ) ; } idlist . add ( dbreferenceInfo ) ; } } catch ( XPathExpressionException e ) { logger . error ( "Problems while parsing db references in UniProt XML: {}. No db references will be available." , e . getMessage ( ) ) ; return new LinkedHashMap < String , ArrayList < DBReferenceInfo > > ( ) ; } return databaseReferencesHashMap ; } | The Uniprot mappings to other database identifiers for this sequence |
24,415 | public static AFPChain fastaToAfpChain ( Map < String , ProteinSequence > sequences , Structure structure1 , Structure structure2 ) throws StructureException { if ( sequences . size ( ) != 2 ) { throw new IllegalArgumentException ( "There must be exactly 2 sequences, but there were " + sequences . size ( ) ) ; } if ( structure1 == null || structure2 == null ) { throw new IllegalArgumentException ( "A structure is null" ) ; } List < ProteinSequence > seqs = new ArrayList < ProteinSequence > ( ) ; List < String > names = new ArrayList < String > ( 2 ) ; for ( Map . Entry < String , ProteinSequence > entry : sequences . entrySet ( ) ) { seqs . add ( entry . getValue ( ) ) ; names . add ( entry . getKey ( ) ) ; } return fastaToAfpChain ( seqs . get ( 0 ) , seqs . get ( 1 ) , structure1 , structure2 ) ; } | Uses two sequences each with a corresponding structure to create an AFPChain corresponding to the alignment . Provided only for convenience since FastaReaders return such maps . |
24,416 | public static AFPChain fastaToAfpChain ( SequencePair < Sequence < AminoAcidCompound > , AminoAcidCompound > alignment , Structure structure1 , Structure structure2 ) throws StructureException { List < AlignedSequence < Sequence < AminoAcidCompound > , AminoAcidCompound > > seqs = alignment . getAlignedSequences ( ) ; StringBuilder sb1 = new StringBuilder ( ) ; for ( AminoAcidCompound a : seqs . get ( 0 ) ) { sb1 . append ( a . getBase ( ) ) ; } try { ProteinSequence seq1 = new ProteinSequence ( sb1 . toString ( ) ) ; StringBuilder sb2 = new StringBuilder ( ) ; for ( AminoAcidCompound a : seqs . get ( 1 ) ) { sb1 . append ( a . getBase ( ) ) ; } ProteinSequence seq2 = new ProteinSequence ( sb2 . toString ( ) ) ; LinkedHashMap < String , ProteinSequence > map = new LinkedHashMap < String , ProteinSequence > ( ) ; map . put ( structure1 . getName ( ) , seq1 ) ; map . put ( structure2 . getName ( ) , seq2 ) ; return fastaToAfpChain ( map , structure1 , structure2 ) ; } catch ( CompoundNotFoundException e ) { logger . error ( "Unexpected error while creating protein sequences: {}. This is most likely a bug." , e . getMessage ( ) ) ; return null ; } } | Provided only for convenience . |
24,417 | public static void main ( String [ ] args ) throws StructureException , IOException { if ( args . length != 3 ) { System . err . println ( "Usage: FastaAFPChainConverter fasta-file structure-1-name structure-2-name" ) ; return ; } File fasta = new File ( args [ 0 ] ) ; Structure structure1 = StructureTools . getStructure ( args [ 1 ] ) ; Structure structure2 = StructureTools . getStructure ( args [ 2 ] ) ; if ( structure1 == null ) throw new IllegalArgumentException ( "No structure for " + args [ 1 ] + " was found" ) ; if ( structure2 == null ) throw new IllegalArgumentException ( "No structure for " + args [ 2 ] + " was found" ) ; AFPChain afpChain = fastaFileToAfpChain ( fasta , structure1 , structure2 ) ; String xml = AFPChainXMLConverter . toXML ( afpChain ) ; System . out . println ( xml ) ; } | Prints out the XML representation of an AFPChain from a file containing exactly two FASTA sequences . |
24,418 | public void put ( Key key , Value val ) { if ( val == null ) st . remove ( key ) ; else st . put ( key , val ) ; } | Put key - value pair into the symbol table . Remove key from table if value is null . |
24,419 | public Key ceil ( Key k ) { SortedMap < Key , Value > tail = st . tailMap ( k ) ; if ( tail . isEmpty ( ) ) return null ; else return tail . firstKey ( ) ; } | Return the smallest key in the table > = k . |
24,420 | public Key floor ( Key k ) { if ( st . containsKey ( k ) ) return k ; SortedMap < Key , Value > head = st . headMap ( k ) ; if ( head . isEmpty ( ) ) return null ; else return head . lastKey ( ) ; } | Return the largest key in the table < = k . |
24,421 | private String [ ] getHeaderValues ( String header ) { String [ ] data = new String [ 0 ] ; ArrayList < String > values = new ArrayList < String > ( ) ; StringBuffer sb = new StringBuffer ( ) ; if ( ! header . startsWith ( "PDB:" ) ) { for ( int i = 0 ; i < header . length ( ) ; i ++ ) { if ( header . charAt ( i ) == '|' ) { values . add ( sb . toString ( ) ) ; sb . setLength ( 0 ) ; } else if ( i == header . length ( ) - 1 ) { sb . append ( header . charAt ( i ) ) ; values . add ( sb . toString ( ) ) ; } else { sb . append ( header . charAt ( i ) ) ; } data = new String [ values . size ( ) ] ; values . toArray ( data ) ; } } else { data = header . split ( " " ) ; } return data ; } | Parse out the components where some have a | and others do not |
24,422 | static < E > List < E > getListFromFutures ( List < Future < E > > futures ) { List < E > list = new ArrayList < E > ( ) ; for ( Future < E > f : futures ) { try { list . add ( f . get ( ) ) ; } catch ( InterruptedException e ) { logger . error ( "Interrupted Exception: " , e ) ; } catch ( ExecutionException e ) { logger . error ( "Execution Exception: " , e ) ; } } return list ; } | Factory method which retrieves calculated elements from a list of tasks on the concurrent execution queue . |
24,423 | public static < S extends Sequence < C > , C extends Compound > PairwiseSequenceAligner < S , C > getPairwiseAligner ( S query , S target , PairwiseSequenceAlignerType type , GapPenalty gapPenalty , SubstitutionMatrix < C > subMatrix ) { if ( ! query . getCompoundSet ( ) . equals ( target . getCompoundSet ( ) ) ) { throw new IllegalArgumentException ( "Sequence compound sets must be the same" ) ; } switch ( type ) { default : case GLOBAL : return new NeedlemanWunsch < S , C > ( query , target , gapPenalty , subMatrix ) ; case LOCAL : return new SmithWaterman < S , C > ( query , target , gapPenalty , subMatrix ) ; case GLOBAL_LINEAR_SPACE : case LOCAL_LINEAR_SPACE : throw new UnsupportedOperationException ( Alignments . class . getSimpleName ( ) + " does not yet support " + type + " alignment" ) ; } } | Factory method which constructs a pairwise sequence aligner . |
24,424 | static < S extends Sequence < C > , C extends Compound > PairwiseSequenceScorer < S , C > getPairwiseScorer ( S query , S target , PairwiseSequenceScorerType type , GapPenalty gapPenalty , SubstitutionMatrix < C > subMatrix ) { switch ( type ) { default : case GLOBAL : return getPairwiseAligner ( query , target , PairwiseSequenceAlignerType . GLOBAL , gapPenalty , subMatrix ) ; case GLOBAL_IDENTITIES : return new FractionalIdentityScorer < S , C > ( getPairwiseAligner ( query , target , PairwiseSequenceAlignerType . GLOBAL , gapPenalty , subMatrix ) ) ; case GLOBAL_SIMILARITIES : return new FractionalSimilarityScorer < S , C > ( getPairwiseAligner ( query , target , PairwiseSequenceAlignerType . GLOBAL , gapPenalty , subMatrix ) ) ; case LOCAL : return getPairwiseAligner ( query , target , PairwiseSequenceAlignerType . LOCAL , gapPenalty , subMatrix ) ; case LOCAL_IDENTITIES : return new FractionalIdentityScorer < S , C > ( getPairwiseAligner ( query , target , PairwiseSequenceAlignerType . LOCAL , gapPenalty , subMatrix ) ) ; case LOCAL_SIMILARITIES : return new FractionalSimilarityScorer < S , C > ( getPairwiseAligner ( query , target , PairwiseSequenceAlignerType . LOCAL , gapPenalty , subMatrix ) ) ; case KMERS : case WU_MANBER : throw new UnsupportedOperationException ( Alignments . class . getSimpleName ( ) + " does not yet support " + type + " scoring" ) ; } } | Factory method which constructs a pairwise sequence scorer . |
24,425 | static < S extends Sequence < C > , C extends Compound > ProfileProfileAligner < S , C > getProfileProfileAligner ( Future < ProfilePair < S , C > > profile1 , Future < ProfilePair < S , C > > profile2 , ProfileProfileAlignerType type , GapPenalty gapPenalty , SubstitutionMatrix < C > subMatrix ) { switch ( type ) { default : case GLOBAL : return new SimpleProfileProfileAligner < S , C > ( profile1 , profile2 , gapPenalty , subMatrix ) ; case GLOBAL_LINEAR_SPACE : case GLOBAL_CONSENSUS : case LOCAL : case LOCAL_LINEAR_SPACE : case LOCAL_CONSENSUS : throw new UnsupportedOperationException ( Alignments . class . getSimpleName ( ) + " does not yet support " + type + " alignment" ) ; } } | Factory method which constructs a profile - profile aligner . |
24,426 | public void process ( ) throws IOException , StructureException { if ( sequences == null ) { LinkedHashMap < String , ProteinSequence > sequenceMap = reader . process ( ) ; sequences = sequenceMap . values ( ) . toArray ( new ProteinSequence [ 0 ] ) ; accessions = new String [ sequences . length ] ; structures = new Structure [ sequences . length ] ; residues = new ResidueNumber [ sequences . length ] [ ] ; for ( int i = 0 ; i < sequences . length ; i ++ ) { accessions [ i ] = sequences [ i ] . getAccession ( ) . getID ( ) ; structures [ i ] = cache . getStructure ( accessions [ i ] ) ; residues [ i ] = StructureSequenceMatcher . matchSequenceToStructure ( sequences [ i ] , structures [ i ] ) ; assert ( residues [ i ] . length == sequences [ i ] . getLength ( ) ) ; } } } | Parses the fasta file and loads it into memory . |
24,427 | public static void downloadFile ( URL url , File destination ) throws IOException { int count = 0 ; int maxTries = 10 ; int timeout = 60000 ; File tempFile = File . createTempFile ( getFilePrefix ( destination ) , "." + getFileExtension ( destination ) ) ; ReadableByteChannel rbc = null ; FileOutputStream fos = null ; while ( true ) { try { URLConnection connection = prepareURLConnection ( url . toString ( ) , timeout ) ; connection . connect ( ) ; InputStream inputStream = connection . getInputStream ( ) ; rbc = Channels . newChannel ( inputStream ) ; fos = new FileOutputStream ( tempFile ) ; fos . getChannel ( ) . transferFrom ( rbc , 0 , Long . MAX_VALUE ) ; break ; } catch ( SocketTimeoutException e ) { if ( ++ count == maxTries ) throw e ; } finally { if ( rbc != null ) { rbc . close ( ) ; } if ( fos != null ) { fos . close ( ) ; } } } logger . debug ( "Copying temp file {} to final location {}" , tempFile , destination ) ; copy ( tempFile , destination ) ; tempFile . delete ( ) ; } | Download the content provided at URL url and store the result to a local file using a temp file to cache the content in case something goes wrong in download |
24,428 | public static String toUnixPath ( String path ) { String uPath = path ; if ( uPath . contains ( "\\" ) ) { uPath = uPath . replaceAll ( "\\\\" , "/" ) ; } if ( uPath . endsWith ( "//" ) ) { uPath = uPath . substring ( 0 , uPath . length ( ) - 1 ) ; } if ( ! uPath . endsWith ( "/" ) ) { uPath = uPath + "/" ; } return uPath ; } | Converts path to Unix convention and adds a terminating slash if it was omitted |
24,429 | public static String expandUserHome ( String file ) { if ( file . startsWith ( "~" + File . separator ) ) { file = System . getProperty ( "user.home" ) + file . substring ( 1 ) ; } return file ; } | Expands ~ in paths to the user s home directory . |
24,430 | public static void deleteDirectory ( Path dir ) throws IOException { if ( dir == null || ! Files . exists ( dir ) ) return ; Files . walkFileTree ( dir , new SimpleFileVisitor < Path > ( ) { public FileVisitResult visitFile ( Path file , BasicFileAttributes attrs ) throws IOException { Files . delete ( file ) ; return FileVisitResult . CONTINUE ; } public FileVisitResult postVisitDirectory ( Path dir , IOException e ) throws IOException { if ( e != null ) { throw e ; } Files . delete ( dir ) ; return FileVisitResult . CONTINUE ; } } ) ; } | Recursively delete a folder & contents |
24,431 | public ChemComp getParent ( ChemComp c ) { if ( c . hasParent ( ) ) { return dictionary . get ( c . getMon_nstd_parent_comp_id ( ) ) ; } return null ; } | Get the parent of a component . If component has no parent return null |
24,432 | public void addChemComp ( ChemComp comp ) { dictionary . put ( comp . getId ( ) , comp ) ; String rep = comp . getPdbx_replaces ( ) ; if ( ( rep != null ) && ( ! rep . equals ( "?" ) ) ) { replaces . put ( comp . getId ( ) , rep ) ; } String isrep = comp . getPdbx_replaced_by ( ) ; if ( ( isrep != null ) && ( ! isrep . equals ( "?" ) ) ) { isreplacedby . put ( comp . getId ( ) , isrep ) ; } } | add a new component to the dictionary |
24,433 | static public LinkedHashMap < String , ChromosomeSequence > loadFastaAddGeneFeaturesFromGeneIDGFF2 ( File fastaSequenceFile , File gffFile ) throws Exception { LinkedHashMap < String , DNASequence > dnaSequenceList = FastaReaderHelper . readFastaDNASequence ( fastaSequenceFile ) ; LinkedHashMap < String , ChromosomeSequence > chromosomeSequenceList = GeneFeatureHelper . getChromosomeSequenceFromDNASequence ( dnaSequenceList ) ; FeatureList listGenes = GeneIDGFF2Reader . read ( gffFile . getAbsolutePath ( ) ) ; addGeneIDGFF2GeneFeatures ( chromosomeSequenceList , listGenes ) ; return chromosomeSequenceList ; } | Loads Fasta file and GFF2 feature file generated from the geneid prediction algorithm |
24,434 | static public LinkedHashMap < String , ChromosomeSequence > loadFastaAddGeneFeaturesFromGmodGFF3 ( File fastaSequenceFile , File gffFile , boolean lazyloadsequences ) throws Exception { LinkedHashMap < String , DNASequence > dnaSequenceList = FastaReaderHelper . readFastaDNASequence ( fastaSequenceFile , lazyloadsequences ) ; LinkedHashMap < String , ChromosomeSequence > chromosomeSequenceList = GeneFeatureHelper . getChromosomeSequenceFromDNASequence ( dnaSequenceList ) ; FeatureList listGenes = GFF3Reader . read ( gffFile . getAbsolutePath ( ) ) ; addGmodGFF3GeneFeatures ( chromosomeSequenceList , listGenes ) ; return chromosomeSequenceList ; } | Lots of variations in the ontology or descriptors that can be used in GFF3 which requires writing a custom parser to handle a GFF3 generated or used by a specific application . Probably could be abstracted out but for now easier to handle with custom code to deal with gff3 elements that are not included but can be extracted from other data elements . |
24,435 | public void setChromosome ( String chr ) throws Exception { if ( twoBitParser == null ) { } twoBitParser . close ( ) ; String [ ] names = twoBitParser . getSequenceNames ( ) ; for ( int i = 0 ; i < names . length ; i ++ ) { if ( names [ i ] . equalsIgnoreCase ( chr ) ) { twoBitParser . setCurrentSequence ( names [ i ] ) ; break ; } } } | Sets a chromosome for TwoBitParser . |
24,436 | public String getSequence ( String chromosomeName , int start , int end ) throws Exception { twoBitParser . close ( ) ; twoBitParser . setCurrentSequence ( chromosomeName ) ; return twoBitParser . loadFragment ( start , end - start ) ; } | Extract a sequence from a chromosome using chromosomal coordinates |
24,437 | public int compareTo ( StructureName o ) { if ( this . equals ( o ) ) return 0 ; String pdb1 = null ; String pdb2 = null ; try { pdb1 = this . getPdbId ( ) ; } catch ( StructureException e ) { } try { pdb2 = this . getPdbId ( ) ; } catch ( StructureException e ) { } int comp = 0 ; if ( pdb1 == null ) { if ( pdb2 != null ) { return 1 ; } } else if ( pdb2 == null ) { return - 1 ; } else { comp = pdb1 . compareTo ( pdb2 ) ; } if ( comp != 0 ) { return comp ; } pdb1 = this . getIdentifier ( ) ; pdb2 = o . getIdentifier ( ) ; return pdb1 . compareTo ( pdb2 ) ; } | Orders identifiers lexicographically by PDB ID and then full Identifier |
24,438 | private String printPDBConnections ( ) { StringBuilder str = new StringBuilder ( ) ; for ( Chain c : structure . getChains ( ) ) { for ( Group g : c . getAtomGroups ( ) ) { for ( Atom a : g . getAtoms ( ) ) { if ( a . getBonds ( ) != null ) { for ( Bond b : a . getBonds ( ) ) { str . append ( String . format ( "CONECT%5d%5d " + newline , b . getAtomA ( ) . getPDBserial ( ) , b . getAtomB ( ) . getPDBserial ( ) ) ) ; } } } } } return str . toString ( ) ; } | Prints the connections in PDB style |
24,439 | public static String toPDB ( Atom a ) { StringBuffer w = new StringBuffer ( ) ; toPDB ( a , w ) ; return w . toString ( ) ; } | Prints the content of an Atom object as a PDB formatted line . |
24,440 | public static String toPDB ( Chain chain ) { StringBuffer w = new StringBuffer ( ) ; int nrGroups = chain . getAtomLength ( ) ; for ( int h = 0 ; h < nrGroups ; h ++ ) { Group g = chain . getAtomGroup ( h ) ; toPDB ( g , w ) ; } return w . toString ( ) ; } | Convert a Chain object to PDB representation |
24,441 | public static String toPDB ( Group g ) { StringBuffer w = new StringBuffer ( ) ; toPDB ( g , w ) ; return w . toString ( ) ; } | Convert a Group object to PDB representation |
24,442 | private static boolean hasInsertionCode ( String pdbserial ) { try { Integer . parseInt ( pdbserial ) ; } catch ( NumberFormatException e ) { return true ; } return false ; } | test if pdbserial has an insertion code |
24,443 | private static String toSingleLoopLineMmCifString ( Object record , Field [ ] fields , int [ ] sizes ) { StringBuilder str = new StringBuilder ( ) ; Class < ? > c = record . getClass ( ) ; if ( fields == null ) fields = getFields ( c ) ; if ( sizes . length != fields . length ) throw new IllegalArgumentException ( "The given sizes of fields differ from the number of declared fields" ) ; int i = - 1 ; for ( Field f : fields ) { i ++ ; f . setAccessible ( true ) ; try { Object obj = f . get ( record ) ; String val ; if ( obj == null ) { logger . debug ( "Field {} is null, will write it out as {}" , f . getName ( ) , MMCIF_MISSING_VALUE ) ; val = MMCIF_MISSING_VALUE ; } else { val = ( String ) obj ; } str . append ( String . format ( "%-" + sizes [ i ] + "s " , addMmCifQuoting ( val ) ) ) ; } catch ( IllegalAccessException e ) { logger . warn ( "Field {} is inaccessible" , f . getName ( ) ) ; continue ; } catch ( ClassCastException e ) { logger . warn ( "Could not cast value to String for field {}" , f . getName ( ) ) ; continue ; } } str . append ( newline ) ; return str . toString ( ) ; } | Given a mmCIF bean produces a String representing it in mmCIF loop format as a single record line |
24,444 | private static < T > int [ ] getFieldSizes ( List < T > list , Field [ ] fields ) { if ( list . isEmpty ( ) ) throw new IllegalArgumentException ( "List of beans is empty!" ) ; if ( fields == null ) fields = getFields ( list . get ( 0 ) . getClass ( ) ) ; int [ ] sizes = new int [ fields . length ] ; for ( T a : list ) { int i = - 1 ; for ( Field f : fields ) { i ++ ; f . setAccessible ( true ) ; try { Object obj = f . get ( a ) ; int length ; if ( obj == null ) { length = MMCIF_MISSING_VALUE . length ( ) ; } else { String val = ( String ) obj ; length = addMmCifQuoting ( val ) . length ( ) ; } if ( length > sizes [ i ] ) sizes [ i ] = length ; } catch ( IllegalAccessException e ) { logger . warn ( "Field {} is inaccessible" , f . getName ( ) ) ; continue ; } catch ( ClassCastException e ) { logger . warn ( "Could not cast value to String for field {}" , f . getName ( ) ) ; continue ; } } } return sizes ; } | Finds the max length of each of the String values contained in each of the fields of the given list of beans . Useful for producing mmCIF loop data that is aligned for all columns . |
24,445 | private static int getMaxStringLength ( String [ ] names ) { int size = 0 ; for ( String s : names ) { if ( s . length ( ) > size ) { size = s . length ( ) ; } } return size ; } | Finds the max length of a list of strings Useful for producing mmCIF single - record data that is aligned for all values . |
24,446 | public String toXML ( boolean hasResult ) throws IOException { StringWriter swriter = new StringWriter ( ) ; PrintWriter writer = new PrintWriter ( swriter ) ; PrettyXMLWriter xml = new PrettyXMLWriter ( writer ) ; xml . openTag ( "alignment" ) ; xml . attribute ( "hasResult" , String . valueOf ( hasResult ) ) ; xml . closeTag ( "alignment" ) ; xml . close ( ) ; return swriter . toString ( ) ; } | return flag if the server has a result |
24,447 | public List < StructureIdentifier > getRepeatsID ( ) throws StructureException { if ( ! isRefined ( ) ) return null ; List < StructureIdentifier > repeats = new ArrayList < StructureIdentifier > ( numRepeats ) ; String pdbId = structureId . toCanonical ( ) . getPdbId ( ) ; Block align = multipleAlignment . getBlocks ( ) . get ( 0 ) ; for ( int su = 0 ; su < numRepeats ; su ++ ) { ResidueNumber res1 = atoms [ align . getStartResidue ( su ) ] . getGroup ( ) . getResidueNumber ( ) ; ResidueNumber res2 = atoms [ align . getFinalResidue ( su ) ] . getGroup ( ) . getResidueNumber ( ) ; ResidueRange range = new ResidueRange ( res1 . getChainName ( ) , res1 , res2 ) ; StructureIdentifier id = new SubstructureIdentifier ( pdbId , Arrays . asList ( range ) ) ; repeats . add ( id ) ; } return repeats ; } | Return the symmetric repeats as structure identifiers if the result is symmetric and it was refined return null otherwise . |
24,448 | public String getReason ( ) { double tm = selfAlignment . getTMScore ( ) ; if ( tm < params . getUnrefinedScoreThreshold ( ) ) { return String . format ( "Insignificant self-alignment (TM=%.2f)" , tm ) ; } if ( numRepeats == 1 ) { return String . format ( "Order detector found asymmetric alignment (TM=%.2f)" , tm ) ; } if ( params . getRefineMethod ( ) != RefineMethod . NOT_REFINED ) { if ( ! refined ) { return "Refinement failed" ; } tm = multipleAlignment . getScore ( MultipleAlignmentScorer . AVGTM_SCORE ) ; if ( ! isSignificant ( ) ) { return String . format ( "Refinement was not significant (TM=%.2f)" , tm ) ; } } else { if ( ! isSignificant ( ) ) { return String . format ( "Result was not significant (TM=%.2f)" , tm ) ; } } String hierarchical = "" ; if ( axes . getNumLevels ( ) > 1 ) { hierarchical = String . format ( "; Contains %d levels of symmetry" , axes . getNumLevels ( ) ) ; } if ( axes . getElementaryAxis ( 0 ) . getSymmType ( ) == SymmetryType . OPEN ) { return String . format ( "Contains %d open repeats (TM=%.2f)%s" , getNumRepeats ( ) , tm , hierarchical ) ; } return String . format ( "Significant (TM=%.2f)%s" , tm , hierarchical ) ; } | Return a String describing the reasons for the CE - Symm final decision in this particular result . |
24,449 | private static List < Integer > initializeEligible ( Map < Integer , Integer > alignment , Map < Integer , Double > scores , List < Integer > eligible , int k , NavigableSet < Integer > forwardLoops , NavigableSet < Integer > backwardLoops ) { if ( eligible == null ) { eligible = new LinkedList < Integer > ( alignment . keySet ( ) ) ; } Map < Integer , Integer > alignK1 = applyAlignmentAndCheckCycles ( alignment , k - 1 , eligible ) ; Iterator < Integer > eligibleIt = eligible . iterator ( ) ; while ( eligibleIt . hasNext ( ) ) { Integer res = eligibleIt . next ( ) ; if ( ! alignK1 . containsKey ( res ) ) { eligibleIt . remove ( ) ; continue ; } Integer k1 = alignK1 . get ( res ) ; if ( k1 == null ) { eligibleIt . remove ( ) ; continue ; } Double score = scores . get ( res ) ; if ( score == null || score <= 0.0 ) { eligibleIt . remove ( ) ; if ( res <= alignment . get ( res ) ) { forwardLoops . add ( res ) ; } else { backwardLoops . add ( res ) ; } continue ; } Double scoreK1 = scores . get ( k1 ) ; if ( scoreK1 == null || scoreK1 <= 0.0 ) { eligibleIt . remove ( ) ; continue ; } } eligibleIt = eligible . iterator ( ) ; while ( eligibleIt . hasNext ( ) ) { Integer res = eligibleIt . next ( ) ; Integer src = alignK1 . get ( res ) ; if ( src < res ) { Integer a = forwardLoops . floor ( src ) ; Integer b = forwardLoops . higher ( src ) ; if ( a != null && alignment . get ( a ) > res ) { eligibleIt . remove ( ) ; continue ; } if ( b != null && alignment . get ( b ) < res ) { eligibleIt . remove ( ) ; continue ; } } } return eligible ; } | Helper method to initialize eligible residues . |
24,450 | private static Map < Integer , Double > initializeScores ( Map < Integer , Integer > alignment , Map < Integer , Double > scores , int k ) { if ( scores == null ) { scores = new HashMap < Integer , Double > ( alignment . size ( ) ) ; } else { scores . clear ( ) ; } Map < Integer , Integer > alignK = AlignmentTools . applyAlignment ( alignment , k ) ; int maxPre = Integer . MIN_VALUE ; int minPre = Integer . MAX_VALUE ; for ( Integer pre : alignment . keySet ( ) ) { if ( pre > maxPre ) maxPre = pre ; if ( pre < minPre ) minPre = pre ; } for ( Integer pre : alignment . keySet ( ) ) { Integer image = alignK . get ( pre ) ; double score = scoreAbsError ( pre , image , minPre , maxPre ) ; scores . put ( pre , score ) ; } return scores ; } | Calculates all scores for an alignment |
24,451 | private static AFPChain partitionAFPchain ( AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 , int order ) throws StructureException { int [ ] [ ] [ ] newAlgn = new int [ order ] [ ] [ ] ; int repeatLen = afpChain . getOptLength ( ) / order ; List < Integer > alignedRes = new ArrayList < Integer > ( ) ; for ( int su = 0 ; su < afpChain . getBlockNum ( ) ; su ++ ) { for ( int i = 0 ; i < afpChain . getOptLen ( ) [ su ] ; i ++ ) { alignedRes . add ( afpChain . getOptAln ( ) [ su ] [ 0 ] [ i ] ) ; } } for ( int su = 0 ; su < order ; su ++ ) { newAlgn [ su ] = new int [ 2 ] [ ] ; newAlgn [ su ] [ 0 ] = new int [ repeatLen ] ; newAlgn [ su ] [ 1 ] = new int [ repeatLen ] ; for ( int i = 0 ; i < repeatLen ; i ++ ) { newAlgn [ su ] [ 0 ] [ i ] = alignedRes . get ( repeatLen * su + i ) ; newAlgn [ su ] [ 1 ] [ i ] = alignedRes . get ( ( repeatLen * ( su + 1 ) + i ) % alignedRes . size ( ) ) ; } } return AlignmentTools . replaceOptAln ( newAlgn , afpChain , ca1 , ca2 ) ; } | Partitions an afpChain alignment into order blocks of aligned residues . |
24,452 | private static SubstitutionMatrix < AminoAcidCompound > getAminoAcidMatrix ( String file ) { if ( ! aminoAcidMatrices . containsKey ( file ) ) { aminoAcidMatrices . put ( file , new SimpleSubstitutionMatrix < AminoAcidCompound > ( AminoAcidCompoundSet . getAminoAcidCompoundSet ( ) , getReader ( file ) , file ) ) ; } return aminoAcidMatrices . get ( file ) ; } | reads in an amino acid substitution matrix if necessary |
24,453 | private static SubstitutionMatrix < NucleotideCompound > getNucleotideMatrix ( String file ) { if ( ! nucleotideMatrices . containsKey ( file ) ) { nucleotideMatrices . put ( file , new SimpleSubstitutionMatrix < NucleotideCompound > ( AmbiguityDNACompoundSet . getDNACompoundSet ( ) , getReader ( file ) , file ) ) ; } return nucleotideMatrices . get ( file ) ; } | reads in a nucleotide substitution matrix if necessary |
24,454 | private static InputStreamReader getReader ( String file ) { String resourcePathPrefix = "matrices/" ; return new InputStreamReader ( SubstitutionMatrixHelper . class . getResourceAsStream ( String . format ( "/%s.txt" , resourcePathPrefix + file ) ) ) ; } | reads in a substitution matrix from a resource file |
24,455 | private Group getNewGroup ( String recordName , Character aminoCode1 , String aminoCode3 ) { Group g = ChemCompGroupFactory . getGroupFromChemCompDictionary ( aminoCode3 ) ; if ( g != null && ! g . getChemComp ( ) . isEmpty ( ) ) return g ; Group group ; if ( aminoCode1 == null || StructureTools . UNKNOWN_GROUP_LABEL == aminoCode1 ) { group = new HetatomImpl ( ) ; } else if ( StructureTools . isNucleotide ( aminoCode3 ) ) { NucleotideImpl nu = new NucleotideImpl ( ) ; group = nu ; } else { AminoAcidImpl aa = new AminoAcidImpl ( ) ; aa . setAminoType ( aminoCode1 ) ; group = aa ; } return group ; } | initiate new resNum either Hetatom Nucleotide or AminoAcid |
24,456 | private void pdb_JRNL_Handler ( String line ) { if ( line . substring ( line . length ( ) - 8 , line . length ( ) - 4 ) . equals ( pdbId ) ) { logger . debug ( "trimming legacy PDB id from end of JRNL section line" ) ; line = line . substring ( 0 , line . length ( ) - 8 ) ; journalLines . add ( line ) ; } else { journalLines . add ( line ) ; } } | JRNL handler . The JRNL record contains the primary literature citation that describes the experiment which resulted in the deposited coordinate set . There is at most one JRNL reference per entry . If there is no primary reference then there is no JRNL reference . Other references are given in REMARK 1 . |
24,457 | private void pdb_SOURCE_Handler ( String line ) { String continuationNr = line . substring ( 9 , 10 ) . trim ( ) ; logger . debug ( "current continuationNo is " + continuationNr ) ; logger . debug ( "previousContinuationField is " + previousContinuationField ) ; logger . debug ( "current continuationField is " + continuationField ) ; logger . debug ( "current continuationString is " + continuationString ) ; logger . debug ( "current compound is " + current_compound ) ; if ( line . length ( ) > 79 ) { line = line . substring ( 0 , 79 ) ; } line = line . substring ( 10 , line . length ( ) ) ; logger . debug ( "LINE: >" + line + "<" ) ; String [ ] fieldList = line . split ( "\\s+" ) ; if ( ! fieldList [ 0 ] . equals ( "" ) && sourceFieldValues . contains ( fieldList [ 0 ] ) ) { continuationField = fieldList [ 0 ] ; if ( previousContinuationField . equals ( "" ) ) { previousContinuationField = continuationField ; } } else if ( ( fieldList . length > 1 ) && ( sourceFieldValues . contains ( fieldList [ 1 ] ) ) ) { continuationField = fieldList [ 1 ] ; if ( previousContinuationField . equals ( "" ) ) { previousContinuationField = continuationField ; } } else { if ( continuationNr . equals ( "" ) ) { logger . debug ( "looks like an old PDB file" ) ; continuationField = "MOLECULE:" ; if ( previousContinuationField . equals ( "" ) ) { previousContinuationField = continuationField ; } } } line = line . replace ( continuationField , "" ) . trim ( ) ; StringTokenizer compndTokens = new StringTokenizer ( line ) ; while ( compndTokens . hasMoreTokens ( ) ) { String token = compndTokens . nextToken ( ) ; if ( previousContinuationField . equals ( "" ) ) { previousContinuationField = continuationField ; } if ( previousContinuationField . equals ( continuationField ) && sourceFieldValues . contains ( continuationField ) ) { logger . debug ( "Still in field " + continuationField ) ; continuationString = continuationString . concat ( token + " " ) ; logger . debug ( "continuationString = " + continuationString ) ; } if ( ! continuationField . equals ( previousContinuationField ) ) { if ( continuationString . equals ( "" ) ) { continuationString = token ; } else { sourceValueSetter ( previousContinuationField , continuationString ) ; previousContinuationField = continuationField ; continuationString = token + " " ; } } else if ( ignoreCompndFieldValues . contains ( token ) ) { } } if ( isLastSourceLine ) { sourceValueSetter ( continuationField , continuationString ) ; continuationString = "" ; } } | Handler for SOURCE Record format |
24,458 | private void pdb_REMARK_Handler ( String line ) { if ( line == null || line . length ( ) < 11 ) return ; if ( line . startsWith ( "REMARK 800" ) ) { pdb_REMARK_800_Handler ( line ) ; } else if ( line . startsWith ( "REMARK 350" ) ) { if ( params . isParseBioAssembly ( ) ) { if ( bioAssemblyParser == null ) { bioAssemblyParser = new PDBBioAssemblyParser ( ) ; } bioAssemblyParser . pdb_REMARK_350_Handler ( line ) ; } } else if ( line . startsWith ( "REMARK 3 FREE R VALUE" ) ) { Pattern pR = Pattern . compile ( "^REMARK 3 FREE R VALUE\\s+(?:\\(NO CUTOFF\\))?\\s+:\\s+(\\d?\\.\\d+).*" ) ; Matcher mR = pR . matcher ( line ) ; if ( mR . matches ( ) ) { try { rfreeNoCutoffLine = Float . parseFloat ( mR . group ( 1 ) ) ; } catch ( NumberFormatException e ) { logger . info ( "Rfree value " + mR . group ( 1 ) + " does not look like a number, will ignore it" ) ; } } pR = Pattern . compile ( "^REMARK 3 FREE R VALUE\\s+:\\s+(\\d?\\.\\d+).*" ) ; mR = pR . matcher ( line ) ; if ( mR . matches ( ) ) { try { rfreeStandardLine = Float . parseFloat ( mR . group ( 1 ) ) ; } catch ( NumberFormatException e ) { logger . info ( "Rfree value '{}' does not look like a number, will ignore it" , mR . group ( 1 ) ) ; } } } else if ( line . startsWith ( "REMARK 3 RESOLUTION RANGE HIGH" ) ) { Pattern pR = Pattern . compile ( "^REMARK 3 RESOLUTION RANGE HIGH \\(ANGSTROMS\\) :\\s+(\\d+\\.\\d+).*" ) ; Matcher mR = pR . matcher ( line ) ; if ( mR . matches ( ) ) { try { float res = Float . parseFloat ( mR . group ( 1 ) ) ; if ( pdbHeader . getResolution ( ) != PDBHeader . DEFAULT_RESOLUTION ) { logger . warn ( "More than 1 resolution value present, will use last one {} and discard previous {} " , mR . group ( 1 ) , String . format ( "%4.2f" , pdbHeader . getResolution ( ) ) ) ; } pdbHeader . setResolution ( res ) ; } catch ( NumberFormatException e ) { logger . info ( "Could not parse resolution '{}', ignoring it" , mR . group ( 1 ) ) ; } } } } | Handler for REMARK lines |
24,459 | private Integer conect_helper ( String line , int start , int end ) { if ( line . length ( ) < end ) return null ; String sbond = line . substring ( start , end ) . trim ( ) ; int bond = - 1 ; Integer b = null ; if ( ! sbond . equals ( "" ) ) { bond = Integer . parseInt ( sbond ) ; b = new Integer ( bond ) ; } return b ; } | safes repeating a few lines ... |
24,460 | private void pdb_SSBOND_Handler ( String line ) { if ( params . isHeaderOnly ( ) ) return ; if ( line . length ( ) < 36 ) { logger . info ( "SSBOND line has length under 36. Ignoring it." ) ; return ; } String chain1 = line . substring ( 15 , 16 ) ; String seqNum1 = line . substring ( 17 , 21 ) . trim ( ) ; String icode1 = line . substring ( 21 , 22 ) ; String chain2 = line . substring ( 29 , 30 ) ; String seqNum2 = line . substring ( 31 , 35 ) . trim ( ) ; String icode2 = line . substring ( 35 , 36 ) ; if ( line . length ( ) >= 72 ) { String symop1 = line . substring ( 59 , 65 ) . trim ( ) ; String symop2 = line . substring ( 66 , 72 ) . trim ( ) ; if ( ! symop1 . equals ( "" ) && ! symop2 . equals ( "" ) && ( ! symop1 . equals ( "1555" ) || ! symop2 . equals ( "1555" ) ) ) { logger . info ( "Skipping ss bond between groups {} and {} belonging to different symmetry partners, because it is not supported yet" , seqNum1 + icode1 , seqNum2 + icode2 ) ; return ; } } if ( icode1 . equals ( " " ) ) icode1 = "" ; if ( icode2 . equals ( " " ) ) icode2 = "" ; SSBondImpl ssbond = new SSBondImpl ( ) ; ssbond . setChainID1 ( chain1 ) ; ssbond . setResnum1 ( seqNum1 ) ; ssbond . setChainID2 ( chain2 ) ; ssbond . setResnum2 ( seqNum2 ) ; ssbond . setInsCode1 ( icode1 ) ; ssbond . setInsCode2 ( icode2 ) ; ssbonds . add ( ssbond ) ; } | Process the disulfide bond info provided by an SSBOND record |
24,461 | private static Chain isKnownChain ( String chainID , List < Chain > chains ) { for ( int i = 0 ; i < chains . size ( ) ; i ++ ) { Chain testchain = chains . get ( i ) ; if ( chainID . equals ( testchain . getName ( ) ) ) { return testchain ; } } return null ; } | Finds in the given list of chains the first one that has as name the given chainID . If no such Chain can be found it returns null . |
24,462 | private void makeCompounds ( List < String > compoundList , List < String > sourceList ) { for ( String line : compoundList ) { if ( compoundList . indexOf ( line ) + 1 == compoundList . size ( ) ) { isLastCompndLine = true ; } pdb_COMPND_Handler ( line ) ; } if ( entities . size ( ) == 0 ) { current_compound = new EntityInfo ( ) ; } else { current_compound = entities . get ( 0 ) ; } for ( String line : sourceList ) { if ( sourceList . indexOf ( line ) + 1 == sourceList . size ( ) ) { isLastSourceLine = true ; } pdb_SOURCE_Handler ( line ) ; } } | This is the new method for building the COMPND and SOURCE records . Now each method is self - contained . |
24,463 | private static List < List < Chain > > findChains ( String chainName , List < List < Chain > > polyModels ) { List < List < Chain > > models = new ArrayList < > ( ) ; for ( List < Chain > chains : polyModels ) { List < Chain > matchingChains = new ArrayList < > ( ) ; models . add ( matchingChains ) ; for ( Chain c : chains ) { if ( c . getName ( ) . equals ( chainName ) ) { matchingChains . add ( c ) ; } } } return models ; } | Gets all chains with given chainName from given models list |
24,464 | private void assignAsymIds ( List < List < Chain > > polys , List < List < Chain > > nonPolys , List < List < Chain > > waters ) { for ( int i = 0 ; i < polys . size ( ) ; i ++ ) { String asymId = "A" ; for ( Chain poly : polys . get ( i ) ) { poly . setId ( asymId ) ; asymId = getNextAsymId ( asymId ) ; } for ( Chain nonPoly : nonPolys . get ( i ) ) { nonPoly . setId ( asymId ) ; asymId = getNextAsymId ( asymId ) ; } for ( Chain water : waters . get ( i ) ) { water . setId ( asymId ) ; asymId = getNextAsymId ( asymId ) ; } } } | Assign asym ids following the rules used by the PDB to assign asym ids in mmCIF files |
24,465 | private void linkSitesToGroups ( ) { if ( siteMap == null || siteToResidueMap == null ) { logger . info ( "Sites can not be linked to residues!" ) ; return ; } List < Site > sites = null ; if ( structure . getChains ( ) . isEmpty ( ) ) { sites = new ArrayList < Site > ( siteMap . values ( ) ) ; logger . info ( "No chains to link Site Groups with - Sites will not be present in the Structure" ) ; return ; } if ( ! siteMap . keySet ( ) . equals ( siteToResidueMap . keySet ( ) ) ) { logger . info ( "Not all sites have been properly described in the PDB " + pdbId + " header - some Sites will not be present in the Structure" ) ; logger . debug ( siteMap . keySet ( ) + " | " + siteToResidueMap . keySet ( ) ) ; } for ( String key : siteMap . keySet ( ) ) { Site currentSite = siteMap . get ( key ) ; List < ResidueNumber > linkedGroups = siteToResidueMap . get ( key ) ; if ( linkedGroups == null ) continue ; for ( ResidueNumber residueNumber : linkedGroups ) { String pdbCode = residueNumber . toString ( ) ; String chain = residueNumber . getChainName ( ) ; Group linkedGroup = null ; try { linkedGroup = structure . findGroup ( chain , pdbCode ) ; } catch ( StructureException ex ) { logger . info ( "Can't find group " + pdbCode + " in chain " + chain + " in order to link up SITE records (PDB ID " + pdbId + ")" ) ; continue ; } currentSite . getGroups ( ) . add ( linkedGroup ) ; } } sites = new ArrayList < Site > ( siteMap . values ( ) ) ; structure . setSites ( sites ) ; } | Links the Sites in the siteMap to the Groups in the Structure via the siteToResidueMap ResidueNumber . |
24,466 | public Sequence < AminoAcidCompound > translate ( Sequence < NucleotideCompound > dna ) { Map < Frame , Sequence < AminoAcidCompound > > trans = multipleFrameTranslation ( dna , Frame . ONE ) ; return trans . get ( Frame . ONE ) ; } | Quick method to let you go from a CDS to a Peptide quickly . It assumes you are translating only in the first frame |
24,467 | public Map < Frame , Sequence < AminoAcidCompound > > multipleFrameTranslation ( Sequence < NucleotideCompound > dna , Frame ... frames ) { Map < Frame , Sequence < AminoAcidCompound > > results = new EnumMap < Frame , Sequence < AminoAcidCompound > > ( Frame . class ) ; for ( Frame frame : frames ) { Sequence < NucleotideCompound > rna = getDnaRnaTranslator ( ) . createSequence ( dna , frame ) ; Sequence < AminoAcidCompound > peptide = getRnaAminoAcidTranslator ( ) . createSequence ( rna ) ; results . put ( frame , peptide ) ; } return results ; } | A way of translating DNA in a number of frames |
24,468 | public boolean isIdenticalTo ( SubunitCluster other ) { String thisSequence = this . subunits . get ( this . representative ) . getProteinSequenceString ( ) ; String otherSequence = other . subunits . get ( other . representative ) . getProteinSequenceString ( ) ; return thisSequence . equals ( otherSequence ) ; } | Tells whether the other SubunitCluster contains exactly the same Subunit . This is checked by String equality of their residue one - letter sequences . |
24,469 | public void actionPerformed ( ActionEvent evt ) { logStatus ( "terminating" ) ; logStatus ( " Total alignments processed: " + alignmentsProcessed ) ; stopButton . setEnabled ( false ) ; setCursor ( Cursor . getPredefinedCursor ( Cursor . WAIT_CURSOR ) ) ; progressBar . setIndeterminate ( true ) ; progressBar . setStringPainted ( false ) ; System . out . println ( "terminating jobs" ) ; farmJob . terminate ( ) ; setCursor ( Cursor . getPredefinedCursor ( Cursor . DEFAULT_CURSOR ) ) ; progressBar . setIndeterminate ( false ) ; } | Invoked when the user presses the stop button . |
24,470 | private static < T > void permuteArray ( T [ ] arr , int cp ) { if ( cp == 0 ) { return ; } if ( cp < 0 ) { cp = arr . length + cp ; } if ( cp < 0 || cp >= arr . length ) { throw new ArrayIndexOutOfBoundsException ( "Permutation point (" + cp + ") must be between -ca2.length and ca2.length-1" ) ; } List < T > temp = new ArrayList < T > ( cp ) ; for ( int i = 0 ; i < cp ; i ++ ) { temp . add ( arr [ i ] ) ; } for ( int j = cp ; j < arr . length ; j ++ ) { arr [ j - cp ] = arr [ j ] ; } for ( int i = 0 ; i < cp ; i ++ ) { arr [ arr . length - cp + i ] = temp . get ( i ) ; } } | Circularly permutes arr in place . |
24,471 | private static void permuteAFPChain ( AFPChain afpChain , int cp ) { int ca2len = afpChain . getCa2Length ( ) ; if ( cp == 0 ) { return ; } if ( cp < 0 ) { cp = ca2len + cp ; } if ( cp < 0 || cp >= ca2len ) { throw new ArrayIndexOutOfBoundsException ( "Permutation point (" + cp + ") must be between -ca2.length and ca2.length-1" ) ; } permuteOptAln ( afpChain , cp ) ; if ( afpChain . getBlockNum ( ) > 1 ) afpChain . setSequentialAlignment ( false ) ; afpChain . setDistanceMatrix ( permuteMatrix ( afpChain . getDistanceMatrix ( ) , 0 , - cp ) ) ; afpChain . setDisTable2 ( permuteMatrix ( afpChain . getDisTable2 ( ) , - cp , - cp ) ) ; } | Permute the second protein of afpChain by the specified number of residues . |
24,472 | public int getSeqPos ( int aligSeq , Point p ) { int x = p . x - DEFAULT_X_SPACE - DEFAULT_LEGEND_SIZE ; int y = p . y - DEFAULT_Y_SPACE ; y -= ( DEFAULT_LINE_SEPARATION * aligSeq ) - DEFAULT_CHAR_SIZE ; int lineNr = y / DEFAULT_Y_STEP ; int linePos = x / DEFAULT_CHAR_SIZE ; return lineNr * DEFAULT_LINE_LENGTH + linePos ; } | Convert from an X position in the JPanel to the position in the sequence alignment . |
24,473 | public Point getPanelPos ( int structure , int pos ) { Point p = new Point ( ) ; int lineNr = pos / DEFAULT_LINE_LENGTH ; int linePos = pos % 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 * structure ; p . setLocation ( x , y ) ; return p ; } | Get the X position on the Panel of a particular sequence position . |
24,474 | public int getAligSeq ( Point point ) { for ( int pos = 0 ; pos < alignmentSize ; pos ++ ) { int i = getSeqPos ( pos , point ) ; Point t = getPanelPos ( pos , i ) ; if ( Math . abs ( t . x - point . x ) <= DEFAULT_CHAR_SIZE && Math . abs ( t . y - point . y ) < DEFAULT_CHAR_SIZE ) return pos ; } return - 1 ; } | Returns the index of the structure for a given point in the Panel . Returns - 1 if not over a position in the sequence alignment . |
24,475 | public String toPDB ( ) { StringBuffer buf = new StringBuffer ( ) ; toPDB ( buf ) ; return buf . toString ( ) ; } | Convert the DBRef object to a DBREF record as it is used in PDB files |
24,476 | public void toPDB ( StringBuffer buf ) { Formatter formatter = new Formatter ( new StringBuilder ( ) , Locale . UK ) ; formatter . format ( "DBREF %4s %1s %4d%1s %4d%1s %-6s %-8s %-12s%6d%1c%6d%1c " , idCode , chainName , seqbegin , insertBegin , seqEnd , insertEnd , database , dbAccession , dbIdCode , dbSeqBegin , idbnsBegin , dbSeqEnd , idbnsEnd ) ; buf . append ( formatter . toString ( ) ) ; formatter . close ( ) ; } | Append the PDB representation of this DBRef to the provided StringBuffer |
24,477 | public static final List < String > getPDBresnum ( int aligPos , AFPChain afpChain , Atom [ ] ca ) { List < String > lst = new ArrayList < String > ( ) ; if ( aligPos > 1 ) { System . err . println ( "multiple alignments not supported yet!" ) ; return lst ; } int blockNum = afpChain . getBlockNum ( ) ; int [ ] optLen = afpChain . getOptLen ( ) ; int [ ] [ ] [ ] optAln = afpChain . getOptAln ( ) ; if ( optLen == null ) return lst ; for ( int bk = 0 ; bk < blockNum ; bk ++ ) { for ( int i = 0 ; i < optLen [ bk ] ; i ++ ) { int pos = optAln [ bk ] [ aligPos ] [ i ] ; if ( pos < ca . length ) { String pdbInfo = JmolTools . getPdbInfo ( ca [ pos ] ) ; lst . add ( pdbInfo ) ; } } } return lst ; } | Return a list of pdb Strings corresponding to the aligned positions of the molecule . Only supports a pairwise alignment with the AFPChain DS . |
24,478 | public static final Atom getAtomForAligPos ( AFPChain afpChain , int chainNr , int aligPos , Atom [ ] ca , boolean getPrevious ) throws StructureException { int [ ] optLen = afpChain . getOptLen ( ) ; if ( optLen == null ) return null ; if ( chainNr < 0 || chainNr > 1 ) { throw new StructureException ( "So far only pairwise alignments are supported, but you requested results for alinged chain nr " + chainNr ) ; } int capos = getUngappedFatCatPos ( afpChain , chainNr , aligPos ) ; if ( capos < 0 ) { capos = getNextFatCatPos ( afpChain , chainNr , aligPos , getPrevious ) ; } else { } if ( capos < 0 ) { System . err . println ( "could not match position " + aligPos + " in chain " + chainNr + ". Returing null..." ) ; return null ; } if ( capos > ca . length ) { System . err . println ( "Atom array " + chainNr + " does not have " + capos + " atoms. Returning null." ) ; return null ; } return ca [ capos ] ; } | Return the atom at alignment position aligPos . at the present only works with block 0 |
24,479 | public static final Atom [ ] getAtomArray ( Atom [ ] ca , List < Group > hetatms ) throws StructureException { List < Atom > atoms = new ArrayList < Atom > ( ) ; Collections . addAll ( atoms , ca ) ; logger . debug ( "got {} hetatoms" , hetatms . size ( ) ) ; for ( Group g : hetatms ) { if ( g . size ( ) < 1 ) continue ; Atom a = g . getAtom ( 0 ) ; a . setGroup ( g ) ; atoms . add ( a ) ; } Atom [ ] arr = atoms . toArray ( new Atom [ atoms . size ( ) ] ) ; return arr ; } | Returns the first atom for each group |
24,480 | public static Structure createArtificalStructure ( AFPChain afpChain , Atom [ ] ca1 , Atom [ ] ca2 ) throws StructureException { if ( afpChain . getNrEQR ( ) < 1 ) { return AlignmentTools . getAlignedStructure ( ca1 , ca2 ) ; } Group [ ] twistedGroups = AlignmentTools . prepareGroupsForDisplay ( afpChain , ca1 , ca2 ) ; List < Atom > twistedAs = new ArrayList < Atom > ( ) ; for ( Group g : twistedGroups ) { if ( g == null ) continue ; if ( g . size ( ) < 1 ) continue ; Atom a = g . getAtom ( 0 ) ; twistedAs . add ( a ) ; } Atom [ ] twistedAtoms = twistedAs . toArray ( new Atom [ twistedAs . size ( ) ] ) ; List < Group > hetatms = StructureTools . getUnalignedGroups ( ca1 ) ; List < Group > hetatms2 = StructureTools . getUnalignedGroups ( ca2 ) ; Atom [ ] arr1 = DisplayAFP . getAtomArray ( ca1 , hetatms ) ; Atom [ ] arr2 = DisplayAFP . getAtomArray ( twistedAtoms , hetatms2 ) ; Structure artificial = AlignmentTools . getAlignedStructure ( arr1 , arr2 ) ; return artificial ; } | Create a fake Structure objects that contains the two sets of atoms aligned on top of each other . |
24,481 | public int getOverlapLength ( HmmerResult other ) { int overlap = 0 ; for ( HmmerDomain d1 : getDomains ( ) ) { for ( HmmerDomain d2 : other . getDomains ( ) ) { overlap += getOverlap ( d1 , d2 ) ; } } return overlap ; } | Get the overlap between two HmmerResult objects |
24,482 | public static File getPath ( ) { if ( path == null ) { UserConfiguration config = new UserConfiguration ( ) ; path = new File ( config . getCacheFilePath ( ) ) ; } return path ; } | Get this provider s cache path |
24,483 | public void checkDoFirstInstall ( ) { if ( ! downloadAll ) { return ; } File dir = new File ( getPath ( ) , CHEM_COMP_CACHE_DIRECTORY ) ; File f = new File ( dir , "components.cif.gz" ) ; if ( ! f . exists ( ) ) { downloadAllDefinitions ( ) ; } else { FilenameFilter filter = new FilenameFilter ( ) { public boolean accept ( File dir , String file ) { return file . endsWith ( ".cif.gz" ) ; } } ; String [ ] files = dir . list ( filter ) ; if ( files . length < 500 ) { try { split ( ) ; } catch ( IOException e ) { logger . error ( "Could not split file {} into individual chemical component files. Error: {}" , f . toString ( ) , e . getMessage ( ) ) ; } } } } | Checks if the chemical components already have been installed into the PDB directory . If not will download the chemical components definitions file and split it up into small subfiles . |
24,484 | private void writeID ( String contents , String currentID ) throws IOException { String localName = getLocalFileName ( currentID ) ; try ( PrintWriter pw = new PrintWriter ( new GZIPOutputStream ( new FileOutputStream ( localName ) ) ) ) { pw . print ( contents ) ; pw . flush ( ) ; } } | Output chemical contents to a file |
24,485 | public boolean isEquivalent ( CrystalTransform other ) { Matrix4d mul = new Matrix4d ( ) ; mul . mul ( this . matTransform , other . matTransform ) ; if ( mul . epsilonEquals ( IDENTITY , 0.0001 ) ) { return true ; } return false ; } | Returns true if the given CrystalTransform is equivalent to this one . Two crystal transforms are equivalent if one is the inverse of the other i . e . their transformation matrices multiplication is equal to the identity . |
24,486 | public String toXYZString ( ) { StringBuilder str = new StringBuilder ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { boolean emptyRow = true ; double coef ; coef = matTransform . getElement ( i , 0 ) ; if ( abs ( coef ) > 1e-6 ) { if ( abs ( abs ( coef ) - 1 ) < 1e-6 ) { if ( coef < 0 ) { str . append ( "-" ) ; } } else { str . append ( formatCoef ( coef ) ) ; str . append ( "*" ) ; } str . append ( "x" ) ; emptyRow = false ; } coef = matTransform . getElement ( i , 1 ) ; if ( abs ( coef ) > 1e-6 ) { if ( abs ( abs ( coef ) - 1 ) < 1e-6 ) { if ( coef < 0 ) { str . append ( "-" ) ; } else if ( ! emptyRow ) { str . append ( "+" ) ; } } else { if ( ! emptyRow && coef > 0 ) { str . append ( "+" ) ; } str . append ( formatCoef ( coef ) ) ; str . append ( "*" ) ; } str . append ( "y" ) ; emptyRow = false ; } coef = matTransform . getElement ( i , 2 ) ; if ( abs ( coef ) > 1e-6 ) { if ( abs ( abs ( coef ) - 1 ) < 1e-6 ) { if ( coef < 0 ) { str . append ( "-" ) ; } else if ( ! emptyRow ) { str . append ( "+" ) ; } } else { if ( ! emptyRow && coef > 0 ) { str . append ( "+" ) ; } str . append ( formatCoef ( coef ) ) ; str . append ( "*" ) ; } str . append ( "z" ) ; emptyRow = false ; } coef = matTransform . getElement ( i , 3 ) ; if ( abs ( coef ) > 1e-6 ) { if ( ! emptyRow && coef > 0 ) { str . append ( "+" ) ; } str . append ( formatCoef ( coef ) ) ; } if ( i < 2 ) { str . append ( "," ) ; } } return str . toString ( ) ; } | Expresses this transformation in terms of x y z fractional coordinates . |
24,487 | private String formatCoef ( double coef ) { double tol = 1e-6 ; if ( Math . abs ( coef ) < tol ) { return "0" ; } long num = Math . round ( coef ) ; if ( Math . abs ( num - coef ) < tol ) { return Long . toString ( num ) ; } for ( int denom = 2 ; denom < 12 ; denom ++ ) { num = Math . round ( coef * denom ) ; if ( num - coef * denom < tol ) { return String . format ( "%d/%d" , num , denom ) ; } } return String . format ( "%.3f" , coef ) ; } | helper function to format simple fractions into rationals |
24,488 | public Matrix4d getGeometicCenterTransformation ( ) { run ( ) ; Matrix4d geometricCentered = new Matrix4d ( reverseTransformationMatrix ) ; geometricCentered . setTranslation ( new Vector3d ( getGeometricCenter ( ) ) ) ; return geometricCentered ; } | Returns a transformation matrix transform polyhedra for Cn structures . The center in this matrix is the geometric center rather then the centroid . In Cn structures those are usually not the same . |
24,489 | public Point3d getGeometricCenter ( ) { run ( ) ; Point3d geometricCenter = new Point3d ( ) ; Vector3d translation = new Vector3d ( ) ; reverseTransformationMatrix . get ( translation ) ; if ( rotationGroup . getPointGroup ( ) . startsWith ( "C" ) ) { Vector3d corr = new Vector3d ( 0 , 0 , minBoundary . z + getDimension ( ) . z ) ; reverseTransformationMatrix . transform ( corr ) ; geometricCenter . set ( corr ) ; } geometricCenter . add ( translation ) ; return geometricCenter ; } | Returns the geometric center of polyhedron . In the case of the Cn point group the centroid and geometric center are usually not identical . |
24,490 | private Matrix4d alignAxes ( Vector3d [ ] axisVectors , Vector3d [ ] referenceVectors ) { Matrix4d m1 = new Matrix4d ( ) ; AxisAngle4d a = new AxisAngle4d ( ) ; Vector3d axis = new Vector3d ( ) ; Vector3d v1 = new Vector3d ( axisVectors [ 0 ] ) ; Vector3d v2 = new Vector3d ( referenceVectors [ 0 ] ) ; double dot = v1 . dot ( v2 ) ; if ( Math . abs ( dot ) < 0.999 ) { axis . cross ( v1 , v2 ) ; axis . normalize ( ) ; a . set ( axis , v1 . angle ( v2 ) ) ; m1 . set ( a ) ; m1 . setElement ( 3 , 3 , 1.0 ) ; } else if ( dot > 0 ) { m1 . setIdentity ( ) ; } else if ( dot < 0 ) { m1 . set ( flipX ( ) ) ; } m1 . transform ( axisVectors [ 0 ] ) ; m1 . transform ( axisVectors [ 1 ] ) ; v1 = new Vector3d ( axisVectors [ 1 ] ) ; v2 = new Vector3d ( referenceVectors [ 1 ] ) ; Matrix4d m2 = new Matrix4d ( ) ; dot = v1 . dot ( v2 ) ; if ( Math . abs ( dot ) < 0.999 ) { axis . cross ( v1 , v2 ) ; axis . normalize ( ) ; a . set ( axis , v1 . angle ( v2 ) ) ; m2 . set ( a ) ; m2 . setElement ( 3 , 3 , 1.0 ) ; } else if ( dot > 0 ) { m2 . setIdentity ( ) ; } else if ( dot < 0 ) { m2 . set ( flipZ ( ) ) ; } m2 . transform ( axisVectors [ 0 ] ) ; m2 . transform ( axisVectors [ 1 ] ) ; m2 . mul ( m1 ) ; Point3d [ ] axes = new Point3d [ 2 ] ; axes [ 0 ] = new Point3d ( axisVectors [ 0 ] ) ; axes [ 1 ] = new Point3d ( axisVectors [ 1 ] ) ; Point3d [ ] ref = new Point3d [ 2 ] ; ref [ 0 ] = new Point3d ( referenceVectors [ 0 ] ) ; ref [ 1 ] = new Point3d ( referenceVectors [ 1 ] ) ; if ( CalcPoint . rmsd ( axes , ref ) > 0.1 ) { logger . warn ( "AxisTransformation: axes alignment is off. RMSD: " + CalcPoint . rmsd ( axes , ref ) ) ; } return m2 ; } | Returns a transformation matrix that rotates refPoints to match coordPoints |
24,491 | private void refineReferenceVector ( ) { referenceVector = new Vector3d ( Y_AXIS ) ; if ( rotationGroup . getPointGroup ( ) . startsWith ( "C" ) ) { referenceVector = getReferenceAxisCylicWithSubunitAlignment ( ) ; } else if ( rotationGroup . getPointGroup ( ) . startsWith ( "D" ) ) { referenceVector = getReferenceAxisDihedralWithSubunitAlignment ( ) ; } referenceVector = orthogonalize ( principalRotationVector , referenceVector ) ; } | Returns a normalized vector that represents a minor rotation axis except for Cn this represents an axis orthogonal to the principal axis . |
24,492 | private Vector3d getReferenceAxisCylicWithSubunitAlignment ( ) { if ( rotationGroup . getPointGroup ( ) . equals ( "C2" ) ) { return referenceVector ; } List < List < Integer > > orbits = getOrbitsByXYWidth ( ) ; List < Integer > widestOrbit = orbits . get ( orbits . size ( ) - 1 ) ; List < Point3d > centers = subunits . getCenters ( ) ; int subunit = widestOrbit . get ( 0 ) ; Vector3d refAxis = new Vector3d ( ) ; refAxis . sub ( centers . get ( subunit ) , subunits . getCentroid ( ) ) ; refAxis . normalize ( ) ; return refAxis ; } | Returns a reference vector for the alignment of Cn structures . |
24,493 | private void init ( String svcUrl ) { try { serviceUrl = new URL ( svcUrl ) ; } catch ( MalformedURLException e ) { throw new RuntimeException ( "It looks like the URL for remote NCBI BLAST service (" + svcUrl + ") is wrong. Cause: " + e . getMessage ( ) , e ) ; } } | Initialize the serviceUrl data member |
24,494 | private URLConnection setQBlastServiceProperties ( URLConnection conn ) { conn . setDoOutput ( true ) ; conn . setUseCaches ( false ) ; conn . setRequestProperty ( "User-Agent" , "Biojava/NCBIQBlastService" ) ; conn . setRequestProperty ( "Connection" , "Keep-Alive" ) ; conn . setRequestProperty ( "Content-type" , "application/x-www-form-urlencoded" ) ; conn . setRequestProperty ( "Content-length" , "200" ) ; return conn ; } | Sets properties for given URLConnection |
24,495 | public SortedSet < String > getDomainNames ( String name ) { if ( name . length ( ) < 4 ) throw new IllegalArgumentException ( "Can't interpret IDs that are shorter than 4 residues!" ) ; String url = String . format ( "%srepresentativeDomains?cluster=%s&structureId=%s" , base , cutoff , name ) ; return requestRepresentativeDomains ( url ) ; } | Gets a list of domain representatives for a given PDB ID . |
24,496 | public SortedSet < String > getRepresentativeDomains ( ) { String url = base + "representativeDomains?cluster=" + cutoff ; return requestRepresentativeDomains ( url ) ; } | Gets a list of all domain representatives |
24,497 | private SortedSet < String > requestRepresentativeDomains ( String url ) { try { final SortedSet < String > results = new TreeSet < String > ( ) ; DefaultHandler handler = new DefaultHandler ( ) { public void startElement ( String uri , String localName , String qName , Attributes attributes ) throws SAXException { if ( qName . equalsIgnoreCase ( "representative" ) ) { String name = attributes . getValue ( "name" ) ; results . add ( name ) ; } } } ; handleRestRequest ( url , handler ) ; return results ; } catch ( MalformedURLException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( SAXException e ) { e . printStackTrace ( ) ; } catch ( ParserConfigurationException e ) { e . printStackTrace ( ) ; } return null ; } | Handles fetching and parsing XML from representativeDomains requests |
24,498 | private static void handleRestRequest ( String url , DefaultHandler handler ) throws SAXException , IOException , ParserConfigurationException { URL u = new URL ( url ) ; InputStream response = URLConnectionTools . getInputStream ( u ) ; InputSource xml = new InputSource ( response ) ; SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; SAXParser saxParser = factory . newSAXParser ( ) ; saxParser . parse ( xml , handler ) ; } | Handles fetching and processing REST requests . The actual XML parsing is handled by the handler which is also in charge of storing interesting data . |
24,499 | private double getDensity ( Atom [ ] ca1subset , Atom [ ] ca2subset ) throws StructureException { Atom centroid1 = Calc . getCentroid ( ca1subset ) ; Atom centroid2 = Calc . getCentroid ( ca2subset ) ; double d1 = 0 ; double d2 = 0 ; for ( int i = 0 ; i < ca1subset . length ; i ++ ) { double dd1 = Calc . getDistance ( centroid1 , ca1subset [ i ] ) ; double dd2 = Calc . getDistance ( centroid2 , ca2subset [ i ] ) ; d1 += dd1 ; d2 += dd2 ; } double avd1 = d1 / ca1subset . length ; double avd2 = d2 / ca2subset . length ; return Math . min ( avd1 , avd2 ) ; } | this is probably useless |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.