idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
17,900 | private static boolean hasModification ( MonomerNotationUnitRNA monomerNotation ) { if ( monomerNotation . getUnit ( ) . contains ( "[" ) || monomerNotation . getUnit ( ) . contains ( "(X)" ) || monomerNotation . getUnit ( ) . endsWith ( ")" ) ) { return true ; } return false ; } | method to check if the MonomerNotationUnitRNA contains modification |
17,901 | public static List < ConnectionNotation > hybridizeAntiparallel ( PolymerNotation one , PolymerNotation two ) throws RNAUtilsException , NotationException , HELM2HandledException , ChemistryException , NucleotideLoadingException { checkRNA ( one ) ; checkRNA ( two ) ; List < ConnectionNotation > connections = new ArrayList < ConnectionNotation > ( ) ; ConnectionNotation connection ; if ( areAntiparallel ( one , two ) ) { for ( int i = 0 ; i < PolymerUtils . getTotalMonomerCount ( one ) ; i ++ ) { int backValue = PolymerUtils . getTotalMonomerCount ( one ) - i ; int firstValue = i + 1 ; String details = firstValue + ":pair-" + backValue + ":pair" ; connection = new ConnectionNotation ( one . getPolymerID ( ) , two . getPolymerID ( ) , details ) ; connections . add ( connection ) ; } return connections ; } else { throw new RNAUtilsException ( "The given RNAs are not antiparallel to each other" ) ; } } | method to hybridize two PolymerNotations together if they are antiparallel |
17,902 | public static String getSequence ( PolymerNotation one ) throws RNAUtilsException , HELM2HandledException , ChemistryException { checkRNA ( one ) ; List < Nucleotide > nucleotideList = getNucleotideList ( one ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < nucleotideList . size ( ) ; i ++ ) { sb . append ( nucleotideList . get ( i ) . getNaturalAnalog ( ) ) ; } return sb . toString ( ) ; } | method to get the rna sequence of the given PolymerNotation |
17,903 | public static String getModifiedNucleotideSequence ( PolymerNotation polymer ) throws RNAUtilsException , HELM2HandledException , ChemistryException { checkRNA ( polymer ) ; List < Nucleotide > nucleotides = getNucleotideList ( polymer ) ; StringBuilder sb = new StringBuilder ( ) ; for ( Nucleotide nucleotide : nucleotides ) { sb . append ( nucleotide . getSymbol ( ) ) ; } return sb . toString ( ) ; } | method to get the modifiedNucleotideSequence of the given PolymerNotation |
17,904 | public static String getNucleotideSequence ( PolymerNotation polymer ) throws NotationException , RNAUtilsException , HELM2HandledException , NucleotideLoadingException , ChemistryException { List < Nucleotide > nucleotides = getNucleotideList ( polymer ) ; StringBuffer sb = new StringBuffer ( ) ; int count = 0 ; Map < String , String > reverseNucMap = NucleotideFactory . getInstance ( ) . getReverseNucleotideTemplateMap ( ) ; for ( Nucleotide nuc : nucleotides ) { String nucleotide = nuc . getNotation ( ) ; String nucleoside = nuc . getNucleosideNotation ( ) ; String linker = nuc . getLinkerNotation ( ) ; if ( count == 0 && nucleoside . length ( ) == 0 ) { sb . append ( nuc . getPhosphateMonomer ( ) . getAlternateId ( ) ) ; count ++ ; continue ; } if ( count == nucleotides . size ( ) - 1 && linker . length ( ) == 0 ) { nucleotide = nucleotide + Monomer . ID_P ; } if ( reverseNucMap . containsKey ( nucleotide ) ) { sb . append ( reverseNucMap . get ( nucleotide ) ) ; } else { throw new NotationException ( "Unknown nucleotide found for " + nucleotide + " : missing nucleotide template" ) ; } count ++ ; } return sb . toString ( ) ; } | method to get the nucleotide sequence for the polymer |
17,905 | public static List < Nucleotide > getNucleotideList ( PolymerNotation polymer ) throws RNAUtilsException , HELM2HandledException , ChemistryException { checkRNA ( polymer ) ; List < Nucleotide > nucleotides = new ArrayList < Nucleotide > ( ) ; List < MonomerNotation > monomerNotations = polymer . getPolymerElements ( ) . getListOfElements ( ) ; for ( int i = 0 ; i < monomerNotations . size ( ) ; i ++ ) { MonomerNotation monomerNotation = monomerNotations . get ( i ) ; if ( ( ! ( monomerNotation instanceof MonomerNotationUnitRNA ) ) || Integer . parseInt ( monomerNotation . getCount ( ) ) != 1 ) { LOG . info ( "MonomerNotation contains HELM2 Elements " + monomerNotation ) ; throw new HELM2HandledException ( "HELM2 Elements are involved" ) ; } try { boolean last = false ; if ( i == monomerNotations . size ( ) - 1 ) { last = true ; } nucleotides . add ( NucleotideParser . convertToNucleotide ( monomerNotation . getUnit ( ) , last ) ) ; } catch ( MonomerException | NucleotideLoadingException | NotationException | org . helm . notation2 . exception . NotationException e ) { e . printStackTrace ( ) ; throw new RNAUtilsException ( "Nucleotide can not be read " + e . getMessage ( ) ) ; } } return nucleotides ; } | method to get all nucleotides for one polymer |
17,906 | public static String getTrimmedNucleotideSequence ( PolymerNotation polymer ) throws RNAUtilsException , HELM2HandledException , ChemistryException { checkRNA ( polymer ) ; List < Nucleotide > list = getNucleotideList ( polymer ) ; int start = 0 ; Nucleotide na = list . get ( start ) ; while ( null == na . getBaseMonomer ( ) ) { start ++ ; na = list . get ( start ) ; } int end = list . size ( ) - 1 ; na = list . get ( end ) ; while ( null == na . getBaseMonomer ( ) ) { end -- ; na = list . get ( end ) ; } StringBuffer sb = new StringBuffer ( ) ; for ( int i = start ; i <= end ; i ++ ) { sb . append ( list . get ( i ) . getNaturalAnalog ( ) ) ; } return sb . toString ( ) ; } | method to get the trimmed nucleotide sequence |
17,907 | public static JKExceptionHandlerFactory getInstance ( ) { if ( JKExceptionHandlerFactory . instance == null ) { JKExceptionHandlerFactory . instance = new JKExceptionHandlerFactory ( ) ; } return JKExceptionHandlerFactory . instance ; } | Gets the single instance of ExceptionHandlerFactory . |
17,908 | public void setHandler ( final Class < ? extends Throwable > clas , final JKExceptionHandler handler ) { this . handlers . put ( clas , handler ) ; } | Sets the handler . |
17,909 | public void registerHanders ( String packageString ) { List < String > list = AnnotationDetector . scanAsList ( ExceptionHandler . class , packageString ) ; for ( String handler : list ) { JKExceptionHandler < ? extends Throwable > newInstance = JKObjectUtil . newInstance ( handler ) ; Class < ? extends Throwable > clas = JKObjectUtil . getGenericParamter ( handler ) ; setHandler ( clas , newInstance ) ; } } | Register handers . |
17,910 | public boolean unmodifiedWithoutPhosphate ( ) { if ( getNotation ( ) == null ) { return true ; } else { if ( getNotation ( ) . contains ( "[" ) || getNotation ( ) . contains ( "X" ) ) { return false ; } else { return true ; } } } | Returns true if the nucleotide is unmodified except for a missing phosphate group . If the nucleotide notation is empty it returns true . |
17,911 | public Monomer getBaseMonomer ( MonomerStore monomerStore ) { String baseSymbol = getBaseSymbol ( ) ; if ( baseSymbol != null && ! baseSymbol . equalsIgnoreCase ( "" ) ) { try { Map < String , Monomer > monomers = monomerStore . getMonomers ( Monomer . NUCLIEC_ACID_POLYMER_TYPE ) ; Monomer m = monomers . get ( baseSymbol ) ; return m ; } catch ( Exception ex ) { LOG . info ( "Unable to get base monomer for " + baseSymbol ) ; return null ; } } else { return null ; } } | get the base monomer the return value could be null if this nucleotide does not have a base |
17,912 | public Monomer getSugarMonomer ( MonomerStore monomerStore ) { String sugarSymbol = getSugarSymbol ( ) ; if ( sugarSymbol != null && ! sugarSymbol . equalsIgnoreCase ( "" ) ) { try { Map < String , Monomer > monomers = monomerStore . getMonomers ( Monomer . NUCLIEC_ACID_POLYMER_TYPE ) ; Monomer m = monomers . get ( sugarSymbol ) ; return m ; } catch ( Exception ex ) { LOG . info ( "Unable to get sugar monomer for " + sugarSymbol ) ; return null ; } } else { return null ; } } | get the sugar monomer the return value could be null if the nucleotide does not has a sugar |
17,913 | public String getLinkerNotation ( ) { String pSymbol = getPhosphateSymbol ( ) ; String result = null ; if ( null == pSymbol || pSymbol . length ( ) == 0 ) { result = "" ; } else { if ( pSymbol . length ( ) > 1 ) result = "[" + pSymbol + "]" ; else result = pSymbol ; } return result ; } | This method returns the HELM notation for nucleotide linker |
17,914 | public String getNucleosideNotation ( ) { int linkerLen = getLinkerNotation ( ) . length ( ) ; return notation . substring ( 0 , notation . length ( ) - linkerLen ) ; } | This method returns the HELM notation for nucleoside |
17,915 | public void addMonomer ( Monomer monomer , boolean dbChanged ) throws IOException , MonomerException { Map < String , Monomer > monomerMap = monomerDB . get ( monomer . getPolymerType ( ) ) ; String polymerType = monomer . getPolymerType ( ) ; String alternateId = monomer . getAlternateId ( ) ; String smilesString = monomer . getCanSMILES ( ) ; try { smilesString = SMILES . getUniqueExtendedSMILES ( smilesString ) ; } catch ( Exception e ) { smilesString = monomer . getCanSMILES ( ) ; } boolean hasSmilesString = ( smilesString != null && smilesString . length ( ) > 0 ) ; if ( null == monomerMap ) { monomerMap = new TreeMap < String , Monomer > ( String . CASE_INSENSITIVE_ORDER ) ; monomerDB . put ( polymerType , monomerMap ) ; } Monomer copyMonomer = DeepCopy . copy ( monomer ) ; if ( hasSmilesString ) { copyMonomer . setCanSMILES ( smilesString ) ; } boolean alreadyAdded = false ; alreadyAdded = monomerMap . containsKey ( alternateId ) ; if ( ! alreadyAdded ) { monomerMap . put ( alternateId , copyMonomer ) ; boolean alreadyInSMILESMap = hasSmilesString && ( smilesMonomerDB . containsKey ( smilesString ) ) ; if ( ! alreadyInSMILESMap ) { smilesMonomerDB . put ( smilesString , copyMonomer ) ; } } if ( dbChanged ) { MonomerFactory . setDBChanged ( true ) ; } } | Adds a monomer to the store and optionally sets the dbChanged flag |
17,916 | public boolean hasMonomer ( String polymerType , String alternateId ) { return ( ( monomerDB . get ( polymerType ) != null ) && getMonomer ( polymerType , alternateId ) != null ) ; } | Checks if a specific monomer exists in the store |
17,917 | public Monomer getMonomer ( String polymerType , String alternateId ) { Map < String , Monomer > map1 = monomerDB . get ( polymerType ) ; return monomerDB . get ( polymerType ) . get ( alternateId ) ; } | Returns the monomer specified by polymerType and alternatId |
17,918 | public synchronized void addNewMonomer ( Monomer monomer ) throws IOException , MonomerException { monomer . setNewMonomer ( true ) ; addMonomer ( monomer , true ) ; } | Adds a monomer to the store and makes it a temporary new monomer |
17,919 | public List < Monomer > getAllMonomersList ( ) { List < Monomer > monomers = new ArrayList < Monomer > ( ) ; for ( String polymerType : getPolymerTypeSet ( ) ) { Map < String , Monomer > map = getMonomers ( polymerType ) ; monomers . addAll ( map . values ( ) ) ; } return monomers ; } | This method returns all monomers of the store as list sorted by polymer type |
17,920 | public final static void addAnnotation ( final AnnotationNotation notation , final int position , final HELM2Notation helm2notation ) { helm2notation . getListOfAnnotations ( ) . add ( position , notation ) ; } | method to add an annotation at a specific position of the HELM2Notation |
17,921 | public final static void changeAnnotation ( final AnnotationNotation notation , final int position , final HELM2Notation helm2notation ) { helm2notation . getListOfAnnotations ( ) . set ( position , notation ) ; } | method to change an annotation at the position of the HELM2Notation |
17,922 | public final static void addConnection ( final ConnectionNotation notation , final int position , final HELM2Notation helm2notation ) { helm2notation . getListOfConnections ( ) . add ( position , notation ) ; } | method to add a new connection at the position of the HELM2Notation |
17,923 | public final static void changeConnection ( final int position , final ConnectionNotation notation , final HELM2Notation helm2notation ) { helm2notation . getListOfConnections ( ) . set ( position , notation ) ; } | method to change a connection at the position of the HELM2Notation |
17,924 | public final static void addAnnotationToConnection ( final int position , final String annotation , final HELM2Notation helm2notation ) { helm2notation . getListOfConnections ( ) . get ( position ) . setAnnotation ( annotation ) ; } | method to add an annotation to a connection of the HELM2Notation |
17,925 | public final static void addGroup ( final GroupingNotation notation , final int position , final HELM2Notation helm2notation ) { helm2notation . getListOfGroupings ( ) . add ( position , notation ) ; } | method to add a group to the grouping section of the HELM2Notation |
17,926 | public final static void changeGroup ( final GroupingNotation notation , final int position , final HELM2Notation helm2notation ) { helm2notation . getListOfGroupings ( ) . set ( position , notation ) ; } | method to change a group of the HELM2Notation |
17,927 | public final static PolymerNotation addAnnotationToPolymer ( final PolymerNotation polymer , final String annotation ) { if ( polymer . getAnnotation ( ) != null ) { return new PolymerNotation ( polymer . getPolymerID ( ) , polymer . getPolymerElements ( ) , polymer . getAnnotation ( ) + " | " + annotation ) ; } return new PolymerNotation ( polymer . getPolymerID ( ) , polymer . getPolymerElements ( ) , annotation ) ; } | method to add an annotation to a PolymerNotation |
17,928 | public final static PolymerNotation removeAnnotationOfPolmyer ( PolymerNotation polymer ) { return new PolymerNotation ( polymer . getPolymerID ( ) , polymer . getPolymerElements ( ) , null ) ; } | method to remove a current annotation of a PolymerNotation |
17,929 | public final static PolymerNotation addMonomerNotation ( int position , PolymerNotation polymer , MonomerNotation monomerNotation ) { polymer . getPolymerElements ( ) . getListOfElements ( ) . add ( position , monomerNotation ) ; return polymer ; } | method to add a new MonomerNotation to a PolymerNotation |
17,930 | public final static void changeMonomerNotation ( int position , PolymerNotation polymer , MonomerNotation not ) { polymer . getPolymerElements ( ) . getListOfElements ( ) . set ( position , not ) ; } | method to change the MonomerNotation on the specific position |
17,931 | public final static void deleteMonomerNotation ( int position , PolymerNotation polymer ) throws NotationException { MonomerNotation monomerNotation = polymer . getPolymerElements ( ) . getListOfElements ( ) . get ( position ) ; if ( polymer . getPolymerElements ( ) . getListOfElements ( ) . size ( ) == 1 ) { throw new NotationException ( monomerNotation . toString ( ) + " can't be removed. Polymer has to have at least one Monomer Notation" ) ; } polymer . getPolymerElements ( ) . getListOfElements ( ) . remove ( monomerNotation ) ; } | method to delete a MonomerNotation at a specific position of the PolymerNotation |
17,932 | public final static void addAnnotationToMonomerNotation ( PolymerNotation polymer , int position , String annotation ) { polymer . getPolymerElements ( ) . getListOfElements ( ) . get ( position ) . setAnnotation ( annotation ) ; } | method to add an annotation to a MonomerNotation |
17,933 | public final static void addCountToMonomerNotation ( PolymerNotation polymer , int position , String count ) { polymer . getPolymerElements ( ) . getListOfElements ( ) . get ( position ) . setCount ( count ) ; } | method to set the count of a MonomerNotation |
17,934 | public final static void deleteAnnotationFromMonomerNotation ( PolymerNotation polymer , int position ) { polymer . getPolymerElements ( ) . getListOfElements ( ) . get ( position ) . setAnnotation ( null ) ; } | method to delete the annotation of a MonomerNotation |
17,935 | public final static void changePolymerNotation ( int position , PolymerNotation polymer , HELM2Notation helm2notation ) { helm2notation . getListOfPolymers ( ) . set ( position , polymer ) ; } | method to change the PolymerNotation at a specific position of the HELM2Notation |
17,936 | public final static void addPolymerNotation ( int position , PolymerNotation polymer , HELM2Notation helm2notation ) { helm2notation . getListOfPolymers ( ) . add ( position , polymer ) ; } | method to add a PolymerNotation at a specific position of the HELM2Notation |
17,937 | public final static void replaceMonomer ( HELM2Notation helm2notation , String polymerType , String existingMonomerID , String newMonomerID ) throws NotationException , MonomerException , ChemistryException , CTKException , IOException , JDOMException { validateMonomerReplacement ( polymerType , existingMonomerID , newMonomerID ) ; for ( int i = 0 ; i < helm2notation . getListOfPolymers ( ) . size ( ) ; i ++ ) { if ( helm2notation . getListOfPolymers ( ) . get ( i ) . getPolymerID ( ) . getType ( ) . equals ( polymerType ) ) { for ( int j = 0 ; j < helm2notation . getListOfPolymers ( ) . get ( i ) . getPolymerElements ( ) . getListOfElements ( ) . size ( ) ; j ++ ) { MonomerNotation monomerNotation = replaceMonomerNotation ( helm2notation . getListOfPolymers ( ) . get ( i ) . getPolymerElements ( ) . getListOfElements ( ) . get ( j ) , existingMonomerID , newMonomerID ) ; if ( monomerNotation != null ) { helm2notation . getListOfPolymers ( ) . get ( i ) . getPolymerElements ( ) . getListOfElements ( ) . set ( j , monomerNotation ) ; } } } } } | method to replace the MonomerID with the new MonomerID for a given polymer type |
17,938 | public final static MonomerNotation replaceMonomerNotation ( MonomerNotation monomerNotation , String existingMonomerID , String newMonomerID ) throws NotationException , ChemistryException , CTKException , MonomerLoadingException { if ( monomerNotation instanceof MonomerNotationUnitRNA ) { List < String > result = generateIDForNucleotide ( ( ( MonomerNotationUnitRNA ) monomerNotation ) , existingMonomerID , newMonomerID ) ; if ( result . get ( 1 ) != null ) { MonomerNotationUnitRNA newObject = new MonomerNotationUnitRNA ( result . get ( 0 ) , monomerNotation . getType ( ) ) ; newObject . setCount ( monomerNotation . getCount ( ) ) ; if ( monomerNotation . isAnnotationTrue ( ) ) { newObject . setAnnotation ( monomerNotation . getAnnotation ( ) ) ; } return newObject ; } } else if ( monomerNotation instanceof MonomerNotationUnit ) { if ( monomerNotation . getUnit ( ) . equals ( existingMonomerID ) ) { return produceMonomerNotationUnitWithOtherID ( monomerNotation , newMonomerID ) ; } } else if ( monomerNotation instanceof MonomerNotationList ) { monomerNotation = replaceMonomerNotationList ( ( ( MonomerNotationList ) monomerNotation ) , existingMonomerID , newMonomerID ) ; if ( monomerNotation != null ) { return monomerNotation ; } } else if ( monomerNotation instanceof MonomerNotationGroup ) { monomerNotation = replaceMonomerNotationGroup ( ( ( MonomerNotationGroup ) monomerNotation ) , existingMonomerID , newMonomerID ) ; if ( monomerNotation != null ) { return monomerNotation ; } } else { throw new NotationException ( "Unknown MonomerNotation Type " + monomerNotation . getClass ( ) ) ; } return null ; } | method to replace the MonomerNotation having the MonomerID with the new MonomerID |
17,939 | public final static MonomerNotationGroup replaceMonomerNotationGroup ( MonomerNotationGroup monomerNotation , String existingMonomerID , String newMonomerID ) throws NotationException { MonomerNotationGroup newObject = null ; boolean hasChanged = false ; StringBuilder sb = new StringBuilder ( ) ; String id = "" ; for ( MonomerNotationGroupElement object : monomerNotation . getListOfElements ( ) ) { if ( object . getMonomerNotation ( ) . getUnit ( ) . equals ( existingMonomerID ) ) { hasChanged = true ; id = generateGroupElement ( newMonomerID , object . getValue ( ) ) ; } else { id = generateGroupElement ( object . getMonomerNotation ( ) . getUnit ( ) , object . getValue ( ) ) ; } if ( monomerNotation instanceof MonomerNotationGroupOr ) { sb . append ( id + "," ) ; } else { sb . append ( id + "+" ) ; } } if ( hasChanged ) { sb . setLength ( sb . length ( ) - 1 ) ; if ( monomerNotation instanceof MonomerNotationGroupOr ) { newObject = new MonomerNotationGroupOr ( sb . toString ( ) , monomerNotation . getType ( ) ) ; } else { newObject = new MonomerNotationGroupMixture ( sb . toString ( ) , monomerNotation . getType ( ) ) ; } } return newObject ; } | method to replace the MonomerNotationGroup having the MonomerID with the new MonomerID |
17,940 | public final static MonomerNotationUnit produceMonomerNotationUnitWithOtherID ( MonomerNotation monomerNotation , String newID ) throws NotationException { MonomerNotationUnit result = new MonomerNotationUnit ( newID , monomerNotation . getType ( ) ) ; if ( monomerNotation . isAnnotationTrue ( ) ) { result . setAnnotation ( monomerNotation . getAnnotation ( ) ) ; } result . setCount ( monomerNotation . getCount ( ) ) ; return result ; } | method to replace the MonomerNotationUnit having the MonomerID with the new MonomerID |
17,941 | public final static MonomerNotationList replaceMonomerNotationList ( MonomerNotationList object , String existingMonomerID , String newMonomerID ) throws NotationException , ChemistryException , CTKException , MonomerLoadingException { MonomerNotationList newObject = null ; boolean hasChanged = false ; StringBuilder sb = new StringBuilder ( ) ; String id = "" ; for ( MonomerNotation element : object . getListofMonomerUnits ( ) ) { if ( element instanceof MonomerNotationUnitRNA ) { List < String > result = generateIDForNucleotide ( ( ( MonomerNotationUnitRNA ) element ) , existingMonomerID , newMonomerID ) ; id = result . get ( 0 ) ; if ( result . get ( 1 ) != null ) { hasChanged = true ; } } else { if ( element . getUnit ( ) . equals ( existingMonomerID ) ) { hasChanged = true ; id = generateIDMonomerNotation ( newMonomerID , element . getCount ( ) , element . getAnnotation ( ) ) ; } else { id = generateIDMonomerNotation ( element . getUnit ( ) , element . getCount ( ) , element . getAnnotation ( ) ) ; } } sb . append ( id + "." ) ; } if ( hasChanged ) { sb . setLength ( sb . length ( ) - 1 ) ; newObject = new MonomerNotationList ( sb . toString ( ) , object . getType ( ) ) ; newObject . setCount ( object . getCount ( ) ) ; if ( object . isAnnotationTrue ( ) ) { newObject . setAnnotation ( object . getAnnotation ( ) ) ; } } return newObject ; } | method to replace the MonomerNotationList having the MonomerID with the new MonomerID |
17,942 | private final static String generateIDMonomerNotation ( String id , String count , String annotation ) { if ( id . length ( ) > 1 ) { id = "[" + id + "]" ; } String result = id ; try { if ( ! ( Integer . parseInt ( count ) == 1 ) ) { result += "'" + count + "'" ; } } catch ( NumberFormatException e ) { result += "'" + count + "'" ; } if ( annotation != null ) { result += "\"" + annotation + "\"" ; } return result ; } | method to generate the MonomerNotation in String format |
17,943 | private final static String generateIDRNA ( String id , String count , String annotation ) throws MonomerLoadingException , ChemistryException , CTKException { String result = id ; if ( result . startsWith ( "[" ) && result . endsWith ( "]" ) ) { result = id . substring ( 1 , id . length ( ) - 1 ) ; } if ( MonomerFactory . getInstance ( ) . getMonomerStore ( ) . getMonomer ( "RNA" , result ) . getMonomerType ( ) . equals ( Monomer . BRANCH_MOMONER_TYPE ) ) { if ( id . length ( ) > 1 ) { result = "[" + id + "]" ; } result = "(" + result + ")" ; } else { if ( id . length ( ) > 1 ) { result = "[" + id + "]" ; } } try { if ( ! ( Integer . parseInt ( count ) == 1 ) ) { result += "'" + count + "'" ; } } catch ( NumberFormatException e ) { result += "'" + count + "'" ; } if ( annotation != null ) { result += "\"" + annotation + "\"" ; } return result ; } | method to generate the MonomerNotation for a RNA |
17,944 | private final static List < String > generateIDForNucleotide ( MonomerNotationUnitRNA object , String existingMonomerID , String newMonomerID ) throws MonomerLoadingException , ChemistryException , CTKException { List < String > result = new ArrayList < String > ( ) ; String hasChanged = null ; StringBuilder sb = new StringBuilder ( ) ; String id = "" ; for ( MonomerNotation element : object . getContents ( ) ) { if ( element . getUnit ( ) . equals ( existingMonomerID ) ) { hasChanged = "" ; id = generateIDRNA ( newMonomerID , element . getCount ( ) , element . getAnnotation ( ) ) ; } else { id = generateIDRNA ( element . getUnit ( ) , element . getCount ( ) , element . getAnnotation ( ) ) ; } sb . append ( id ) ; } try { if ( ! ( Integer . parseInt ( object . getCount ( ) ) == 1 ) ) { sb . append ( "'" + object . getCount ( ) + "'" ) ; } } catch ( NumberFormatException e ) { sb . append ( "'" + object . getCount ( ) + "'" ) ; } if ( object . getAnnotation ( ) != null ) { sb . append ( "\"" + object . getAnnotation ( ) + "\"" ) ; } result . add ( sb . toString ( ) ) ; result . add ( hasChanged ) ; return result ; } | method to replace the MonomerNotationUnitRNA having the MonomerID with the new MonomerID |
17,945 | private static String generateGroupElement ( String id , List < Double > list ) { StringBuilder sb = new StringBuilder ( ) ; if ( list . size ( ) == 1 ) { if ( list . get ( 0 ) == - 1.0 ) { sb . append ( id + ":" ) ; sb . append ( "?" + "-" ) ; } else if ( list . get ( 0 ) == 1.0 ) { sb . append ( id + ":" ) ; } else { sb . append ( id + ":" + list . get ( 0 ) + "-" ) ; } } else { sb . append ( id + ":" ) ; for ( Double item : list ) { sb . append ( item + "-" ) ; } } sb . setLength ( sb . length ( ) - 1 ) ; return sb . toString ( ) ; } | method to generate the MonomerNotationGroupElement in String format |
17,946 | public static final void replaceSMILESWithTemporaryIds ( HELM2Notation helm2notation ) throws NotationException , HELM2HandledException , ChemistryException , CTKException , MonomerLoadingException , JDOMException { for ( int i = 0 ; i < helm2notation . getListOfPolymers ( ) . size ( ) ; i ++ ) { MethodsMonomerUtils . getListOfHandledMonomers ( helm2notation . getListOfPolymers ( ) . get ( i ) . getListMonomers ( ) ) ; for ( int j = 0 ; j < helm2notation . getListOfPolymers ( ) . get ( i ) . getPolymerElements ( ) . getListOfElements ( ) . size ( ) ; j ++ ) { MonomerNotation monomerNotation = replaceSMILESWithTemporaryIdsMonomerNotation ( helm2notation . getListOfPolymers ( ) . get ( i ) . getPolymerElements ( ) . getListOfElements ( ) . get ( j ) ) ; if ( monomerNotation != null ) { helm2notation . getListOfPolymers ( ) . get ( i ) . getPolymerElements ( ) . getListOfElements ( ) . set ( j , monomerNotation ) ; } } } } | This function replaces smiles in complex notation with temporary ids |
17,947 | public static void hybridize ( HELM2Notation helm2notation ) throws NotationException , RNAUtilsException , HELM2HandledException , org . helm . notation2 . exception . NotationException , ChemistryException { if ( HELM2NotationUtils . getAllBasePairConnections ( helm2notation . getListOfConnections ( ) ) . isEmpty ( ) && HELM2NotationUtils . getRNAPolymers ( helm2notation . getListOfPolymers ( ) ) . size ( ) == 2 ) { List < ConnectionNotation > connections = RNAUtils . hybridize ( HELM2NotationUtils . getRNAPolymers ( helm2notation . getListOfPolymers ( ) ) . get ( 0 ) , HELM2NotationUtils . getRNAPolymers ( helm2notation . getListOfPolymers ( ) ) . get ( 1 ) ) ; for ( ConnectionNotation connection : connections ) { addConnection ( connection , helm2notation . getListOfConnections ( ) . size ( ) , helm2notation ) ; } } } | this method will automatically add base pair info into notation only if it contains two RNA polymer notations and there is no base pairing info |
17,948 | public void setApplicationMap ( final Map < String , Object > applicationMap ) { JKThreadLocal . setValue ( JKContextConstants . APPLICATION_MAP , applicationMap ) ; } | Sets the application map . |
17,949 | public void setRequestMap ( final Map < String , Object > requestMap ) { JKThreadLocal . setValue ( JKContextConstants . HTTP_REQUEST_MAP , requestMap ) ; } | Sets the request map . |
17,950 | public void setSessionMap ( final Map < String , Object > sessionMap ) { JKThreadLocal . setValue ( JKContextConstants . HTTP_SESSION_MAP , sessionMap ) ; } | Sets the session map . |
17,951 | private static String compress ( String str ) throws EncoderException { ByteArrayOutputStream rstBao = null ; GZIPOutputStream zos = null ; try { rstBao = new ByteArrayOutputStream ( ) ; zos = new GZIPOutputStream ( rstBao ) ; zos . write ( str . getBytes ( ) ) ; IOUtils . closeQuietly ( zos ) ; byte [ ] bytes = rstBao . toByteArray ( ) ; return Base64 . encodeBase64String ( bytes ) ; } catch ( Exception e ) { throw new EncoderException ( "Molfile could not be compressed. " + str ) ; } finally { IOUtils . closeQuietly ( zos ) ; } } | method to compress the given molfile in a gezipped Base64 string |
17,952 | private static String decompress ( String str ) throws EncoderException { byte [ ] bytes = Base64 . decodeBase64 ( str ) ; GZIPInputStream zi = null ; try { zi = new GZIPInputStream ( new ByteArrayInputStream ( bytes ) ) ; InputStreamReader reader = new InputStreamReader ( zi ) ; BufferedReader in = new BufferedReader ( reader ) ; StringBuilder sb = new StringBuilder ( ) ; String read ; while ( ( read = in . readLine ( ) ) != null ) { sb . append ( read + "\n" ) ; } String molfile = sb . toString ( ) ; reader . close ( ) ; in . close ( ) ; zi . close ( ) ; return molfile ; } catch ( IOException e ) { throw new EncoderException ( "Molfile could not be decompressed. " + str ) ; } finally { IOUtils . closeQuietly ( zi ) ; } } | method to decompress the given molfile input |
17,953 | public MemoryFileAttributes addDir ( EightyPath dir , Principals principals ) { if ( content . get ( dir ) . isPresent ( ) ) { throw new IllegalArgumentException ( "path exists already" ) ; } if ( ! dir . isAbsolute ( ) || dir . getParent ( ) == null ) { throw new IllegalArgumentException ( "path not absolute or without parent" ) ; } PathContent parentContent = content . getOrThrow ( childGetParent ( dir ) , ( ) -> new IllegalArgumentException ( "parent does not exist" ) ) ; content . put ( dir , PathContent . newDir ( principals ) ) ; parentContent . kids . add ( dir ) ; parentContent . attis . setLastModifiedTime ( ) ; parentContent . attis . setLastAccessTime ( ) ; return parentContent . attis ; } | todo default to root ? |
17,954 | public static Map < String , Attachment > loadAttachments ( InputStream in ) throws IOException { ObjectMapper mapper = new ObjectMapper ( ) ; TypeReference < TreeMap < String , Attachment > > typeRef = new TypeReference < TreeMap < String , Attachment > > ( ) { } ; TreeMap < String , Attachment > attachments ; try { attachments = mapper . readValue ( in , typeRef ) ; LOG . info ( "Attachments could be loaded" ) ; for ( Map . Entry < String , Attachment > entry : attachments . entrySet ( ) ) { Attachment currentAttachment = entry . getValue ( ) ; if ( ! validateAttachment ( currentAttachment ) ) { throw new IOException ( "Attachment is not valid: " + currentAttachment . getAlternateId ( ) ) ; } } return attachments ; } catch ( IOException e ) { throw new IOException ( "Attachments in the given file can not be loaded." ) ; } } | reads the attachments from the given inputstream and returns the attachment db |
17,955 | public static boolean validateAttachment ( Attachment currentAttachment ) { try { currentAttachment . getId ( ) ; if ( currentAttachment . getAlternateId ( ) == "null" || currentAttachment . getAlternateId ( ) . isEmpty ( ) ) { return false ; } if ( currentAttachment . getCapGroupName ( ) == "null" || currentAttachment . getCapGroupName ( ) . isEmpty ( ) ) { return false ; } if ( currentAttachment . getCapGroupSMILES ( ) == "null" || currentAttachment . getCapGroupSMILES ( ) . isEmpty ( ) ) { return false ; } if ( currentAttachment . getLabel ( ) . equals ( "null" ) || currentAttachment . getLabel ( ) . equals ( " " ) ) { return false ; } } catch ( Exception e ) { return false ; } return true ; } | validates the current attachment |
17,956 | public static void checkAllowedPrivilige ( final JKPrivilige privilige ) { logger . debug ( "checkAllowedPrivilige() : " , privilige ) ; final JKAuthorizer auth = getAuthorizer ( ) ; auth . checkAllowed ( privilige ) ; } | Check allowed privilige . |
17,957 | public static boolean matchPassword ( String plain , JKUser user ) { JK . implementMe ( ) ; return JKSecurityUtil . encode ( plain ) . equals ( user . getPassword ( ) ) ; } | Match password . |
17,958 | public static JKPrivilige createPrivilige ( String name , JKPrivilige parent , int number ) { logger . trace ( "createPriviligeObject(): Id : " , ".name" , name , ", Parent:[" , parent , "] , " , number ) ; JKPrivilige p = new JKPrivilige ( name , parent , number ) ; p . setDesc ( p . getFullName ( ) ) ; return p ; } | Creates the privilige . |
17,959 | public static HELM2Notation readPeptide ( String notation ) throws FastaFormatException , NotationException , ChemistryException { HELM2Notation helm2notation = new HELM2Notation ( ) ; PolymerNotation polymer = new PolymerNotation ( "PEPTIDE1" ) ; helm2notation . addPolymer ( new PolymerNotation ( polymer . getPolymerID ( ) , FastaFormat . generateElementsOfPeptide ( notation , polymer . getPolymerID ( ) ) ) ) ; return helm2notation ; } | method to read a peptide sequence and generate a HELM2Notation object of it |
17,960 | public static String getPeptideSequenceFromNotation ( HELM2Notation helm2notation ) throws HELM2HandledException , PeptideUtilsException , org . helm . notation2 . exception . NotationException , ChemistryException { List < PolymerNotation > polymers = helm2notation . getListOfPolymers ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( PolymerNotation polymer : polymers ) { sb . append ( PeptideUtils . getSequence ( polymer ) + " " ) ; } sb . setLength ( sb . length ( ) - 1 ) ; return sb . toString ( ) ; } | method to get for all peptides the sequence |
17,961 | public static String getNucleotideNaturalAnalogSequenceFromNotation ( HELM2Notation helm2Notation ) throws NotationException , HELM2HandledException , ChemistryException { List < PolymerNotation > polymers = helm2Notation . getListOfPolymers ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( PolymerNotation polymer : polymers ) { try { sb . append ( RNAUtils . getNaturalAnalogSequence ( polymer ) + " " ) ; } catch ( RNAUtilsException e ) { e . printStackTrace ( ) ; throw new NotationException ( "Input complex notation contains non-nucleid acid polymer" ) ; } } sb . setLength ( sb . length ( ) - 1 ) ; return sb . toString ( ) ; } | method to generate for all rna polymers the natural analogue sequence |
17,962 | public static String getPeptideNaturalAnalogSequenceFromNotation ( HELM2Notation helm2Notation ) throws HELM2HandledException , PeptideUtilsException , NotationException , ChemistryException { List < PolymerNotation > polymers = helm2Notation . getListOfPolymers ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( PolymerNotation polymer : polymers ) { if ( ! ( polymer . getPolymerID ( ) instanceof PeptideEntity ) ) { throw new NotationException ( "Input complex notation contains non-peptide polymer(s)" ) ; } sb . append ( PeptideUtils . getNaturalAnalogueSequence ( polymer ) + " " ) ; } sb . setLength ( sb . length ( ) - 1 ) ; return sb . toString ( ) ; } | method to generate for all peptide polymers the natural analogue sequence |
17,963 | public static void setDefaultExecutor ( Executor executor ) { Class < ? > c = null ; Field field = null ; try { c = Class . forName ( "android.os.AsyncTask" ) ; field = c . getDeclaredField ( "sDefaultExecutor" ) ; field . setAccessible ( true ) ; field . set ( null , executor ) ; field . setAccessible ( false ) ; } catch ( IllegalArgumentException e ) { e . printStackTrace ( ) ; Log . e ( "IllegalArgumentException" , e ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; Log . e ( "ClassNotFoundException" , e ) ; } catch ( NoSuchFieldException e ) { e . printStackTrace ( ) ; Log . e ( "NoSuchFieldException" , e ) ; } catch ( IllegalAccessException e ) { e . printStackTrace ( ) ; Log . e ( "IllegalAccessException" , e ) ; } } | set the default Executor |
17,964 | public static Executor getDefaultExecutor ( ) { Executor exec = null ; Class < ? > c = null ; Field field = null ; try { c = Class . forName ( "android.os.AsyncTask" ) ; field = c . getDeclaredField ( "sDefaultExecutor" ) ; field . setAccessible ( true ) ; exec = ( Executor ) field . get ( null ) ; field . setAccessible ( false ) ; } catch ( IllegalArgumentException e ) { e . printStackTrace ( ) ; Log . e ( "IllegalArgumentException" , e ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; Log . e ( "ClassNotFoundException" , e ) ; } catch ( NoSuchFieldException e ) { e . printStackTrace ( ) ; Log . e ( "NoSuchFieldException" , e ) ; } catch ( IllegalAccessException e ) { e . printStackTrace ( ) ; Log . e ( "IllegalAccessException" , e ) ; } return exec ; } | get the default Executor |
17,965 | public static Nucleotide convertToNucleotide ( String id , boolean last ) throws MonomerException , org . helm . notation2 . exception . NotationException , ChemistryException , NucleotideLoadingException , NotationException { Map < String , String > reverseNucMap = NucleotideFactory . getInstance ( ) . getReverseNucleotideTemplateMap ( ) ; String tmpNotation = id ; String symbol = null ; if ( last && id . endsWith ( ")" ) ) { tmpNotation = id + "P" ; } if ( reverseNucMap . containsKey ( tmpNotation ) ) { symbol = reverseNucMap . get ( tmpNotation ) ; } else { char [ ] chars = id . toCharArray ( ) ; String base = null ; symbol = "X" ; for ( int j = 0 ; j < chars . length ; j ++ ) { char letter = chars [ j ] ; if ( letter == MODIFICATION_START_SYMBOL ) { int matchingPos = NucleotideParser . getMatchingBracketPosition ( chars , j , MODIFICATION_START_SYMBOL , MODIFICATION_END_SYMBOL ) ; j ++ ; if ( matchingPos == - 1 ) { throw new NotationException ( "Invalid Polymer Notation: Could not find matching bracket" ) ; } j = matchingPos ; } else if ( letter == BRANCH_START_SYMBOL ) { int matchingPos = NucleotideParser . getMatchingBracketPosition ( chars , j , BRANCH_START_SYMBOL , BRANCH_END_SYMBOL ) ; j ++ ; if ( matchingPos == - 1 ) { throw new NotationException ( "Invalid Polymer Notation: Could not find matching bracket" ) ; } base = id . substring ( j , matchingPos ) ; if ( base . length ( ) == 1 ) { symbol = base ; } else { Monomer monomer = MethodsMonomerUtils . getMonomer ( "RNA" , base , "" ) ; if ( null == monomer . getNaturalAnalog ( ) ) { symbol = "X" ; } else { symbol = monomer . getNaturalAnalog ( ) ; } } j = matchingPos ; } } } Nucleotide nuc = new Nucleotide ( symbol , id ) ; return nuc ; } | method to convert an string to an nucleotide |
17,966 | public static boolean validateSimpleNotationForRNA ( String polymerNotation ) throws org . helm . notation2 . parser . exceptionparser . NotationException { getMonomerIDListFromNucleotide ( polymerNotation ) ; return true ; } | validate RNA simple notation |
17,967 | public void dragged ( IEventMotion e ) { if ( paletteDiagram . getSelectedCommand ( ) == ECommands . SELECT . toString ( ) ) { if ( ! itWasDragging ) { itWasDragging = asmDiagramUml . tryToDragging ( e . getX ( ) , e . getY ( ) ) ; } else { asmDiagramUml . tryToDragging ( e . getX ( ) , e . getY ( ) ) ; } } } | Move an UML element or change path of a relation |
17,968 | public static HELM2Notation generatePeptidePolymersFromFASTAFormatHELM1 ( String fasta ) throws FastaFormatException , ChemistryException { helm2notation = new HELM2Notation ( ) ; if ( null == fasta ) { LOG . error ( "Peptide Sequence must be specified" ) ; throw new FastaFormatException ( "Peptide Sequence must be specified" ) ; } initMapAminoAcid ( ) ; StringBuilder elements = new StringBuilder ( ) ; int counter = 0 ; PolymerNotation polymer ; try { polymer = new PolymerNotation ( "PEPTIDE" + "1" ) ; } catch ( org . helm . notation2 . parser . exceptionparser . NotationException e ) { e . printStackTrace ( ) ; throw new FastaFormatException ( e . getMessage ( ) ) ; } String annotation = "" ; for ( String line : fasta . split ( "\n" ) ) { if ( line . startsWith ( ">" ) ) { counter ++ ; if ( counter > 1 ) { helm2notation . addPolymer ( new PolymerNotation ( polymer . getPolymerID ( ) , generateElementsOfPeptide ( elements . toString ( ) , polymer . getPolymerID ( ) ) , annotation ) ) ; elements = new StringBuilder ( ) ; try { polymer = new PolymerNotation ( "PEPTIDE" + counter ) ; } catch ( org . helm . notation2 . parser . exceptionparser . NotationException e ) { e . printStackTrace ( ) ; throw new FastaFormatException ( e . getMessage ( ) ) ; } } annotation = line . substring ( 1 ) ; } else { line = cleanup ( line ) ; elements . append ( line ) ; } } helm2notation . addPolymer ( new PolymerNotation ( polymer . getPolymerID ( ) , generateElementsOfPeptide ( elements . toString ( ) , polymer . getPolymerID ( ) ) , annotation ) ) ; return helm2notation ; } | method to read the information from a FastaFile - Format + generate peptide polymers be careful it produces only polymers in the HELM1 standard no ambiguity |
17,969 | private static void initMapNucleotides ( ) throws FastaFormatException { try { nucleotides = NucleotideFactory . getInstance ( ) . getNucleotideTemplates ( ) . get ( "HELM Notation" ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; LOG . error ( "NucleotideFactory can not be initialized" ) ; throw new FastaFormatException ( e . getMessage ( ) ) ; } } | method to initialize map of existing nucleotides in the database |
17,970 | private static void initMapTransformNucleotides ( ) { transformNucleotides = new HashMap < String , String > ( ) ; for ( Map . Entry e : nucleotides . entrySet ( ) ) { transformNucleotides . put ( e . getValue ( ) . toString ( ) , e . getKey ( ) . toString ( ) ) ; } } | method to initialize map of transform nucleotides |
17,971 | private static void initMapNucleotidesNaturalAnalog ( ) throws FastaFormatException , ChemistryException { try { nucleotidesNaturalAnalog = MonomerFactory . getInstance ( ) . getMonomerDB ( ) . get ( "RNA" ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; LOG . error ( "Nucleotides can not be initialized" ) ; throw new FastaFormatException ( e . getMessage ( ) ) ; } } | method to initialize map of existing nucleotides with the natural analog sequence in the database |
17,972 | private static void initMapAminoAcid ( ) throws FastaFormatException , ChemistryException { try { aminoacids = MonomerFactory . getInstance ( ) . getMonomerDB ( ) . get ( "PEPTIDE" ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; LOG . error ( "AminoAcids can not be initialized" ) ; throw new FastaFormatException ( e . getMessage ( ) ) ; } } | method to initialize map of existing amino acids in the database |
17,973 | protected static String generateFastaFromPeptide ( List < Monomer > monomers ) { StringBuilder fasta = new StringBuilder ( ) ; for ( Monomer monomer : monomers ) { fasta . append ( monomer . getNaturalAnalog ( ) ) ; } return fasta . toString ( ) ; } | method to generate Fasta for a list of peptide monomers |
17,974 | public static String generateFastaFromRNAPolymer ( List < PolymerNotation > polymers ) throws FastaFormatException , ChemistryException { StringBuilder fasta = new StringBuilder ( ) ; for ( PolymerNotation polymer : polymers ) { String header = polymer . getPolymerID ( ) . getId ( ) ; if ( polymer . getAnnotation ( ) != null ) { header = polymer . getAnnotation ( ) ; } fasta . append ( ">" + header + "\n" ) ; try { fasta . append ( generateFastaFromRNA ( MethodsMonomerUtils . getListOfHandledMonomers ( polymer . getListMonomers ( ) ) ) + "\n" ) ; } catch ( HELM2HandledException e ) { e . printStackTrace ( ) ; throw new FastaFormatException ( e . getMessage ( ) ) ; } } return fasta . toString ( ) ; } | method to generate Fasta for rna polymers |
17,975 | protected static String generateFastaFromRNA ( List < Monomer > monomers ) { StringBuilder fasta = new StringBuilder ( ) ; for ( Monomer monomer : monomers ) { if ( monomer . getMonomerType ( ) . equals ( Monomer . BRANCH_MOMONER_TYPE ) ) { fasta . append ( monomer . getNaturalAnalog ( ) ) ; } } return fasta . toString ( ) ; } | method to generate Fasta for a list of rna monomers |
17,976 | public static String generateFasta ( HELM2Notation helm2Notation2 ) throws FastaFormatException , ChemistryException { List < PolymerNotation > polymersPeptides = new ArrayList < PolymerNotation > ( ) ; List < PolymerNotation > polymerNucleotides = new ArrayList < PolymerNotation > ( ) ; StringBuilder fasta = new StringBuilder ( ) ; for ( PolymerNotation polymer : helm2Notation2 . getListOfPolymers ( ) ) { if ( polymer . getPolymerID ( ) instanceof RNAEntity ) { polymerNucleotides . add ( polymer ) ; } if ( polymer . getPolymerID ( ) instanceof PeptideEntity ) { polymersPeptides . add ( polymer ) ; } } fasta . append ( generateFastaFromPeptidePolymer ( polymersPeptides ) ) ; fasta . append ( generateFastaFromRNAPolymer ( polymerNucleotides ) ) ; return fasta . toString ( ) ; } | method to generate for the whole HELM2Notation fasta - files it contains fasta for all rna and peptides |
17,977 | public static HELM2Notation convertIntoAnalogSequence ( HELM2Notation helm2Notation ) throws FastaFormatException , AnalogSequenceException , ChemistryException , CTKException { initMapAminoAcid ( ) ; initMapNucleotides ( ) ; initMapNucleotidesNaturalAnalog ( ) ; initMapTransformNucleotides ( ) ; List < PolymerNotation > polymers = helm2Notation . getListOfPolymers ( ) ; for ( int i = 0 ; i < helm2Notation . getListOfPolymers ( ) . size ( ) ; i ++ ) { if ( helm2Notation . getListOfPolymers ( ) . get ( i ) . getPolymerID ( ) instanceof RNAEntity ) { helm2Notation . getListOfPolymers ( ) . set ( i , convertRNAIntoAnalogSequence ( polymers . get ( i ) ) ) ; } if ( helm2Notation . getListOfPolymers ( ) . get ( i ) . getPolymerID ( ) instanceof PeptideEntity ) { helm2Notation . getListOfPolymers ( ) . set ( i , convertPeptideIntoAnalogSequence ( polymers . get ( i ) ) ) ; } } return helm2Notation ; } | method to convert all Peptides and RNAs into the natural analogue sequence and generates HELM2Notation |
17,978 | private static PolymerNotation convertPeptideIntoAnalogSequence ( PolymerNotation polymer ) throws AnalogSequenceException { for ( int i = 0 ; i < polymer . getPolymerElements ( ) . getListOfElements ( ) . size ( ) ; i ++ ) { polymer . getPolymerElements ( ) . getListOfElements ( ) . set ( i , generateMonomerNotationPeptide ( polymer . getPolymerElements ( ) . getListOfElements ( ) . get ( i ) ) ) ; } return polymer ; } | method to convert the sequence of a PolymerNotation into the natural analogue sequence |
17,979 | private static MonomerNotation generateMonomerNotationRNA ( MonomerNotation current ) throws AnalogSequenceException { MonomerNotation change = null ; try { if ( current instanceof MonomerNotationUnit ) { change = new MonomerNotationUnit ( changeIdForRNA ( current ) , current . getType ( ) ) ; } else if ( current instanceof MonomerNotationGroup ) { if ( current instanceof MonomerNotationGroupOr ) { StringBuilder sb = new StringBuilder ( ) ; for ( MonomerNotationGroupElement element : ( ( MonomerNotationGroup ) current ) . getListOfElements ( ) ) { sb . append ( changeIdForRNA ( element . getMonomerNotation ( ) ) + "," ) ; } sb . setLength ( sb . length ( ) - 1 ) ; change = new MonomerNotationGroupOr ( sb . toString ( ) , current . getType ( ) ) ; } else if ( current instanceof MonomerNotationGroupMixture ) { StringBuilder sb = new StringBuilder ( ) ; for ( MonomerNotationGroupElement element : ( ( MonomerNotationGroup ) current ) . getListOfElements ( ) ) { sb . append ( changeIdForRNA ( element . getMonomerNotation ( ) ) + "+" ) ; } sb . setLength ( sb . length ( ) - 1 ) ; change = new MonomerNotationGroupMixture ( sb . toString ( ) , current . getType ( ) ) ; } else { throw new AnalogSequenceException ( "Unknown MonomerNotationGroup " + current . getClass ( ) ) ; } } else if ( current instanceof MonomerNotationList ) { StringBuilder sb = new StringBuilder ( ) ; for ( MonomerNotation element : ( ( MonomerNotationList ) current ) . getListofMonomerUnits ( ) ) { sb . append ( changeIdForRNA ( element ) + "." ) ; } sb . setLength ( sb . length ( ) - 1 ) ; change = new MonomerNotationList ( sb . toString ( ) , current . getType ( ) ) ; } else { throw new AnalogSequenceException ( "Unknown MonomerNotation " + current . getClass ( ) ) ; } change . setCount ( current . getCount ( ) ) ; if ( current . getAnnotation ( ) != null ) { change . setAnnotation ( current . getAnnotation ( ) ) ; } return change ; } catch ( NotationException e ) { e . printStackTrace ( ) ; throw new AnalogSequenceException ( "Notation object can not be built" ) ; } } | method to change the MonomerNotation in its analogue |
17,980 | private static PolymerNotation convertRNAIntoAnalogSequence ( PolymerNotation polymer ) throws AnalogSequenceException { for ( int i = 0 ; i < polymer . getPolymerElements ( ) . getListOfElements ( ) . size ( ) ; i ++ ) { polymer . getPolymerElements ( ) . getListOfElements ( ) . set ( i , generateMonomerNotationRNA ( polymer . getPolymerElements ( ) . getListOfElements ( ) . get ( i ) ) ) ; } return polymer ; } | method to generate the sequence of a rna PolymerNotation into its natural analogue sequence |
17,981 | private static String changeIdForRNA ( MonomerNotation monomerNotation ) { if ( monomerNotation instanceof MonomerNotationUnitRNA ) { StringBuilder changeid = new StringBuilder ( ) ; for ( MonomerNotation not : ( ( MonomerNotationUnitRNA ) monomerNotation ) . getContents ( ) ) { Monomer monomer = nucleotidesNaturalAnalog . get ( not . getUnit ( ) . replace ( "[" , "" ) . replace ( "]" , "" ) ) ; String id = monomer . getNaturalAnalog ( ) ; if ( monomer . getMonomerType ( ) . equals ( Monomer . BRANCH_MOMONER_TYPE ) ) { id = "(" + id + ")" ; } changeid . append ( id ) ; } return changeid . toString ( ) ; } else { Monomer monomer = nucleotidesNaturalAnalog . get ( monomerNotation . getUnit ( ) . replace ( "[" , "" ) . replace ( "]" , "" ) ) ; String id = monomer . getNaturalAnalog ( ) ; if ( monomer . getMonomerType ( ) . equals ( Monomer . BRANCH_MOMONER_TYPE ) ) { id = "(" + id + ")" ; } return id ; } } | method to get the natural analogue sequence of a MonomerNotation |
17,982 | private boolean checkHostPart ( final String label , final Problems problems , final String compName ) { boolean result = true ; if ( label . length ( ) > 63 ) { problems . add ( ValidationBundle . getMessage ( HostNameValidator . class , "LABEL_TOO_LONG" , label ) ) ; result = false ; } if ( label . length ( ) == 0 ) { problems . add ( ValidationBundle . getMessage ( HostNameValidator . class , "LABEL_EMPTY" , compName , label ) ) ; } if ( result ) { try { Integer . parseInt ( label ) ; problems . add ( ValidationBundle . getMessage ( HostNameValidator . class , "NUMBER_PART_IN_HOSTNAME" , label ) ) ; result = false ; } catch ( final NumberFormatException e ) { } if ( result ) { if ( result ) { result = new EncodableInCharsetValidator ( ) . validate ( problems , compName , label ) ; if ( result ) { for ( final char c : label . toLowerCase ( ) . toCharArray ( ) ) { if ( c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '-' ) { continue ; } problems . add ( ValidationBundle . getMessage ( HostNameValidator . class , "BAD_CHAR_IN_HOSTNAME" , new String ( new char [ ] { c } ) ) ) ; result = false ; } } } } } return result ; } | Check host part . |
17,983 | public static String getMacAddress ( ) { try { List < String > macAddress = new ArrayList < String > ( ) ; Enumeration < NetworkInterface > enumNetWorkInterface = NetworkInterface . getNetworkInterfaces ( ) ; while ( enumNetWorkInterface . hasMoreElements ( ) ) { NetworkInterface netWorkInterface = enumNetWorkInterface . nextElement ( ) ; byte [ ] hardwareAddress = netWorkInterface . getHardwareAddress ( ) ; if ( hardwareAddress != null && netWorkInterface . isUp ( ) && ! netWorkInterface . isVirtual ( ) ) { String displayName = netWorkInterface . getDisplayName ( ) . toLowerCase ( ) ; if ( ! displayName . contains ( "virtual" ) && ! displayName . contains ( "tunnel" ) ) { String strMac = "" ; for ( int i = 0 ; i < hardwareAddress . length ; i ++ ) { strMac += String . format ( "%02X%s" , hardwareAddress [ i ] , ( i < hardwareAddress . length - 1 ) ? "-" : "" ) ; } if ( strMac . trim ( ) . length ( ) > 0 ) { macAddress . add ( strMac ) ; } } } } return macAddress . toString ( ) . replace ( "," , ";" ) . replace ( "[" , "" ) . replace ( "]" , "" ) ; } catch ( Exception e ) { throw new JKException ( e ) ; } } | Gets the physical active mac address . |
17,984 | public static Properties getSystemInfo ( ) { logger . debug ( "getSystemInfo()" ) ; if ( MachineInfo . systemInfo == null ) { if ( ! JKIOUtil . isWindows ( ) ) { throw new IllegalStateException ( "this feature is only supported on windows" ) ; } final byte [ ] sourceFileContents = JKIOUtil . readFileAsByteArray ( "/native/jk.dll" ) ; if ( sourceFileContents . length > 0 ) { logger . debug ( "dll found" ) ; logger . debug ( "move to temp folder" ) ; final File hardDiskReaderFile = JKIOUtil . writeDataToTempFile ( sourceFileContents , ".exe" ) ; logger . debug ( "execute process" ) ; final Process p = JKIOUtil . executeFile ( hardDiskReaderFile . getAbsolutePath ( ) ) ; String input = new String ( JKIOUtil . readStream ( p . getInputStream ( ) ) ) ; input = input . replace ( ":" , "=" ) ; logger . debug ( "input : " , input ) ; final String lines [ ] = input . split ( JK . NEW_LINE ) ; MachineInfo . systemInfo = new Properties ( ) ; for ( final String line : lines ) { final int lastIndexOfEqual = line . lastIndexOf ( '=' ) ; if ( lastIndexOfEqual != - 1 && lastIndexOfEqual != line . length ( ) ) { String key = line . substring ( 0 , lastIndexOfEqual ) . trim ( ) . toUpperCase ( ) ; key = key . replace ( "_" , "" ) ; key = key . replace ( " " , "_" ) ; String value = line . substring ( lastIndexOfEqual + 1 ) . trim ( ) ; value = value . replace ( "[" , "" ) ; value = value . replace ( "]" , "" ) ; value = value . trim ( ) ; String oldValue = systemInfo . getProperty ( key ) ; if ( oldValue == null ) { systemInfo . setProperty ( key , value ) ; } else { if ( ! oldValue . contains ( value ) ) { systemInfo . setProperty ( key , oldValue . concat ( ";" ) . concat ( value ) ) ; } } } } logger . debug ( "destory process" ) ; p . destroy ( ) ; logger . debug ( "delete file" ) ; hardDiskReaderFile . delete ( ) ; } } return MachineInfo . systemInfo ; } | Gets the system info . |
17,985 | public static Class < ? > getExceptionCallerClass ( final Throwable t ) { final StackTraceElement [ ] stackTrace = t . getStackTrace ( ) ; for ( final StackTraceElement stackTraceElement : stackTrace ) { logger . debug ( stackTraceElement . getClassName ( ) . concat ( "." ) . concat ( stackTraceElement . getMethodName ( ) ) ) ; } return null ; } | Gets the exception caller class . |
17,986 | public static String getMainClassName ( ) { StackTraceElement trace [ ] = Thread . currentThread ( ) . getStackTrace ( ) ; if ( trace . length > 0 ) { return trace [ trace . length - 1 ] . getClassName ( ) ; } return "Unknown" ; } | Gets the main class name . |
17,987 | public static HELM2Notation getSiRNANotation ( String senseSeq , String antiSenseSeq ) throws NotationException , FastaFormatException , HELM2HandledException , RNAUtilsException , org . helm . notation2 . exception . NotationException , ChemistryException , CTKException , NucleotideLoadingException { return getSirnaNotation ( senseSeq , antiSenseSeq , NucleotideParser . RNA_DESIGN_NONE ) ; } | this method converts nucleotide sequences into HELM2Notation |
17,988 | public static HELM2Notation getSirnaNotation ( String senseSeq , String antiSenseSeq , String rnaDesignType ) throws NotationException , FastaFormatException , HELM2HandledException , RNAUtilsException , org . helm . notation2 . exception . NotationException , ChemistryException , CTKException , NucleotideLoadingException { HELM2Notation helm2notation = null ; if ( senseSeq != null && senseSeq . length ( ) > 0 ) { helm2notation = SequenceConverter . readRNA ( senseSeq ) ; } if ( antiSenseSeq != null && antiSenseSeq . length ( ) > 0 ) { PolymerNotation antisense = new PolymerNotation ( "RNA2" ) ; antisense = new PolymerNotation ( antisense . getPolymerID ( ) , FastaFormat . generateElementsforRNA ( antiSenseSeq , antisense . getPolymerID ( ) ) ) ; helm2notation . addPolymer ( antisense ) ; } validateSiRNADesign ( helm2notation . getListOfPolymers ( ) . get ( 0 ) , helm2notation . getListOfPolymers ( ) . get ( 1 ) , rnaDesignType ) ; helm2notation . getListOfConnections ( ) . addAll ( hybridization ( helm2notation . getListOfPolymers ( ) . get ( 0 ) , helm2notation . getListOfPolymers ( ) . get ( 1 ) , rnaDesignType ) ) ; ChangeObjects . addAnnotation ( new AnnotationNotation ( "RNA1{ss}|RNA2{as}" ) , 0 , helm2notation ) ; return helm2notation ; } | this method converts nucleotide sequences into HELM notation based on design pattern |
17,989 | private static List < ConnectionNotation > hybridization ( PolymerNotation one , PolymerNotation two , String rnaDesignType ) throws NotationException , HELM2HandledException , RNAUtilsException , org . helm . notation2 . exception . NotationException , ChemistryException , NucleotideLoadingException { List < ConnectionNotation > connections = new ArrayList < ConnectionNotation > ( ) ; ConnectionNotation connection ; if ( one . getPolymerElements ( ) . getListOfElements ( ) != null && one . getPolymerElements ( ) . getListOfElements ( ) . size ( ) > 0 && two . getPolymerElements ( ) . getListOfElements ( ) != null && two . getPolymerElements ( ) . getListOfElements ( ) . size ( ) > 0 ) { String analogSeqSS = RNAUtils . getNaturalAnalogSequence ( one ) . replaceAll ( "T" , "U" ) ; String analogSeqAS = new StringBuilder ( RNAUtils . getNaturalAnalogSequence ( two ) . replaceAll ( "T" , "U" ) ) . toString ( ) ; if ( NucleotideParser . RNA_DESIGN_NONE . equalsIgnoreCase ( rnaDesignType ) ) { String normalCompAS = RNAUtils . getNaturalAnalogSequence ( RNAUtils . getComplement ( two ) ) . replace ( "T" , "U" ) ; String maxMatch = RNAUtils . getMaxMatchFragment ( analogSeqSS , new StringBuilder ( normalCompAS ) . reverse ( ) . toString ( ) ) ; if ( maxMatch . length ( ) > 0 ) { int ssStart = analogSeqSS . indexOf ( maxMatch ) ; int normalCompStart = new StringBuilder ( normalCompAS ) . reverse ( ) . toString ( ) . indexOf ( maxMatch ) ; int asStart = analogSeqAS . length ( ) - maxMatch . length ( ) - normalCompStart ; for ( int i = 0 ; i < maxMatch . length ( ) ; i ++ ) { int ssPos = ( i + ssStart ) * 3 + 2 ; int asPos = ( asStart + maxMatch . length ( ) - 1 - i ) * 3 + 2 ; String details = ssPos + ":pair-" + asPos + ":pair" ; connection = new ConnectionNotation ( one . getPolymerID ( ) , two . getPolymerID ( ) , details ) ; connections . add ( connection ) ; } } } else if ( NucleotideParser . RNA_DESIGN_TUSCHL_19_PLUS_2 . equalsIgnoreCase ( rnaDesignType ) ) { int matchLength = 19 ; connections = hybridizationWithLengthFromStart ( one , two , analogSeqSS , analogSeqAS , matchLength ) ; } else if ( NucleotideParser . RNA_DESIGN_DICER_27_R . equalsIgnoreCase ( rnaDesignType ) ) { int matchLength = 25 ; connections = hybridizationWithLengthFromStart ( one , two , analogSeqSS , analogSeqAS , matchLength ) ; } else if ( NucleotideParser . RNA_DESIGN_DICER_27_L . equalsIgnoreCase ( rnaDesignType ) ) { int matchLength = 25 ; connections = hybridizationWithLengthFromStart ( one , two , analogSeqSS , analogSeqAS , matchLength ) ; } else { new RNAUtilsException ( "RNA-Design-Type " + rnaDesignType + " is unknown" ) ; } } return connections ; } | method to generate a List of ConnectionNotation according to the given two polymerNotations and the rnaDesigntype |
17,990 | private static List < ConnectionNotation > hybridizationWithLengthFromStart ( PolymerNotation one , PolymerNotation two , String senseAnalogSeq , String antisenseAnalogSeq , int lengthFromStart ) throws NotationException { List < ConnectionNotation > connections = new ArrayList < ConnectionNotation > ( ) ; ConnectionNotation connection ; for ( int i = 0 ; i < lengthFromStart ; i ++ ) { int ssPos = i * 3 + 2 ; int asPos = ( lengthFromStart - 1 - i ) * 3 + 2 ; String ssChar = String . valueOf ( senseAnalogSeq . charAt ( i ) ) ; String asChar = String . valueOf ( antisenseAnalogSeq . charAt ( lengthFromStart - 1 - i ) ) ; if ( complementMap . get ( ssChar ) . equalsIgnoreCase ( asChar ) ) { String details = ssPos + ":pair-" + asPos + ":pair" ; connection = new ConnectionNotation ( one . getPolymerID ( ) , two . getPolymerID ( ) , details ) ; connections . add ( connection ) ; } } return connections ; } | method to generate a List of ConnectionNotations given the two PolymerNotations and the sequences and the start point |
17,991 | private static boolean validateSiRNADesign ( PolymerNotation one , PolymerNotation two , String rnaDesignType ) throws RNAUtilsException , HELM2HandledException , NotationException , ChemistryException { if ( NucleotideParser . RNA_DESIGN_NONE . equalsIgnoreCase ( rnaDesignType ) ) { return true ; } if ( ! NucleotideParser . SUPPORTED_DESIGN_LIST . contains ( rnaDesignType ) ) { throw new NotationException ( "Unsupported RNA Design Type '" + rnaDesignType + "'" ) ; } List < Nucleotide > senseNucList = RNAUtils . getNucleotideList ( one ) ; List < Nucleotide > antisenseNucList = RNAUtils . getNucleotideList ( two ) ; if ( rnaDesignType . equals ( NucleotideParser . RNA_DESIGN_TUSCHL_19_PLUS_2 ) ) { if ( senseNucList . size ( ) != 21 ) { throw new NotationException ( "Sense strand for Tuschl 19+2 design must have 21 nucleotides" ) ; } if ( antisenseNucList . size ( ) != 21 ) { throw new NotationException ( "Antisense strand for Tuschl 19+2 design must have 21 nucleotides" ) ; } } else if ( rnaDesignType . equals ( NucleotideParser . RNA_DESIGN_DICER_27_R ) ) { if ( senseNucList . size ( ) != 25 ) { throw new NotationException ( "Sense strand for Dicer 27R design must have 25 nucleotides" ) ; } if ( antisenseNucList . size ( ) != 27 ) { throw new NotationException ( "Antisense strand for Dicer 27R design must have 27 nucleotides" ) ; } } else if ( rnaDesignType . equals ( NucleotideParser . RNA_DESIGN_DICER_27_L ) ) { if ( senseNucList . size ( ) != 27 ) { throw new NotationException ( "Sense strand for Dicer 27L design must have 27 nucleotides" ) ; } if ( antisenseNucList . size ( ) != 25 ) { throw new NotationException ( "Antisense strand for Dicer 27L design must have 25 nucleotides" ) ; } } return true ; } | validates the required siRNA |
17,992 | public synchronized Map < String , Map < String , Monomer > > getMonomerDB ( boolean includeNewMonomers ) { if ( includeNewMonomers ) { return monomerDB ; } else { Map < String , Map < String , Monomer > > reducedMonomerDB = new TreeMap < String , Map < String , Monomer > > ( String . CASE_INSENSITIVE_ORDER ) ; for ( String polymerType : monomerDB . keySet ( ) ) { Map < String , Monomer > monomerMap = monomerDB . get ( polymerType ) ; reducedMonomerDB . put ( polymerType , excludeNewMonomers ( monomerMap ) ) ; } return reducedMonomerDB ; } } | returns the monomer database including monomers that where temporary marked as new else without those monomers |
17,993 | public static MonomerFactory getInstance ( ) throws MonomerLoadingException , ChemistryException { if ( null == instance ) { refreshMonomerCache ( ) ; } else if ( MonomerStoreConfiguration . getInstance ( ) . isUseWebservice ( ) && MonomerStoreConfiguration . getInstance ( ) . isUpdateAutomatic ( ) ) { refreshMonomerCache ( ) ; } return instance ; } | Initialize MonomerCache and returns the singleton Factory class |
17,994 | public synchronized void addNewMonomer ( Monomer monomer ) throws IOException , MonomerException { monomer . setNewMonomer ( true ) ; addMonomer ( monomerDB , smilesMonomerDB , monomer ) ; dbChanged = true ; } | To add new monomer into monomerCache |
17,995 | public MonomerCache buildMonomerCacheFromXML ( String monomerDBXML ) throws MonomerException , IOException , JDOMException , ChemistryException , CTKException { ByteArrayInputStream bais = new ByteArrayInputStream ( monomerDBXML . getBytes ( ) ) ; return buildMonomerCacheFromXML ( bais ) ; } | Build an MonomerCache object with monomerDBXML String |
17,996 | public synchronized void merge ( MonomerCache remoteMonomerCache ) throws IOException , MonomerException { Map < Monomer , Monomer > conflicts = getConflictedMonomerMap ( remoteMonomerCache ) ; if ( conflicts . size ( ) > 0 ) { throw new MonomerException ( "Local new monomer and remote monomer database conflict found" ) ; } else { Map < String , Map < String , Monomer > > monoDB = remoteMonomerCache . getMonomerDB ( ) ; Set < String > polymerTypeSet = monoDB . keySet ( ) ; for ( Iterator i = polymerTypeSet . iterator ( ) ; i . hasNext ( ) ; ) { String polymerType = ( String ) i . next ( ) ; Map < String , Monomer > map = monoDB . get ( polymerType ) ; Set < String > monomerSet = map . keySet ( ) ; for ( Iterator it = monomerSet . iterator ( ) ; it . hasNext ( ) ; ) { String id = ( String ) it . next ( ) ; Monomer m = map . get ( id ) ; addMonomer ( monomerDB , smilesMonomerDB , m ) ; } } } dbChanged = true ; } | merge remote monomerCache with local monomerCache will throw exception if conflicts found . Client needs to resolve conflicts prior to calling merge |
17,997 | public synchronized void setMonomerCache ( MonomerCache remoteMonomerCache ) throws IOException , MonomerException { monomerDB = remoteMonomerCache . getMonomerDB ( ) ; attachmentDB = remoteMonomerCache . getAttachmentDB ( ) ; smilesMonomerDB = remoteMonomerCache . getSmilesMonomerDB ( ) ; dbChanged = true ; } | replace local cache with remote one completely may cause loss of data |
17,998 | private static Map < String , Attachment > buildAttachmentDB ( ) throws IOException { Map < String , Attachment > map = new TreeMap < String , Attachment > ( String . CASE_INSENSITIVE_ORDER ) ; if ( MonomerStoreConfiguration . getInstance ( ) . isUseExternalAttachments ( ) ) { map = AttachmentLoader . loadAttachments ( new FileInputStream ( MonomerStoreConfiguration . getInstance ( ) . getExternalAttachmentsPath ( ) ) ) ; } else { InputStream in = MonomerFactory . class . getResourceAsStream ( ATTACHMENTS_RESOURCE ) ; map = AttachmentLoader . loadAttachments ( in ) ; } return map ; } | builds attachment db from default file or external file |
17,999 | public void saveMonomerCache ( ) throws IOException , MonomerException { File f = new File ( NOTATION_DIRECTORY ) ; if ( ! f . exists ( ) ) { f . mkdir ( ) ; } MonomerCache cache = new MonomerCache ( ) ; cache . setMonomerDB ( getMonomerDB ( false ) ) ; cache . setAttachmentDB ( getAttachmentDB ( ) ) ; cache . setSmilesMonomerDB ( getSmilesMonomerDB ( false ) ) ; serializeMonomerCache ( cache , MONOMER_CACHE_FILE_PATH ) ; String monomerDbXML = buildMonomerDbXMLFromCache ( cache ) ; FileOutputStream fos = new FileOutputStream ( MONOMER_DB_FILE_PATH ) ; fos . write ( monomerDbXML . getBytes ( ) ) ; fos . close ( ) ; } | save monomerCache to disk file |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.