idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
24,600
public void jmolColorByChain ( ) { String script = "function color_by_chain(objtype, color_list) {" + String . format ( "%n" ) + "" + String . format ( "%n" ) + " if (color_list) {" + String . format ( "%n" ) + " if (color_list.type == \"string\") {" + String . format ( "%n" ) + " color_list = color_list.split(\",\").trim();" + String . format ( "%n" ) + " }" + String . format ( "%n" ) + " } else {" + String . format ( "%n" ) + " color_list = [\"104BA9\",\"AA00A2\",\"C9F600\",\"FFA200\",\"284A7E\",\"7F207B\",\"9FB82E\",\"BF8B30\",\"052D6E\",\"6E0069\",\"83A000\",\"A66A00\",\"447BD4\",\"D435CD\",\"D8FA3F\",\"FFBA40\",\"6A93D4\",\"D460CF\",\"E1FA71\",\"FFCC73\"];" + String . format ( "%n" ) + " }" + String . format ( "%n" ) + " var cmd2 = \"\";" + String . format ( "%n" ) + " if (!objtype) {" + String . format ( "%n" ) + " var type_list = [ \"backbone\",\"cartoon\",\"dots\",\"halo\",\"label\",\"meshribbon\",\"polyhedra\",\"rocket\",\"star\",\"strand\",\"strut\",\"trace\"];" + String . format ( "%n" ) + " cmd2 = \"color \" + type_list.join(\" none; color \") + \" none;\";" + String . format ( "%n" ) + " objtype = \"atoms\";" + String . format ( "%n" ) + " }" + String . format ( "%n" ) + " var chain_list = script(\"show chain\").trim().lines;" + String . format ( "%n" ) + " var chain_count = chain_list.length;" + String . format ( "%n" ) + " var color_count = color_list.length;" + String . format ( "%n" ) + " var sel = {selected};" + String . format ( "%n" ) + " var cmds = \"\";" + String . format ( "%n" ) + " for (var chain_number=1; chain_number<=chain_count; chain_number++) {" + String . format ( "%n" ) + " // remember, Jmol arrays start with 1, but % can return 0" + String . format ( "%n" ) + " cmds += \"select sel and :\" + chain_list[chain_number] + \";color \" + objtype + \" [x\" + color_list[(chain_number-1) % color_count + 1] + \"];\" + cmd2;" + String . format ( "%n" ) + " }" + String . format ( "%n" ) + " script INLINE @{cmds + \"select sel\"}" + String . format ( "%n" ) + "}" ; executeCmd ( script ) ; }
assign a custom color to the Jmol chains command .
24,601
private void addAmbiguousEquivalents ( String one , String two , String either ) { Set < AminoAcidCompound > equivalents ; AminoAcidCompound cOne , cTwo , cEither ; equivalents = new HashSet < AminoAcidCompound > ( ) ; equivalents . add ( cOne = aminoAcidCompoundCache . get ( one ) ) ; equivalents . add ( cTwo = aminoAcidCompoundCache . get ( two ) ) ; equivalents . add ( cEither = aminoAcidCompoundCache . get ( either ) ) ; equivalentsCache . put ( cEither , equivalents ) ; equivalents = new HashSet < AminoAcidCompound > ( ) ; equivalents . add ( cOne ) ; equivalents . add ( cEither ) ; equivalentsCache . put ( cOne , equivalents ) ; equivalents = new HashSet < AminoAcidCompound > ( ) ; equivalents . add ( cTwo ) ; equivalents . add ( cEither ) ; equivalentsCache . put ( cTwo , equivalents ) ; }
helper method to initialize the equivalent sets for 2 amino acid compounds and their ambiguity compound
24,602
private Group getNewGroup ( String recordName , Character aminoCode1 , long seq_id , String groupCode3 ) { Group g = ChemCompGroupFactory . getGroupFromChemCompDictionary ( groupCode3 ) ; if ( g != null && ! g . getChemComp ( ) . isEmpty ( ) ) { if ( g instanceof AminoAcidImpl ) { AminoAcidImpl aa = ( AminoAcidImpl ) g ; aa . setId ( seq_id ) ; } else if ( g instanceof NucleotideImpl ) { NucleotideImpl nuc = ( NucleotideImpl ) g ; nuc . setId ( seq_id ) ; } else if ( g instanceof HetatomImpl ) { HetatomImpl het = ( HetatomImpl ) g ; het . setId ( seq_id ) ; } return g ; } Group group ; if ( recordName . equals ( "ATOM" ) ) { if ( StructureTools . isNucleotide ( groupCode3 ) ) { NucleotideImpl nu = new NucleotideImpl ( ) ; group = nu ; nu . setId ( seq_id ) ; } else if ( aminoCode1 == null || aminoCode1 == StructureTools . UNKNOWN_GROUP_LABEL ) { HetatomImpl h = new HetatomImpl ( ) ; h . setId ( seq_id ) ; group = h ; } else { AminoAcidImpl aa = new AminoAcidImpl ( ) ; aa . setAminoType ( aminoCode1 ) ; aa . setId ( seq_id ) ; group = aa ; } } else { if ( StructureTools . isNucleotide ( groupCode3 ) ) { NucleotideImpl nu = new NucleotideImpl ( ) ; group = nu ; nu . setId ( seq_id ) ; } else if ( aminoCode1 != null ) { AminoAcidImpl aa = new AminoAcidImpl ( ) ; aa . setAminoType ( aminoCode1 ) ; aa . setId ( seq_id ) ; group = aa ; } else { HetatomImpl h = new HetatomImpl ( ) ; h . setId ( seq_id ) ; group = h ; } } return group ; }
initiate new group either Hetatom Nucleotide or AminoAcid
24,603
private static Chain isKnownChain ( String asymId , List < Chain > chains ) { for ( int i = 0 ; i < chains . size ( ) ; i ++ ) { Chain testchain = chains . get ( i ) ; if ( asymId . equals ( testchain . getId ( ) ) ) { return testchain ; } } return null ; }
Test if the given asymId is already present in the list of chains given . If yes returns the chain otherwise returns null .
24,604
private Atom convertAtom ( AtomSite atom ) { Atom a = new AtomImpl ( ) ; a . setPDBserial ( Integer . parseInt ( atom . getId ( ) ) ) ; a . setName ( atom . getLabel_atom_id ( ) ) ; double x = Double . parseDouble ( atom . getCartn_x ( ) ) ; double y = Double . parseDouble ( atom . getCartn_y ( ) ) ; double z = Double . parseDouble ( atom . getCartn_z ( ) ) ; a . setX ( x ) ; a . setY ( y ) ; a . setZ ( z ) ; float occupancy = Float . parseFloat ( atom . getOccupancy ( ) ) ; a . setOccupancy ( occupancy ) ; float temp = Float . parseFloat ( atom . getB_iso_or_equiv ( ) ) ; a . setTempFactor ( temp ) ; String alt = atom . getLabel_alt_id ( ) ; if ( ( alt != null ) && ( alt . length ( ) > 0 ) && ( ! alt . equals ( "." ) ) ) { a . setAltLoc ( new Character ( alt . charAt ( 0 ) ) ) ; } else { a . setAltLoc ( new Character ( ' ' ) ) ; } Element element = Element . R ; try { element = Element . valueOfIgnoreCase ( atom . getType_symbol ( ) ) ; } catch ( IllegalArgumentException e ) { logger . info ( "Element {} was not recognised as a BioJava-known element, the element will be represented as the generic element {}" , atom . getType_symbol ( ) , Element . R . name ( ) ) ; } a . setElement ( element ) ; return a ; }
Convert a mmCIF AtomSite object to a BioJava Atom object
24,605
public void documentStart ( ) { structure = new StructureImpl ( ) ; currentChain = null ; currentGroup = null ; currentNmrModelNumber = null ; allModels = new ArrayList < List < Chain > > ( ) ; currentModel = new ArrayList < Chain > ( ) ; entities = new ArrayList < Entity > ( ) ; entityPolys = new ArrayList < > ( ) ; strucRefs = new ArrayList < StructRef > ( ) ; seqResChains = new ArrayList < Chain > ( ) ; entityChains = new ArrayList < Chain > ( ) ; structAsyms = new ArrayList < StructAsym > ( ) ; asymId2entityId = new HashMap < String , String > ( ) ; asymId2authorId = new HashMap < > ( ) ; structOpers = new ArrayList < PdbxStructOperList > ( ) ; strucAssemblies = new ArrayList < PdbxStructAssembly > ( ) ; strucAssemblyGens = new ArrayList < PdbxStructAssemblyGen > ( ) ; entitySrcGens = new ArrayList < EntitySrcGen > ( ) ; entitySrcNats = new ArrayList < EntitySrcNat > ( ) ; entitySrcSyns = new ArrayList < EntitySrcSyn > ( ) ; structConn = new ArrayList < StructConn > ( ) ; structNcsOper = new ArrayList < StructNcsOper > ( ) ; sequenceDifs = new ArrayList < StructRefSeqDif > ( ) ; structSiteGens = new ArrayList < StructSiteGen > ( ) ; }
Start the parsing
24,606
private void addAncilliaryEntityData ( StructAsym asym , int entityId , Entity entity , EntityInfo entityInfo ) { for ( EntitySrcGen esg : entitySrcGens ) { if ( ! esg . getEntity_id ( ) . equals ( asym . getEntity_id ( ) ) ) continue ; addInformationFromESG ( esg , entityId , entityInfo ) ; } for ( EntitySrcNat esn : entitySrcNats ) { if ( ! esn . getEntity_id ( ) . equals ( asym . getEntity_id ( ) ) ) continue ; addInformationFromESN ( esn , entityId , entityInfo ) ; } for ( EntitySrcSyn ess : entitySrcSyns ) { if ( ! ess . getEntity_id ( ) . equals ( asym . getEntity_id ( ) ) ) continue ; addInfoFromESS ( ess , entityId , entityInfo ) ; } }
Add any extra information to the entity information .
24,607
private void addInformationFromESG ( EntitySrcGen entitySrcInfo , int entityId , EntityInfo c ) { c . setAtcc ( entitySrcInfo . getPdbx_gene_src_atcc ( ) ) ; c . setCell ( entitySrcInfo . getPdbx_gene_src_cell ( ) ) ; c . setOrganismCommon ( entitySrcInfo . getGene_src_common_name ( ) ) ; c . setOrganismScientific ( entitySrcInfo . getPdbx_gene_src_scientific_name ( ) ) ; c . setOrganismTaxId ( entitySrcInfo . getPdbx_gene_src_ncbi_taxonomy_id ( ) ) ; c . setExpressionSystemTaxId ( entitySrcInfo . getPdbx_host_org_ncbi_taxonomy_id ( ) ) ; c . setExpressionSystem ( entitySrcInfo . getPdbx_host_org_scientific_name ( ) ) ; }
Add the information from an ESG to a compound .
24,608
private void addInformationFromESN ( EntitySrcNat esn , int eId , EntityInfo c ) { c . setAtcc ( esn . getPdbx_atcc ( ) ) ; c . setCell ( esn . getPdbx_cell ( ) ) ; c . setOrganismCommon ( esn . getCommon_name ( ) ) ; c . setOrganismScientific ( esn . getPdbx_organism_scientific ( ) ) ; c . setOrganismTaxId ( esn . getPdbx_ncbi_taxonomy_id ( ) ) ; }
Add the information to entity info from ESN .
24,609
private void addInfoFromESS ( EntitySrcSyn ess , int eId , EntityInfo c ) { c . setOrganismCommon ( ess . getOrganism_common_name ( ) ) ; c . setOrganismScientific ( ess . getOrganism_scientific ( ) ) ; c . setOrganismTaxId ( ess . getNcbi_taxonomy_id ( ) ) ; }
Add the information from ESS to Entity info .
24,610
private void addSites ( ) { List < Site > sites = structure . getSites ( ) ; if ( sites == null ) sites = new ArrayList < Site > ( ) ; for ( StructSiteGen siteGen : structSiteGens ) { String site_id = siteGen . getSite_id ( ) ; if ( site_id == null ) site_id = "" ; String comp_id = siteGen . getLabel_comp_id ( ) ; String asymId = siteGen . getLabel_asym_id ( ) ; String authId = siteGen . getAuth_asym_id ( ) ; String auth_seq_id = siteGen . getAuth_seq_id ( ) ; String insCode = siteGen . getPdbx_auth_ins_code ( ) ; if ( insCode != null && insCode . equals ( "?" ) ) insCode = null ; Group g = null ; try { Chain chain = structure . getChain ( asymId ) ; if ( null != chain ) { try { Character insChar = null ; if ( null != insCode && insCode . length ( ) > 0 ) insChar = insCode . charAt ( 0 ) ; g = chain . getGroupByPDB ( new ResidueNumber ( null , Integer . parseInt ( auth_seq_id ) , insChar ) ) ; } catch ( NumberFormatException e ) { logger . warn ( "Could not lookup residue : " + authId + auth_seq_id ) ; } } } catch ( StructureException e ) { logger . warn ( "Problem finding residue in site entry " + siteGen . getSite_id ( ) + " - " + e . getMessage ( ) , e . getMessage ( ) ) ; } if ( g != null ) { Site site = null ; for ( Site asite : sites ) { if ( site_id . equals ( asite . getSiteID ( ) ) ) site = asite ; } boolean addSite = false ; if ( site == null ) { addSite = true ; site = new Site ( ) ; site . setSiteID ( site_id ) ; } List < Group > groups = site . getGroups ( ) ; if ( groups == null ) groups = new ArrayList < Group > ( ) ; if ( ! comp_id . equals ( g . getPDBName ( ) ) ) { logger . warn ( "comp_id doesn't match the residue at " + authId + " " + auth_seq_id + " - skipping" ) ; } else { groups . add ( g ) ; site . setGroups ( groups ) ; } if ( addSite ) sites . add ( site ) ; } } structure . setSites ( sites ) ; }
Build sites in a BioJava Structure using the original author chain id & residue numbers . Sites are built from struct_site_gen records that have been parsed .
24,611
public void drawPairs ( Graphics g ) { if ( aligs == null ) return ; int nr = aligs . length ; Graphics2D g2D = ( Graphics2D ) g ; Stroke oldStroke = g2D . getStroke ( ) ; g2D . setStroke ( stroke ) ; Color color ; float hue ; int width = Math . round ( scale ) ; int w2 = width / 2 ; for ( int i = 0 ; i < aligs . length ; i ++ ) { AlternativeAlignment a = aligs [ i ] ; int [ ] idx1 = a . getIdx1 ( ) ; int [ ] idx2 = a . getIdx2 ( ) ; int xold = - 1 ; int yold = - 1 ; boolean start = true ; if ( ( selectedAlignmentPos != - 1 ) && ( selectedAlignmentPos == i ) ) { color = Color . white ; } else { hue = i * ( 1 / ( float ) nr ) ; color = Color . getHSBColor ( hue , 1.0f , 1.0f ) ; } g . setColor ( color ) ; for ( int j = 0 ; j < idx1 . length ; j ++ ) { int x1 = Math . round ( idx1 [ j ] * scale ) ; int y1 = Math . round ( idx2 [ j ] * scale ) ; if ( ! start ) { g . fillRect ( xold , yold , 2 , 2 ) ; } else { g . fillRect ( x1 , y1 , w2 , w2 ) ; start = false ; } xold = x1 ; yold = y1 ; } if ( ! start ) g . fillRect ( xold , yold , w2 , w2 ) ; } g2D . setStroke ( oldStroke ) ; }
draw alternative alignments
24,612
public void drawBoxes ( Graphics g ) { if ( fragmentPairs == null ) return ; g . setColor ( Color . yellow ) ; for ( int i = 0 ; i < fragmentPairs . length ; i ++ ) { FragmentPair fp = fragmentPairs [ i ] ; int xp = fp . getPos1 ( ) ; int yp = fp . getPos2 ( ) ; int width = Math . round ( scale ) ; g . drawRect ( Math . round ( xp * scale ) , Math . round ( yp * scale ) , width , width ) ; } }
draw high scoring fragments that are used for the initial alignment seed selection
24,613
public void drawDistances ( Graphics g1 ) { Graphics2D g = ( Graphics2D ) g1 ; int c = matrix . getRowDimension ( ) ; int d = matrix . getColumnDimension ( ) ; float scale = getScale ( ) ; int width = Math . round ( scale ) ; for ( int i = 0 ; i < c ; i ++ ) { int ipaint = Math . round ( i * scale ) ; for ( int j = 0 ; j < d ; j ++ ) { double val = matrix . get ( i , j ) ; int jpaint = Math . round ( j * scale ) ; Color color = cellColor . getColor ( val ) ; g . setColor ( color ) ; g . fillRect ( ipaint , jpaint , width , width ) ; } } }
For each element in matrix draw it as a colored square or pixel .
24,614
private void ABITraceInit ( BufferedInputStream bis ) throws IOException { byte [ ] bytes = null ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; int b ; while ( ( b = bis . read ( ) ) >= 0 ) { baos . write ( b ) ; } bis . close ( ) ; baos . close ( ) ; bytes = baos . toByteArray ( ) ; initData ( bytes ) ; }
Helper method for constructors
24,615
public int [ ] getTrace ( String base ) throws CompoundNotFoundException { if ( base . equals ( "A" ) ) { return A ; } else if ( base . equals ( "C" ) ) { return C ; } else if ( base . equals ( "G" ) ) { return G ; } else if ( base . equals ( "T" ) ) { return T ; } else { throw new CompoundNotFoundException ( "Don't know base: " + base ) ; } }
Returns one of the four traces - all of the y - coordinate values each of which correspond to a single x - coordinate relative to the position in the array so that if element 4 in the array is 972 then x is 4 and y is 972 for that point .
24,616
private double calculateScale ( int height ) { double newScale = 0.0 ; double max = ( double ) getMaximum ( ) ; double ht = ( double ) height ; newScale = ( ( ht - 50.0 ) ) / max ; return newScale ; }
Returns the scaling factor necessary to allow all of the traces to fit vertically into the specified space .
24,617
private int getMaximum ( ) { int max = 0 ; for ( int x = 0 ; x <= T . length - 1 ; x ++ ) { if ( T [ x ] > max ) max = T [ x ] ; if ( A [ x ] > max ) max = A [ x ] ; if ( C [ x ] > max ) max = C [ x ] ; if ( G [ x ] > max ) max = G [ x ] ; } return max ; }
Get the maximum height of any of the traces . The data is persisted for performance in the event of multiple calls but it initialized lazily .
24,618
private void initData ( byte [ ] fileData ) { traceData = fileData ; if ( isABI ( ) ) { setIndex ( ) ; setBasecalls ( ) ; setQcalls ( ) ; setSeq ( ) ; setTraces ( ) ; } else throw new IllegalArgumentException ( "Not a valid ABI file." ) ; }
Initialize all of the data fields for this object .
24,619
private void setTraces ( ) { int pointers [ ] = new int [ 4 ] ; int datas [ ] = new int [ 4 ] ; char order [ ] = new char [ 4 ] ; datas [ 0 ] = DATA9 ; datas [ 1 ] = DATA10 ; datas [ 2 ] = DATA11 ; datas [ 3 ] = DATA12 ; for ( int i = 0 ; i <= 3 ; i ++ ) { order [ i ] = ( char ) traceData [ FWO + i ] ; } for ( int i = 0 ; i <= 3 ; i ++ ) { switch ( order [ i ] ) { case 'A' : case 'a' : pointers [ 0 ] = datas [ i ] ; break ; case 'C' : case 'c' : pointers [ 1 ] = datas [ i ] ; break ; case 'G' : case 'g' : pointers [ 2 ] = datas [ i ] ; break ; case 'T' : case 't' : pointers [ 3 ] = datas [ i ] ; break ; default : throw new IllegalArgumentException ( "Trace contains illegal values." ) ; } } A = new int [ traceLength ] ; C = new int [ traceLength ] ; G = new int [ traceLength ] ; T = new int [ traceLength ] ; for ( int i = 0 ; i <= 3 ; i ++ ) { byte [ ] qq = new byte [ traceLength * 2 ] ; getSubArray ( qq , pointers [ i ] ) ; DataInputStream dis = new DataInputStream ( new ByteArrayInputStream ( qq ) ) ; for ( int x = 0 ; x <= traceLength - 1 ; x ++ ) { try { if ( i == 0 ) A [ x ] = ( int ) dis . readShort ( ) ; if ( i == 1 ) C [ x ] = ( int ) dis . readShort ( ) ; if ( i == 2 ) G [ x ] = ( int ) dis . readShort ( ) ; if ( i == 3 ) T [ x ] = ( int ) dis . readShort ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Unexpected IOException encountered while manipulating internal streams." ) ; } } } return ; }
Shuffle the pointers to point to the proper spots in the trace then load the traces into their arrays .
24,620
private void setSeq ( ) { char tempseq [ ] = new char [ seqLength ] ; for ( int x = 0 ; x <= seqLength - 1 ; ++ x ) { tempseq [ x ] = ( char ) traceData [ PBAS2 + x ] ; } sequence = new String ( tempseq ) ; }
Fetch the sequence from the trace data .
24,621
private void setQcalls ( ) { qCalls = new int [ seqLength ] ; byte [ ] qq = new byte [ seqLength ] ; getSubArray ( qq , PCON ) ; DataInputStream dis = new DataInputStream ( new ByteArrayInputStream ( qq ) ) ; for ( int i = 0 ; i <= seqLength - 1 ; ++ i ) { try { qCalls [ i ] = ( int ) dis . readByte ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Unexpected IOException encountered while manipulating internal streams." ) ; } } }
Fetch the quality calls from the trace data .
24,622
private void setBasecalls ( ) { baseCalls = new int [ seqLength ] ; byte [ ] qq = new byte [ seqLength * 2 ] ; getSubArray ( qq , PLOC ) ; DataInputStream dis = new DataInputStream ( new ByteArrayInputStream ( qq ) ) ; for ( int i = 0 ; i <= seqLength - 1 ; ++ i ) { try { baseCalls [ i ] = ( int ) dis . readShort ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Unexpected IOException encountered while manipulating internal streams." ) ; } } }
Fetch the basecalls from the trace data .
24,623
private void setIndex ( ) { int DataCounter , PBASCounter , PLOCCounter , PCONCounter , NumRecords , indexBase ; byte [ ] RecNameArray = new byte [ 4 ] ; String RecName ; DataCounter = 0 ; PBASCounter = 0 ; PLOCCounter = 0 ; PCONCounter = 0 ; indexBase = getIntAt ( absIndexBase + macJunk ) ; NumRecords = getIntAt ( absIndexBase - 8 + macJunk ) ; for ( int record = 0 ; record <= NumRecords - 1 ; record ++ ) { getSubArray ( RecNameArray , ( indexBase + ( record * 28 ) ) ) ; RecName = new String ( RecNameArray ) ; if ( RecName . equals ( "FWO_" ) ) FWO = indexBase + ( record * 28 ) + 20 ; if ( RecName . equals ( "DATA" ) ) { ++ DataCounter ; if ( DataCounter == 9 ) DATA9 = indexBase + ( record * 28 ) + 20 ; if ( DataCounter == 10 ) DATA10 = indexBase + ( record * 28 ) + 20 ; if ( DataCounter == 11 ) DATA11 = indexBase + ( record * 28 ) + 20 ; if ( DataCounter == 12 ) DATA12 = indexBase + ( record * 28 ) + 20 ; } if ( RecName . equals ( "PBAS" ) ) { ++ PBASCounter ; if ( PBASCounter == 2 ) PBAS2 = indexBase + ( record * 28 ) + 20 ; } if ( RecName . equals ( "PLOC" ) ) { ++ PLOCCounter ; if ( PLOCCounter == 2 ) PLOC = indexBase + ( record * 28 ) + 20 ; } if ( RecName . equals ( "PCON" ) ) { ++ PCONCounter ; if ( PCONCounter == 2 ) PCON = indexBase + ( record * 28 ) + 20 ; } } traceLength = getIntAt ( DATA12 - 8 ) ; seqLength = getIntAt ( PBAS2 - 4 ) ; PLOC = getIntAt ( PLOC ) + macJunk ; DATA9 = getIntAt ( DATA9 ) + macJunk ; DATA10 = getIntAt ( DATA10 ) + macJunk ; DATA11 = getIntAt ( DATA11 ) + macJunk ; DATA12 = getIntAt ( DATA12 ) + macJunk ; PBAS2 = getIntAt ( PBAS2 ) + macJunk ; PCON = getIntAt ( PCON ) + macJunk ; }
Sets up all of the initial pointers to the important records in TraceData .
24,624
private void getSubArray ( byte [ ] b , int traceDataOffset ) { for ( int x = 0 ; x <= b . length - 1 ; x ++ ) { b [ x ] = traceData [ traceDataOffset + x ] ; } }
A utility method which fills array b with data from the trace starting at traceDataOffset .
24,625
private boolean isABI ( ) { char ABI [ ] = new char [ 4 ] ; for ( int i = 0 ; i <= 2 ; i ++ ) { ABI [ i ] = ( char ) traceData [ i ] ; } if ( ABI [ 0 ] == 'A' && ( ABI [ 1 ] == 'B' && ABI [ 2 ] == 'I' ) ) { return true ; } else { for ( int i = 128 ; i <= 130 ; i ++ ) { ABI [ i - 128 ] = ( char ) traceData [ i ] ; } if ( ABI [ 0 ] == 'A' && ( ABI [ 1 ] == 'B' && ABI [ 2 ] == 'I' ) ) { macJunk = 128 ; return true ; } else return false ; } }
Test to see if the file is ABI format by checking to see that the first three bytes are ABI . Also handle the special case where 128 bytes were prepended to the file due to binary FTP from an older macintosh system .
24,626
public static void main ( String [ ] args ) { try { List < GeneName > geneNames = getGeneNames ( ) ; logger . info ( "got {} gene names" , geneNames . size ( ) ) ; for ( GeneName g : geneNames ) { if ( g . getApprovedSymbol ( ) . equals ( "FOLH1" ) ) logger . info ( "Gene Name: {}" , g ) ; } } catch ( Exception e ) { logger . error ( "Exception: " , e ) ; } }
parses a file from the genenames website
24,627
public static List < GeneName > getGeneNames ( InputStream inStream ) throws IOException { ArrayList < GeneName > geneNames = new ArrayList < GeneName > ( ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( inStream ) ) ; String line = reader . readLine ( ) ; while ( ( line = reader . readLine ( ) ) != null ) { GeneName geneName = getGeneName ( line ) ; if ( geneName != null ) geneNames . add ( geneName ) ; } geneNames . trimToSize ( ) ; return geneNames ; }
Get a list of GeneNames from an input stream .
24,628
public void addIntronsUsingExons ( ) throws Exception { if ( intronAdded ) { return ; } if ( exonSequenceList . size ( ) == 0 ) { return ; } ExonComparator exonComparator = new ExonComparator ( ) ; Collections . sort ( exonSequenceList , exonComparator ) ; int shift = - 1 ; if ( getStrand ( ) == Strand . NEGATIVE ) { shift = 1 ; } int intronIndex = 1 ; for ( int i = 0 ; i < exonSequenceList . size ( ) - 1 ; i ++ ) { ExonSequence exon1 = exonSequenceList . get ( i ) ; ExonSequence exon2 = exonSequenceList . get ( i + 1 ) ; this . addIntron ( new AccessionID ( this . getAccession ( ) . getID ( ) + "-" + "intron" + intronIndex ) , exon1 . getBioEnd ( ) - shift , exon2 . getBioBegin ( ) + shift ) ; intronIndex ++ ; } }
Once everything has been added to the gene sequence where you might have added exon sequences only then you can infer the intron sequences and add them . You may also have the case where you only added one or more TranscriptSequences and from that you can infer the exon sequences and intron sequences . Currently not implement
24,629
public TranscriptSequence addTranscript ( AccessionID accession , int begin , int end ) throws Exception { if ( transcriptSequenceHashMap . containsKey ( accession . getID ( ) ) ) { throw new Exception ( "Duplicate accesion id " + accession . getID ( ) ) ; } TranscriptSequence transcriptSequence = new TranscriptSequence ( this , begin , end ) ; transcriptSequence . setAccession ( accession ) ; transcriptSequenceHashMap . put ( accession . getID ( ) , transcriptSequence ) ; return transcriptSequence ; }
Add a transcription sequence to a gene which describes a ProteinSequence
24,630
public IntronSequence removeIntron ( String accession ) { for ( IntronSequence intronSequence : intronSequenceList ) { if ( intronSequence . getAccession ( ) . getID ( ) . equals ( accession ) ) { intronSequenceList . remove ( intronSequence ) ; intronSequenceHashMap . remove ( accession ) ; return intronSequence ; } } return null ; }
Remove the intron by accession
24,631
public IntronSequence addIntron ( AccessionID accession , int begin , int end ) throws Exception { if ( intronSequenceHashMap . containsKey ( accession . getID ( ) ) ) { throw new Exception ( "Duplicate accesion id " + accession . getID ( ) ) ; } intronAdded = true ; IntronSequence intronSequence = new IntronSequence ( this , begin , end ) ; intronSequence . setAccession ( accession ) ; intronSequenceList . add ( intronSequence ) ; intronSequenceHashMap . put ( accession . getID ( ) , intronSequence ) ; return intronSequence ; }
Add an Intron Currently used to mark an IntronSequence as a feature
24,632
public ExonSequence removeExon ( String accession ) { for ( ExonSequence exonSequence : exonSequenceList ) { if ( exonSequence . getAccession ( ) . getID ( ) . equals ( accession ) ) { exonSequenceList . remove ( exonSequence ) ; exonSequenceHashMap . remove ( accession ) ; intronSequenceList . clear ( ) ; intronSequenceHashMap . clear ( ) ; intronAdded = false ; try { addIntronsUsingExons ( ) ; } catch ( Exception e ) { logger . error ( "Remove Exon validate() error " + e . getMessage ( ) ) ; } return exonSequence ; } } return null ; }
Remove the exon sequence
24,633
public ExonSequence addExon ( AccessionID accession , int begin , int end ) throws Exception { if ( exonSequenceHashMap . containsKey ( accession . getID ( ) ) ) { throw new Exception ( "Duplicate accesion id " + accession . getID ( ) ) ; } ExonSequence exonSequence = new ExonSequence ( this , begin , end ) ; exonSequence . setAccession ( accession ) ; exonSequenceList . add ( exonSequence ) ; exonSequenceHashMap . put ( accession . getID ( ) , exonSequence ) ; return exonSequence ; }
Add an ExonSequence mainly used to mark as a feature
24,634
public DNASequence getSequence5PrimeTo3Prime ( ) { String sequence = getSequenceAsString ( this . getBioBegin ( ) , this . getBioEnd ( ) , this . getStrand ( ) ) ; if ( getStrand ( ) == Strand . NEGATIVE ) { StringBuilder b = new StringBuilder ( getLength ( ) ) ; CompoundSet < NucleotideCompound > compoundSet = this . getCompoundSet ( ) ; for ( int i = 0 ; i < sequence . length ( ) ; i ++ ) { String nucleotide = String . valueOf ( sequence . charAt ( i ) ) ; NucleotideCompound nucleotideCompound = compoundSet . getCompoundForString ( nucleotide ) ; b . append ( nucleotideCompound . getComplement ( ) . getShortName ( ) ) ; } sequence = b . toString ( ) ; } DNASequence dnaSequence = null ; try { dnaSequence = new DNASequence ( sequence . toUpperCase ( ) ) ; } catch ( CompoundNotFoundException e ) { logger . error ( "Could not create new DNA sequence in getSequence5PrimeTo3Prime(). Error: {}" , e . getMessage ( ) ) ; } dnaSequence . setAccession ( new AccessionID ( this . getAccession ( ) . getID ( ) ) ) ; return dnaSequence ; }
Try to give method clarity where you want a DNASequence coding in the 5 to 3 direction Returns the DNASequence representative of the 5 and 3 reading based on strand
24,635
public void toPDB ( StringBuffer buf ) { printHeader ( buf ) ; printTitle ( buf ) ; printExpdata ( buf ) ; printAuthors ( buf ) ; printResolution ( buf ) ; }
Appends a PDB representation of the PDB header to the provided StringBuffer
24,636
public boolean setExperimentalTechnique ( String techniqueStr ) { ExperimentalTechnique et = ExperimentalTechnique . getByName ( techniqueStr ) ; if ( et == null ) return false ; if ( techniques == null ) { techniques = EnumSet . of ( et ) ; return true ; } else { return techniques . add ( et ) ; } }
Adds the experimental technique to the set of experimental techniques of this header . Note that if input is not a recognised technique string then no errors will be produced but false will be returned
24,637
public static void addCharges ( Structure structure ) { for ( int i = 0 ; i < structure . nrModels ( ) ; i ++ ) { for ( Chain c : structure . getChains ( i ) ) { for ( Group g : c . getAtomGroups ( ) ) { ChemComp thisChemComp = ChemCompGroupFactory . getChemComp ( g . getPDBName ( ) ) ; List < ChemCompAtom > chemAtoms = thisChemComp . getAtoms ( ) ; for ( ChemCompAtom chemCompAtom : chemAtoms ) { Atom atom = g . getAtom ( chemCompAtom . getAtom_id ( ) ) ; String stringCharge = chemCompAtom . getCharge ( ) ; short shortCharge = 0 ; if ( stringCharge != null ) { if ( ! stringCharge . equals ( "?" ) ) { try { shortCharge = Short . parseShort ( stringCharge ) ; } catch ( NumberFormatException e ) { logger . warn ( "Number format exception. Parsing '" + stringCharge + "' to short" ) ; } } else { logger . warn ( "? charge on atom " + chemCompAtom . getAtom_id ( ) + " in group " + thisChemComp . getId ( ) ) ; } } else { logger . warn ( "Null charge on atom " + chemCompAtom . getAtom_id ( ) + " in group " + thisChemComp . getId ( ) ) ; } if ( atom != null ) { atom . setCharge ( shortCharge ) ; } for ( Group altLoc : g . getAltLocs ( ) ) { Atom altAtom = altLoc . getAtom ( chemCompAtom . getAtom_id ( ) ) ; if ( altAtom != null ) { altAtom . setCharge ( shortCharge ) ; } } } } } } }
Function to add the charges to a given structure .
24,638
private void updateMultipleAlignment ( ) throws StructureException , RefinerFailedException { msa . clear ( ) ; Block b = msa . getBlock ( 0 ) ; b . setAlignRes ( block ) ; repeatCore = b . getCoreLength ( ) ; if ( repeatCore < 1 ) throw new RefinerFailedException ( "Optimization converged to length 0" ) ; SymmetryTools . updateSymmetryTransformation ( axes , msa ) ; }
This method translates the internal data structures to a MultipleAlignment of the repeats in order to use the methods to score MultipleAlignments .
24,639
private boolean shrinkBlock ( ) throws StructureException , RefinerFailedException { if ( repeatCore <= Lmin ) return false ; updateMultipleAlignment ( ) ; Matrix residueDistances = MultipleAlignmentTools . getAverageResidueDistances ( msa ) ; double maxDist = Double . MIN_VALUE ; double [ ] colDistances = new double [ length ] ; int res = 0 ; for ( int col = 0 ; col < length ; col ++ ) { int normalize = 0 ; for ( int s = 0 ; s < order ; s ++ ) { if ( residueDistances . get ( s , col ) != - 1 ) { colDistances [ col ] += residueDistances . get ( s , col ) ; normalize ++ ; } } colDistances [ col ] /= normalize ; if ( colDistances [ col ] > maxDist ) { if ( rnd . nextDouble ( ) > 0.5 ) { maxDist = colDistances [ col ] ; res = col ; } } } for ( int su = 0 ; su < order ; su ++ ) { Integer residue = block . get ( su ) . get ( res ) ; block . get ( su ) . remove ( res ) ; if ( residue != null ) freePool . add ( residue ) ; Collections . sort ( freePool ) ; } length -- ; checkGaps ( ) ; return true ; }
Deletes an alignment column at a randomly selected position .
24,640
private void saveHistory ( String folder ) throws IOException { String name = msa . getStructureIdentifier ( 0 ) . getIdentifier ( ) ; FileWriter writer = new FileWriter ( folder + name + "-symm_opt.csv" ) ; writer . append ( "Step,Time,RepeatLength,RMSD,TMscore,MCscore\n" ) ; for ( int i = 0 ; i < lengthHistory . size ( ) ; i ++ ) { writer . append ( i * saveStep + "," ) ; writer . append ( timeHistory . get ( i ) + "," ) ; writer . append ( lengthHistory . get ( i ) + "," ) ; writer . append ( rmsdHistory . get ( i ) + "," ) ; writer . append ( tmScoreHistory . get ( i ) + "," ) ; writer . append ( mcScoreHistory . get ( i ) + "\n" ) ; } writer . flush ( ) ; writer . close ( ) ; }
Save the evolution of the optimization process as a csv file .
24,641
private void addBonds ( Atom atom , List < Atom > atomsInGroup , List < Atom > allAtoms ) { if ( atom . getBonds ( ) == null ) { return ; } for ( Bond bond : atom . getBonds ( ) ) { Atom other = bond . getOther ( atom ) ; if ( atomsInGroup . indexOf ( other ) != - 1 ) { Integer firstBondIndex = atomsInGroup . indexOf ( atom ) ; Integer secondBondIndex = atomsInGroup . indexOf ( other ) ; if ( firstBondIndex > secondBondIndex ) { int bondOrder = bond . getBondOrder ( ) ; mmtfDecoderInterface . setGroupBond ( firstBondIndex , secondBondIndex , bondOrder ) ; } } else { Integer firstBondIndex = allAtoms . indexOf ( atom ) ; Integer secondBondIndex = allAtoms . indexOf ( other ) ; if ( firstBondIndex > secondBondIndex ) { int bondOrder = bond . getBondOrder ( ) ; mmtfDecoderInterface . setInterGroupBond ( firstBondIndex , secondBondIndex , bondOrder ) ; } } } }
Add the bonds for a given atom .
24,642
private void storeEntityInformation ( List < Chain > allChains , List < EntityInfo > entityInfos ) { for ( EntityInfo entityInfo : entityInfos ) { String description = entityInfo . getDescription ( ) ; String type ; if ( entityInfo . getType ( ) == null ) { type = null ; } else { type = entityInfo . getType ( ) . getEntityType ( ) ; } List < Chain > entityChains = entityInfo . getChains ( ) ; if ( entityChains . isEmpty ( ) ) { System . err . println ( "ERROR MAPPING CHAIN TO ENTITY: " + description ) ; mmtfDecoderInterface . setEntityInfo ( new int [ 0 ] , "" , description , type ) ; continue ; } else { int [ ] chainIndices = new int [ entityChains . size ( ) ] ; for ( int i = 0 ; i < entityChains . size ( ) ; i ++ ) { chainIndices [ i ] = allChains . indexOf ( entityChains . get ( i ) ) ; } Chain chain = entityChains . get ( 0 ) ; ChainImpl chainImpl ; if ( chain instanceof ChainImpl ) { chainImpl = ( ChainImpl ) entityChains . get ( 0 ) ; } else { throw new RuntimeException ( ) ; } String sequence = chainImpl . getSeqResOneLetterSeq ( ) ; mmtfDecoderInterface . setEntityInfo ( chainIndices , sequence , description , type ) ; } } }
Store the entity information for a given structure .
24,643
private void storeBioassemblyInformation ( Map < String , Integer > chainIdToIndexMap , Map < Integer , BioAssemblyInfo > inputBioAss ) { int bioAssemblyIndex = 0 ; for ( Entry < Integer , BioAssemblyInfo > entry : inputBioAss . entrySet ( ) ) { Map < double [ ] , int [ ] > transformMap = MmtfUtils . getTransformMap ( entry . getValue ( ) , chainIdToIndexMap ) ; for ( Entry < double [ ] , int [ ] > transformEntry : transformMap . entrySet ( ) ) { mmtfDecoderInterface . setBioAssemblyTrans ( bioAssemblyIndex , transformEntry . getValue ( ) , transformEntry . getKey ( ) , entry . getKey ( ) . toString ( ) ) ; } bioAssemblyIndex ++ ; } }
Generate the bioassembly information on in the desired form .
24,644
public CDSSequence removeCDS ( String accession ) { for ( CDSSequence cdsSequence : cdsSequenceList ) { if ( cdsSequence . getAccession ( ) . getID ( ) . equals ( accession ) ) { cdsSequenceList . remove ( cdsSequence ) ; cdsSequenceHashMap . remove ( accession ) ; return cdsSequence ; } } return null ; }
Remove a CDS or coding sequence from the transcript sequence
24,645
public CDSSequence addCDS ( AccessionID accession , int begin , int end , int phase ) throws Exception { if ( cdsSequenceHashMap . containsKey ( accession . getID ( ) ) ) { throw new Exception ( "Duplicate accesion id " + accession . getID ( ) ) ; } CDSSequence cdsSequence = new CDSSequence ( this , begin , end , phase ) ; cdsSequence . setAccession ( accession ) ; cdsSequenceList . add ( cdsSequence ) ; Collections . sort ( cdsSequenceList , new CDSComparator ( ) ) ; cdsSequenceHashMap . put ( accession . getID ( ) , cdsSequence ) ; return cdsSequence ; }
Add a Coding Sequence region with phase to the transcript sequence
24,646
public DNASequence getDNACodingSequence ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( CDSSequence cdsSequence : cdsSequenceList ) { sb . append ( cdsSequence . getCodingSequence ( ) ) ; } DNASequence dnaSequence = null ; try { dnaSequence = new DNASequence ( sb . toString ( ) . toUpperCase ( ) ) ; } catch ( CompoundNotFoundException e ) { logger . error ( "Could not create DNA coding sequence, {}. This is most likely a bug." , e . getMessage ( ) ) ; } dnaSequence . setAccession ( new AccessionID ( this . getAccession ( ) . getID ( ) ) ) ; return dnaSequence ; }
Get the stitched together CDS sequences then maps to the cDNA
24,647
public ProteinSequence getProteinSequence ( TranscriptionEngine engine ) { DNASequence dnaCodingSequence = getDNACodingSequence ( ) ; RNASequence rnaCodingSequence = dnaCodingSequence . getRNASequence ( engine ) ; ProteinSequence proteinSequence = rnaCodingSequence . getProteinSequence ( engine ) ; proteinSequence . setAccession ( new AccessionID ( this . getAccession ( ) . getID ( ) ) ) ; return proteinSequence ; }
Get the protein sequence with user defined TranscriptEngine
24,648
protected void setPaintDefaults ( Graphics2D g2D ) { g2D . setRenderingHint ( RenderingHints . KEY_TEXT_ANTIALIASING , RenderingHints . VALUE_TEXT_ANTIALIAS_ON ) ; g2D . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; g2D . setFont ( seqFont ) ; }
set some default rendering hints like text antialiasing on
24,649
protected int drawSequence ( Graphics2D g2D , int y ) { g2D . setColor ( SEQUENCE_COLOR ) ; int aminosize = Math . round ( 1 * scale ) ; if ( aminosize < 1 ) aminosize = 1 ; Rectangle drawHere = g2D . getClipBounds ( ) ; int startpos = coordManager . getSeqPos ( drawHere . x ) ; Composite oldComp = g2D . getComposite ( ) ; g2D . setComposite ( AlphaComposite . getInstance ( AlphaComposite . SRC_OVER , 0.8f ) ) ; if ( startpos < 0 ) startpos = 999 ; if ( scale > SEQUENCE_SHOW ) { g2D . setColor ( Color . black ) ; int i = startpos ; for ( int gap = startpos ; gap < apos . size ( ) ; gap ++ ) { int xpos = coordManager . getPanelPos ( gap ) ; AlignedPosition m = apos . get ( gap ) ; if ( m . getPos ( position ) == - 1 ) { g2D . drawString ( "-" , xpos + 1 , y + 2 + DEFAULT_Y_STEP ) ; continue ; } i = m . getPos ( position ) ; g2D . drawString ( seqArr [ i ] . toString ( ) , xpos + 1 , y + 2 + DEFAULT_Y_STEP ) ; } y += 2 ; } g2D . setComposite ( oldComp ) ; y += DEFAULT_Y_STEP + 2 ; return y ; }
draw the Amino acid sequence
24,650
public static Point3d centroid ( Point3d [ ] x ) { Point3d center = new Point3d ( ) ; for ( Point3d p : x ) { center . add ( p ) ; } center . scale ( 1.0 / x . length ) ; return center ; }
Calculate the centroid of the point cloud .
24,651
public static void transform ( Matrix4d rotTrans , Point3d [ ] x ) { for ( Point3d p : x ) { rotTrans . transform ( p ) ; } }
Transform all points with a 4x4 transformation matrix .
24,652
public static void translate ( Vector3d trans , Point3d [ ] x ) { for ( Point3d p : x ) { p . add ( trans ) ; } }
Translate all points with a translation vector .
24,653
public static Point3d [ ] clonePoint3dArray ( Point3d [ ] x ) { Point3d [ ] clone = new Point3d [ x . length ] ; for ( int i = 0 ; i < x . length ; i ++ ) { clone [ i ] = new Point3d ( x [ i ] ) ; } return clone ; }
Clone an array of points .
24,654
public static double rmsd ( Point3d [ ] x , Point3d [ ] y ) { if ( x . length != y . length ) { throw new IllegalArgumentException ( "Point arrays are not of the same length." ) ; } double sum = 0.0 ; for ( int i = 0 ; i < x . length ; i ++ ) { sum += x [ i ] . distanceSquared ( y [ i ] ) ; } return Math . sqrt ( sum / x . length ) ; }
Calculate the RMSD of two point arrays already superposed .
24,655
public static JMenuBar initMenu ( ) { JMenuBar menu = new JMenuBar ( ) ; JMenu file = new JMenu ( "File" ) ; file . getAccessibleContext ( ) . setAccessibleDescription ( "File Menu" ) ; JMenuItem openI = new JMenuItem ( "Open" ) ; openI . setMnemonic ( KeyEvent . VK_O ) ; openI . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { String cmd = e . getActionCommand ( ) ; if ( cmd . equals ( "Open" ) ) { final JFileChooser fc = new JFileChooser ( ) ; int returnVal = fc . showOpenDialog ( null ) ; if ( returnVal == JFileChooser . APPROVE_OPTION ) { File file = fc . getSelectedFile ( ) ; PDBFileReader reader = new PDBFileReader ( ) ; try { Structure s = reader . getStructure ( file ) ; BiojavaJmol jmol = new BiojavaJmol ( ) ; jmol . setStructure ( s ) ; jmol . evalString ( "select * ; color chain;" ) ; jmol . evalString ( "select *; spacefill off; wireframe off; backbone 0.4; " ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } } } } } ) ; file . add ( openI ) ; JMenuItem exitI = new JMenuItem ( "Exit" ) ; exitI . setMnemonic ( KeyEvent . VK_X ) ; exitI . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { String cmd = e . getActionCommand ( ) ; if ( cmd . equals ( "Exit" ) ) { System . exit ( 0 ) ; } } } ) ; file . add ( exitI ) ; menu . add ( file ) ; JMenu align = new JMenu ( "Align" ) ; JMenuItem pairI = new JMenuItem ( "2 protein structures" ) ; pairI . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { String cmd = e . getActionCommand ( ) ; if ( cmd . equals ( "2 protein structures" ) ) { MenuCreator . showPairDialog ( ) ; } } } ) ; align . add ( pairI ) ; menu . add ( align ) ; JMenu about = new JMenu ( "About" ) ; JMenuItem aboutI = new JMenuItem ( "PDBview" ) ; aboutI . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { String cmd = e . getActionCommand ( ) ; if ( cmd . equals ( "PDBview" ) ) { MenuCreator . showAboutDialog ( ) ; } } } ) ; about . add ( aboutI ) ; menu . add ( Box . createGlue ( ) ) ; menu . add ( about ) ; return menu ; }
provide a JMenuBar that can be added to a JFrame
24,656
private static void showAboutDialog ( ) { JDialog dialog = new JDialog ( ) ; dialog . setSize ( new Dimension ( 300 , 300 ) ) ; String msg = "This viewer is based on <b>BioJava</b> and <b>Jmol</>. <br>Author: Andreas Prlic <br> " ; msg += "Structure Alignment algorithm based on a variation of the PSC++ algorithm by Peter Lackner." ; JEditorPane txt = new JEditorPane ( "text/html" , msg ) ; txt . setEditable ( false ) ; JScrollPane scroll = new JScrollPane ( txt ) ; Box vBox = Box . createVerticalBox ( ) ; vBox . add ( scroll ) ; JButton close = new JButton ( "Close" ) ; close . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { Object source = event . getSource ( ) ; JButton but = ( JButton ) source ; Container parent = but . getParent ( ) . getParent ( ) . getParent ( ) . getParent ( ) . getParent ( ) . getParent ( ) ; JDialog dia = ( JDialog ) parent ; dia . dispose ( ) ; } } ) ; Box hBoxb = Box . createHorizontalBox ( ) ; hBoxb . add ( Box . createGlue ( ) ) ; hBoxb . add ( close , BorderLayout . EAST ) ; vBox . add ( hBoxb ) ; dialog . getContentPane ( ) . add ( vBox ) ; dialog . setVisible ( true ) ; }
show some info about this gui
24,657
public int [ ] getAnchors ( ) { int [ ] anchor = new int [ getScoreMatrixDimensions ( ) [ 0 ] - 1 ] ; for ( int i = 0 ; i < anchor . length ; i ++ ) { anchor [ i ] = - 1 ; } for ( int i = 0 ; i < anchors . size ( ) ; i ++ ) { anchor [ anchors . get ( i ) . getQueryIndex ( ) ] = anchors . get ( i ) . getTargetIndex ( ) ; } return anchor ; }
Returns the list of anchors . The populated elements correspond to query compounds with a connection established to a target compound .
24,658
public void setAnchors ( int [ ] anchors ) { super . anchors = new ArrayList < Anchor > ( ) ; if ( anchors != null ) { for ( int i = 0 ; i < anchors . length ; i ++ ) { if ( anchors [ i ] >= 0 ) { addAnchor ( i , anchors [ i ] ) ; } } } }
Sets the starting list of anchors before running the alignment routine .
24,659
public static LinkedHashMap < String , ProteinSequence > readGenbankProteinSequence ( File file ) throws Exception { FileInputStream inStream = new FileInputStream ( file ) ; LinkedHashMap < String , ProteinSequence > proteinSequences = readGenbankProteinSequence ( inStream ) ; inStream . close ( ) ; return proteinSequences ; }
Read a Genbank file containing amino acids with setup that would handle most cases .
24,660
public static LinkedHashMap < String , ProteinSequence > readGenbankProteinSequence ( InputStream inStream ) throws Exception { GenbankReader < ProteinSequence , AminoAcidCompound > GenbankReader = new GenbankReader < ProteinSequence , AminoAcidCompound > ( inStream , new GenericGenbankHeaderParser < ProteinSequence , AminoAcidCompound > ( ) , new ProteinSequenceCreator ( AminoAcidCompoundSet . getAminoAcidCompoundSet ( ) ) ) ; return GenbankReader . process ( ) ; }
Read a Genbank file containing amino acids with setup that would handle most cases . User is responsible for closing InputStream because you opened it
24,661
public static LinkedHashMap < String , DNASequence > readGenbankDNASequence ( InputStream inStream ) throws Exception { GenbankReader < DNASequence , NucleotideCompound > GenbankReader = new GenbankReader < DNASequence , NucleotideCompound > ( inStream , new GenericGenbankHeaderParser < DNASequence , NucleotideCompound > ( ) , new DNASequenceCreator ( DNACompoundSet . getDNACompoundSet ( ) ) ) ; return GenbankReader . process ( ) ; }
Read a Genbank DNA sequence
24,662
public static LinkedHashMap < String , RNASequence > readGenbankRNASequence ( InputStream inStream ) throws Exception { GenbankReader < RNASequence , NucleotideCompound > GenbankReader = new GenbankReader < RNASequence , NucleotideCompound > ( inStream , new GenericGenbankHeaderParser < RNASequence , NucleotideCompound > ( ) , new RNASequenceCreator ( RNACompoundSet . getRNACompoundSet ( ) ) ) ; return GenbankReader . process ( ) ; }
Read a Genbank RNA sequence
24,663
private void loadRepresentativeDomains ( ) throws IOException { URL u = null ; try { u = new URL ( RemoteScopInstallation . DEFAULT_SERVER + "getRepresentativeScopDomains" ) ; } catch ( MalformedURLException e ) { throw new IOException ( "URL " + RemoteScopInstallation . DEFAULT_SERVER + "getRepresentativeScopDomains" + " is wrong" , e ) ; } logger . info ( "Using " + u + " to download representative domains" ) ; InputStream response = URLConnectionTools . getInputStream ( u ) ; String xml = JFatCatClient . convertStreamToString ( response ) ; ScopDomains results = ScopDomains . fromXML ( xml ) ; logger . info ( "got " + results . getScopDomain ( ) . size ( ) + " domain ranges for Scop domains from server." ) ; for ( ScopDomain dom : results . getScopDomain ( ) ) { String scopId = dom . getScopId ( ) ; serializedCache . put ( scopId , dom ) ; } }
get the ranges of representative domains from the centralized server
24,664
public static final double getDistance ( Atom a , Atom b ) { double x = a . getX ( ) - b . getX ( ) ; double y = a . getY ( ) - b . getY ( ) ; double z = a . getZ ( ) - b . getZ ( ) ; double s = x * x + y * y + z * z ; return Math . sqrt ( s ) ; }
calculate distance between two atoms .
24,665
public static final double angle ( Atom a , Atom b ) { Vector3d va = new Vector3d ( a . getCoordsAsPoint3d ( ) ) ; Vector3d vb = new Vector3d ( b . getCoordsAsPoint3d ( ) ) ; return Math . toDegrees ( va . angle ( vb ) ) ; }
Gets the angle between two vectors
24,666
public static final Atom unitVector ( Atom a ) { double amount = amount ( a ) ; double [ ] coords = new double [ 3 ] ; coords [ 0 ] = a . getX ( ) / amount ; coords [ 1 ] = a . getY ( ) / amount ; coords [ 2 ] = a . getZ ( ) / amount ; a . setCoords ( coords ) ; return a ; }
Returns the unit vector of vector a .
24,667
public static final double getPhi ( AminoAcid a , AminoAcid b ) throws StructureException { if ( ! isConnected ( a , b ) ) { throw new StructureException ( "can not calc Phi - AminoAcids are not connected!" ) ; } Atom a_C = a . getC ( ) ; Atom b_N = b . getN ( ) ; Atom b_CA = b . getCA ( ) ; Atom b_C = b . getC ( ) ; if ( b_CA == null ) throw new StructureException ( "Can not calculate Phi, CA atom is missing" ) ; return torsionAngle ( a_C , b_N , b_CA , b_C ) ; }
Calculate the phi angle .
24,668
public static final double getPsi ( AminoAcid a , AminoAcid b ) throws StructureException { if ( ! isConnected ( a , b ) ) { throw new StructureException ( "can not calc Psi - AminoAcids are not connected!" ) ; } Atom a_N = a . getN ( ) ; Atom a_CA = a . getCA ( ) ; Atom a_C = a . getC ( ) ; Atom b_N = b . getN ( ) ; if ( a_CA == null ) throw new StructureException ( "Can not calculate Psi, CA atom is missing" ) ; return torsionAngle ( a_N , a_CA , a_C , b_N ) ; }
Calculate the psi angle .
24,669
public static final boolean isConnected ( AminoAcid a , AminoAcid b ) { Atom C = null ; Atom N = null ; C = a . getC ( ) ; N = b . getN ( ) ; if ( C == null || N == null ) return false ; double distance = getDistance ( C , N ) ; return distance < 2.5 ; }
Test if two amino acids are connected i . e . if the distance from C to N < 2 . 5 Angstrom .
24,670
public static final void rotate ( Atom atom , double [ ] [ ] m ) { double x = atom . getX ( ) ; double y = atom . getY ( ) ; double z = atom . getZ ( ) ; double nx = m [ 0 ] [ 0 ] * x + m [ 0 ] [ 1 ] * y + m [ 0 ] [ 2 ] * z ; double ny = m [ 1 ] [ 0 ] * x + m [ 1 ] [ 1 ] * y + m [ 1 ] [ 2 ] * z ; double nz = m [ 2 ] [ 0 ] * x + m [ 2 ] [ 1 ] * y + m [ 2 ] [ 2 ] * z ; atom . setX ( nx ) ; atom . setY ( ny ) ; atom . setZ ( nz ) ; }
Rotate a single Atom aroud a rotation matrix . The rotation Matrix must be a pre - multiplication 3x3 Matrix .
24,671
public static final void rotate ( Structure structure , double [ ] [ ] rotationmatrix ) throws StructureException { if ( rotationmatrix . length != 3 ) { throw new StructureException ( "matrix does not have size 3x3 !" ) ; } AtomIterator iter = new AtomIterator ( structure ) ; while ( iter . hasNext ( ) ) { Atom atom = iter . next ( ) ; Calc . rotate ( atom , rotationmatrix ) ; } }
Rotate a structure . The rotation Matrix must be a pre - multiplication Matrix .
24,672
public static final void rotate ( Group group , double [ ] [ ] rotationmatrix ) throws StructureException { if ( rotationmatrix . length != 3 ) { throw new StructureException ( "matrix does not have size 3x3 !" ) ; } AtomIterator iter = new AtomIterator ( group ) ; while ( iter . hasNext ( ) ) { Atom atom = null ; atom = iter . next ( ) ; rotate ( atom , rotationmatrix ) ; } }
Rotate a Group . The rotation Matrix must be a pre - multiplication Matrix .
24,673
public static final void rotate ( Atom atom , Matrix m ) { double x = atom . getX ( ) ; double y = atom . getY ( ) ; double z = atom . getZ ( ) ; double [ ] [ ] ad = new double [ ] [ ] { { x , y , z } } ; Matrix am = new Matrix ( ad ) ; Matrix na = am . times ( m ) ; atom . setX ( na . get ( 0 , 0 ) ) ; atom . setY ( na . get ( 0 , 1 ) ) ; atom . setZ ( na . get ( 0 , 2 ) ) ; }
Rotate an Atom around a Matrix object . The rotation Matrix must be a pre - multiplication Matrix .
24,674
public static final void rotate ( Group group , Matrix m ) { AtomIterator iter = new AtomIterator ( group ) ; while ( iter . hasNext ( ) ) { Atom atom = iter . next ( ) ; rotate ( atom , m ) ; } }
Rotate a group object . The rotation Matrix must be a pre - multiplication Matrix .
24,675
public static final void rotate ( Structure structure , Matrix m ) { AtomIterator iter = new AtomIterator ( structure ) ; while ( iter . hasNext ( ) ) { Atom atom = iter . next ( ) ; rotate ( atom , m ) ; } }
Rotate a structure object . The rotation Matrix must be a pre - multiplication Matrix .
24,676
public static void transform ( Atom [ ] ca , Matrix4d t ) { for ( Atom atom : ca ) Calc . transform ( atom , t ) ; }
Transform an array of atoms at once . The transformation Matrix must be a post - multiplication Matrix .
24,677
public static final void plus ( Structure s , Matrix matrix ) { AtomIterator iter = new AtomIterator ( s ) ; Atom oldAtom = null ; Atom rotOldAtom = null ; while ( iter . hasNext ( ) ) { Atom atom = null ; atom = iter . next ( ) ; try { if ( oldAtom != null ) { logger . debug ( "before {}" , getDistance ( oldAtom , atom ) ) ; } } catch ( Exception e ) { logger . error ( "Exception: " , e ) ; } oldAtom = ( Atom ) atom . clone ( ) ; double x = atom . getX ( ) ; double y = atom . getY ( ) ; double z = atom . getZ ( ) ; double [ ] [ ] ad = new double [ ] [ ] { { x , y , z } } ; Matrix am = new Matrix ( ad ) ; Matrix na = am . plus ( matrix ) ; double [ ] coords = new double [ 3 ] ; coords [ 0 ] = na . get ( 0 , 0 ) ; coords [ 1 ] = na . get ( 0 , 1 ) ; coords [ 2 ] = na . get ( 0 , 2 ) ; atom . setCoords ( coords ) ; try { if ( rotOldAtom != null ) { logger . debug ( "after {}" , getDistance ( rotOldAtom , atom ) ) ; } } catch ( Exception e ) { logger . error ( "Exception: " , e ) ; } rotOldAtom = ( Atom ) atom . clone ( ) ; } }
calculate structure + Matrix coodinates ...
24,678
public static final void shift ( Structure structure , Atom a ) { AtomIterator iter = new AtomIterator ( structure ) ; while ( iter . hasNext ( ) ) { Atom atom = null ; atom = iter . next ( ) ; Atom natom = add ( atom , a ) ; double x = natom . getX ( ) ; double y = natom . getY ( ) ; double z = natom . getZ ( ) ; atom . setX ( x ) ; atom . setY ( y ) ; atom . setZ ( z ) ; } }
shift a structure with a vector .
24,679
public static final void shift ( Atom a , Atom b ) { Atom natom = add ( a , b ) ; double x = natom . getX ( ) ; double y = natom . getY ( ) ; double z = natom . getZ ( ) ; a . setX ( x ) ; a . setY ( y ) ; a . setZ ( z ) ; }
Shift a vector .
24,680
public static final Atom getCentroid ( Atom [ ] atomSet ) { if ( atomSet . length == 0 ) throw new IllegalArgumentException ( "Atom array has length 0, can't calculate centroid!" ) ; double [ ] coords = new double [ 3 ] ; coords [ 0 ] = 0 ; coords [ 1 ] = 0 ; coords [ 2 ] = 0 ; for ( Atom a : atomSet ) { coords [ 0 ] += a . getX ( ) ; coords [ 1 ] += a . getY ( ) ; coords [ 2 ] += a . getZ ( ) ; } int n = atomSet . length ; coords [ 0 ] = coords [ 0 ] / n ; coords [ 1 ] = coords [ 1 ] / n ; coords [ 2 ] = coords [ 2 ] / n ; Atom vec = new AtomImpl ( ) ; vec . setCoords ( coords ) ; return vec ; }
Returns the centroid of the set of atoms .
24,681
public static Atom centerOfMass ( Atom [ ] points ) { Atom center = new AtomImpl ( ) ; float totalMass = 0.0f ; for ( Atom a : points ) { float mass = a . getElement ( ) . getAtomicMass ( ) ; totalMass += mass ; center = scaleAdd ( mass , a , center ) ; } center = scaleEquals ( center , 1.0f / totalMass ) ; return center ; }
Returns the center of mass of the set of atoms . Atomic masses of the Atoms are used .
24,682
public static Atom scale ( Atom a , double s ) { double x = a . getX ( ) ; double y = a . getY ( ) ; double z = a . getZ ( ) ; Atom b = new AtomImpl ( ) ; b . setX ( x * s ) ; b . setY ( y * s ) ; b . setZ ( z * s ) ; return b ; }
Multiply elements of a by s
24,683
public static final Atom getCenterVector ( Atom [ ] atomSet ) { Atom centroid = getCentroid ( atomSet ) ; return getCenterVector ( atomSet , centroid ) ; }
Returns the Vector that needs to be applied to shift a set of atoms to the Centroid .
24,684
public static final Atom getCenterVector ( Atom [ ] atomSet , Atom centroid ) { double [ ] coords = new double [ 3 ] ; coords [ 0 ] = 0 - centroid . getX ( ) ; coords [ 1 ] = 0 - centroid . getY ( ) ; coords [ 2 ] = 0 - centroid . getZ ( ) ; Atom shiftVec = new AtomImpl ( ) ; shiftVec . setCoords ( coords ) ; return shiftVec ; }
Returns the Vector that needs to be applied to shift a set of atoms to the Centroid if the centroid is already known
24,685
public static final Atom [ ] centerAtoms ( Atom [ ] atomSet ) throws StructureException { Atom centroid = getCentroid ( atomSet ) ; return centerAtoms ( atomSet , centroid ) ; }
Center the atoms at the Centroid .
24,686
public static final Atom [ ] centerAtoms ( Atom [ ] atomSet , Atom centroid ) throws StructureException { Atom shiftVector = getCenterVector ( atomSet , centroid ) ; Atom [ ] newAtoms = new AtomImpl [ atomSet . length ] ; for ( int i = 0 ; i < atomSet . length ; i ++ ) { Atom a = atomSet [ i ] ; Atom n = add ( a , shiftVector ) ; newAtoms [ i ] = n ; } return newAtoms ; }
Center the atoms at the Centroid if the centroid is already know .
24,687
public static final Atom createVirtualCBAtom ( AminoAcid amino ) throws StructureException { AminoAcid ala = StandardAminoAcid . getAminoAcid ( "ALA" ) ; Atom aN = ala . getN ( ) ; Atom aCA = ala . getCA ( ) ; Atom aC = ala . getC ( ) ; Atom aCB = ala . getCB ( ) ; Atom [ ] arr1 = new Atom [ 3 ] ; arr1 [ 0 ] = aN ; arr1 [ 1 ] = aCA ; arr1 [ 2 ] = aC ; Atom [ ] arr2 = new Atom [ 3 ] ; arr2 [ 0 ] = amino . getN ( ) ; arr2 [ 1 ] = amino . getCA ( ) ; arr2 [ 2 ] = amino . getC ( ) ; SuperPositionSVD svd = new SuperPositionSVD ( false ) ; Matrix4d transform = svd . superpose ( Calc . atomsToPoints ( arr1 ) , Calc . atomsToPoints ( arr2 ) ) ; Matrix rotMatrix = Matrices . getRotationJAMA ( transform ) ; Atom tranMatrix = getTranslationVector ( transform ) ; Calc . rotate ( aCB , rotMatrix ) ; Atom virtualCB = Calc . add ( aCB , tranMatrix ) ; virtualCB . setName ( "CB" ) ; return virtualCB ; }
creates a virtual C - beta atom . this might be needed when working with GLY
24,688
public static double calcRotationAngleInDegrees ( Atom centerPt , Atom targetPt ) { double theta = Math . atan2 ( targetPt . getY ( ) - centerPt . getY ( ) , targetPt . getX ( ) - centerPt . getX ( ) ) ; theta += Math . PI / 2.0 ; double angle = Math . toDegrees ( theta ) ; if ( angle < 0 ) { angle += 360 ; } return angle ; }
Calculates the angle from centerPt to targetPt in degrees . The return should range from [ 0 360 ) rotating CLOCKWISE 0 and 360 degrees represents NORTH 90 degrees represents EAST etc ...
24,689
public static void shift ( Atom [ ] ca , Atom b ) { for ( Atom atom : ca ) Calc . shift ( atom , b ) ; }
Shift an array of atoms at once .
24,690
public static Matrix4d getTransformation ( Matrix rot , Atom trans ) { return new Matrix4d ( new Matrix3d ( rot . getColumnPackedCopy ( ) ) , new Vector3d ( trans . getCoordsAsPoint3d ( ) ) , 1.0 ) ; }
Convert JAMA rotation and translation to a Vecmath transformation matrix . Because the JAMA matrix is a pre - multiplication matrix and the Vecmath matrix is a post - multiplication one the rotation matrix is transposed to ensure that the transformation they produce is the same .
24,691
public static Atom getTranslationVector ( Matrix4d transform ) { Atom transl = new AtomImpl ( ) ; double [ ] coords = { transform . m03 , transform . m13 , transform . m23 } ; transl . setCoords ( coords ) ; return transl ; }
Extract the translational vector as an Atom of a transformation matrix .
24,692
public static double rmsd ( Atom [ ] x , Atom [ ] y ) { return CalcPoint . rmsd ( atomsToPoints ( x ) , atomsToPoints ( y ) ) ; }
Calculate the RMSD of two Atom arrays already superposed .
24,693
public static < T extends Enum < ? > > String getEnumValuesAsString ( Class < T > enumClass ) { T [ ] vals = enumClass . getEnumConstants ( ) ; StringBuilder str = new StringBuilder ( ) ; if ( vals . length == 1 ) { str . append ( vals [ 0 ] . name ( ) ) ; } else if ( vals . length > 1 ) { for ( int i = 0 ; i < vals . length - 1 ; i ++ ) { str . append ( vals [ i ] . name ( ) ) ; str . append ( ", " ) ; } str . append ( "or " ) ; str . append ( vals [ vals . length - 1 ] . name ( ) ) ; } return str . toString ( ) ; }
Constructs a comma - separated list of values for an enum .
24,694
public UnitCellBoundingBox getTranslatedBbs ( Vector3d translation ) { UnitCellBoundingBox translatedBbs = new UnitCellBoundingBox ( numOperatorsSg , numPolyChainsAu ) ; for ( int i = 0 ; i < numOperatorsSg ; i ++ ) { for ( int j = 0 ; j < numPolyChainsAu ; j ++ ) { translatedBbs . chainBbs [ i ] [ j ] = new BoundingBox ( this . chainBbs [ i ] [ j ] ) ; translatedBbs . chainBbs [ i ] [ j ] . translate ( translation ) ; } translatedBbs . auBbs [ i ] = new BoundingBox ( translatedBbs . chainBbs [ i ] ) ; } return translatedBbs ; }
Returns a new BoundingBoxes object containing the same bounds as this BoundingBoxes object translated by the given translation
24,695
private static void releaseReferences ( ) { synchronized ( versionedEcodDBs ) { Iterator < Entry < String , SoftReference < EcodDatabase > > > it = versionedEcodDBs . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Entry < String , SoftReference < EcodDatabase > > entry = it . next ( ) ; SoftReference < EcodDatabase > ref = entry . getValue ( ) ; if ( ref . get ( ) == null ) { logger . debug ( "Removed version {} from EcodFactory to save memory." , entry . getKey ( ) ) ; it . remove ( ) ; } } } }
removes SoftReferences which have already been garbage collected
24,696
public AbstractSequence < AminoAcidCompound > getSequence ( List < AminoAcidCompound > list ) { AbstractSequence < AminoAcidCompound > seq = super . getSequence ( list ) ; Collection < Object > strCase = new ArrayList < Object > ( seq . getLength ( ) ) ; for ( int i = 0 ; i < seq . getLength ( ) ; i ++ ) { strCase . add ( true ) ; } seq . setUserCollection ( strCase ) ; return seq ; }
Assumes all compounds were uppercase
24,697
private static List < Object > getStringCase ( String str ) { List < Object > types = new ArrayList < Object > ( str . length ( ) ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { types . add ( Character . isUpperCase ( str . charAt ( i ) ) ) ; } return types ; }
Returns a list of Booleans of the same length as the input specifying whether each character was uppercase or not .
24,698
public static SortedSet < String > getAll ( ) { SortedSet < String > representatives = new TreeSet < String > ( ) ; try { URL u = new URL ( allUrl ) ; InputStream stream = URLConnectionTools . getInputStream ( u , 60000 ) ; if ( stream != null ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( stream ) ) ; String line = null ; while ( ( line = reader . readLine ( ) ) != null ) { int index = line . lastIndexOf ( "structureId=" ) ; if ( index > 0 ) { representatives . add ( line . substring ( index + 13 , index + 17 ) ) ; } } } } catch ( Exception e ) { e . printStackTrace ( ) ; } return representatives ; }
Returns the current list of all PDB IDs .
24,699
private static void lazyInit ( ) { if ( components == null ) { components = new HashSet < Component > ( ) ; nonTerminalComps = new HashMap < Set < String > , Component > ( ) ; nTerminalAminoAcids = new HashMap < Set < String > , Component > ( ) ; cTerminalAminoAcids = new HashMap < Set < String > , Component > ( ) ; } }
Lazy initialization of the static variables .