idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
141,100 | public static String getFirstLine ( final String message ) { if ( isEmpty ( message ) ) { return message ; } if ( message . contains ( "\n" ) ) { return message . split ( "\n" ) [ 0 ] ; } return message ; } | Gets the first line . | 55 | 6 |
141,101 | public static void copyToClipboard ( String text ) { final StringSelection stringSelection = new StringSelection ( text ) ; final Clipboard clipboard = Toolkit . getDefaultToolkit ( ) . getSystemClipboard ( ) ; clipboard . setContents ( stringSelection , stringSelection ) ; } | Copy to clipboard . | 67 | 4 |
141,102 | public String toQueryString ( ) { final StringBuffer buf = new StringBuffer ( ) ; final Object value1 = this . values . get ( 0 ) ; buf . append ( this . column . getName ( ) ) ; switch ( this . type ) { case STARTS_WIDTH : buf . append ( " like '" + value1 + "%'" ) ; break ; case CONTAINS : buf . append ( " like '%" + value1 + "%'" ) ; break ; case ENDS_WITH : buf . append ( " like '%" + value1 + "'" ) ; break ; case DOESNOT_CONTAINS : buf . append ( " not like '%" + value1 + "%'" ) ; break ; case MORE_THAN : buf . append ( " > '" + value1 + "'" ) ; break ; case LESS_THAN : buf . append ( " < '" + value1 + "'" ) ; break ; } return buf . toString ( ) ; } | To query string . | 214 | 4 |
141,103 | public static String getNaturalAnalogueSequence ( PolymerNotation polymer ) throws HELM2HandledException , PeptideUtilsException , ChemistryException { checkPeptidePolymer ( polymer ) ; return FastaFormat . generateFastaFromPeptide ( MethodsMonomerUtils . getListOfHandledMonomers ( polymer . getListMonomers ( ) ) ) ; } | method to produce for a peptide PolymerNotation the natural analogue sequence | 86 | 15 |
141,104 | public static String getSequence ( PolymerNotation polymer ) throws HELM2HandledException , PeptideUtilsException , ChemistryException { checkPeptidePolymer ( polymer ) ; StringBuilder sb = new StringBuilder ( ) ; List < Monomer > monomers = MethodsMonomerUtils . getListOfHandledMonomers ( polymer . getListMonomers ( ) ) ; for ( Monomer monomer : monomers ) { String id = monomer . getAlternateId ( ) ; if ( id . length ( ) > 1 ) { id = "[" + id + "]" ; } sb . append ( id ) ; } return sb . toString ( ) ; } | method to produce for a peptide PolymerNotation the sequence | 152 | 13 |
141,105 | private static void processOtherMappings ( ) { codeToJavaMapping . clear ( ) ; codeToJKTypeMapping . clear ( ) ; shortListOfJKTypes . clear ( ) ; Set < Class < ? > > keySet = javaToCodeMapping . keySet ( ) ; for ( Class < ? > clas : keySet ) { List < Integer > codes = javaToCodeMapping . get ( clas ) ; for ( Integer code : codes ) { codeToJavaMapping . put ( code , clas ) ; logger . debug ( " Code ({}) class ({}) name ({})" , code , clas . getSimpleName ( ) , namesMapping . get ( code ) ) ; codeToJKTypeMapping . put ( code , new JKType ( code , clas , namesMapping . get ( code ) ) ) ; } shortListOfJKTypes . add ( new JKType ( codes . get ( 0 ) , clas , namesMapping . get ( codes . get ( 0 ) ) ) ) ; } } | This method is used to avoid reconigure the mapping in the otherside again . | 230 | 16 |
141,106 | protected void loadDefaultConfigurations ( ) { if ( JK . getURL ( DEFAULT_LABLES_FILE_NAME ) != null ) { logger . debug ( "Load default lables from : " + DEFAULT_LABLES_FILE_NAME ) ; addLables ( JKIOUtil . readPropertiesFile ( DEFAULT_LABLES_FILE_NAME ) ) ; } } | Load default configurations . | 83 | 4 |
141,107 | public static < T > T cloneBean ( final Object bean ) { try { return ( T ) BeanUtils . cloneBean ( bean ) ; } catch ( IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e ) { throw new RuntimeException ( e ) ; } } | Clone bean . | 65 | 4 |
141,108 | public static Class < ? > getClass ( final String beanClassName ) { try { return Class . forName ( beanClassName ) ; } catch ( final ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } } | Gets the class . | 50 | 5 |
141,109 | public static < T > T getPropertyValue ( final Object instance , final String fieldName ) { try { return ( T ) PropertyUtils . getProperty ( instance , fieldName ) ; } catch ( final Exception e ) { throw new RuntimeException ( e ) ; } } | Gets the property value . | 57 | 6 |
141,110 | public static boolean isBoolean ( final Class type ) { if ( Boolean . class . isAssignableFrom ( type ) ) { return true ; } return type . getName ( ) . equals ( "boolean" ) ; } | Checks if is boolean . | 49 | 6 |
141,111 | public static void setPeopertyValue ( final Object target , final String fieldName , Object value ) { JK . logger . trace ( "setPeopertyValue On class({}) on field ({}) with value ({})" , target , fieldName , value ) ; try { if ( value != null ) { Field field = getFieldByName ( target . getClass ( ) , fieldName ) ; if ( field . getType ( ) . isEnum ( ) ) { Class < ? extends Enum > clas = ( Class ) field . getType ( ) ; value = Enum . valueOf ( clas , value . toString ( ) ) ; JK . logger . debug ( "Field is enum, new value is ({}) for class ({})" , value , value . getClass ( ) ) ; } } PropertyUtils . setNestedProperty ( target , fieldName , value ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } | Sets the peoperty value . | 209 | 8 |
141,112 | public static void addItemToList ( final Object target , final String fieldName , final Object value ) { try { List list = ( List ) getFieldValue ( target , fieldName ) ; list . add ( value ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } | Adds the item to list . | 64 | 6 |
141,113 | public static Class < ? > toClass ( final String name ) { try { return Class . forName ( name ) ; } catch ( final ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } } | To class . | 46 | 3 |
141,114 | public static Class < ? > [ ] toClassesFromObjects ( final Object [ ] params ) { final Class < ? > [ ] classes = new Class < ? > [ params . length ] ; int i = 0 ; for ( final Object object : params ) { if ( object != null ) { classes [ i ++ ] = object . getClass ( ) ; } else { classes [ i ++ ] = Object . class ; } } return classes ; } | To classes from objects . | 95 | 5 |
141,115 | public static boolean isMethodDirectlyExists ( Object object , String methodName , Class < ? > ... params ) { try { Method method = object . getClass ( ) . getDeclaredMethod ( methodName , params ) ; return true ; } catch ( NoSuchMethodException e ) { return false ; } catch ( SecurityException e ) { throw new RuntimeException ( e ) ; } } | Checks if is method directly exists . | 82 | 8 |
141,116 | public static Object toObject ( final String xml ) { // XStream x = createXStream(); // return x.fromXML(xml); // try { final ByteArrayInputStream out = new ByteArrayInputStream ( xml . getBytes ( ) ) ; final XMLDecoder encoder = new XMLDecoder ( out ) ; final Object object = encoder . readObject ( ) ; // encoder . close ( ) ; return object ; // } catch (Exception e) { // System.err.println("Failed to decode object : \n" + xml); // return null; // } // return null; } | To object . | 130 | 3 |
141,117 | public static < T > Class < ? extends T > getGenericParamter ( String handler ) { ParameterizedType parameterizedType = ( ParameterizedType ) JKObjectUtil . getClass ( handler ) . getGenericInterfaces ( ) [ 0 ] ; Class < ? extends T > clas = ( Class < ? extends T > ) ( parameterizedType . getActualTypeArguments ( ) [ 0 ] ) ; return clas ; } | Gets the generic paramter . | 96 | 7 |
141,118 | public static boolean isClassAvilableInClassPath ( String string ) { try { Class . forName ( string ) ; return true ; } catch ( ClassNotFoundException e ) { return false ; } } | Checks if is class avilable in class path . | 44 | 12 |
141,119 | public static < T > String getInstanceVariables ( Class < T > clas ) { StringBuffer fieldsString = new StringBuffer ( ) ; Field [ ] fields = clas . getDeclaredFields ( ) ; int i = 0 ; for ( Field field : fields ) { if ( i ++ > 0 ) { fieldsString . append ( JK . CSV_SEPARATOR ) ; } fieldsString . append ( field . getName ( ) ) ; } return fieldsString . toString ( ) ; } | Gets the instance variables . | 107 | 6 |
141,120 | public static String toJson ( Object obj ) { ObjectMapper mapper = new ObjectMapper ( ) ; try { return mapper . writeValueAsString ( obj ) ; } catch ( IOException e ) { JK . throww ( e ) ; return null ; } } | To json . | 60 | 3 |
141,121 | public static < T > Object jsonToObject ( String json , Class < T > clas ) { ObjectMapper mapper = new ObjectMapper ( ) ; try { return mapper . readValue ( json , clas ) ; } catch ( IOException e ) { JK . throww ( e ) ; return null ; } } | Json to object . | 71 | 5 |
141,122 | public static String getFieldNameByType ( Class < ? > classType , Class < ? > fieldType ) { Field [ ] declaredFields = classType . getDeclaredFields ( ) ; for ( Field field : declaredFields ) { if ( field . getType ( ) . isAssignableFrom ( fieldType ) ) { return field . getName ( ) ; } } if ( classType . getSuperclass ( ) != null ) { return getFieldNameByType ( classType . getSuperclass ( ) , fieldType ) ; } return null ; } | Gets the field name by type . | 121 | 8 |
141,123 | public static boolean isFieldExists ( Class < ? > clas , String fieldName ) { Field [ ] fields = clas . getDeclaredFields ( ) ; for ( Field field : fields ) { if ( field . getName ( ) . equals ( fieldName ) ) { return true ; } } if ( clas . getSuperclass ( ) != null ) { return isFieldExists ( clas . getSuperclass ( ) , fieldName ) ; } return false ; } | Checks if is field exists . | 103 | 7 |
141,124 | public static List < String > getAllClassesInPackage ( String packageName ) { List < String > classesNames = new Vector <> ( ) ; // create scanner and disable default filters (that is the 'false' argument) final ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider ( false ) ; // add include filters which matches all the classes (or use your own) provider . addIncludeFilter ( new RegexPatternTypeFilter ( Pattern . compile ( ".*" ) ) ) ; // get matching classes defined in the package final Set < BeanDefinition > classes = provider . findCandidateComponents ( packageName ) ; // this is how you can load the class type from BeanDefinition instance for ( BeanDefinition bean : classes ) { classesNames . add ( bean . getBeanClassName ( ) ) ; } return classesNames ; } | Gets the all classes in package . | 185 | 8 |
141,125 | public static List < Field > getAllFields ( Class < ? > clas ) { JK . fixMe ( "add caching.." ) ; List < Field > list = new Vector <> ( ) ; // start by fields from the super class if ( clas . getSuperclass ( ) != null ) { list . addAll ( getAllFields ( clas . getSuperclass ( ) ) ) ; } Field [ ] fields = clas . getDeclaredFields ( ) ; for ( Field field : fields ) { if ( ! Modifier . isStatic ( field . getModifiers ( ) ) ) { list . add ( field ) ; } } return list ; } | Gets the all fields . | 145 | 6 |
141,126 | public static < T > T createInstanceForGenericClass ( Object parent ) { try { Object instance = getGenericClassFromParent ( parent ) . newInstance ( ) ; return ( T ) instance ; } catch ( InstantiationException | IllegalAccessException e ) { JK . throww ( e ) ; } return null ; } | Creates the instance for generic class . | 68 | 8 |
141,127 | public static Class getGenericClassFromParent ( Object parent ) { return ( Class ) ( ( ParameterizedType ) parent . getClass ( ) . getGenericSuperclass ( ) ) . getActualTypeArguments ( ) [ 0 ] ; } | Gets the generic class from parent . | 52 | 8 |
141,128 | public static String formatDouble ( final Double amount , String pattern ) { if ( pattern == null || pattern . equals ( "" ) ) { pattern = JKFormatUtil . DEFAULT_DOUBLE_FORMAT ; } return JKFormatUtil . getNumberFormatter ( pattern ) . format ( amount ) ; } | Format double . | 68 | 3 |
141,129 | public synchronized static String formatTime ( final Time object , String pattern ) { if ( pattern == null || pattern . equals ( "" ) ) { pattern = JKFormatUtil . DEFAULT_TIME_PATTERN ; } return JKFormatUtil . getDateFormatter ( pattern ) . format ( object ) ; } | Format time . | 68 | 3 |
141,130 | public synchronized static String formatTimeStamp ( final Timestamp date , String pattern ) { if ( pattern == null || pattern . equals ( "" ) ) { pattern = JKFormatUtil . DEFAULT_TIMESTAMP_PATTERN ; } return JKFormatUtil . getDateFormatter ( pattern ) . format ( date ) ; } | Format time stamp . | 74 | 4 |
141,131 | public static Format getDateFormatter ( final String pattern ) { Format format = JKFormatUtil . formatMap . get ( pattern ) ; if ( format == null ) { format = new SimpleDateFormat ( pattern ) ; JKFormatUtil . formatMap . put ( pattern , format ) ; } return format ; } | Gets the date formatter . | 68 | 7 |
141,132 | public static Format getNumberFormatter ( final String pattern ) { Format format = JKFormatUtil . formatMap . get ( pattern ) ; if ( format == null ) { format = new DecimalFormat ( pattern ) ; JKFormatUtil . formatMap . put ( pattern , format ) ; } return format ; } | Gets the number formatter . | 68 | 7 |
141,133 | public static String formatNumber ( Number count ) { Format numberFormatter = getNumberFormatter ( DEFAULT_NUMBER_FORMAT ) ; return numberFormatter . format ( count ) ; } | Format number . | 41 | 3 |
141,134 | public static java . util . Date parseDate ( String strDate , String pattern ) { try { SimpleDateFormat parser = new SimpleDateFormat ( pattern , Locale . US ) ; return parser . parse ( strDate ) ; } catch ( ParseException e ) { throw new JKException ( e ) ; } } | Parses the date . | 67 | 6 |
141,135 | public static int getYearFromData ( Date date ) { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; return cal . get ( Calendar . YEAR ) ; } | Gets the year from data . | 41 | 7 |
141,136 | public static boolean isTimesEqaualed ( Date time1 , Date time2 ) { return formatTime ( time1 ) . equals ( formatTime ( time2 ) ) ; } | Checks if is times eqaualed . | 38 | 9 |
141,137 | public static int getNumOfMonths ( Date date1 , Date date2 ) { Calendar firstDate = Calendar . getInstance ( ) ; Date date = new Date ( date1 . getTime ( ) ) ; firstDate . setTime ( date ) ; Calendar secondDate = Calendar . getInstance ( ) ; Date date3 = new Date ( date2 . getTime ( ) ) ; secondDate . setTime ( date3 ) ; int months = firstDate . get ( Calendar . MONTH ) - secondDate . get ( Calendar . MONTH ) ; return months ; } | Gets the num of months . | 119 | 7 |
141,138 | public static CompareDates compareTwoDates ( Date date1 , Date date2 ) { Date d1 = new Date ( date1 . getTime ( ) ) ; // to unify the format of the dates // before the compare Date d2 = new Date ( date2 . getTime ( ) ) ; if ( d1 . compareTo ( d2 ) < 0 ) return CompareDates . DATE1_LESS_THAN_DATE2 ; else if ( d1 . compareTo ( d2 ) > 0 ) return CompareDates . DATE1_GREATER_THAN_DATE2 ; else return CompareDates . DATE1_EQUAL_DATE2 ; } | Compare two dates . | 149 | 4 |
141,139 | public static Date adddDaysToCurrentDate ( int numberOfDays ) { Date date = new Date ( ) ; Calendar instance = Calendar . getInstance ( ) ; instance . setTime ( date ) ; instance . add ( Calendar . DATE , numberOfDays ) ; return instance . getTime ( ) ; } | Addd days to current date . | 65 | 7 |
141,140 | public static boolean isDate ( String strDate , String pattern ) { try { parseDate ( strDate , pattern ) ; return true ; } catch ( Exception e ) { return false ; } } | Checks if is date . | 40 | 6 |
141,141 | public static Date addMonths ( Date date , int numOfMonths ) { Calendar instance = Calendar . getInstance ( ) ; instance . setTime ( date ) ; instance . add ( Calendar . MONTH , numOfMonths ) ; return instance . getTime ( ) ; } | Adds the months . | 59 | 4 |
141,142 | public static long getDifference ( Time timeFrom , Time timeTo ) { try { DateFormat format = new SimpleDateFormat ( "HH:mm:ss" ) ; // the a means am/pm marker Date date = format . parse ( timeFrom . toString ( ) ) ; Date date2 = format . parse ( timeTo . toString ( ) ) ; long difference = ( date2 . getTime ( ) - date . getTime ( ) ) / 1000 / 60 ; return difference ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } | Gets the difference . | 121 | 5 |
141,143 | private static int getDayOfMonth ( Date date ) { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; return cal . get ( Calendar . DAY_OF_MONTH ) ; } | Gets the day of month . | 46 | 7 |
141,144 | public static int getDayOfWeek ( Date date ) { Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; return cal . get ( Calendar . DAY_OF_WEEK ) ; } | Gets the day of week . | 46 | 7 |
141,145 | public static int getHour ( Date timeFrom ) { Calendar instance = Calendar . getInstance ( ) ; instance . setTime ( timeFrom ) ; int hour = instance . get ( Calendar . HOUR ) ; return hour ; } | Gets the hour . | 47 | 5 |
141,146 | public static boolean isCurrentTimeBetweenTowTimes ( Date fromDate , Date fromTime , Date toDate , Date timeTo ) { JKTimeObject currntTime = getCurrntTime ( ) ; JKTimeObject fromTimeObject = new JKTimeObject ( ) ; JKTimeObject toTimeObject = new JKTimeObject ( ) ; if ( currntTime . after ( fromTimeObject . toTimeObject ( fromDate , fromTime ) ) && currntTime . before ( toTimeObject . toTimeObject ( toDate , timeTo ) ) ) { return true ; } return false ; } | Checks if is current time between tow times . | 134 | 10 |
141,147 | public static long getDayDifference ( Date startDate , Date endDate ) { long startTime = startDate . getTime ( ) ; long endTime = endDate . getTime ( ) ; long diffTime = endTime - startTime ; long diffDays = TimeUnit . MILLISECONDS . toDays ( diffTime ) ; return diffDays ; } | Gets the day difference . | 76 | 6 |
141,148 | public static long getSecondsDifference ( Date startDate , Date endDate ) { long startTime = startDate . getTime ( ) ; long endTime = endDate . getTime ( ) ; long diffTime = endTime - startTime ; long diffInSeconds = TimeUnit . MILLISECONDS . toSeconds ( diffTime ) ; return diffInSeconds ; } | Gets the seconds difference . | 82 | 6 |
141,149 | public static long getHoursDifference ( Date startDate , Date endDate ) { long startTime = startDate . getTime ( ) ; long endTime = endDate . getTime ( ) ; long diffTime = endTime - startTime ; long diffInHours = TimeUnit . MILLISECONDS . toHours ( diffTime ) ; return diffInHours ; } | Gets the hours difference . | 78 | 6 |
141,150 | public static long getMillisDifference ( Date startDate , Date endDate ) { long startTime = startDate . getTime ( ) ; long endTime = endDate . getTime ( ) ; long diffTime = endTime - startTime ; return diffTime ; } | Gets the millis difference . | 57 | 7 |
141,151 | public static long getMinutesDifference ( Date startDate , Date endDate ) { long startTime = startDate . getTime ( ) ; long endTime = endDate . getTime ( ) ; long diffTime = endTime - startTime ; long diffInMinutes = TimeUnit . MILLISECONDS . toMinutes ( diffTime ) ; return diffInMinutes ; } | Gets the minutes difference . | 82 | 6 |
141,152 | public static boolean isDateEqaualed ( final java . util . Date date1 , final java . util . Date date2 ) { final String d1 = JKFormatUtil . formatDate ( date1 , JKFormatUtil . MYSQL_DATE_DB_PATTERN ) ; final String d2 = JKFormatUtil . formatDate ( date2 , JKFormatUtil . MYSQL_DATE_DB_PATTERN ) ; return d1 . equalsIgnoreCase ( d2 ) ; } | Checks if is date eqaualed . | 117 | 9 |
141,153 | public static boolean isPeriodActive ( final Date startDate , final Date endDate ) { if ( startDate == null && endDate == null ) { return true ; } if ( startDate == null ) { throw new JKException ( "START_DATE_CAN_NOT_BE_NULL" ) ; } if ( endDate == null ) { throw new JKException ( "END_DATE_CAN_NOT_BE_NULL" ) ; } if ( compareTwoDates ( startDate , endDate ) . equals ( CompareDates . DATE1_GREATER_THAN_DATE2 ) ) { throw new JKException ( "START_DATE_MUST_BE_BEFORE_END_DATE" ) ; } final boolean startLessThanCurrent = compareTwoDates ( startDate , getSystemDate ( ) ) . equals ( CompareDates . DATE1_LESS_THAN_DATE2 ) ; final boolean endGreaterThanCurrent = compareTwoDates ( endDate , getSystemDate ( ) ) . equals ( CompareDates . DATE1_GREATER_THAN_DATE2 ) ; return startLessThanCurrent && endGreaterThanCurrent ; } | Checks if is period active . | 267 | 7 |
141,154 | private static List < AbstractMolecule > buildMolecule ( HELM2Notation helm2notation ) throws BuilderMoleculeException , ChemistryException { return BuilderMolecule . buildMoleculefromPolymers ( helm2notation . getListOfPolymers ( ) , HELM2NotationUtils . getAllEdgeConnections ( helm2notation . getListOfConnections ( ) ) ) ; } | method to build from one notation one molecule | 88 | 8 |
141,155 | public static double getMolecularWeight ( HELM2Notation helm2notation ) throws BuilderMoleculeException , CTKException , ChemistryException { /* First build one big molecule; List of molecules? */ List < AbstractMolecule > molecules = buildMolecule ( helm2notation ) ; return calculateMolecularWeight ( molecules ) ; } | method to get the molecular weight for the whole HELM | 74 | 11 |
141,156 | private static double calculateMolecularWeight ( List < AbstractMolecule > molecules ) throws BuilderMoleculeException , CTKException , ChemistryException { Double result = 0.0 ; for ( AbstractMolecule molecule : molecules ) { molecule = BuilderMolecule . mergeRgroups ( molecule ) ; result += Chemistry . getInstance ( ) . getManipulator ( ) . getMoleculeInfo ( molecule ) . getMolecularWeight ( ) ; } return result ; } | intern method to calculate the molecular weight for a list of molecules | 102 | 12 |
141,157 | public static double getExactMass ( HELM2Notation helm2notation ) throws BuilderMoleculeException , CTKException , ChemistryException { /* First build one big molecule; List of molecules */ List < AbstractMolecule > molecules = buildMolecule ( helm2notation ) ; return calculateExactMass ( molecules ) ; } | method to get the ExactMass for the whole HELM | 71 | 12 |
141,158 | private static double calculateExactMass ( List < AbstractMolecule > molecules ) throws CTKException , ChemistryException , BuilderMoleculeException { Double result = 0.0 ; for ( AbstractMolecule molecule : molecules ) { molecule = BuilderMolecule . mergeRgroups ( molecule ) ; result += Chemistry . getInstance ( ) . getManipulator ( ) . getMoleculeInfo ( molecule ) . getExactMass ( ) ; } return result ; } | intern method to calculate the exact mass for a list of molecules | 100 | 12 |
141,159 | public static String getMolecularFormular ( HELM2Notation helm2notation ) throws BuilderMoleculeException , CTKException , ChemistryException { /* First build HELM molecule */ List < AbstractMolecule > molecules = buildMolecule ( helm2notation ) ; LOG . info ( "Build process is finished" ) ; return calculateMolecularFormula ( molecules ) ; } | method to get the MolecularFormular for the whole HELM | 83 | 12 |
141,160 | private static String calculateMolecularFormula ( List < AbstractMolecule > molecules ) throws BuilderMoleculeException , CTKException , ChemistryException { Map < String , Integer > atomNumberMap = new TreeMap < String , Integer > ( ) ; for ( AbstractMolecule molecule : molecules ) { LOG . info ( molecule . getMolecule ( ) . toString ( ) ) ; atomNumberMap = generateAtomNumberMap ( molecule , atomNumberMap ) ; } LOG . info ( "GET map" ) ; StringBuilder sb = new StringBuilder ( ) ; Set < String > atoms = atomNumberMap . keySet ( ) ; for ( Iterator < String > i = atoms . iterator ( ) ; i . hasNext ( ) ; ) { String atom = i . next ( ) ; String num = atomNumberMap . get ( atom ) . toString ( ) ; if ( num . equals ( "1" ) ) { num = "" ; } sb . append ( atom ) ; sb . append ( num . toString ( ) ) ; } return sb . toString ( ) ; } | intern method to calculate the molecular formular for a list of molecules | 237 | 13 |
141,161 | public static MoleculeProperty getMoleculeProperties ( HELM2Notation helm2notation ) throws BuilderMoleculeException , CTKException , ExtinctionCoefficientException , ChemistryException { MoleculeProperty result = new MoleculeProperty ( ) ; /* First build HELM molecule */ List < AbstractMolecule > molecules = buildMolecule ( helm2notation ) ; /* calculate molecular formula */ result . setMolecularFormula ( calculateMolecularFormula ( molecules ) ) ; /* calculate molecular weight */ result . setMolecularWeight ( calculateMolecularWeight ( molecules ) ) ; /* calculate exact mass */ result . setExactMass ( calculateExactMass ( molecules ) ) ; /* add Extinction Coefficient calculation to it */ result . setExtinctionCoefficient ( ExtinctionCoefficient . getInstance ( ) . calculate ( helm2notation ) ) ; return result ; } | method to get all molecule properties for one HELM2Notation | 191 | 13 |
141,162 | private static Map < String , Integer > generateAtomNumberMap ( AbstractMolecule molecule , Map < String , Integer > mapAtoms ) throws BuilderMoleculeException , CTKException , ChemistryException { molecule = BuilderMolecule . mergeRgroups ( molecule ) ; LOG . info ( "Merge group is finished" ) ; String formula = Chemistry . getInstance ( ) . getManipulator ( ) . getMoleculeInfo ( molecule ) . getMolecularFormula ( ) ; String atom = "" ; String number = "" ; for ( int i = 0 ; i < formula . length ( ) ; i ++ ) { String oneChar = String . valueOf ( formula . charAt ( i ) ) ; if ( oneChar . matches ( "[A-Z]" ) ) { if ( atom . length ( ) == 0 ) { atom = oneChar ; } else { if ( number == "" ) { number = "1" ; } if ( mapAtoms . get ( atom ) != null ) { mapAtoms . put ( atom , mapAtoms . get ( atom ) + Integer . valueOf ( number ) ) ; } else { mapAtoms . put ( atom , Integer . valueOf ( number ) ) ; } atom = oneChar ; number = "" ; } } else if ( oneChar . matches ( "[a-z]" ) ) { if ( atom . length ( ) > 0 ) { atom = atom + oneChar ; } } else { if ( number . length ( ) == 0 ) { number = oneChar ; } else { number = number + oneChar ; } } } if ( number == "" ) { number = "1" ; } if ( mapAtoms . get ( atom ) != null ) { mapAtoms . put ( atom , mapAtoms . get ( atom ) + Integer . valueOf ( number ) ) ; } else { mapAtoms . put ( atom , Integer . valueOf ( number ) ) ; } return mapAtoms ; } | method to get for every atom the number of occurences | 421 | 12 |
141,163 | public void switchOff ( BitSet switchGroupAddress , int switchCode ) { if ( switchGroupAddress . length ( ) > 5 ) { throw new IllegalArgumentException ( "switch group address has more than 5 bits!" ) ; } this . sendTriState ( this . getCodeWordA ( switchGroupAddress , switchCode , false ) ) ; } | Switch a remote switch off | 74 | 5 |
141,164 | public void send ( final String bitString ) { BitSet bitSet = new BitSet ( bitString . length ( ) ) ; for ( int i = 0 ; i < bitString . length ( ) ; i ++ ) { if ( bitString . charAt ( i ) == ' ' ) { bitSet . set ( i ) ; } } send ( bitSet , bitString . length ( ) ) ; } | Send a string of bits | 86 | 5 |
141,165 | public void send ( final BitSet bitSet , int length ) { if ( transmitterPin != null ) { for ( int nRepeat = 0 ; nRepeat < repeatTransmit ; nRepeat ++ ) { for ( int i = 0 ; i < length ; i ++ ) { if ( bitSet . get ( i ) ) { transmit ( protocol . getOneBit ( ) ) ; } else { transmit ( protocol . getZeroBit ( ) ) ; } } sendSync ( ) ; } transmitterPin . low ( ) ; } } | Send a set of bits | 110 | 5 |
141,166 | public void sendTriState ( String codeWord ) { if ( transmitterPin != null ) { for ( int nRepeat = 0 ; nRepeat < repeatTransmit ; nRepeat ++ ) { for ( int i = 0 ; i < codeWord . length ( ) ; ++ i ) { switch ( codeWord . charAt ( i ) ) { case ' ' : this . sendT0 ( ) ; break ; case ' ' : this . sendTF ( ) ; break ; case ' ' : this . sendT1 ( ) ; break ; } } this . sendSync ( ) ; } transmitterPin . low ( ) ; } } | Sends a Code Word | 131 | 5 |
141,167 | public static BitSet getSwitchGroupAddress ( String address ) { if ( address . length ( ) != 5 ) { throw new IllegalArgumentException ( "the switchGroupAddress must consist of exactly 5 bits!" ) ; } BitSet bitSet = new BitSet ( 5 ) ; for ( int i = 0 ; i < 5 ; i ++ ) { bitSet . set ( i , address . charAt ( i ) == ' ' ) ; } return bitSet ; } | convenient method to convert a string like 11011 to a BitSet . | 98 | 15 |
141,168 | public static boolean start ( RootDoc root ) throws Exception { umlProject = null ; mainGui = null ; Standard . start ( root ) ; setOptions ( root ) ; openOrCreateUmlProject ( root ) ; generateUml ( root ) ; return true ; } | Standard doclet start method | 58 | 5 |
141,169 | public static int optionLength ( String option ) { int result = Standard . optionLength ( option ) ; if ( result == 0 ) { if ( option . equals ( OPTION_PATH_UML_PROJECT ) ) { result = 2 ; } } return result ; } | Standard doclet method must be present! | 57 | 8 |
141,170 | public final void add ( final String problem , final Severity severity ) { this . problems . add ( new Problem ( problem , severity ) ) ; this . hasFatal |= severity == Severity . FATAL ; } | Add a problem with the specified severity . | 46 | 8 |
141,171 | public final Problem getLeadProblem ( ) { Collections . sort ( this . problems ) ; return this . problems . isEmpty ( ) ? null : this . problems . get ( this . problems . size ( ) - 1 ) ; } | Get the first problem of the highest severity . | 48 | 9 |
141,172 | public String toMutilLineString ( ) { final String newLine = System . getProperty ( "line.separator" ) ; final StringBuffer problemStr = new StringBuffer ( ) ; for ( final Problem problem : this . problems ) { problemStr . append ( problem . getMessage ( ) + newLine ) ; } return problemStr . toString ( ) ; } | To mutil line string . | 78 | 6 |
141,173 | public static int getTotalMonomerCount ( PolymerNotation polymer ) { int count = 0 ; for ( MonomerNotation element : polymer . getPolymerElements ( ) . getListOfElements ( ) ) { count += getMonomerCountFromMonomerNotation ( element ) ; } return count ; } | method to get the total monomer count of one PolymerNotation | 71 | 14 |
141,174 | private static int getMonomerCountFromMonomerNotation ( MonomerNotation monomerNotation ) { int multiply ; try { multiply = Integer . parseInt ( monomerNotation . getCount ( ) ) ; if ( multiply < 1 ) { multiply = 1 ; } } catch ( NumberFormatException e ) { multiply = 1 ; } if ( monomerNotation instanceof MonomerNotationGroup ) { return 1 * multiply ; } if ( monomerNotation instanceof MonomerNotationList ) { int count = 0 ; for ( MonomerNotation unit : ( ( MonomerNotationList ) monomerNotation ) . getListofMonomerUnits ( ) ) { count += getMonomerCountFromMonomerNotation ( unit ) ; } return count * multiply ; } if ( monomerNotation instanceof MonomerNotationUnitRNA ) { int count = 0 ; for ( MonomerNotationUnit unit : ( ( MonomerNotationUnitRNA ) monomerNotation ) . getContents ( ) ) { count += getMonomerCountFromMonomerNotation ( unit ) ; } return count * multiply ; } return 1 * multiply ; } | method to get the number of all existing monomers from one MonomerNotation | 254 | 16 |
141,175 | public String nextGroup ( ) { int currentPosition = this . position ; do { char currentCharacter = this . characters [ currentPosition ] ; if ( currentCharacter == ' ' ) { currentPosition = NucleotideParser . getMatchingBracketPosition ( this . characters , currentPosition , ' ' , ' ' ) ; } else if ( currentCharacter == ' ' ) { currentPosition = NucleotideParser . getMatchingBracketPosition ( this . characters , currentPosition , ' ' , ' ' ) ; } else if ( currentCharacter != ' ' ) { currentPosition ++ ; } if ( currentPosition < 0 ) { currentPosition = this . characters . length ; } } while ( ( currentPosition < this . characters . length ) && ( this . characters [ currentPosition ] != ' ' ) ) ; String token = this . notationString . substring ( this . position , currentPosition ) ; this . position = currentPosition + 1 ; return token ; } | Returns the next group | 201 | 4 |
141,176 | public final static String toJSON ( HELM2Notation helm2notation ) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper ( ) ; String jsonINString = mapper . writeValueAsString ( helm2notation ) ; jsonINString = mapper . writerWithDefaultPrettyPrinter ( ) . writeValueAsString ( helm2notation ) ; return jsonINString ; } | method to generate a JSON - Object from the given HELM2Notation | 86 | 15 |
141,177 | public final static List < ConnectionNotation > getAllEdgeConnections ( List < ConnectionNotation > connections ) { List < ConnectionNotation > listEdgeConnection = new ArrayList < ConnectionNotation > ( ) ; for ( ConnectionNotation connection : connections ) { if ( ! ( connection . getrGroupSource ( ) . equals ( "pair" ) ) ) { listEdgeConnection . add ( connection ) ; } } return listEdgeConnection ; } | method to get all edge connections of a given List of ConnectionNotation | 94 | 14 |
141,178 | public final static List < PolymerNotation > getRNAPolymers ( List < PolymerNotation > polymers ) { List < PolymerNotation > rnaPolymers = new ArrayList < PolymerNotation > ( ) ; for ( PolymerNotation polymer : polymers ) { if ( polymer . getPolymerID ( ) instanceof RNAEntity ) { rnaPolymers . add ( polymer ) ; } } return rnaPolymers ; } | method to get all rna polymers given a List of PolymerNotation objects | 98 | 17 |
141,179 | public final static List < PolymerNotation > getPeptidePolymers ( List < PolymerNotation > polymers ) { List < PolymerNotation > peptidePolymers = new ArrayList < PolymerNotation > ( ) ; for ( PolymerNotation polymer : polymers ) { if ( polymer . getPolymerID ( ) instanceof PeptideEntity ) { peptidePolymers . add ( polymer ) ; } } return peptidePolymers ; } | method to get all peptide polymers given a list of PolymerNotation objects | 101 | 17 |
141,180 | public final static List < PolymerNotation > getCHEMPolymers ( List < PolymerNotation > polymers ) { List < PolymerNotation > chemPolymers = new ArrayList < PolymerNotation > ( ) ; for ( PolymerNotation polymer : polymers ) { if ( polymer . getPolymerID ( ) instanceof ChemEntity ) { chemPolymers . add ( polymer ) ; } } return chemPolymers ; } | method to get all chem polymers given a list of PolymerNotation objects | 95 | 16 |
141,181 | public final static List < PolymerNotation > getBLOBPolymers ( List < PolymerNotation > polymers ) { List < PolymerNotation > blobPolymers = new ArrayList < PolymerNotation > ( ) ; for ( PolymerNotation polymer : polymers ) { if ( polymer . getPolymerID ( ) instanceof BlobEntity ) { blobPolymers . add ( polymer ) ; } } return blobPolymers ; } | method to get all blob polymers given a list of PolymerNotation objects | 96 | 16 |
141,182 | public final static void combineHELM2notation ( HELM2Notation helm2notation , HELM2Notation newHELM2Notation ) throws NotationException { HELM2NotationUtils . helm2notation = helm2notation ; Map < String , String > mapIds = generateMapChangeIds ( newHELM2Notation . getPolymerAndGroupingIDs ( ) ) ; /* method to merge the new HELM2Notation into the existing one */ /* section 1 */ /* id's have to changed */ section1 ( newHELM2Notation . getListOfPolymers ( ) , mapIds ) ; /* section 2 */ section2 ( newHELM2Notation . getListOfConnections ( ) , mapIds ) ; /* section 3 */ section3 ( newHELM2Notation . getListOfGroupings ( ) , mapIds ) ; /* section 4 */ section4 ( newHELM2Notation . getListOfAnnotations ( ) , mapIds ) ; } | method to add a new HELMNotation to another HELM2Notation the new HELM2Notation will be merged to the first HELM2Notation | 225 | 34 |
141,183 | private static Map < String , String > generateMapChangeIds ( List < String > newIDs ) { Map < String , String > mapIds = new HashMap < String , String > ( ) ; List < String > oldIds = HELM2NotationUtils . helm2notation . getPolymerAndGroupingIDs ( ) ; Map < String , String > mapOldIds = new HashMap < String , String > ( ) ; for ( String oldID : oldIds ) { mapOldIds . put ( oldID , "" ) ; } for ( String newId : newIDs ) { if ( mapOldIds . containsKey ( newId ) ) { int i = 1 ; String type = newId . split ( "\\d" ) [ 0 ] ; while ( mapOldIds . containsKey ( type + i ) ) { i ++ ; } mapIds . put ( newId , type + i ) ; } } return mapIds ; } | method to generate a Map of old ids with the new ids | 209 | 14 |
141,184 | private static void section1 ( List < PolymerNotation > polymers , Map < String , String > mapIds ) throws NotationException { for ( PolymerNotation polymer : polymers ) { if ( mapIds . containsKey ( polymer . getPolymerID ( ) . getId ( ) ) ) { /* change id */ PolymerNotation newpolymer = new PolymerNotation ( mapIds . get ( polymer . getPolymerID ( ) . getId ( ) ) ) ; newpolymer = new PolymerNotation ( newpolymer . getPolymerID ( ) , polymer . getPolymerElements ( ) ) ; helm2notation . addPolymer ( newpolymer ) ; } else { helm2notation . addPolymer ( polymer ) ; } } } | method to add PolymerNotations to the existent | 170 | 11 |
141,185 | private static void section2 ( List < ConnectionNotation > connections , Map < String , String > mapIds ) throws NotationException { for ( ConnectionNotation connection : connections ) { HELMEntity first = connection . getSourceId ( ) ; String idFirst = first . getId ( ) ; HELMEntity second = connection . getTargetId ( ) ; String idSecond = second . getId ( ) ; if ( mapIds . containsKey ( idFirst ) ) { first = new ConnectionNotation ( mapIds . get ( idFirst ) ) . getSourceId ( ) ; } if ( mapIds . containsKey ( idSecond ) ) { second = new ConnectionNotation ( mapIds . get ( idSecond ) ) . getSourceId ( ) ; } ConnectionNotation newConnection = new ConnectionNotation ( first , second , connection . getSourceUnit ( ) , connection . getrGroupSource ( ) , connection . getTargetUnit ( ) , connection . getrGroupTarget ( ) , connection . getAnnotation ( ) ) ; helm2notation . addConnection ( newConnection ) ; } } | method to add ConnectionNotation to the existent | 238 | 10 |
141,186 | private static void section3 ( List < GroupingNotation > groupings , Map < String , String > mapIds ) throws NotationException { for ( GroupingNotation grouping : groupings ) { GroupEntity groupID = grouping . getGroupID ( ) ; if ( mapIds . containsKey ( groupID . getId ( ) ) ) { groupID = new GroupingNotation ( mapIds . get ( groupID . getId ( ) ) ) . getGroupID ( ) ; } String details = grouping . toHELM2 ( ) . split ( "\\(" ) [ 1 ] . split ( "\\)" ) [ 0 ] ; details = changeIDs ( details , mapIds ) ; helm2notation . addGrouping ( new GroupingNotation ( groupID , details ) ) ; } } | method to add groupings to the existent grouping section | 175 | 11 |
141,187 | private static void section4 ( List < AnnotationNotation > annotations , Map < String , String > mapIds ) { for ( AnnotationNotation annotation : annotations ) { String notation = annotation . getAnnotation ( ) ; notation = changeIDs ( notation , mapIds ) ; helm2notation . addAnnotation ( new AnnotationNotation ( notation ) ) ; } } | method to add annotations to the existent annotation section | 80 | 10 |
141,188 | private static String changeIDs ( String text , Map < String , String > mapIds ) { String result = text ; for ( String key : mapIds . keySet ( ) ) { result = result . replace ( key , mapIds . get ( key ) ) ; } return result ; } | method to change the ids in a text according to map | 63 | 12 |
141,189 | public static final int getTotalMonomerCount ( HELM2Notation helm2notation ) { int result = 0 ; for ( PolymerNotation polymer : helm2notation . getListOfPolymers ( ) ) { result += PolymerUtils . getTotalMonomerCount ( polymer ) ; } return result ; } | method to get the total number of MonomerNotationUnits in a HELMNotation object | 69 | 20 |
141,190 | public static boolean hasNucleotideModification ( List < PolymerNotation > polymers ) throws NotationException { for ( PolymerNotation polymer : getRNAPolymers ( polymers ) ) { if ( RNAUtils . hasNucleotideModification ( polymer ) ) { return true ; } } return false ; } | method to check if any of the rna polymers have a modified nucleotide | 70 | 16 |
141,191 | public static String [ ] getFormatedSirnaSequences ( HELM2Notation helm2notation ) throws NotationException , RNAUtilsException , HELM2HandledException , org . helm . notation2 . exception . NotationException , ChemistryException { return getFormatedSirnaSequences ( helm2notation , DEFAULT_PADDING_CHAR , DEFAULT_BASE_PAIR_CHAR ) ; } | generate formated siRNA sequence with default padding char and base - pair char | | 90 | 17 |
141,192 | private static String reverseString ( String source ) { int i ; int len = source . length ( ) ; StringBuffer dest = new StringBuffer ( ) ; for ( i = ( len - 1 ) ; i >= 0 ; i -- ) { dest . append ( source . charAt ( i ) ) ; } return dest . toString ( ) ; } | method to reverse a String | 73 | 5 |
141,193 | public List < HELM2Notation > decompose ( HELM2Notation helm2notation ) { List < HELM2Notation > list = new ArrayList < HELM2Notation > ( ) ; List < ConnectionNotation > allselfConnections = getAllSelfCycleConnections ( helm2notation . getListOfConnections ( ) ) ; for ( PolymerNotation polymer : helm2notation . getListOfPolymers ( ) ) { HELM2Notation single = new HELM2Notation ( ) ; single . addPolymer ( polymer ) ; List < ConnectionNotation > selfConnections = getSelfCycleConnections ( polymer . getPolymerID ( ) . getId ( ) , allselfConnections ) ; for ( ConnectionNotation selfConnection : selfConnections ) { single . addConnection ( selfConnection ) ; } list . add ( single ) ; } return list ; } | decompose the HELM2 into smaller HELM2 objects | 195 | 13 |
141,194 | private static List < ConnectionNotation > getAllSelfCycleConnections ( List < ConnectionNotation > connections ) { List < ConnectionNotation > listSelfCycle = new ArrayList < ConnectionNotation > ( ) ; for ( ConnectionNotation connection : connections ) { if ( ( connection . getTargetId ( ) . getId ( ) . equals ( connection . getSourceId ( ) . getId ( ) ) ) ) { listSelfCycle . add ( connection ) ; } } return listSelfCycle ; } | method to get all self - cycle Connections | 110 | 9 |
141,195 | private static List < ConnectionNotation > getSelfCycleConnections ( String id , List < ConnectionNotation > connections ) { List < ConnectionNotation > list = new ArrayList < ConnectionNotation > ( ) ; for ( ConnectionNotation connection : connections ) { if ( connection . getSourceId ( ) . getId ( ) . equals ( id ) ) { list . add ( connection ) ; } } return list ; } | method to get for one polymer all self - cycle ConnectionNotations | 90 | 13 |
141,196 | public static List < PolymerNotation > getListOfPolymersSpecificType ( String str , List < PolymerNotation > polymers ) { List < PolymerNotation > list = new ArrayList < PolymerNotation > ( ) ; for ( PolymerNotation polymer : polymers ) { if ( polymer . getPolymerID ( ) . getType ( ) . equals ( str ) ) { list . add ( polymer ) ; } } return list ; } | method to get all polymers for one specific polymer type | 99 | 11 |
141,197 | public static String buildDynamicKey ( final Object [ ] paramNames , final Object [ ] paramValues ) { return Arrays . toString ( paramNames ) . concat ( Arrays . toString ( paramValues ) ) ; } | Builds the dynamic key . | 48 | 6 |
141,198 | private Map < String , String > deserializeNucleotideStore ( JsonParser parser ) throws JsonParseException , IOException { Map < String , String > nucleotides = new TreeMap < String , String > ( String . CASE_INSENSITIVE_ORDER ) ; String currentNucleotideSymbol = "" ; String currentNucleotideNotation = "" ; boolean foundSymbol = false ; boolean foundNotation = false ; parser . nextToken ( ) ; while ( parser . hasCurrentToken ( ) ) { String fieldName = parser . getCurrentName ( ) ; if ( fieldName != null ) { switch ( fieldName ) { case "symbol" : parser . nextToken ( ) ; currentNucleotideSymbol = parser . getText ( ) ; foundSymbol = true ; break ; case "notation" : parser . nextToken ( ) ; currentNucleotideNotation = parser . getText ( ) ; foundNotation = true ; break ; default : break ; } if ( foundSymbol && foundNotation ) { nucleotides . put ( currentNucleotideSymbol , currentNucleotideNotation ) ; foundNotation = false ; foundSymbol = false ; } } parser . nextToken ( ) ; } return nucleotides ; } | Private routine to deserialize nucleotide Store JSON . This is done manually to give more freedom regarding data returned by the webservice . | 274 | 28 |
141,199 | public static void fixPropertiesKeys ( final Properties prop ) { final Enumeration < Object > keys = prop . keys ( ) ; while ( keys . hasMoreElements ( ) ) { String currentKey = ( String ) keys . nextElement ( ) ; String fixedKey = fixPropertyKey ( currentKey ) ; String value = prop . getProperty ( currentKey ) ; value = fixPropertyValue ( value ) ; prop . remove ( currentKey ) ; prop . setProperty ( fixedKey , value ) ; } } | Fix properties keys . | 108 | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.