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 . ...
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 ( ) ) ; } ...
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 ( ) ; }...
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 . valueO...
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 ch...
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 , compound...
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 . select...
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 ( uni...
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 ( unipro...
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 ...
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 ( gene...
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" ) ; ...
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 { Eleme...
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 ( s...
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 ( ) ; ...
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 . getStructu...
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 ) == '...
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 ) { logg...
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 ( ) ) ) { thr...
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 , Pairw...
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 ) { de...
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 St...
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 ; ...
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 uP...
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 ...
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 ....
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 , ChromosomeSeq...
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 , lazyloadsequen...
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 extr...
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 ] ...
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 != nul...
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%...
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 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 )...
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 . ...
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 ( ...
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 ) ; }...
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 ...
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 . ap...
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...
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 ) ) ; } re...
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 ) ) ; } ...
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 =...
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 { journa...
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 " + ...
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 ) { bioAssembl...
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 icod...
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 Ent...
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 : ch...
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 ...
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 chai...
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 < Nucleo...
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 . setStrin...
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 = ne...
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....
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 + linePo...
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_SEPARATI...
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 , dbSe...
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 =...
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 pai...
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...
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 ) ...
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 acce...
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 { st...
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 ...
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 + getDimensio...
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 ....
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 = getReferenceAxis...
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...
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" , "app...
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 requestRepresent...
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 ...
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 = SAXPar...
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 ( ...
this is probably useless