id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
31,400
gotev/android-upload-service
uploadservice/src/main/java/net/gotev/uploadservice/UploadFile.java
UploadFile.getProperty
public String getProperty(String key, String defaultValue) { String val = properties.get(key); if (val == null) { val = defaultValue; } return val; }
java
public String getProperty(String key, String defaultValue) { String val = properties.get(key); if (val == null) { val = defaultValue; } return val; }
[ "public", "String", "getProperty", "(", "String", "key", ",", "String", "defaultValue", ")", "{", "String", "val", "=", "properties", ".", "get", "(", "key", ")", ";", "if", "(", "val", "==", "null", ")", "{", "val", "=", "defaultValue", ";", "}", "r...
Gets a property associated to this file. @param key property key @param defaultValue default value to use if the key does not exist or the value is null @return property value or the default value passed
[ "Gets", "a", "property", "associated", "to", "this", "file", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadFile.java#L161-L169
31,401
gotev/android-upload-service
uploadservice-ftp/src/main/java/net/gotev/uploadservice/ftp/FTPUploadTask.java
FTPUploadTask.calculateUploadedAndTotalBytes
private void calculateUploadedAndTotalBytes() { uploadedBytes = 0; for (String filePath : getSuccessfullyUploadedFiles()) { uploadedBytes += new File(filePath).length(); } totalBytes = uploadedBytes; for (UploadFile file : params.files) { totalBytes += file.length(service); } }
java
private void calculateUploadedAndTotalBytes() { uploadedBytes = 0; for (String filePath : getSuccessfullyUploadedFiles()) { uploadedBytes += new File(filePath).length(); } totalBytes = uploadedBytes; for (UploadFile file : params.files) { totalBytes += file.length(service); } }
[ "private", "void", "calculateUploadedAndTotalBytes", "(", ")", "{", "uploadedBytes", "=", "0", ";", "for", "(", "String", "filePath", ":", "getSuccessfullyUploadedFiles", "(", ")", ")", "{", "uploadedBytes", "+=", "new", "File", "(", "filePath", ")", ".", "len...
Calculates the total bytes of this upload task. This the sum of all the lengths of the successfully uploaded files and also the pending ones.
[ "Calculates", "the", "total", "bytes", "of", "this", "upload", "task", ".", "This", "the", "sum", "of", "all", "the", "lengths", "of", "the", "successfully", "uploaded", "files", "and", "also", "the", "pending", "ones", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice-ftp/src/main/java/net/gotev/uploadservice/ftp/FTPUploadTask.java#L159-L171
31,402
gotev/android-upload-service
uploadservice-ftp/src/main/java/net/gotev/uploadservice/ftp/FTPUploadTask.java
FTPUploadTask.makeDirectories
private void makeDirectories(String dirPath, String permissions) throws IOException { if (!dirPath.contains("/")) return; String[] pathElements = dirPath.split("/"); if (pathElements.length == 1) return; // if the string ends with / it means that the dir path contains only directories, // otherwise if it does not contain /, the last element of the path is the file name, // so it must be ignored when creating the directory structure int lastElement = dirPath.endsWith("/") ? pathElements.length : pathElements.length - 1; for (int i = 0; i < lastElement; i++) { String singleDir = pathElements[i]; if (singleDir.isEmpty()) continue; if (!ftpClient.changeWorkingDirectory(singleDir)) { if (ftpClient.makeDirectory(singleDir)) { Logger.debug(LOG_TAG, "Created remote directory: " + singleDir); if (permissions != null) { setPermission(singleDir, permissions); } ftpClient.changeWorkingDirectory(singleDir); } else { throw new IOException("Unable to create remote directory: " + singleDir); } } } }
java
private void makeDirectories(String dirPath, String permissions) throws IOException { if (!dirPath.contains("/")) return; String[] pathElements = dirPath.split("/"); if (pathElements.length == 1) return; // if the string ends with / it means that the dir path contains only directories, // otherwise if it does not contain /, the last element of the path is the file name, // so it must be ignored when creating the directory structure int lastElement = dirPath.endsWith("/") ? pathElements.length : pathElements.length - 1; for (int i = 0; i < lastElement; i++) { String singleDir = pathElements[i]; if (singleDir.isEmpty()) continue; if (!ftpClient.changeWorkingDirectory(singleDir)) { if (ftpClient.makeDirectory(singleDir)) { Logger.debug(LOG_TAG, "Created remote directory: " + singleDir); if (permissions != null) { setPermission(singleDir, permissions); } ftpClient.changeWorkingDirectory(singleDir); } else { throw new IOException("Unable to create remote directory: " + singleDir); } } } }
[ "private", "void", "makeDirectories", "(", "String", "dirPath", ",", "String", "permissions", ")", "throws", "IOException", "{", "if", "(", "!", "dirPath", ".", "contains", "(", "\"/\"", ")", ")", "return", ";", "String", "[", "]", "pathElements", "=", "di...
Creates a nested directory structure on a FTP server and enters into it. @param dirPath Path of the directory, i.e /projects/java/ftp/demo @param permissions UNIX permissions to apply to created directories. If null, the FTP server defaults will be applied, because no UNIX permissions will be explicitly set @throws IOException if any error occurred during client-server communication
[ "Creates", "a", "nested", "directory", "structure", "on", "a", "FTP", "server", "and", "enters", "into", "it", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice-ftp/src/main/java/net/gotev/uploadservice/ftp/FTPUploadTask.java#L251-L279
31,403
gotev/android-upload-service
uploadservice-ftp/src/main/java/net/gotev/uploadservice/ftp/FTPUploadTask.java
FTPUploadTask.getRemoteFileName
private String getRemoteFileName(UploadFile file) { // if the remote path ends with / // it means that the remote path specifies only the directory structure, so // get the remote file name from the local file if (file.getProperty(PARAM_REMOTE_PATH).endsWith("/")) { return file.getName(service); } // if the remote path contains /, but it's not the last character // it means that I have something like: /path/to/myfilename // so the remote file name is the last path element (myfilename in this example) if (file.getProperty(PARAM_REMOTE_PATH).contains("/")) { String[] tmp = file.getProperty(PARAM_REMOTE_PATH).split("/"); return tmp[tmp.length - 1]; } // if the remote path does not contain /, it means that it specifies only // the remote file name return file.getProperty(PARAM_REMOTE_PATH); }
java
private String getRemoteFileName(UploadFile file) { // if the remote path ends with / // it means that the remote path specifies only the directory structure, so // get the remote file name from the local file if (file.getProperty(PARAM_REMOTE_PATH).endsWith("/")) { return file.getName(service); } // if the remote path contains /, but it's not the last character // it means that I have something like: /path/to/myfilename // so the remote file name is the last path element (myfilename in this example) if (file.getProperty(PARAM_REMOTE_PATH).contains("/")) { String[] tmp = file.getProperty(PARAM_REMOTE_PATH).split("/"); return tmp[tmp.length - 1]; } // if the remote path does not contain /, it means that it specifies only // the remote file name return file.getProperty(PARAM_REMOTE_PATH); }
[ "private", "String", "getRemoteFileName", "(", "UploadFile", "file", ")", "{", "// if the remote path ends with /", "// it means that the remote path specifies only the directory structure, so", "// get the remote file name from the local file", "if", "(", "file", ".", "getProperty", ...
Checks if the remote file path contains also the remote file name. If it's not specified, the name of the local file will be used. @param file file to upload @return remote file name
[ "Checks", "if", "the", "remote", "file", "path", "contains", "also", "the", "remote", "file", "name", ".", "If", "it", "s", "not", "specified", "the", "name", "of", "the", "local", "file", "will", "be", "used", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice-ftp/src/main/java/net/gotev/uploadservice/ftp/FTPUploadTask.java#L287-L307
31,404
gotev/android-upload-service
uploadservice-ftp/src/main/java/net/gotev/uploadservice/ftp/FTPUploadRequest.java
FTPUploadRequest.setUsernameAndPassword
public FTPUploadRequest setUsernameAndPassword(String username, String password) { if (username == null || "".equals(username)) { throw new IllegalArgumentException("Specify FTP account username!"); } if (password == null || "".equals(password)) { throw new IllegalArgumentException("Specify FTP account password!"); } ftpParams.username = username; ftpParams.password = password; return this; }
java
public FTPUploadRequest setUsernameAndPassword(String username, String password) { if (username == null || "".equals(username)) { throw new IllegalArgumentException("Specify FTP account username!"); } if (password == null || "".equals(password)) { throw new IllegalArgumentException("Specify FTP account password!"); } ftpParams.username = username; ftpParams.password = password; return this; }
[ "public", "FTPUploadRequest", "setUsernameAndPassword", "(", "String", "username", ",", "String", "password", ")", "{", "if", "(", "username", "==", "null", "||", "\"\"", ".", "equals", "(", "username", ")", ")", "{", "throw", "new", "IllegalArgumentException", ...
Set the credentials used to login on the FTP Server. @param username account username @param password account password @return {@link FTPUploadRequest}
[ "Set", "the", "credentials", "used", "to", "login", "on", "the", "FTP", "Server", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice-ftp/src/main/java/net/gotev/uploadservice/ftp/FTPUploadRequest.java#L74-L86
31,405
gotev/android-upload-service
uploadservice/src/main/java/net/gotev/uploadservice/http/BodyWriter.java
BodyWriter.writeStream
public final void writeStream(InputStream stream, OnStreamWriteListener listener) throws IOException { if (listener == null) throw new IllegalArgumentException("listener MUST not be null!"); byte[] buffer = new byte[UploadService.BUFFER_SIZE]; int bytesRead; try { while (listener.shouldContinueWriting() && (bytesRead = stream.read(buffer, 0, buffer.length)) > 0) { write(buffer, bytesRead); flush(); listener.onBytesWritten(bytesRead); } } finally { stream.close(); } }
java
public final void writeStream(InputStream stream, OnStreamWriteListener listener) throws IOException { if (listener == null) throw new IllegalArgumentException("listener MUST not be null!"); byte[] buffer = new byte[UploadService.BUFFER_SIZE]; int bytesRead; try { while (listener.shouldContinueWriting() && (bytesRead = stream.read(buffer, 0, buffer.length)) > 0) { write(buffer, bytesRead); flush(); listener.onBytesWritten(bytesRead); } } finally { stream.close(); } }
[ "public", "final", "void", "writeStream", "(", "InputStream", "stream", ",", "OnStreamWriteListener", "listener", ")", "throws", "IOException", "{", "if", "(", "listener", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"listener MUST not be null...
Writes an input stream to the request body. The stream will be automatically closed after successful write or if an exception is thrown. @param stream input stream from which to read @param listener listener which gets notified when bytes are written and which controls if the transfer should continue @throws IOException if an I/O error occurs
[ "Writes", "an", "input", "stream", "to", "the", "request", "body", ".", "The", "stream", "will", "be", "automatically", "closed", "after", "successful", "write", "or", "if", "an", "exception", "is", "thrown", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/http/BodyWriter.java#L42-L58
31,406
gotev/android-upload-service
uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationAction.java
UploadNotificationAction.from
public static UploadNotificationAction from(NotificationCompat.Action action) { return new UploadNotificationAction(action.icon, action.title, action.actionIntent); }
java
public static UploadNotificationAction from(NotificationCompat.Action action) { return new UploadNotificationAction(action.icon, action.title, action.actionIntent); }
[ "public", "static", "UploadNotificationAction", "from", "(", "NotificationCompat", ".", "Action", "action", ")", "{", "return", "new", "UploadNotificationAction", "(", "action", ".", "icon", ",", "action", ".", "title", ",", "action", ".", "actionIntent", ")", "...
Creates a new object from an existing NotificationCompat.Action object. @param action notification compat action @return new instance
[ "Creates", "a", "new", "object", "from", "an", "existing", "NotificationCompat", ".", "Action", "object", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadNotificationAction.java#L30-L32
31,407
gotev/android-upload-service
uploadservice/src/main/java/net/gotev/uploadservice/Placeholders.java
Placeholders.replace
public static String replace(String string, UploadInfo uploadInfo) { if (string == null || string.isEmpty()) return ""; String tmp; tmp = string.replace(ELAPSED_TIME, uploadInfo.getElapsedTimeString()); tmp = tmp.replace(PROGRESS, uploadInfo.getProgressPercent() + "%"); tmp = tmp.replace(UPLOAD_RATE, uploadInfo.getUploadRateString()); tmp = tmp.replace(UPLOADED_FILES, Integer.toString(uploadInfo.getSuccessfullyUploadedFiles().size())); tmp = tmp.replace(TOTAL_FILES, Integer.toString(uploadInfo.getTotalFiles())); return tmp; }
java
public static String replace(String string, UploadInfo uploadInfo) { if (string == null || string.isEmpty()) return ""; String tmp; tmp = string.replace(ELAPSED_TIME, uploadInfo.getElapsedTimeString()); tmp = tmp.replace(PROGRESS, uploadInfo.getProgressPercent() + "%"); tmp = tmp.replace(UPLOAD_RATE, uploadInfo.getUploadRateString()); tmp = tmp.replace(UPLOADED_FILES, Integer.toString(uploadInfo.getSuccessfullyUploadedFiles().size())); tmp = tmp.replace(TOTAL_FILES, Integer.toString(uploadInfo.getTotalFiles())); return tmp; }
[ "public", "static", "String", "replace", "(", "String", "string", ",", "UploadInfo", "uploadInfo", ")", "{", "if", "(", "string", "==", "null", "||", "string", ".", "isEmpty", "(", ")", ")", "return", "\"\"", ";", "String", "tmp", ";", "tmp", "=", "str...
Replace placeholders in a string. @param string string in which to replace placeholders @param uploadInfo upload information data @return string with replaced placeholders
[ "Replace", "placeholders", "in", "a", "string", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/Placeholders.java#L44-L56
31,408
gotev/android-upload-service
uploadservice/src/main/java/net/gotev/uploadservice/UploadTask.java
UploadTask.broadcastProgress
protected final void broadcastProgress(final long uploadedBytes, final long totalBytes) { long currentTime = System.currentTimeMillis(); if (uploadedBytes < totalBytes && currentTime < lastProgressNotificationTime + UploadService.PROGRESS_REPORT_INTERVAL) { return; } setLastProgressNotificationTime(currentTime); Logger.debug(LOG_TAG, "Broadcasting upload progress for " + params.id + ": " + uploadedBytes + " bytes of " + totalBytes); final UploadInfo uploadInfo = new UploadInfo(params.id, startTime, uploadedBytes, totalBytes, (attempts - 1), successfullyUploadedFiles, pathStringListFrom(params.files)); BroadcastData data = new BroadcastData() .setStatus(BroadcastData.Status.IN_PROGRESS) .setUploadInfo(uploadInfo); final UploadStatusDelegate delegate = UploadService.getUploadStatusDelegate(params.id); if (delegate != null) { mainThreadHandler.post(new Runnable() { @Override public void run() { delegate.onProgress(service, uploadInfo); } }); } else { service.sendBroadcast(data.getIntent()); } updateNotificationProgress(uploadInfo); }
java
protected final void broadcastProgress(final long uploadedBytes, final long totalBytes) { long currentTime = System.currentTimeMillis(); if (uploadedBytes < totalBytes && currentTime < lastProgressNotificationTime + UploadService.PROGRESS_REPORT_INTERVAL) { return; } setLastProgressNotificationTime(currentTime); Logger.debug(LOG_TAG, "Broadcasting upload progress for " + params.id + ": " + uploadedBytes + " bytes of " + totalBytes); final UploadInfo uploadInfo = new UploadInfo(params.id, startTime, uploadedBytes, totalBytes, (attempts - 1), successfullyUploadedFiles, pathStringListFrom(params.files)); BroadcastData data = new BroadcastData() .setStatus(BroadcastData.Status.IN_PROGRESS) .setUploadInfo(uploadInfo); final UploadStatusDelegate delegate = UploadService.getUploadStatusDelegate(params.id); if (delegate != null) { mainThreadHandler.post(new Runnable() { @Override public void run() { delegate.onProgress(service, uploadInfo); } }); } else { service.sendBroadcast(data.getIntent()); } updateNotificationProgress(uploadInfo); }
[ "protected", "final", "void", "broadcastProgress", "(", "final", "long", "uploadedBytes", ",", "final", "long", "totalBytes", ")", "{", "long", "currentTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "uploadedBytes", "<", "totalBytes", ...
Broadcasts a progress update. @param uploadedBytes number of bytes which has been uploaded to the server @param totalBytes total bytes of the request
[ "Broadcasts", "a", "progress", "update", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadTask.java#L228-L262
31,409
gotev/android-upload-service
uploadservice/src/main/java/net/gotev/uploadservice/UploadTask.java
UploadTask.addSuccessfullyUploadedFile
protected final void addSuccessfullyUploadedFile(UploadFile file) { if (!successfullyUploadedFiles.contains(file.path)) { successfullyUploadedFiles.add(file.path); params.files.remove(file); } }
java
protected final void addSuccessfullyUploadedFile(UploadFile file) { if (!successfullyUploadedFiles.contains(file.path)) { successfullyUploadedFiles.add(file.path); params.files.remove(file); } }
[ "protected", "final", "void", "addSuccessfullyUploadedFile", "(", "UploadFile", "file", ")", "{", "if", "(", "!", "successfullyUploadedFiles", ".", "contains", "(", "file", ".", "path", ")", ")", "{", "successfullyUploadedFiles", ".", "add", "(", "file", ".", ...
Add a file to the list of the successfully uploaded files and remove it from the file list @param file file on the device
[ "Add", "a", "file", "to", "the", "list", "of", "the", "successfully", "uploaded", "files", "and", "remove", "it", "from", "the", "file", "list" ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadTask.java#L375-L380
31,410
gotev/android-upload-service
uploadservice/src/main/java/net/gotev/uploadservice/UploadTask.java
UploadTask.createNotification
private void createNotification(UploadInfo uploadInfo) { if (params.notificationConfig == null || params.notificationConfig.getProgress().message == null) return; UploadNotificationStatusConfig statusConfig = params.notificationConfig.getProgress(); notificationCreationTimeMillis = System.currentTimeMillis(); NotificationCompat.Builder notification = new NotificationCompat.Builder(service, params.notificationConfig.getNotificationChannelId()) .setWhen(notificationCreationTimeMillis) .setContentTitle(Placeholders.replace(statusConfig.title, uploadInfo)) .setContentText(Placeholders.replace(statusConfig.message, uploadInfo)) .setContentIntent(statusConfig.getClickIntent(service)) .setSmallIcon(statusConfig.iconResourceID) .setLargeIcon(statusConfig.largeIcon) .setColor(statusConfig.iconColorResourceID) .setGroup(UploadService.NAMESPACE) .setProgress(100, 0, true) .setOngoing(true); statusConfig.addActionsToNotificationBuilder(notification); Notification builtNotification = notification.build(); if (service.holdForegroundNotification(params.id, builtNotification)) { notificationManager.cancel(notificationId); } else { notificationManager.notify(notificationId, builtNotification); } }
java
private void createNotification(UploadInfo uploadInfo) { if (params.notificationConfig == null || params.notificationConfig.getProgress().message == null) return; UploadNotificationStatusConfig statusConfig = params.notificationConfig.getProgress(); notificationCreationTimeMillis = System.currentTimeMillis(); NotificationCompat.Builder notification = new NotificationCompat.Builder(service, params.notificationConfig.getNotificationChannelId()) .setWhen(notificationCreationTimeMillis) .setContentTitle(Placeholders.replace(statusConfig.title, uploadInfo)) .setContentText(Placeholders.replace(statusConfig.message, uploadInfo)) .setContentIntent(statusConfig.getClickIntent(service)) .setSmallIcon(statusConfig.iconResourceID) .setLargeIcon(statusConfig.largeIcon) .setColor(statusConfig.iconColorResourceID) .setGroup(UploadService.NAMESPACE) .setProgress(100, 0, true) .setOngoing(true); statusConfig.addActionsToNotificationBuilder(notification); Notification builtNotification = notification.build(); if (service.holdForegroundNotification(params.id, builtNotification)) { notificationManager.cancel(notificationId); } else { notificationManager.notify(notificationId, builtNotification); } }
[ "private", "void", "createNotification", "(", "UploadInfo", "uploadInfo", ")", "{", "if", "(", "params", ".", "notificationConfig", "==", "null", "||", "params", ".", "notificationConfig", ".", "getProgress", "(", ")", ".", "message", "==", "null", ")", "retur...
If the upload task is initialized with a notification configuration, this handles its creation. @param uploadInfo upload information and statistics
[ "If", "the", "upload", "task", "is", "initialized", "with", "a", "notification", "configuration", "this", "handles", "its", "creation", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadTask.java#L460-L488
31,411
gotev/android-upload-service
uploadservice/src/main/java/net/gotev/uploadservice/UploadTask.java
UploadTask.deleteFile
private boolean deleteFile(File fileToDelete) { boolean deleted = false; try { deleted = fileToDelete.delete(); if (!deleted) { Logger.error(LOG_TAG, "Unable to delete: " + fileToDelete.getAbsolutePath()); } else { Logger.info(LOG_TAG, "Successfully deleted: " + fileToDelete.getAbsolutePath()); } } catch (Exception exc) { Logger.error(LOG_TAG, "Error while deleting: " + fileToDelete.getAbsolutePath() + " Check if you granted: android.permission.WRITE_EXTERNAL_STORAGE", exc); } return deleted; }
java
private boolean deleteFile(File fileToDelete) { boolean deleted = false; try { deleted = fileToDelete.delete(); if (!deleted) { Logger.error(LOG_TAG, "Unable to delete: " + fileToDelete.getAbsolutePath()); } else { Logger.info(LOG_TAG, "Successfully deleted: " + fileToDelete.getAbsolutePath()); } } catch (Exception exc) { Logger.error(LOG_TAG, "Error while deleting: " + fileToDelete.getAbsolutePath() + " Check if you granted: android.permission.WRITE_EXTERNAL_STORAGE", exc); } return deleted; }
[ "private", "boolean", "deleteFile", "(", "File", "fileToDelete", ")", "{", "boolean", "deleted", "=", "false", ";", "try", "{", "deleted", "=", "fileToDelete", ".", "delete", "(", ")", ";", "if", "(", "!", "deleted", ")", "{", "Logger", ".", "error", "...
Tries to delete a file from the device. If it fails, the error will be printed in the LogCat. @param fileToDelete file to delete @return true if the file has been deleted, otherwise false.
[ "Tries", "to", "delete", "a", "file", "from", "the", "device", ".", "If", "it", "fails", "the", "error", "will", "be", "printed", "in", "the", "LogCat", "." ]
0952fcbe4b32c100150ffd0a237de3be4942e0a8
https://github.com/gotev/android-upload-service/blob/0952fcbe4b32c100150ffd0a237de3be4942e0a8/uploadservice/src/main/java/net/gotev/uploadservice/UploadTask.java#L572-L593
31,412
thymeleaf/thymeleaf
src/main/java/org/thymeleaf/util/NumberUtils.java
NumberUtils.formatNumber
private static String formatNumber(final Number target, final Integer minIntegerDigits, final NumberPointType thousandsPointType, final Integer fractionDigits, final NumberPointType decimalPointType, final Locale locale) { Validate.notNull(fractionDigits, "Fraction digits cannot be null"); Validate.notNull(decimalPointType, "Decimal point type cannot be null"); Validate.notNull(thousandsPointType, "Thousands point type cannot be null"); Validate.notNull(locale, "Locale cannot be null"); if (target == null) { return null; } DecimalFormat format = (DecimalFormat)NumberFormat.getNumberInstance(locale); format.setMinimumFractionDigits(fractionDigits.intValue()); format.setMaximumFractionDigits(fractionDigits.intValue()); if (minIntegerDigits != null) { format.setMinimumIntegerDigits(minIntegerDigits.intValue()); } format.setDecimalSeparatorAlwaysShown(decimalPointType != NumberPointType.NONE && fractionDigits.intValue() > 0); format.setGroupingUsed(thousandsPointType != NumberPointType.NONE); format.setDecimalFormatSymbols(computeDecimalFormatSymbols(decimalPointType, thousandsPointType, locale)); return format.format(target); }
java
private static String formatNumber(final Number target, final Integer minIntegerDigits, final NumberPointType thousandsPointType, final Integer fractionDigits, final NumberPointType decimalPointType, final Locale locale) { Validate.notNull(fractionDigits, "Fraction digits cannot be null"); Validate.notNull(decimalPointType, "Decimal point type cannot be null"); Validate.notNull(thousandsPointType, "Thousands point type cannot be null"); Validate.notNull(locale, "Locale cannot be null"); if (target == null) { return null; } DecimalFormat format = (DecimalFormat)NumberFormat.getNumberInstance(locale); format.setMinimumFractionDigits(fractionDigits.intValue()); format.setMaximumFractionDigits(fractionDigits.intValue()); if (minIntegerDigits != null) { format.setMinimumIntegerDigits(minIntegerDigits.intValue()); } format.setDecimalSeparatorAlwaysShown(decimalPointType != NumberPointType.NONE && fractionDigits.intValue() > 0); format.setGroupingUsed(thousandsPointType != NumberPointType.NONE); format.setDecimalFormatSymbols(computeDecimalFormatSymbols(decimalPointType, thousandsPointType, locale)); return format.format(target); }
[ "private", "static", "String", "formatNumber", "(", "final", "Number", "target", ",", "final", "Integer", "minIntegerDigits", ",", "final", "NumberPointType", "thousandsPointType", ",", "final", "Integer", "fractionDigits", ",", "final", "NumberPointType", "decimalPoint...
Formats a number as per the given values. @param target The number to format. @param minIntegerDigits Minimum number digits to return (0 padding). @param thousandsPointType Character to use for separating number groups. @param fractionDigits Minimum number of fraction digits to format to (0 padding). @param decimalPointType Character to use for separating decimals. @param locale Locale to draw more information from. @return The number formatted as specified, or {@code null} if the number given is {@code null}.
[ "Formats", "a", "number", "as", "per", "the", "given", "values", "." ]
2b0e6d6d7571fbe638904b5fd222fc9e77188879
https://github.com/thymeleaf/thymeleaf/blob/2b0e6d6d7571fbe638904b5fd222fc9e77188879/src/main/java/org/thymeleaf/util/NumberUtils.java#L192-L216
31,413
thymeleaf/thymeleaf
src/main/java/org/thymeleaf/util/NumberUtils.java
NumberUtils.formatCurrency
public static String formatCurrency(final Number target, final Locale locale) { Validate.notNull(locale, "Locale cannot be null"); if (target == null) { return null; } NumberFormat format = NumberFormat.getCurrencyInstance(locale); return format.format(target); }
java
public static String formatCurrency(final Number target, final Locale locale) { Validate.notNull(locale, "Locale cannot be null"); if (target == null) { return null; } NumberFormat format = NumberFormat.getCurrencyInstance(locale); return format.format(target); }
[ "public", "static", "String", "formatCurrency", "(", "final", "Number", "target", ",", "final", "Locale", "locale", ")", "{", "Validate", ".", "notNull", "(", "locale", ",", "\"Locale cannot be null\"", ")", ";", "if", "(", "target", "==", "null", ")", "{", ...
Formats a number as a currency value according to the specified locale. @param target The number to format. @param locale Locale to use for formatting. @return The number formatted as a currency, or {@code null} if the number given is {@code null}.
[ "Formats", "a", "number", "as", "a", "currency", "value", "according", "to", "the", "specified", "locale", "." ]
2b0e6d6d7571fbe638904b5fd222fc9e77188879
https://github.com/thymeleaf/thymeleaf/blob/2b0e6d6d7571fbe638904b5fd222fc9e77188879/src/main/java/org/thymeleaf/util/NumberUtils.java#L279-L290
31,414
thymeleaf/thymeleaf
src/main/java/org/thymeleaf/util/NumberUtils.java
NumberUtils.formatPercent
public static String formatPercent(final Number target, final Integer minIntegerDigits, final Integer fractionDigits, final Locale locale) { Validate.notNull(fractionDigits, "Fraction digits cannot be null"); Validate.notNull(locale, "Locale cannot be null"); if (target == null) { return null; } NumberFormat format = NumberFormat.getPercentInstance(locale); format.setMinimumFractionDigits(fractionDigits.intValue()); format.setMaximumFractionDigits(fractionDigits.intValue()); if (minIntegerDigits != null) { format.setMinimumIntegerDigits(minIntegerDigits.intValue()); } return format.format(target); }
java
public static String formatPercent(final Number target, final Integer minIntegerDigits, final Integer fractionDigits, final Locale locale) { Validate.notNull(fractionDigits, "Fraction digits cannot be null"); Validate.notNull(locale, "Locale cannot be null"); if (target == null) { return null; } NumberFormat format = NumberFormat.getPercentInstance(locale); format.setMinimumFractionDigits(fractionDigits.intValue()); format.setMaximumFractionDigits(fractionDigits.intValue()); if (minIntegerDigits != null) { format.setMinimumIntegerDigits(minIntegerDigits.intValue()); } return format.format(target); }
[ "public", "static", "String", "formatPercent", "(", "final", "Number", "target", ",", "final", "Integer", "minIntegerDigits", ",", "final", "Integer", "fractionDigits", ",", "final", "Locale", "locale", ")", "{", "Validate", ".", "notNull", "(", "fractionDigits", ...
Formats a number as a percentage value. @param target The number to format. @param minIntegerDigits Minimum number of digits to return (0 padding). @param fractionDigits Minimum number of fraction digits to return (0 padding). @param locale Locale to use for formatting. @return The number formatted as a percentage, or {@code null} if the number given is {@code null}.
[ "Formats", "a", "number", "as", "a", "percentage", "value", "." ]
2b0e6d6d7571fbe638904b5fd222fc9e77188879
https://github.com/thymeleaf/thymeleaf/blob/2b0e6d6d7571fbe638904b5fd222fc9e77188879/src/main/java/org/thymeleaf/util/NumberUtils.java#L303-L321
31,415
thymeleaf/thymeleaf
src/main/java/org/thymeleaf/engine/Model.java
Model.sameAs
boolean sameAs(final Model model) { if (model == null || model.queueSize != this.queueSize) { return false; } for (int i = 0; i < this.queueSize; i++) { if (this.queue[i] != model.queue[i]) { return false; } } return true; }
java
boolean sameAs(final Model model) { if (model == null || model.queueSize != this.queueSize) { return false; } for (int i = 0; i < this.queueSize; i++) { if (this.queue[i] != model.queue[i]) { return false; } } return true; }
[ "boolean", "sameAs", "(", "final", "Model", "model", ")", "{", "if", "(", "model", "==", "null", "||", "model", ".", "queueSize", "!=", "this", ".", "queueSize", ")", "{", "return", "false", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "...
considered "a change" anyway.
[ "considered", "a", "change", "anyway", "." ]
2b0e6d6d7571fbe638904b5fd222fc9e77188879
https://github.com/thymeleaf/thymeleaf/blob/2b0e6d6d7571fbe638904b5fd222fc9e77188879/src/main/java/org/thymeleaf/engine/Model.java#L352-L362
31,416
thymeleaf/thymeleaf
src/main/java/org/thymeleaf/engine/SSEThrottledTemplateWriter.java
SSEThrottledTemplateWriter.checkTokenValid
private static boolean checkTokenValid(final char[] token) { if (token == null || token.length == 0) { return true; } for (int i = 0; i < token.length; i++) { if (token[i] == '\n') { return false; } } return true; }
java
private static boolean checkTokenValid(final char[] token) { if (token == null || token.length == 0) { return true; } for (int i = 0; i < token.length; i++) { if (token[i] == '\n') { return false; } } return true; }
[ "private", "static", "boolean", "checkTokenValid", "(", "final", "char", "[", "]", "token", ")", "{", "if", "(", "token", "==", "null", "||", "token", ".", "length", "==", "0", ")", "{", "return", "true", ";", "}", "for", "(", "int", "i", "=", "0",...
Used to check internally that neither event names nor IDs contain line feeds
[ "Used", "to", "check", "internally", "that", "neither", "event", "names", "nor", "IDs", "contain", "line", "feeds" ]
2b0e6d6d7571fbe638904b5fd222fc9e77188879
https://github.com/thymeleaf/thymeleaf/blob/2b0e6d6d7571fbe638904b5fd222fc9e77188879/src/main/java/org/thymeleaf/engine/SSEThrottledTemplateWriter.java#L216-L227
31,417
codelibs/fess
src/main/java/org/codelibs/fess/app/web/base/FessBaseAction.java
FessBaseAction.godHandPrologue
@Override public ActionResponse godHandPrologue(final ActionRuntime runtime) { fessLoginAssist.getSavedUserBean().ifPresent(u -> { boolean result = u.getFessUser().refresh(); if (logger.isDebugEnabled()) { logger.debug("refresh user info: {}", result); } }); return viewHelper.getActionHook().godHandPrologue(runtime, r -> super.godHandPrologue(r)); }
java
@Override public ActionResponse godHandPrologue(final ActionRuntime runtime) { fessLoginAssist.getSavedUserBean().ifPresent(u -> { boolean result = u.getFessUser().refresh(); if (logger.isDebugEnabled()) { logger.debug("refresh user info: {}", result); } }); return viewHelper.getActionHook().godHandPrologue(runtime, r -> super.godHandPrologue(r)); }
[ "@", "Override", "public", "ActionResponse", "godHandPrologue", "(", "final", "ActionRuntime", "runtime", ")", "{", "fessLoginAssist", ".", "getSavedUserBean", "(", ")", ".", "ifPresent", "(", "u", "->", "{", "boolean", "result", "=", "u", ".", "getFessUser", ...
you should remove the 'final' if you need to override this
[ "you", "should", "remove", "the", "final", "if", "you", "need", "to", "override", "this" ]
e5e4b722549d32a4958dfd94965b21937bfe64cf
https://github.com/codelibs/fess/blob/e5e4b722549d32a4958dfd94965b21937bfe64cf/src/main/java/org/codelibs/fess/app/web/base/FessBaseAction.java#L110-L119
31,418
codelibs/fess
src/main/java/org/codelibs/fess/util/KuromojiCSVUtil.java
KuromojiCSVUtil.quoteEscape
public static String quoteEscape(final String original) { String result = original; if (result.indexOf('\"') >= 0) { result = result.replace("\"", ESCAPED_QUOTE); } if (result.indexOf(COMMA) >= 0) { result = "\"" + result + "\""; } return result; }
java
public static String quoteEscape(final String original) { String result = original; if (result.indexOf('\"') >= 0) { result = result.replace("\"", ESCAPED_QUOTE); } if (result.indexOf(COMMA) >= 0) { result = "\"" + result + "\""; } return result; }
[ "public", "static", "String", "quoteEscape", "(", "final", "String", "original", ")", "{", "String", "result", "=", "original", ";", "if", "(", "result", ".", "indexOf", "(", "'", "'", ")", ">=", "0", ")", "{", "result", "=", "result", ".", "replace", ...
Quote and escape input value for CSV @param original Original text. @return Escaped text.
[ "Quote", "and", "escape", "input", "value", "for", "CSV" ]
e5e4b722549d32a4958dfd94965b21937bfe64cf
https://github.com/codelibs/fess/blob/e5e4b722549d32a4958dfd94965b21937bfe64cf/src/main/java/org/codelibs/fess/util/KuromojiCSVUtil.java#L121-L131
31,419
codelibs/fess
src/main/java/org/codelibs/fess/util/ComponentUtil.java
ComponentUtil.setFessConfig
public static void setFessConfig(final FessConfig fessConfig) { ComponentUtil.fessConfig = fessConfig; if (fessConfig == null) { FessProp.propMap.clear(); componentMap.clear(); } }
java
public static void setFessConfig(final FessConfig fessConfig) { ComponentUtil.fessConfig = fessConfig; if (fessConfig == null) { FessProp.propMap.clear(); componentMap.clear(); } }
[ "public", "static", "void", "setFessConfig", "(", "final", "FessConfig", "fessConfig", ")", "{", "ComponentUtil", ".", "fessConfig", "=", "fessConfig", ";", "if", "(", "fessConfig", "==", "null", ")", "{", "FessProp", ".", "propMap", ".", "clear", "(", ")", ...
For test purpose only. @param fessConfig fessConfig instance
[ "For", "test", "purpose", "only", "." ]
e5e4b722549d32a4958dfd94965b21937bfe64cf
https://github.com/codelibs/fess/blob/e5e4b722549d32a4958dfd94965b21937bfe64cf/src/main/java/org/codelibs/fess/util/ComponentUtil.java#L506-L512
31,420
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionQCP.java
SuperPositionQCP.set
private void set(Point3d[] x, Point3d[] y) { this.x = x; this.y = y; rmsdCalculated = false; transformationCalculated = false; }
java
private void set(Point3d[] x, Point3d[] y) { this.x = x; this.y = y; rmsdCalculated = false; transformationCalculated = false; }
[ "private", "void", "set", "(", "Point3d", "[", "]", "x", ",", "Point3d", "[", "]", "y", ")", "{", "this", ".", "x", "=", "x", ";", "this", ".", "y", "=", "y", ";", "rmsdCalculated", "=", "false", ";", "transformationCalculated", "=", "false", ";", ...
Sets the two input coordinate arrays. These input arrays must be of equal length. Input coordinates are not modified. @param x 3d points of reference coordinate set @param y 3d points of coordinate set for superposition
[ "Sets", "the", "two", "input", "coordinate", "arrays", ".", "These", "input", "arrays", "must", "be", "of", "equal", "length", ".", "Input", "coordinates", "are", "not", "modified", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionQCP.java#L177-L182
31,421
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionQCP.java
SuperPositionQCP.weightedSuperpose
public Matrix4d weightedSuperpose(Point3d[] fixed, Point3d[] moved, double[] weight) { set(moved, fixed, weight); getRotationMatrix(); if (!centered) { calcTransformation(); } else { transformation.set(rotmat); } return transformation; }
java
public Matrix4d weightedSuperpose(Point3d[] fixed, Point3d[] moved, double[] weight) { set(moved, fixed, weight); getRotationMatrix(); if (!centered) { calcTransformation(); } else { transformation.set(rotmat); } return transformation; }
[ "public", "Matrix4d", "weightedSuperpose", "(", "Point3d", "[", "]", "fixed", ",", "Point3d", "[", "]", "moved", ",", "double", "[", "]", "weight", ")", "{", "set", "(", "moved", ",", "fixed", ",", "weight", ")", ";", "getRotationMatrix", "(", ")", ";"...
Weighted superposition. @param fixed @param moved @param weight array of weigths for each equivalent point position @return
[ "Weighted", "superposition", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionQCP.java#L228-L237
31,422
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionQCP.java
SuperPositionQCP.calcRmsd
private void calcRmsd(Point3d[] x, Point3d[] y) { if (centered) { innerProduct(y, x); } else { // translate to origin xref = CalcPoint.clonePoint3dArray(x); xtrans = CalcPoint.centroid(xref); logger.debug("x centroid: " + xtrans); xtrans.negate(); CalcPoint.translate(new Vector3d(xtrans), xref); yref = CalcPoint.clonePoint3dArray(y); ytrans = CalcPoint.centroid(yref); logger.debug("y centroid: " + ytrans); ytrans.negate(); CalcPoint.translate(new Vector3d(ytrans), yref); innerProduct(yref, xref); } calcRmsd(wsum); }
java
private void calcRmsd(Point3d[] x, Point3d[] y) { if (centered) { innerProduct(y, x); } else { // translate to origin xref = CalcPoint.clonePoint3dArray(x); xtrans = CalcPoint.centroid(xref); logger.debug("x centroid: " + xtrans); xtrans.negate(); CalcPoint.translate(new Vector3d(xtrans), xref); yref = CalcPoint.clonePoint3dArray(y); ytrans = CalcPoint.centroid(yref); logger.debug("y centroid: " + ytrans); ytrans.negate(); CalcPoint.translate(new Vector3d(ytrans), yref); innerProduct(yref, xref); } calcRmsd(wsum); }
[ "private", "void", "calcRmsd", "(", "Point3d", "[", "]", "x", ",", "Point3d", "[", "]", "y", ")", "{", "if", "(", "centered", ")", "{", "innerProduct", "(", "y", ",", "x", ")", ";", "}", "else", "{", "// translate to origin", "xref", "=", "CalcPoint"...
Calculates the RMSD value for superposition of y onto x. This requires the coordinates to be precentered. @param x 3d points of reference coordinate set @param y 3d points of coordinate set for superposition
[ "Calculates", "the", "RMSD", "value", "for", "superposition", "of", "y", "onto", "x", ".", "This", "requires", "the", "coordinates", "to", "be", "precentered", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionQCP.java#L257-L276
31,423
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java
AsaCalculator.calculateAsas
public double[] calculateAsas() { double[] asas = new double[atomCoords.length]; long start = System.currentTimeMillis(); if (useSpatialHashingForNeighbors) { logger.debug("Will use spatial hashing to find neighbors"); neighborIndices = findNeighborIndicesSpatialHashing(); } else { logger.debug("Will not use spatial hashing to find neighbors"); neighborIndices = findNeighborIndices(); } long end = System.currentTimeMillis(); logger.debug("Took {} s to find neighbors", (end-start)/1000.0); start = System.currentTimeMillis(); if (nThreads<=1) { // (i.e. it will also be 1 thread if 0 or negative number specified) logger.debug("Will use 1 thread for ASA calculation"); for (int i=0;i<atomCoords.length;i++) { asas[i] = calcSingleAsa(i); } } else { logger.debug("Will use {} threads for ASA calculation", nThreads); // NOTE the multithreaded calculation does not scale up well in some systems, // why? I guess some memory/garbage collect problem? I tried increasing Xmx in pc8201 but didn't help // Following scaling tests are for 3hbx, calculating ASA of full asym unit (6 chains): // SCALING test done in merlinl01 (12 cores, Xeon X5670 @ 2.93GHz, 24GB RAM) //1 threads, time: 8.8s -- x1.0 //2 threads, time: 4.4s -- x2.0 //3 threads, time: 2.9s -- x3.0 //4 threads, time: 2.2s -- x3.9 //5 threads, time: 1.8s -- x4.9 //6 threads, time: 1.6s -- x5.5 //7 threads, time: 1.4s -- x6.5 //8 threads, time: 1.3s -- x6.9 // SCALING test done in pc8201 (4 cores, Core2 Quad Q9550 @ 2.83GHz, 8GB RAM) //1 threads, time: 17.2s -- x1.0 //2 threads, time: 9.7s -- x1.8 //3 threads, time: 7.7s -- x2.2 //4 threads, time: 7.9s -- x2.2 // SCALING test done in eppic01 (16 cores, Xeon E5-2650 0 @ 2.00GHz, 128GB RAM) //1 threads, time: 10.7s -- x1.0 //2 threads, time: 5.6s -- x1.9 //3 threads, time: 3.6s -- x3.0 //4 threads, time: 2.8s -- x3.9 //5 threads, time: 2.3s -- x4.8 //6 threads, time: 1.8s -- x6.0 //7 threads, time: 1.6s -- x6.8 //8 threads, time: 1.3s -- x8.0 //9 threads, time: 1.3s -- x8.5 //10 threads, time: 1.1s -- x10.0 //11 threads, time: 1.0s -- x10.9 //12 threads, time: 0.9s -- x11.4 ExecutorService threadPool = Executors.newFixedThreadPool(nThreads); for (int i=0;i<atomCoords.length;i++) { threadPool.submit(new AsaCalcWorker(i,asas)); } threadPool.shutdown(); while (!threadPool.isTerminated()); } end = System.currentTimeMillis(); logger.debug("Took {} s to calculate all {} atoms ASAs (excluding neighbors calculation)", (end-start)/1000.0, atomCoords.length); return asas; }
java
public double[] calculateAsas() { double[] asas = new double[atomCoords.length]; long start = System.currentTimeMillis(); if (useSpatialHashingForNeighbors) { logger.debug("Will use spatial hashing to find neighbors"); neighborIndices = findNeighborIndicesSpatialHashing(); } else { logger.debug("Will not use spatial hashing to find neighbors"); neighborIndices = findNeighborIndices(); } long end = System.currentTimeMillis(); logger.debug("Took {} s to find neighbors", (end-start)/1000.0); start = System.currentTimeMillis(); if (nThreads<=1) { // (i.e. it will also be 1 thread if 0 or negative number specified) logger.debug("Will use 1 thread for ASA calculation"); for (int i=0;i<atomCoords.length;i++) { asas[i] = calcSingleAsa(i); } } else { logger.debug("Will use {} threads for ASA calculation", nThreads); // NOTE the multithreaded calculation does not scale up well in some systems, // why? I guess some memory/garbage collect problem? I tried increasing Xmx in pc8201 but didn't help // Following scaling tests are for 3hbx, calculating ASA of full asym unit (6 chains): // SCALING test done in merlinl01 (12 cores, Xeon X5670 @ 2.93GHz, 24GB RAM) //1 threads, time: 8.8s -- x1.0 //2 threads, time: 4.4s -- x2.0 //3 threads, time: 2.9s -- x3.0 //4 threads, time: 2.2s -- x3.9 //5 threads, time: 1.8s -- x4.9 //6 threads, time: 1.6s -- x5.5 //7 threads, time: 1.4s -- x6.5 //8 threads, time: 1.3s -- x6.9 // SCALING test done in pc8201 (4 cores, Core2 Quad Q9550 @ 2.83GHz, 8GB RAM) //1 threads, time: 17.2s -- x1.0 //2 threads, time: 9.7s -- x1.8 //3 threads, time: 7.7s -- x2.2 //4 threads, time: 7.9s -- x2.2 // SCALING test done in eppic01 (16 cores, Xeon E5-2650 0 @ 2.00GHz, 128GB RAM) //1 threads, time: 10.7s -- x1.0 //2 threads, time: 5.6s -- x1.9 //3 threads, time: 3.6s -- x3.0 //4 threads, time: 2.8s -- x3.9 //5 threads, time: 2.3s -- x4.8 //6 threads, time: 1.8s -- x6.0 //7 threads, time: 1.6s -- x6.8 //8 threads, time: 1.3s -- x8.0 //9 threads, time: 1.3s -- x8.5 //10 threads, time: 1.1s -- x10.0 //11 threads, time: 1.0s -- x10.9 //12 threads, time: 0.9s -- x11.4 ExecutorService threadPool = Executors.newFixedThreadPool(nThreads); for (int i=0;i<atomCoords.length;i++) { threadPool.submit(new AsaCalcWorker(i,asas)); } threadPool.shutdown(); while (!threadPool.isTerminated()); } end = System.currentTimeMillis(); logger.debug("Took {} s to calculate all {} atoms ASAs (excluding neighbors calculation)", (end-start)/1000.0, atomCoords.length); return asas; }
[ "public", "double", "[", "]", "calculateAsas", "(", ")", "{", "double", "[", "]", "asas", "=", "new", "double", "[", "atomCoords", ".", "length", "]", ";", "long", "start", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "useSpatialH...
Calculates the Accessible Surface Areas for the atoms given in constructor and with parameters given. Beware that the parallel implementation is quite memory hungry. It scales well as long as there is enough memory available. @return an array with asa values corresponding to each atom of the input array
[ "Calculates", "the", "Accessible", "Surface", "Areas", "for", "the", "atoms", "given", "in", "constructor", "and", "with", "parameters", "given", ".", "Beware", "that", "the", "parallel", "implementation", "is", "quite", "memory", "hungry", ".", "It", "scales", ...
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java#L255-L332
31,424
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java
AsaCalculator.generateSpherePoints
private Point3d[] generateSpherePoints(int nSpherePoints) { Point3d[] points = new Point3d[nSpherePoints]; double inc = Math.PI * (3.0 - Math.sqrt(5.0)); double offset = 2.0 / nSpherePoints; for (int k=0;k<nSpherePoints;k++) { double y = k * offset - 1.0 + (offset / 2.0); double r = Math.sqrt(1.0 - y*y); double phi = k * inc; points[k] = new Point3d(Math.cos(phi)*r, y, Math.sin(phi)*r); } return points; }
java
private Point3d[] generateSpherePoints(int nSpherePoints) { Point3d[] points = new Point3d[nSpherePoints]; double inc = Math.PI * (3.0 - Math.sqrt(5.0)); double offset = 2.0 / nSpherePoints; for (int k=0;k<nSpherePoints;k++) { double y = k * offset - 1.0 + (offset / 2.0); double r = Math.sqrt(1.0 - y*y); double phi = k * inc; points[k] = new Point3d(Math.cos(phi)*r, y, Math.sin(phi)*r); } return points; }
[ "private", "Point3d", "[", "]", "generateSpherePoints", "(", "int", "nSpherePoints", ")", "{", "Point3d", "[", "]", "points", "=", "new", "Point3d", "[", "nSpherePoints", "]", ";", "double", "inc", "=", "Math", ".", "PI", "*", "(", "3.0", "-", "Math", ...
Returns list of 3d coordinates of points on a sphere using the Golden Section Spiral algorithm. @param nSpherePoints the number of points to be used in generating the spherical dot-density @return
[ "Returns", "list", "of", "3d", "coordinates", "of", "points", "on", "a", "sphere", "using", "the", "Golden", "Section", "Spiral", "algorithm", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java#L350-L361
31,425
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java
AsaCalculator.findNeighborIndices
int[][] findNeighborIndices() { // looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30 int initialCapacity = 60; int[][] nbsIndices = new int[atomCoords.length][]; for (int k=0; k<atomCoords.length; k++) { double radius = radii[k] + probe + probe; List<Integer> thisNbIndices = new ArrayList<>(initialCapacity); for (int i = 0; i < atomCoords.length; i++) { if (i == k) continue; double dist = atomCoords[i].distance(atomCoords[k]); if (dist < radius + radii[i]) { thisNbIndices.add(i); } } int[] indicesArray = new int[thisNbIndices.size()]; for (int i=0;i<thisNbIndices.size();i++) indicesArray[i] = thisNbIndices.get(i); nbsIndices[k] = indicesArray; } return nbsIndices; }
java
int[][] findNeighborIndices() { // looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30 int initialCapacity = 60; int[][] nbsIndices = new int[atomCoords.length][]; for (int k=0; k<atomCoords.length; k++) { double radius = radii[k] + probe + probe; List<Integer> thisNbIndices = new ArrayList<>(initialCapacity); for (int i = 0; i < atomCoords.length; i++) { if (i == k) continue; double dist = atomCoords[i].distance(atomCoords[k]); if (dist < radius + radii[i]) { thisNbIndices.add(i); } } int[] indicesArray = new int[thisNbIndices.size()]; for (int i=0;i<thisNbIndices.size();i++) indicesArray[i] = thisNbIndices.get(i); nbsIndices[k] = indicesArray; } return nbsIndices; }
[ "int", "[", "]", "[", "]", "findNeighborIndices", "(", ")", "{", "// looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30", "int", "initialCapacity", "=", "60", ";", "int", "[", "]", "[", "]", "nbsIndices", "=", "new", "int...
Returns the 2-dimensional array with neighbor indices for every atom. @return 2-dimensional array of size: n_atoms x n_neighbors_per_atom
[ "Returns", "the", "2", "-", "dimensional", "array", "with", "neighbor", "indices", "for", "every", "atom", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java#L367-L394
31,426
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java
AsaCalculator.findNeighborIndicesSpatialHashing
int[][] findNeighborIndicesSpatialHashing() { // looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30 int initialCapacity = 60; List<Contact> contactList = calcContacts(); Map<Integer, List<Integer>> indices = new HashMap<>(atomCoords.length); for (Contact contact : contactList) { // note contacts are stored 1-way only, with j>i int i = contact.getI(); int j = contact.getJ(); List<Integer> iIndices; List<Integer> jIndices; if (!indices.containsKey(i)) { iIndices = new ArrayList<>(initialCapacity); indices.put(i, iIndices); } else { iIndices = indices.get(i); } if (!indices.containsKey(j)) { jIndices = new ArrayList<>(initialCapacity); indices.put(j, jIndices); } else { jIndices = indices.get(j); } double radius = radii[i] + probe + probe; double dist = contact.getDistance(); if (dist < radius + radii[j]) { iIndices.add(j); jIndices.add(i); } } // convert map to array for fast access int[][] nbsIndices = new int[atomCoords.length][]; for (Map.Entry<Integer, List<Integer>> entry : indices.entrySet()) { List<Integer> list = entry.getValue(); int[] indicesArray = new int[list.size()]; for (int i=0;i<entry.getValue().size();i++) indicesArray[i] = list.get(i); nbsIndices[entry.getKey()] = indicesArray; } // important: some atoms might have no neighbors at all: we need to initialise to empty arrays for (int i=0; i<nbsIndices.length; i++) { if (nbsIndices[i] == null) { nbsIndices[i] = new int[0]; } } return nbsIndices; }
java
int[][] findNeighborIndicesSpatialHashing() { // looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30 int initialCapacity = 60; List<Contact> contactList = calcContacts(); Map<Integer, List<Integer>> indices = new HashMap<>(atomCoords.length); for (Contact contact : contactList) { // note contacts are stored 1-way only, with j>i int i = contact.getI(); int j = contact.getJ(); List<Integer> iIndices; List<Integer> jIndices; if (!indices.containsKey(i)) { iIndices = new ArrayList<>(initialCapacity); indices.put(i, iIndices); } else { iIndices = indices.get(i); } if (!indices.containsKey(j)) { jIndices = new ArrayList<>(initialCapacity); indices.put(j, jIndices); } else { jIndices = indices.get(j); } double radius = radii[i] + probe + probe; double dist = contact.getDistance(); if (dist < radius + radii[j]) { iIndices.add(j); jIndices.add(i); } } // convert map to array for fast access int[][] nbsIndices = new int[atomCoords.length][]; for (Map.Entry<Integer, List<Integer>> entry : indices.entrySet()) { List<Integer> list = entry.getValue(); int[] indicesArray = new int[list.size()]; for (int i=0;i<entry.getValue().size();i++) indicesArray[i] = list.get(i); nbsIndices[entry.getKey()] = indicesArray; } // important: some atoms might have no neighbors at all: we need to initialise to empty arrays for (int i=0; i<nbsIndices.length; i++) { if (nbsIndices[i] == null) { nbsIndices[i] = new int[0]; } } return nbsIndices; }
[ "int", "[", "]", "[", "]", "findNeighborIndicesSpatialHashing", "(", ")", "{", "// looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30", "int", "initialCapacity", "=", "60", ";", "List", "<", "Contact", ">", "contactList", "=", ...
Returns the 2-dimensional array with neighbor indices for every atom, using spatial hashing to avoid all to all distance calculation. @return 2-dimensional array of size: n_atoms x n_neighbors_per_atom
[ "Returns", "the", "2", "-", "dimensional", "array", "with", "neighbor", "indices", "for", "every", "atom", "using", "spatial", "hashing", "to", "avoid", "all", "to", "all", "distance", "calculation", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java#L401-L453
31,427
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java
AsaCalculator.getRadiusForAmino
private static double getRadiusForAmino(AminoAcid amino, Atom atom) { if (atom.getElement().equals(Element.H)) return Element.H.getVDWRadius(); // some unusual entries (e.g. 1tes) contain Deuterium atoms in standard aminoacids if (atom.getElement().equals(Element.D)) return Element.D.getVDWRadius(); String atomCode = atom.getName(); char aa = amino.getAminoType(); // here we use the values that Chothia gives in his paper (as NACCESS does) if (atom.getElement()==Element.O) { return OXIGEN_VDW; } else if (atom.getElement()==Element.S) { return SULFUR_VDW; } else if (atom.getElement()==Element.N) { if (atomCode.equals("NZ")) return TETRAHEDRAL_NITROGEN_VDW; // tetrahedral Nitrogen return TRIGONAL_NITROGEN_VDW; // trigonal Nitrogen } else if (atom.getElement()==Element.C) { // it must be a carbon if (atomCode.equals("C") || atomCode.equals("CE1") || atomCode.equals("CE2") || atomCode.equals("CE3") || atomCode.equals("CH2") || atomCode.equals("CZ") || atomCode.equals("CZ2") || atomCode.equals("CZ3")) { return TRIGONAL_CARBON_VDW; // trigonal Carbon } else if (atomCode.equals("CA") || atomCode.equals("CB") || atomCode.equals("CE") || atomCode.equals("CG1") || atomCode.equals("CG2")) { return TETRAHEDRAL_CARBON_VDW; // tetrahedral Carbon } // the rest of the cases (CD, CD1, CD2, CG) depend on amino acid else { switch (aa) { case 'F': case 'W': case 'Y': case 'H': case 'D': case 'N': return TRIGONAL_CARBON_VDW; case 'P': case 'K': case 'R': case 'M': case 'I': case 'L': return TETRAHEDRAL_CARBON_VDW; case 'Q': case 'E': if (atomCode.equals("CD")) return TRIGONAL_CARBON_VDW; else if (atomCode.equals("CG")) return TETRAHEDRAL_CARBON_VDW; default: logger.info("Unexpected carbon atom "+atomCode+" for aminoacid "+aa+", assigning its standard vdw radius"); return Element.C.getVDWRadius(); } } // not any of the expected atoms } else { // non standard aas, (e.g. MSE, LLP) will always have this problem, logger.info("Unexpected atom "+atomCode+" for aminoacid "+aa+ " ("+amino.getPDBName()+"), assigning its standard vdw radius"); return atom.getElement().getVDWRadius(); } }
java
private static double getRadiusForAmino(AminoAcid amino, Atom atom) { if (atom.getElement().equals(Element.H)) return Element.H.getVDWRadius(); // some unusual entries (e.g. 1tes) contain Deuterium atoms in standard aminoacids if (atom.getElement().equals(Element.D)) return Element.D.getVDWRadius(); String atomCode = atom.getName(); char aa = amino.getAminoType(); // here we use the values that Chothia gives in his paper (as NACCESS does) if (atom.getElement()==Element.O) { return OXIGEN_VDW; } else if (atom.getElement()==Element.S) { return SULFUR_VDW; } else if (atom.getElement()==Element.N) { if (atomCode.equals("NZ")) return TETRAHEDRAL_NITROGEN_VDW; // tetrahedral Nitrogen return TRIGONAL_NITROGEN_VDW; // trigonal Nitrogen } else if (atom.getElement()==Element.C) { // it must be a carbon if (atomCode.equals("C") || atomCode.equals("CE1") || atomCode.equals("CE2") || atomCode.equals("CE3") || atomCode.equals("CH2") || atomCode.equals("CZ") || atomCode.equals("CZ2") || atomCode.equals("CZ3")) { return TRIGONAL_CARBON_VDW; // trigonal Carbon } else if (atomCode.equals("CA") || atomCode.equals("CB") || atomCode.equals("CE") || atomCode.equals("CG1") || atomCode.equals("CG2")) { return TETRAHEDRAL_CARBON_VDW; // tetrahedral Carbon } // the rest of the cases (CD, CD1, CD2, CG) depend on amino acid else { switch (aa) { case 'F': case 'W': case 'Y': case 'H': case 'D': case 'N': return TRIGONAL_CARBON_VDW; case 'P': case 'K': case 'R': case 'M': case 'I': case 'L': return TETRAHEDRAL_CARBON_VDW; case 'Q': case 'E': if (atomCode.equals("CD")) return TRIGONAL_CARBON_VDW; else if (atomCode.equals("CG")) return TETRAHEDRAL_CARBON_VDW; default: logger.info("Unexpected carbon atom "+atomCode+" for aminoacid "+aa+", assigning its standard vdw radius"); return Element.C.getVDWRadius(); } } // not any of the expected atoms } else { // non standard aas, (e.g. MSE, LLP) will always have this problem, logger.info("Unexpected atom "+atomCode+" for aminoacid "+aa+ " ("+amino.getPDBName()+"), assigning its standard vdw radius"); return atom.getElement().getVDWRadius(); } }
[ "private", "static", "double", "getRadiusForAmino", "(", "AminoAcid", "amino", ",", "Atom", "atom", ")", "{", "if", "(", "atom", ".", "getElement", "(", ")", ".", "equals", "(", "Element", ".", "H", ")", ")", "return", "Element", ".", "H", ".", "getVDW...
Gets the radius for given amino acid and atom @param amino @param atom @return
[ "Gets", "the", "radius", "for", "given", "amino", "acid", "and", "atom" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java#L523-L593
31,428
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java
AsaCalculator.getRadiusForNucl
private static double getRadiusForNucl(NucleotideImpl nuc, Atom atom) { if (atom.getElement().equals(Element.H)) return Element.H.getVDWRadius(); if (atom.getElement().equals(Element.D)) return Element.D.getVDWRadius(); if (atom.getElement()==Element.C) return NUC_CARBON_VDW; if (atom.getElement()==Element.N) return NUC_NITROGEN_VDW; if (atom.getElement()==Element.P) return PHOSPHOROUS_VDW; if (atom.getElement()==Element.O) return OXIGEN_VDW; logger.info("Unexpected atom "+atom.getName()+" for nucleotide "+nuc.getPDBName()+", assigning its standard vdw radius"); return atom.getElement().getVDWRadius(); }
java
private static double getRadiusForNucl(NucleotideImpl nuc, Atom atom) { if (atom.getElement().equals(Element.H)) return Element.H.getVDWRadius(); if (atom.getElement().equals(Element.D)) return Element.D.getVDWRadius(); if (atom.getElement()==Element.C) return NUC_CARBON_VDW; if (atom.getElement()==Element.N) return NUC_NITROGEN_VDW; if (atom.getElement()==Element.P) return PHOSPHOROUS_VDW; if (atom.getElement()==Element.O) return OXIGEN_VDW; logger.info("Unexpected atom "+atom.getName()+" for nucleotide "+nuc.getPDBName()+", assigning its standard vdw radius"); return atom.getElement().getVDWRadius(); }
[ "private", "static", "double", "getRadiusForNucl", "(", "NucleotideImpl", "nuc", ",", "Atom", "atom", ")", "{", "if", "(", "atom", ".", "getElement", "(", ")", ".", "equals", "(", "Element", ".", "H", ")", ")", "return", "Element", ".", "H", ".", "getV...
Gets the radius for given nucleotide atom @param atom @return
[ "Gets", "the", "radius", "for", "given", "nucleotide", "atom" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/asa/AsaCalculator.java#L601-L616
31,429
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfStructureReader.java
MmtfStructureReader.getCorrectAltLocGroup
private Group getCorrectAltLocGroup(Character altLoc) { // see if we know this altLoc already; List<Atom> atoms = group.getAtoms(); if (atoms.size() > 0) { Atom a1 = atoms.get(0); // we are just adding atoms to the current group // probably there is a second group following later... if (a1.getAltLoc().equals(altLoc)) { return group; } } // Get the altLocGroup Group altLocgroup = group.getAltLocGroup(altLoc); if (altLocgroup != null) { return altLocgroup; } // If the group already exists (microheterogenity). Group oldGroup = getGroupWithSameResNumButDiffPDBName(); if (oldGroup!= null){ Group altLocG = group; group = oldGroup; group.addAltLoc(altLocG); chain.getAtomGroups().remove(altLocG); return altLocG; } // no matching altLoc group found. // build it up. if (group.getAtoms().size() == 0) { return group; } Group altLocG = (Group) group.clone(); // drop atoms from cloned group... // https://redmine.open-bio.org/issues/3307 altLocG.setAtoms(new ArrayList<Atom>()); altLocG.getAltLocs().clear(); group.addAltLoc(altLocG); return altLocG; }
java
private Group getCorrectAltLocGroup(Character altLoc) { // see if we know this altLoc already; List<Atom> atoms = group.getAtoms(); if (atoms.size() > 0) { Atom a1 = atoms.get(0); // we are just adding atoms to the current group // probably there is a second group following later... if (a1.getAltLoc().equals(altLoc)) { return group; } } // Get the altLocGroup Group altLocgroup = group.getAltLocGroup(altLoc); if (altLocgroup != null) { return altLocgroup; } // If the group already exists (microheterogenity). Group oldGroup = getGroupWithSameResNumButDiffPDBName(); if (oldGroup!= null){ Group altLocG = group; group = oldGroup; group.addAltLoc(altLocG); chain.getAtomGroups().remove(altLocG); return altLocG; } // no matching altLoc group found. // build it up. if (group.getAtoms().size() == 0) { return group; } Group altLocG = (Group) group.clone(); // drop atoms from cloned group... // https://redmine.open-bio.org/issues/3307 altLocG.setAtoms(new ArrayList<Atom>()); altLocG.getAltLocs().clear(); group.addAltLoc(altLocG); return altLocG; }
[ "private", "Group", "getCorrectAltLocGroup", "(", "Character", "altLoc", ")", "{", "// see if we know this altLoc already;", "List", "<", "Atom", ">", "atoms", "=", "group", ".", "getAtoms", "(", ")", ";", "if", "(", "atoms", ".", "size", "(", ")", ">", "0",...
Generates Alternate location groups. @param altLoc the alt loc @return the correct alt loc group
[ "Generates", "Alternate", "location", "groups", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfStructureReader.java#L362-L400
31,430
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/URLIdentifier.java
URLIdentifier.loadStructure
@Override public Structure loadStructure(AtomCache cache) throws StructureException, IOException { StructureFiletype format = StructureFiletype.UNKNOWN; // Use user-specified format try { Map<String, String> params = parseQuery(url); if(params.containsKey(FORMAT_PARAM)) { String formatStr = params.get(FORMAT_PARAM); format = StructureIO.guessFiletype("."+formatStr); } } catch (UnsupportedEncodingException e) { logger.error("Unable to decode URL "+url,e); } // Guess format from extension if(format == StructureFiletype.UNKNOWN) { format = StructureIO.guessFiletype(url.getPath()); } switch(format) { case CIF: // need to do mmcif parsing! InputStreamProvider prov = new InputStreamProvider(); InputStream inStream = prov.getInputStream(url); MMcifParser parser = new SimpleMMcifParser(); SimpleMMcifConsumer consumer = new SimpleMMcifConsumer(); consumer.setFileParsingParameters(cache.getFileParsingParams()); parser.addMMcifConsumer(consumer); try { parser.parse(new BufferedReader(new InputStreamReader(inStream))); } catch (IOException e){ e.printStackTrace(); } // now get the protein structure. return consumer.getStructure(); default: case PDB: // pdb file based parsing PDBFileReader reader = new PDBFileReader(cache.getPath()); reader.setFetchBehavior(cache.getFetchBehavior()); reader.setObsoleteBehavior(cache.getObsoleteBehavior()); reader.setFileParsingParameters(cache.getFileParsingParams()); return reader.getStructure(url); } }
java
@Override public Structure loadStructure(AtomCache cache) throws StructureException, IOException { StructureFiletype format = StructureFiletype.UNKNOWN; // Use user-specified format try { Map<String, String> params = parseQuery(url); if(params.containsKey(FORMAT_PARAM)) { String formatStr = params.get(FORMAT_PARAM); format = StructureIO.guessFiletype("."+formatStr); } } catch (UnsupportedEncodingException e) { logger.error("Unable to decode URL "+url,e); } // Guess format from extension if(format == StructureFiletype.UNKNOWN) { format = StructureIO.guessFiletype(url.getPath()); } switch(format) { case CIF: // need to do mmcif parsing! InputStreamProvider prov = new InputStreamProvider(); InputStream inStream = prov.getInputStream(url); MMcifParser parser = new SimpleMMcifParser(); SimpleMMcifConsumer consumer = new SimpleMMcifConsumer(); consumer.setFileParsingParameters(cache.getFileParsingParams()); parser.addMMcifConsumer(consumer); try { parser.parse(new BufferedReader(new InputStreamReader(inStream))); } catch (IOException e){ e.printStackTrace(); } // now get the protein structure. return consumer.getStructure(); default: case PDB: // pdb file based parsing PDBFileReader reader = new PDBFileReader(cache.getPath()); reader.setFetchBehavior(cache.getFetchBehavior()); reader.setObsoleteBehavior(cache.getObsoleteBehavior()); reader.setFileParsingParameters(cache.getFileParsingParams()); return reader.getStructure(url); } }
[ "@", "Override", "public", "Structure", "loadStructure", "(", "AtomCache", "cache", ")", "throws", "StructureException", ",", "IOException", "{", "StructureFiletype", "format", "=", "StructureFiletype", ".", "UNKNOWN", ";", "// Use user-specified format", "try", "{", ...
Load the structure from the URL @return null
[ "Load", "the", "structure", "from", "the", "URL" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/URLIdentifier.java#L139-L193
31,431
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/URLIdentifier.java
URLIdentifier.guessPDBID
public static String guessPDBID(String name) { Matcher match = PDBID_REGEX.matcher(name); if(match.matches()) { return match.group(1).toUpperCase(); } else { // Give up if doesn't match return null; } }
java
public static String guessPDBID(String name) { Matcher match = PDBID_REGEX.matcher(name); if(match.matches()) { return match.group(1).toUpperCase(); } else { // Give up if doesn't match return null; } }
[ "public", "static", "String", "guessPDBID", "(", "String", "name", ")", "{", "Matcher", "match", "=", "PDBID_REGEX", ".", "matcher", "(", "name", ")", ";", "if", "(", "match", ".", "matches", "(", ")", ")", "{", "return", "match", ".", "group", "(", ...
Recognizes PDB IDs that occur at the beginning of name followed by some delimiter. @param name Input filename @return A 4-character id-like string, or null if none is found
[ "Recognizes", "PDB", "IDs", "that", "occur", "at", "the", "beginning", "of", "name", "followed", "by", "some", "delimiter", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/URLIdentifier.java#L202-L210
31,432
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/URLIdentifier.java
URLIdentifier.parseQuery
private static Map<String,String> parseQuery(URL url) throws UnsupportedEncodingException { Map<String,String> params = new LinkedHashMap<String, String>(); String query = url.getQuery(); if( query == null || query.isEmpty()) { // empty query return params; } String[] pairs = url.getQuery().split("&"); for(String pair: pairs) { int i = pair.indexOf("="); String key = pair; if(i > 0) { key = URLDecoder.decode(pair.substring(0, i), "UTF-8"); } String value = null; if(i > 0 && pair.length() > i+1) { value = URLDecoder.decode(pair.substring(i+1), "UTF-8"); } // note that this uses the last instance if a parameter is specified multiple times params.put(key.toLowerCase(), value); } return params; }
java
private static Map<String,String> parseQuery(URL url) throws UnsupportedEncodingException { Map<String,String> params = new LinkedHashMap<String, String>(); String query = url.getQuery(); if( query == null || query.isEmpty()) { // empty query return params; } String[] pairs = url.getQuery().split("&"); for(String pair: pairs) { int i = pair.indexOf("="); String key = pair; if(i > 0) { key = URLDecoder.decode(pair.substring(0, i), "UTF-8"); } String value = null; if(i > 0 && pair.length() > i+1) { value = URLDecoder.decode(pair.substring(i+1), "UTF-8"); } // note that this uses the last instance if a parameter is specified multiple times params.put(key.toLowerCase(), value); } return params; }
[ "private", "static", "Map", "<", "String", ",", "String", ">", "parseQuery", "(", "URL", "url", ")", "throws", "UnsupportedEncodingException", "{", "Map", "<", "String", ",", "String", ">", "params", "=", "new", "LinkedHashMap", "<", "String", ",", "String",...
Parses URL parameters into a map. Keys are stored lower-case. @param url @return @throws UnsupportedEncodingException
[ "Parses", "URL", "parameters", "into", "a", "map", ".", "Keys", "are", "stored", "lower", "-", "case", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/URLIdentifier.java#L219-L241
31,433
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
LocalPDBDirectory.getInputStream
protected InputStream getInputStream(String pdbId) throws IOException{ if ( pdbId.length() != 4) throw new IOException("The provided ID does not look like a PDB ID : " + pdbId); // Check existing File file = downloadStructure(pdbId); if(!file.exists()) { throw new IOException("Structure "+pdbId+" not found and unable to download."); } InputStreamProvider isp = new InputStreamProvider(); InputStream inputStream = isp.getInputStream(file); return inputStream; }
java
protected InputStream getInputStream(String pdbId) throws IOException{ if ( pdbId.length() != 4) throw new IOException("The provided ID does not look like a PDB ID : " + pdbId); // Check existing File file = downloadStructure(pdbId); if(!file.exists()) { throw new IOException("Structure "+pdbId+" not found and unable to download."); } InputStreamProvider isp = new InputStreamProvider(); InputStream inputStream = isp.getInputStream(file); return inputStream; }
[ "protected", "InputStream", "getInputStream", "(", "String", "pdbId", ")", "throws", "IOException", "{", "if", "(", "pdbId", ".", "length", "(", ")", "!=", "4", ")", "throw", "new", "IOException", "(", "\"The provided ID does not look like a PDB ID : \"", "+", "pd...
Load or download the specified structure and return it as an InputStream for direct parsing. @param pdbId @return @throws IOException
[ "Load", "or", "download", "the", "specified", "structure", "and", "return", "it", "as", "an", "InputStream", "for", "direct", "parsing", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java#L347-L364
31,434
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
LocalPDBDirectory.prefetchStructure
public void prefetchStructure(String pdbId) throws IOException { if ( pdbId.length() != 4) throw new IOException("The provided ID does not look like a PDB ID : " + pdbId); // Check existing File file = downloadStructure(pdbId); if(!file.exists()) { throw new IOException("Structure "+pdbId+" not found and unable to download."); } }
java
public void prefetchStructure(String pdbId) throws IOException { if ( pdbId.length() != 4) throw new IOException("The provided ID does not look like a PDB ID : " + pdbId); // Check existing File file = downloadStructure(pdbId); if(!file.exists()) { throw new IOException("Structure "+pdbId+" not found and unable to download."); } }
[ "public", "void", "prefetchStructure", "(", "String", "pdbId", ")", "throws", "IOException", "{", "if", "(", "pdbId", ".", "length", "(", ")", "!=", "4", ")", "throw", "new", "IOException", "(", "\"The provided ID does not look like a PDB ID : \"", "+", "pdbId", ...
Download a structure, but don't parse it yet or store it in memory. Used to pre-fetch large numbers of structures. @param pdbId @throws IOException
[ "Download", "a", "structure", "but", "don", "t", "parse", "it", "yet", "or", "store", "it", "in", "memory", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java#L373-L383
31,435
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
LocalPDBDirectory.deleteStructure
public boolean deleteStructure(String pdbId) throws IOException{ boolean deleted = false; // Force getLocalFile to check in obsolete locations ObsoleteBehavior obsolete = getObsoleteBehavior(); setObsoleteBehavior(ObsoleteBehavior.FETCH_OBSOLETE); try { File existing = getLocalFile(pdbId); while(existing != null) { assert(existing.exists()); // should exist unless concurrency problems if( getFetchBehavior() == FetchBehavior.LOCAL_ONLY) { throw new RuntimeException("Refusing to delete from LOCAL_ONLY directory"); } // delete file boolean success = existing.delete(); if(success) { logger.debug("Deleting "+existing.getAbsolutePath()); } deleted = deleted || success; // delete parent if empty File parent = existing.getParentFile(); if(parent != null) { success = parent.delete(); if(success) { logger.debug("Deleting "+parent.getAbsolutePath()); } } existing = getLocalFile(pdbId); } return deleted; } finally { setObsoleteBehavior(obsolete); } }
java
public boolean deleteStructure(String pdbId) throws IOException{ boolean deleted = false; // Force getLocalFile to check in obsolete locations ObsoleteBehavior obsolete = getObsoleteBehavior(); setObsoleteBehavior(ObsoleteBehavior.FETCH_OBSOLETE); try { File existing = getLocalFile(pdbId); while(existing != null) { assert(existing.exists()); // should exist unless concurrency problems if( getFetchBehavior() == FetchBehavior.LOCAL_ONLY) { throw new RuntimeException("Refusing to delete from LOCAL_ONLY directory"); } // delete file boolean success = existing.delete(); if(success) { logger.debug("Deleting "+existing.getAbsolutePath()); } deleted = deleted || success; // delete parent if empty File parent = existing.getParentFile(); if(parent != null) { success = parent.delete(); if(success) { logger.debug("Deleting "+parent.getAbsolutePath()); } } existing = getLocalFile(pdbId); } return deleted; } finally { setObsoleteBehavior(obsolete); } }
[ "public", "boolean", "deleteStructure", "(", "String", "pdbId", ")", "throws", "IOException", "{", "boolean", "deleted", "=", "false", ";", "// Force getLocalFile to check in obsolete locations", "ObsoleteBehavior", "obsolete", "=", "getObsoleteBehavior", "(", ")", ";", ...
Attempts to delete all versions of a structure from the local directory. @param pdbId @return True if one or more files were deleted @throws IOException if the file cannot be deleted
[ "Attempts", "to", "delete", "all", "versions", "of", "a", "structure", "from", "the", "local", "directory", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java#L391-L429
31,436
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
LocalPDBDirectory.downloadStructure
protected File downloadStructure(String pdbId) throws IOException{ if ( pdbId.length() != 4) throw new IOException("The provided ID does not look like a PDB ID : " + pdbId); // decide whether download is required File existing = getLocalFile(pdbId); switch(fetchBehavior) { case LOCAL_ONLY: if( existing == null ) { throw new IOException(String.format("Structure %s not found in %s " + "and configured not to download.",pdbId,getPath())); } else { return existing; } case FETCH_FILES: // Use existing if present if( existing != null) { return existing; } // existing is null, downloadStructure(String,String,boolean,File) will download it break; case FETCH_IF_OUTDATED: // here existing can be null or not: // existing == null : downloadStructure(String,String,boolean,File) will download it // existing != null : downloadStructure(String,String,boolean,File) will check its date and download if older break; case FETCH_REMEDIATED: // Use existing if present and recent enough if( existing != null) { long lastModified = existing.lastModified(); if (lastModified < LAST_REMEDIATION_DATE) { // the file is too old, replace with newer version logger.warn("Replacing file {} with latest remediated (remediation of {}) file from PDB.", existing, LAST_REMEDIATION_DATE_STRING); existing = null; break; } else { return existing; } } case FORCE_DOWNLOAD: // discard the existing file to force redownload existing = null; // downloadStructure(String,String,boolean,File) will download it break; } // Force the download now if(obsoleteBehavior == ObsoleteBehavior.FETCH_CURRENT) { String current = PDBStatus.getCurrent(pdbId); if(current == null) { // either an error or there is not current entry current = pdbId; } return downloadStructure(current, splitDirURL,false, existing); } else if(obsoleteBehavior == ObsoleteBehavior.FETCH_OBSOLETE && PDBStatus.getStatus(pdbId) == Status.OBSOLETE) { return downloadStructure(pdbId, obsoleteDirURL, true, existing); } else { return downloadStructure(pdbId, splitDirURL, false, existing); } }
java
protected File downloadStructure(String pdbId) throws IOException{ if ( pdbId.length() != 4) throw new IOException("The provided ID does not look like a PDB ID : " + pdbId); // decide whether download is required File existing = getLocalFile(pdbId); switch(fetchBehavior) { case LOCAL_ONLY: if( existing == null ) { throw new IOException(String.format("Structure %s not found in %s " + "and configured not to download.",pdbId,getPath())); } else { return existing; } case FETCH_FILES: // Use existing if present if( existing != null) { return existing; } // existing is null, downloadStructure(String,String,boolean,File) will download it break; case FETCH_IF_OUTDATED: // here existing can be null or not: // existing == null : downloadStructure(String,String,boolean,File) will download it // existing != null : downloadStructure(String,String,boolean,File) will check its date and download if older break; case FETCH_REMEDIATED: // Use existing if present and recent enough if( existing != null) { long lastModified = existing.lastModified(); if (lastModified < LAST_REMEDIATION_DATE) { // the file is too old, replace with newer version logger.warn("Replacing file {} with latest remediated (remediation of {}) file from PDB.", existing, LAST_REMEDIATION_DATE_STRING); existing = null; break; } else { return existing; } } case FORCE_DOWNLOAD: // discard the existing file to force redownload existing = null; // downloadStructure(String,String,boolean,File) will download it break; } // Force the download now if(obsoleteBehavior == ObsoleteBehavior.FETCH_CURRENT) { String current = PDBStatus.getCurrent(pdbId); if(current == null) { // either an error or there is not current entry current = pdbId; } return downloadStructure(current, splitDirURL,false, existing); } else if(obsoleteBehavior == ObsoleteBehavior.FETCH_OBSOLETE && PDBStatus.getStatus(pdbId) == Status.OBSOLETE) { return downloadStructure(pdbId, obsoleteDirURL, true, existing); } else { return downloadStructure(pdbId, splitDirURL, false, existing); } }
[ "protected", "File", "downloadStructure", "(", "String", "pdbId", ")", "throws", "IOException", "{", "if", "(", "pdbId", ".", "length", "(", ")", "!=", "4", ")", "throw", "new", "IOException", "(", "\"The provided ID does not look like a PDB ID : \"", "+", "pdbId"...
Downloads an MMCIF file from the PDB to the local path @param pdbId @return The file, or null if it was unavailable for download @throws IOException for errors downloading or writing, or if the fetchBehavior is {@link FetchBehavior#LOCAL_ONLY}
[ "Downloads", "an", "MMCIF", "file", "from", "the", "PDB", "to", "the", "local", "path" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java#L438-L500
31,437
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
LocalPDBDirectory.downloadStructure
private File downloadStructure(String pdbId, String pathOnServer, boolean obsolete, File existingFile) throws IOException{ File dir = getDir(pdbId,obsolete); File realFile = new File(dir,getFilename(pdbId)); String ftp; if (getFilename(pdbId).endsWith(".mmtf.gz")){ ftp = CodecUtils.getMmtfEntryUrl(pdbId, true, false); } else { ftp = String.format("%s%s/%s/%s", serverName, pathOnServer, pdbId.substring(1,3).toLowerCase(), getFilename(pdbId)); } URL url = new URL(ftp); Date serverFileDate = null; if (existingFile!=null) { serverFileDate = getLastModifiedTime(url); if (serverFileDate!=null) { if (existingFile.lastModified()>=serverFileDate.getTime()) { return existingFile; } else { // otherwise we go ahead and download, warning about it first logger.warn("File {} is outdated, will download new one from PDB (updated on {})", existingFile, serverFileDate.toString()); } } else { logger.warn("Could not determine if file {} is outdated (could not get timestamp from server). Will force redownload", existingFile); } } logger.info("Fetching " + ftp); logger.info("Writing to "+ realFile); FileDownloadUtils.downloadFile(url, realFile); // Commented out following code used for setting the modified date to the downloaded file - JD 2015-01-15 // The only reason to have it was in order to get an rsync-like behavior, respecting the timestamps // but the issue is that it would make the FETCH_REMEDIATED mode redownload files with timestamps before // the remediation. //if (serverFileDate==null) // serverFileDate = getLastModifiedTime(url); // //if (serverFileDate!=null) { // logger.debug("Setting modified time of downloaded file {} to {}",realFile,serverFileDate.toString()); // realFile.setLastModified(serverFileDate.getTime()); //} else { // logger.warn("Unknown modified time of file {}, will set its modified time to now.", ftp); //} return realFile; }
java
private File downloadStructure(String pdbId, String pathOnServer, boolean obsolete, File existingFile) throws IOException{ File dir = getDir(pdbId,obsolete); File realFile = new File(dir,getFilename(pdbId)); String ftp; if (getFilename(pdbId).endsWith(".mmtf.gz")){ ftp = CodecUtils.getMmtfEntryUrl(pdbId, true, false); } else { ftp = String.format("%s%s/%s/%s", serverName, pathOnServer, pdbId.substring(1,3).toLowerCase(), getFilename(pdbId)); } URL url = new URL(ftp); Date serverFileDate = null; if (existingFile!=null) { serverFileDate = getLastModifiedTime(url); if (serverFileDate!=null) { if (existingFile.lastModified()>=serverFileDate.getTime()) { return existingFile; } else { // otherwise we go ahead and download, warning about it first logger.warn("File {} is outdated, will download new one from PDB (updated on {})", existingFile, serverFileDate.toString()); } } else { logger.warn("Could not determine if file {} is outdated (could not get timestamp from server). Will force redownload", existingFile); } } logger.info("Fetching " + ftp); logger.info("Writing to "+ realFile); FileDownloadUtils.downloadFile(url, realFile); // Commented out following code used for setting the modified date to the downloaded file - JD 2015-01-15 // The only reason to have it was in order to get an rsync-like behavior, respecting the timestamps // but the issue is that it would make the FETCH_REMEDIATED mode redownload files with timestamps before // the remediation. //if (serverFileDate==null) // serverFileDate = getLastModifiedTime(url); // //if (serverFileDate!=null) { // logger.debug("Setting modified time of downloaded file {} to {}",realFile,serverFileDate.toString()); // realFile.setLastModified(serverFileDate.getTime()); //} else { // logger.warn("Unknown modified time of file {}, will set its modified time to now.", ftp); //} return realFile; }
[ "private", "File", "downloadStructure", "(", "String", "pdbId", ",", "String", "pathOnServer", ",", "boolean", "obsolete", ",", "File", "existingFile", ")", "throws", "IOException", "{", "File", "dir", "=", "getDir", "(", "pdbId", ",", "obsolete", ")", ";", ...
Download a file from the ftp server, replacing any existing files if needed @param pdbId PDB ID @param pathOnServer Path on the FTP server, e.g. data/structures/divided/pdb @param obsolete Whether or not file should be saved to the obsolete location locally @param existingFile if not null and checkServerFileDate is true, the last modified date of the server file and this file will be compared to decide whether to download or not @return @throws IOException
[ "Download", "a", "file", "from", "the", "ftp", "server", "replacing", "any", "existing", "files", "if", "needed" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java#L512-L568
31,438
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
LocalPDBDirectory.getLastModifiedTime
private Date getLastModifiedTime(URL url) { // see http://stackoverflow.com/questions/2416872/how-do-you-obtain-modified-date-from-a-remote-file-java Date date = null; try { String lastModified = url.openConnection().getHeaderField("Last-Modified"); logger.debug("Last modified date of server file ({}) is {}",url.toString(),lastModified); if (lastModified!=null) { try { date = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH).parse(lastModified); } catch (ParseException e) { logger.warn("Could not parse last modified time from string '{}', no last modified time available for file {}", lastModified, url.toString()); // this will return null } } } catch (IOException e) { logger.warn("Problems while retrieving last modified time for file {}", url.toString()); } return date; }
java
private Date getLastModifiedTime(URL url) { // see http://stackoverflow.com/questions/2416872/how-do-you-obtain-modified-date-from-a-remote-file-java Date date = null; try { String lastModified = url.openConnection().getHeaderField("Last-Modified"); logger.debug("Last modified date of server file ({}) is {}",url.toString(),lastModified); if (lastModified!=null) { try { date = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH).parse(lastModified); } catch (ParseException e) { logger.warn("Could not parse last modified time from string '{}', no last modified time available for file {}", lastModified, url.toString()); // this will return null } } } catch (IOException e) { logger.warn("Problems while retrieving last modified time for file {}", url.toString()); } return date; }
[ "private", "Date", "getLastModifiedTime", "(", "URL", "url", ")", "{", "// see http://stackoverflow.com/questions/2416872/how-do-you-obtain-modified-date-from-a-remote-file-java", "Date", "date", "=", "null", ";", "try", "{", "String", "lastModified", "=", "url", ".", "open...
Get the last modified time of the file in given url by retrieveing the "Last-Modified" header. Note that this only works for http URLs @param url @return the last modified date or null if it couldn't be retrieved (in that case a warning will be logged)
[ "Get", "the", "last", "modified", "time", "of", "the", "file", "in", "given", "url", "by", "retrieveing", "the", "Last", "-", "Modified", "header", ".", "Note", "that", "this", "only", "works", "for", "http", "URLs" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java#L576-L601
31,439
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
LocalPDBDirectory.getDir
protected File getDir(String pdbId, boolean obsolete) { File dir = null; if (obsolete) { // obsolete is always split String middle = pdbId.substring(1,3).toLowerCase(); dir = new File(obsoleteDirPath, middle); } else { String middle = pdbId.substring(1,3).toLowerCase(); dir = new File(splitDirPath, middle); } if (!dir.exists()) { boolean success = dir.mkdirs(); if (!success) logger.error("Could not create mmCIF dir {}",dir.toString()); } return dir; }
java
protected File getDir(String pdbId, boolean obsolete) { File dir = null; if (obsolete) { // obsolete is always split String middle = pdbId.substring(1,3).toLowerCase(); dir = new File(obsoleteDirPath, middle); } else { String middle = pdbId.substring(1,3).toLowerCase(); dir = new File(splitDirPath, middle); } if (!dir.exists()) { boolean success = dir.mkdirs(); if (!success) logger.error("Could not create mmCIF dir {}",dir.toString()); } return dir; }
[ "protected", "File", "getDir", "(", "String", "pdbId", ",", "boolean", "obsolete", ")", "{", "File", "dir", "=", "null", ";", "if", "(", "obsolete", ")", "{", "// obsolete is always split", "String", "middle", "=", "pdbId", ".", "substring", "(", "1", ",",...
Gets the directory in which the file for a given MMCIF file would live, creating it if necessary. The obsolete parameter is necessary to avoid additional server queries. @param pdbId @param obsolete Whether the pdbId is obsolete or not @return File pointing to the directory,
[ "Gets", "the", "directory", "in", "which", "the", "file", "for", "a", "given", "MMCIF", "file", "would", "live", "creating", "it", "if", "necessary", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java#L612-L632
31,440
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java
LocalPDBDirectory.getLocalFile
public File getLocalFile(String pdbId) throws IOException { // Search for existing files // Search directories: // 1) LOCAL_MMCIF_SPLIT_DIR/<middle>/(pdb)?<pdbId>.<ext> // 2) LOCAL_MMCIF_ALL_DIR/<middle>/(pdb)?<pdbId>.<ext> LinkedList<File> searchdirs = new LinkedList<File>(); String middle = pdbId.substring(1,3).toLowerCase(); File splitdir = new File(splitDirPath, middle); searchdirs.add(splitdir); // Search obsolete files if requested if(getObsoleteBehavior() == ObsoleteBehavior.FETCH_OBSOLETE) { File obsdir = new File(obsoleteDirPath,middle); searchdirs.add(obsdir); } // valid prefixes before the <pdbId> in the filename String[] prefixes = new String[] {"", "pdb"}; for( File searchdir :searchdirs){ for( String prefix : prefixes) { for(String ex : getExtensions() ){ File f = new File(searchdir,prefix + pdbId.toLowerCase() + ex) ; if ( f.exists()) { // delete files that are too short to have contents if( f.length() < MIN_PDB_FILE_SIZE ) { Files.delete(f.toPath()); return null; } return f; } } } } //Not found return null; }
java
public File getLocalFile(String pdbId) throws IOException { // Search for existing files // Search directories: // 1) LOCAL_MMCIF_SPLIT_DIR/<middle>/(pdb)?<pdbId>.<ext> // 2) LOCAL_MMCIF_ALL_DIR/<middle>/(pdb)?<pdbId>.<ext> LinkedList<File> searchdirs = new LinkedList<File>(); String middle = pdbId.substring(1,3).toLowerCase(); File splitdir = new File(splitDirPath, middle); searchdirs.add(splitdir); // Search obsolete files if requested if(getObsoleteBehavior() == ObsoleteBehavior.FETCH_OBSOLETE) { File obsdir = new File(obsoleteDirPath,middle); searchdirs.add(obsdir); } // valid prefixes before the <pdbId> in the filename String[] prefixes = new String[] {"", "pdb"}; for( File searchdir :searchdirs){ for( String prefix : prefixes) { for(String ex : getExtensions() ){ File f = new File(searchdir,prefix + pdbId.toLowerCase() + ex) ; if ( f.exists()) { // delete files that are too short to have contents if( f.length() < MIN_PDB_FILE_SIZE ) { Files.delete(f.toPath()); return null; } return f; } } } } //Not found return null; }
[ "public", "File", "getLocalFile", "(", "String", "pdbId", ")", "throws", "IOException", "{", "// Search for existing files", "// Search directories:", "// 1) LOCAL_MMCIF_SPLIT_DIR/<middle>/(pdb)?<pdbId>.<ext>", "// 2) LOCAL_MMCIF_ALL_DIR/<middle>/(pdb)?<pdbId>.<ext>", "LinkedList", "<"...
Searches for previously downloaded files @param pdbId @return A file pointing to the existing file, or null if not found @throws IOException If the file exists but is empty and can't be deleted
[ "Searches", "for", "previously", "downloaded", "files" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/LocalPDBDirectory.java#L640-L678
31,441
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionAbstract.java
SuperPositionAbstract.checkInput
protected void checkInput(Point3d[] fixed, Point3d[] moved) { if (fixed.length != moved.length) throw new IllegalArgumentException( "Point arrays to superpose are of different lengths."); }
java
protected void checkInput(Point3d[] fixed, Point3d[] moved) { if (fixed.length != moved.length) throw new IllegalArgumentException( "Point arrays to superpose are of different lengths."); }
[ "protected", "void", "checkInput", "(", "Point3d", "[", "]", "fixed", ",", "Point3d", "[", "]", "moved", ")", "{", "if", "(", "fixed", ".", "length", "!=", "moved", ".", "length", ")", "throw", "new", "IllegalArgumentException", "(", "\"Point arrays to super...
Check that the input to the superposition algorithms is valid. @param fixed @param moved
[ "Check", "that", "the", "input", "to", "the", "superposition", "algorithms", "is", "valid", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/geometry/SuperPositionAbstract.java#L55-L59
31,442
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/math/SparseSquareMatrix.java
SparseSquareMatrix.get
public double get(int i, int j) { if (i < 0 || i >= N) throw new IllegalArgumentException("Illegal index " + i + " should be > 0 and < " + N); if (j < 0 || j >= N) throw new IllegalArgumentException("Illegal index " + j + " should be > 0 and < " + N); return rows[i].get(j); }
java
public double get(int i, int j) { if (i < 0 || i >= N) throw new IllegalArgumentException("Illegal index " + i + " should be > 0 and < " + N); if (j < 0 || j >= N) throw new IllegalArgumentException("Illegal index " + j + " should be > 0 and < " + N); return rows[i].get(j); }
[ "public", "double", "get", "(", "int", "i", ",", "int", "j", ")", "{", "if", "(", "i", "<", "0", "||", "i", ">=", "N", ")", "throw", "new", "IllegalArgumentException", "(", "\"Illegal index \"", "+", "i", "+", "\" should be > 0 and < \"", "+", "N", ")"...
access a value at i,j @param i @param j @return return A[i][j]
[ "access", "a", "value", "at", "i", "j" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/math/SparseSquareMatrix.java#L87-L93
31,443
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/align/MultiThreadedDBSearch.java
MultiThreadedDBSearch.interrupt
public void interrupt() { interrupted.set(true); ExecutorService pool = ConcurrencyTools.getThreadPool(); pool.shutdownNow(); try { DomainProvider domainProvider = DomainProviderFactory.getDomainProvider(); if (domainProvider instanceof RemoteDomainProvider){ RemoteDomainProvider remote = (RemoteDomainProvider) domainProvider; remote.flushCache(); } } catch (IOException e) { // If errors occur, the cache should be empty anyways } }
java
public void interrupt() { interrupted.set(true); ExecutorService pool = ConcurrencyTools.getThreadPool(); pool.shutdownNow(); try { DomainProvider domainProvider = DomainProviderFactory.getDomainProvider(); if (domainProvider instanceof RemoteDomainProvider){ RemoteDomainProvider remote = (RemoteDomainProvider) domainProvider; remote.flushCache(); } } catch (IOException e) { // If errors occur, the cache should be empty anyways } }
[ "public", "void", "interrupt", "(", ")", "{", "interrupted", ".", "set", "(", "true", ")", ";", "ExecutorService", "pool", "=", "ConcurrencyTools", ".", "getThreadPool", "(", ")", ";", "pool", ".", "shutdownNow", "(", ")", ";", "try", "{", "DomainProvider"...
stops what is currently happening and does not continue
[ "stops", "what", "is", "currently", "happening", "and", "does", "not", "continue" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/MultiThreadedDBSearch.java#L449-L463
31,444
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/util/Equals.java
Equals.equal
public static boolean equal(Object one, Object two) { return one == null && two == null || !(one == null || two == null) && (one == two || one.equals(two)); }
java
public static boolean equal(Object one, Object two) { return one == null && two == null || !(one == null || two == null) && (one == two || one.equals(two)); }
[ "public", "static", "boolean", "equal", "(", "Object", "one", ",", "Object", "two", ")", "{", "return", "one", "==", "null", "&&", "two", "==", "null", "||", "!", "(", "one", "==", "null", "||", "two", "==", "null", ")", "&&", "(", "one", "==", "...
Does not compare class types. @see #classEqual(Object, Object)
[ "Does", "not", "compare", "class", "types", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/util/Equals.java#L49-L51
31,445
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.processReader
public static void processReader(BufferedReader br, ReaderProcessor processor) throws ParserException { String line; try { while( (line = br.readLine()) != null ) { processor.process(line); } } catch(IOException e) { throw new ParserException("Could not read from the given BufferedReader"); } finally { close(br); } }
java
public static void processReader(BufferedReader br, ReaderProcessor processor) throws ParserException { String line; try { while( (line = br.readLine()) != null ) { processor.process(line); } } catch(IOException e) { throw new ParserException("Could not read from the given BufferedReader"); } finally { close(br); } }
[ "public", "static", "void", "processReader", "(", "BufferedReader", "br", ",", "ReaderProcessor", "processor", ")", "throws", "ParserException", "{", "String", "line", ";", "try", "{", "while", "(", "(", "line", "=", "br", ".", "readLine", "(", ")", ")", "...
Takes in a reader and a processor, reads every line from the given file and then invokes the processor. What you do with the lines is dependent on your processor. The code will automatically close the given BufferedReader. @param br The reader to process @param processor The processor to invoke on all lines @throws ParserException Can throw this if we cannot parse the given reader
[ "Takes", "in", "a", "reader", "and", "a", "processor", "reads", "every", "line", "from", "the", "given", "file", "and", "then", "invokes", "the", "processor", ".", "What", "you", "do", "with", "the", "lines", "is", "dependent", "on", "your", "processor", ...
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L90-L103
31,446
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getList
public static List<String> getList(BufferedReader br) throws ParserException { final List<String> list = new ArrayList<String>(); processReader(br, new ReaderProcessor() { @Override public void process(String line) { list.add(line); } }); return list; }
java
public static List<String> getList(BufferedReader br) throws ParserException { final List<String> list = new ArrayList<String>(); processReader(br, new ReaderProcessor() { @Override public void process(String line) { list.add(line); } }); return list; }
[ "public", "static", "List", "<", "String", ">", "getList", "(", "BufferedReader", "br", ")", "throws", "ParserException", "{", "final", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "processReader", "(", ...
Returns the contents of a buffered reader as a list of strings @param br BufferedReader to read from; <strong>will be closed</strong> @return List of Strings @throws ParserException Can throw this if we cannot parse the given reader
[ "Returns", "the", "contents", "of", "a", "buffered", "reader", "as", "a", "list", "of", "strings" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L112-L121
31,447
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getGCGChecksum
public static <S extends Sequence<C>, C extends Compound> int getGCGChecksum(List<S> sequences) { int check = 0; for (S as : sequences) { check += getGCGChecksum(as); } return check % 10000; }
java
public static <S extends Sequence<C>, C extends Compound> int getGCGChecksum(List<S> sequences) { int check = 0; for (S as : sequences) { check += getGCGChecksum(as); } return check % 10000; }
[ "public", "static", "<", "S", "extends", "Sequence", "<", "C", ">", ",", "C", "extends", "Compound", ">", "int", "getGCGChecksum", "(", "List", "<", "S", ">", "sequences", ")", "{", "int", "check", "=", "0", ";", "for", "(", "S", "as", ":", "sequen...
Calculates GCG checksum for entire list of sequences @param sequences list of sequences @return GCG checksum
[ "Calculates", "GCG", "checksum", "for", "entire", "list", "of", "sequences" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L196-L202
31,448
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getGCGChecksum
public static <S extends Sequence<C>, C extends Compound> int getGCGChecksum(S sequence) { String s = sequence.toString().toUpperCase(); int count = 0, check = 0; for (int i = 0; i < s.length(); i++) { count++; check += count * s.charAt(i); if (count == 57) { count = 0; } } return check % 10000; }
java
public static <S extends Sequence<C>, C extends Compound> int getGCGChecksum(S sequence) { String s = sequence.toString().toUpperCase(); int count = 0, check = 0; for (int i = 0; i < s.length(); i++) { count++; check += count * s.charAt(i); if (count == 57) { count = 0; } } return check % 10000; }
[ "public", "static", "<", "S", "extends", "Sequence", "<", "C", ">", ",", "C", "extends", "Compound", ">", "int", "getGCGChecksum", "(", "S", "sequence", ")", "{", "String", "s", "=", "sequence", ".", "toString", "(", ")", ".", "toUpperCase", "(", ")", ...
Calculates GCG checksum for a given sequence @param sequence given sequence @return GCG checksum
[ "Calculates", "GCG", "checksum", "for", "a", "given", "sequence" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L210-L221
31,449
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getGCGHeader
public static <S extends Sequence<C>, C extends Compound> String getGCGHeader(List<S> sequences) { StringBuilder header = new StringBuilder(); S s1 = sequences.get(0); header.append(String.format("MSA from BioJava%n%n MSF: %d Type: %s Check: %d ..%n%n", s1.getLength(), getGCGType(s1.getCompoundSet()), getGCGChecksum(sequences))); String format = " Name: " + getIDFormat(sequences) + " Len: " + s1.getLength() + " Check: %4d Weight: 1.0%n"; for (S as : sequences) { header.append(String.format(format, as.getAccession(), getGCGChecksum(as))); // TODO show weights in MSF header } header.append(String.format("%n//%n%n")); // TODO? convert gap characters to '.' return header.toString(); }
java
public static <S extends Sequence<C>, C extends Compound> String getGCGHeader(List<S> sequences) { StringBuilder header = new StringBuilder(); S s1 = sequences.get(0); header.append(String.format("MSA from BioJava%n%n MSF: %d Type: %s Check: %d ..%n%n", s1.getLength(), getGCGType(s1.getCompoundSet()), getGCGChecksum(sequences))); String format = " Name: " + getIDFormat(sequences) + " Len: " + s1.getLength() + " Check: %4d Weight: 1.0%n"; for (S as : sequences) { header.append(String.format(format, as.getAccession(), getGCGChecksum(as))); // TODO show weights in MSF header } header.append(String.format("%n//%n%n")); // TODO? convert gap characters to '.' return header.toString(); }
[ "public", "static", "<", "S", "extends", "Sequence", "<", "C", ">", ",", "C", "extends", "Compound", ">", "String", "getGCGHeader", "(", "List", "<", "S", ">", "sequences", ")", "{", "StringBuilder", "header", "=", "new", "StringBuilder", "(", ")", ";", ...
Assembles a GCG file header @param sequences list of sequences @return GCG header
[ "Assembles", "a", "GCG", "file", "header" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L229-L242
31,450
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getGCGType
public static <C extends Compound> String getGCGType(CompoundSet<C> cs) { return (cs == DNACompoundSet.getDNACompoundSet() || cs == AmbiguityDNACompoundSet.getDNACompoundSet()) ? "D" : (cs == RNACompoundSet.getRNACompoundSet() || cs == AmbiguityRNACompoundSet.getRNACompoundSet()) ? "R" : "P"; }
java
public static <C extends Compound> String getGCGType(CompoundSet<C> cs) { return (cs == DNACompoundSet.getDNACompoundSet() || cs == AmbiguityDNACompoundSet.getDNACompoundSet()) ? "D" : (cs == RNACompoundSet.getRNACompoundSet() || cs == AmbiguityRNACompoundSet.getRNACompoundSet()) ? "R" : "P"; }
[ "public", "static", "<", "C", "extends", "Compound", ">", "String", "getGCGType", "(", "CompoundSet", "<", "C", ">", "cs", ")", "{", "return", "(", "cs", "==", "DNACompoundSet", ".", "getDNACompoundSet", "(", ")", "||", "cs", "==", "AmbiguityDNACompoundSet",...
Determines GCG type @param cs compound set of sequences @return GCG type
[ "Determines", "GCG", "type" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L249-L252
31,451
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getIDFormat
public static <S extends Sequence<C>, C extends Compound> String getIDFormat(List<S> sequences) { int length = 0; for (S as : sequences) { length = Math.max(length, (as.getAccession() == null) ? 0 : as.getAccession().toString().length()); } return (length == 0) ? null : "%-" + (length + 1) + "s"; }
java
public static <S extends Sequence<C>, C extends Compound> String getIDFormat(List<S> sequences) { int length = 0; for (S as : sequences) { length = Math.max(length, (as.getAccession() == null) ? 0 : as.getAccession().toString().length()); } return (length == 0) ? null : "%-" + (length + 1) + "s"; }
[ "public", "static", "<", "S", "extends", "Sequence", "<", "C", ">", ",", "C", "extends", "Compound", ">", "String", "getIDFormat", "(", "List", "<", "S", ">", "sequences", ")", "{", "int", "length", "=", "0", ";", "for", "(", "S", "as", ":", "seque...
Creates format String for accession IDs @param sequences list of sequences @return format String for accession IDs
[ "Creates", "format", "String", "for", "accession", "IDs" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L260-L266
31,452
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getPDBCharacter
public static String getPDBCharacter(boolean web, char c1, char c2, boolean similar, char c) { String s = String.valueOf(c); return getPDBString(web, c1, c2, similar, s, s, s, s); }
java
public static String getPDBCharacter(boolean web, char c1, char c2, boolean similar, char c) { String s = String.valueOf(c); return getPDBString(web, c1, c2, similar, s, s, s, s); }
[ "public", "static", "String", "getPDBCharacter", "(", "boolean", "web", ",", "char", "c1", ",", "char", "c2", ",", "boolean", "similar", ",", "char", "c", ")", "{", "String", "s", "=", "String", ".", "valueOf", "(", "c", ")", ";", "return", "getPDBStri...
Creates formatted String for a single character of PDB output @param web true for HTML display @param c1 character in first sequence @param c2 character in second sequence @param similar true if c1 and c2 are considered similar compounds @param c character to display @return formatted String
[ "Creates", "formatted", "String", "for", "a", "single", "character", "of", "PDB", "output" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L278-L281
31,453
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getPDBConservation
public static String getPDBConservation(boolean web, char c1, char c2, boolean similar) { return getPDBString(web, c1, c2, similar, "|", ".", " ", web ? "&nbsp;" : " "); }
java
public static String getPDBConservation(boolean web, char c1, char c2, boolean similar) { return getPDBString(web, c1, c2, similar, "|", ".", " ", web ? "&nbsp;" : " "); }
[ "public", "static", "String", "getPDBConservation", "(", "boolean", "web", ",", "char", "c1", ",", "char", "c2", ",", "boolean", "similar", ")", "{", "return", "getPDBString", "(", "web", ",", "c1", ",", "c2", ",", "similar", ",", "\"|\"", ",", "\".\"", ...
Creates formatted String for displaying conservation in PDB output @param web true for HTML display @param c1 character in first sequence @param c2 character in second sequence @param similar true if c1 and c2 are considered similar compounds @return formatted String
[ "Creates", "formatted", "String", "for", "displaying", "conservation", "in", "PDB", "output" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L292-L294
31,454
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getPDBString
private static String getPDBString(boolean web, char c1, char c2, boolean similar, String m, String sm, String dm, String qg) { if (c1 == c2) return web ? "<span class=\"m\">" + m + "</span>" : m; else if (similar) return web ? "<span class=\"sm\">" + sm + "</span>" : sm; else if (c1 == '-' || c2 == '-') return web ? "<span class=\"dm\">" + dm + "</span>" : dm; else return web ? "<span class=\"qg\">" + qg + "</span>" : qg; }
java
private static String getPDBString(boolean web, char c1, char c2, boolean similar, String m, String sm, String dm, String qg) { if (c1 == c2) return web ? "<span class=\"m\">" + m + "</span>" : m; else if (similar) return web ? "<span class=\"sm\">" + sm + "</span>" : sm; else if (c1 == '-' || c2 == '-') return web ? "<span class=\"dm\">" + dm + "</span>" : dm; else return web ? "<span class=\"qg\">" + qg + "</span>" : qg; }
[ "private", "static", "String", "getPDBString", "(", "boolean", "web", ",", "char", "c1", ",", "char", "c2", ",", "boolean", "similar", ",", "String", "m", ",", "String", "sm", ",", "String", "dm", ",", "String", "qg", ")", "{", "if", "(", "c1", "==",...
helper method for getPDBCharacter and getPDBConservation
[ "helper", "method", "for", "getPDBCharacter", "and", "getPDBConservation" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L297-L307
31,455
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java
IOUtils.getPDBLegend
public static String getPDBLegend() { StringBuilder s = new StringBuilder(); s.append("</pre></div>"); s.append(" <div class=\"subText\">"); s.append(" <b>Legend:</b>"); s.append(" <span class=\"m\">Green</span> - identical residues |"); s.append(" <span class=\"sm\">Pink</span> - similar residues | "); s.append(" <span class=\"qg\">Blue</span> - sequence mismatch |"); s.append(" <span class=\"dm\">Brown</span> - insertion/deletion |"); s.append(" </div>"); s.append(String.format("%n")); return s.toString(); }
java
public static String getPDBLegend() { StringBuilder s = new StringBuilder(); s.append("</pre></div>"); s.append(" <div class=\"subText\">"); s.append(" <b>Legend:</b>"); s.append(" <span class=\"m\">Green</span> - identical residues |"); s.append(" <span class=\"sm\">Pink</span> - similar residues | "); s.append(" <span class=\"qg\">Blue</span> - sequence mismatch |"); s.append(" <span class=\"dm\">Brown</span> - insertion/deletion |"); s.append(" </div>"); s.append(String.format("%n")); return s.toString(); }
[ "public", "static", "String", "getPDBLegend", "(", ")", "{", "StringBuilder", "s", "=", "new", "StringBuilder", "(", ")", ";", "s", ".", "append", "(", "\"</pre></div>\"", ")", ";", "s", ".", "append", "(", "\" <div class=\\\"subText\\\">\"", ")", ";"...
Creates formatted String for displaying conservation legend in PDB output @return legend String
[ "Creates", "formatted", "String", "for", "displaying", "conservation", "legend", "in", "PDB", "output" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/util/IOUtils.java#L314-L326
31,456
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueNumber.java
ResidueNumber.equalsPositional
public boolean equalsPositional(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ResidueNumber other = (ResidueNumber) obj; if (insCode == null) { if (other.insCode != null) return false; } else if (!insCode.equals(other.insCode)) return false; if (seqNum == null) { if (other.seqNum != null) return false; } else if (!seqNum.equals(other.seqNum)) return false; return true; }
java
public boolean equalsPositional(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ResidueNumber other = (ResidueNumber) obj; if (insCode == null) { if (other.insCode != null) return false; } else if (!insCode.equals(other.insCode)) return false; if (seqNum == null) { if (other.seqNum != null) return false; } else if (!seqNum.equals(other.seqNum)) return false; return true; }
[ "public", "boolean", "equalsPositional", "(", "Object", "obj", ")", "{", "if", "(", "this", "==", "obj", ")", "return", "true", ";", "if", "(", "obj", "==", "null", ")", "return", "false", ";", "if", "(", "getClass", "(", ")", "!=", "obj", ".", "ge...
Check if the seqNum and insertion code are equivalent, ignoring the chain @param obj @return
[ "Check", "if", "the", "seqNum", "and", "insertion", "code", "are", "equivalent", "ignoring", "the", "chain" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueNumber.java#L122-L143
31,457
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueNumber.java
ResidueNumber.fromString
public static ResidueNumber fromString(String pdb_code) { if(pdb_code == null) return null; ResidueNumber residueNumber = new ResidueNumber(); Integer resNum = null; String icode = null; try { resNum = Integer.parseInt(pdb_code); } catch ( NumberFormatException e){ // there is an insertion code.. // Split at any position that's either: // preceded by a digit and followed by a non-digit, or // preceded by a non-digit and followed by a digit. String[] spl = pdb_code.split("(?<=\\d)(?=\\D)|(?<=\\D)(?=\\d)"); if ( spl.length == 2){ resNum = Integer.parseInt(spl[0]); icode = spl[1]; } } residueNumber.setSeqNum(resNum); if ( icode == null) residueNumber.setInsCode(null); else if ( icode.length() > 0) residueNumber.setInsCode(icode.charAt(0)); return residueNumber; }
java
public static ResidueNumber fromString(String pdb_code) { if(pdb_code == null) return null; ResidueNumber residueNumber = new ResidueNumber(); Integer resNum = null; String icode = null; try { resNum = Integer.parseInt(pdb_code); } catch ( NumberFormatException e){ // there is an insertion code.. // Split at any position that's either: // preceded by a digit and followed by a non-digit, or // preceded by a non-digit and followed by a digit. String[] spl = pdb_code.split("(?<=\\d)(?=\\D)|(?<=\\D)(?=\\d)"); if ( spl.length == 2){ resNum = Integer.parseInt(spl[0]); icode = spl[1]; } } residueNumber.setSeqNum(resNum); if ( icode == null) residueNumber.setInsCode(null); else if ( icode.length() > 0) residueNumber.setInsCode(icode.charAt(0)); return residueNumber; }
[ "public", "static", "ResidueNumber", "fromString", "(", "String", "pdb_code", ")", "{", "if", "(", "pdb_code", "==", "null", ")", "return", "null", ";", "ResidueNumber", "residueNumber", "=", "new", "ResidueNumber", "(", ")", ";", "Integer", "resNum", "=", "...
Convert a string representation of a residue number to a residue number object. The string representation can be a integer followed by a character. @param pdb_code @return a ResidueNumber object, or null if the input was null
[ "Convert", "a", "string", "representation", "of", "a", "residue", "number", "to", "a", "residue", "number", "object", ".", "The", "string", "representation", "can", "be", "a", "integer", "followed", "by", "a", "character", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueNumber.java#L192-L222
31,458
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueNumber.java
ResidueNumber.compareTo
@Override public int compareTo(ResidueNumber other) { // chain id if (chainName != null && other.chainName != null) { if (!chainName.equals(other.chainName)) return chainName.compareTo(other.chainName); } if (chainName != null && other.chainName == null) { return 1; } else if (chainName == null && other.chainName != null) { return -1; } return compareToPositional(other); }
java
@Override public int compareTo(ResidueNumber other) { // chain id if (chainName != null && other.chainName != null) { if (!chainName.equals(other.chainName)) return chainName.compareTo(other.chainName); } if (chainName != null && other.chainName == null) { return 1; } else if (chainName == null && other.chainName != null) { return -1; } return compareToPositional(other); }
[ "@", "Override", "public", "int", "compareTo", "(", "ResidueNumber", "other", ")", "{", "// chain id", "if", "(", "chainName", "!=", "null", "&&", "other", ".", "chainName", "!=", "null", ")", "{", "if", "(", "!", "chainName", ".", "equals", "(", "other"...
Compare residue numbers by chain, sequence number, and insertion code
[ "Compare", "residue", "numbers", "by", "chain", "sequence", "number", "and", "insertion", "code" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueNumber.java#L228-L242
31,459
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueNumber.java
ResidueNumber.compareToPositional
public int compareToPositional(ResidueNumber other) { // sequence number if (seqNum != null && other.seqNum != null) { if (!seqNum.equals(other.seqNum)) return seqNum.compareTo(other.seqNum); } if (seqNum != null && other.seqNum == null) { return 1; } else if (seqNum == null && other.seqNum != null) { return -1; } // insertion code if (insCode != null && other.insCode != null) { if (!insCode.equals(other.insCode)) return insCode.compareTo(other.insCode); } if (insCode != null && other.insCode == null) { return 1; } else if (insCode == null && other.insCode != null) { return -1; } return 0; }
java
public int compareToPositional(ResidueNumber other) { // sequence number if (seqNum != null && other.seqNum != null) { if (!seqNum.equals(other.seqNum)) return seqNum.compareTo(other.seqNum); } if (seqNum != null && other.seqNum == null) { return 1; } else if (seqNum == null && other.seqNum != null) { return -1; } // insertion code if (insCode != null && other.insCode != null) { if (!insCode.equals(other.insCode)) return insCode.compareTo(other.insCode); } if (insCode != null && other.insCode == null) { return 1; } else if (insCode == null && other.insCode != null) { return -1; } return 0; }
[ "public", "int", "compareToPositional", "(", "ResidueNumber", "other", ")", "{", "// sequence number", "if", "(", "seqNum", "!=", "null", "&&", "other", ".", "seqNum", "!=", "null", ")", "{", "if", "(", "!", "seqNum", ".", "equals", "(", "other", ".", "s...
Compare residue numbers by sequence number and insertion code, ignoring the chain @param other @return
[ "Compare", "residue", "numbers", "by", "sequence", "number", "and", "insertion", "code", "ignoring", "the", "chain" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueNumber.java#L250-L272
31,460
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueRangeAndLength.java
ResidueRangeAndLength.parse
public static ResidueRangeAndLength parse(String s, AtomPositionMap map) { ResidueRange rr = parse(s); ResidueNumber start = rr.getStart(); String chain = rr.getChainName(); // handle special "_" chain if(chain == null || chain.equals("_")) { ResidueNumber first = map.getNavMap().firstKey(); chain = first.getChainName(); // Quick check for additional chains. Not guaranteed if the atoms are out of order. if( ! map.getNavMap().lastKey().getChainName().equals(chain) ) { logger.warn("Multiple possible chains match '_'. Using chain {}",chain); } } // get a non-null start and end // if it's the whole chain, choose the first and last residue numbers in the chain if (start==null) { start = map.getFirst(chain); } ResidueNumber end = rr.getEnd(); if (end==null) { // should happen iff start==null end = map.getLast(chain); } // Replace '_' start.setChainName(chain); end.setChainName(chain); // Now fix any errors and calculate the length return map.trimToValidResidues(new ResidueRange(chain, start, end)); }
java
public static ResidueRangeAndLength parse(String s, AtomPositionMap map) { ResidueRange rr = parse(s); ResidueNumber start = rr.getStart(); String chain = rr.getChainName(); // handle special "_" chain if(chain == null || chain.equals("_")) { ResidueNumber first = map.getNavMap().firstKey(); chain = first.getChainName(); // Quick check for additional chains. Not guaranteed if the atoms are out of order. if( ! map.getNavMap().lastKey().getChainName().equals(chain) ) { logger.warn("Multiple possible chains match '_'. Using chain {}",chain); } } // get a non-null start and end // if it's the whole chain, choose the first and last residue numbers in the chain if (start==null) { start = map.getFirst(chain); } ResidueNumber end = rr.getEnd(); if (end==null) { // should happen iff start==null end = map.getLast(chain); } // Replace '_' start.setChainName(chain); end.setChainName(chain); // Now fix any errors and calculate the length return map.trimToValidResidues(new ResidueRange(chain, start, end)); }
[ "public", "static", "ResidueRangeAndLength", "parse", "(", "String", "s", ",", "AtomPositionMap", "map", ")", "{", "ResidueRange", "rr", "=", "parse", "(", "s", ")", ";", "ResidueNumber", "start", "=", "rr", ".", "getStart", "(", ")", ";", "String", "chain...
Parses a residue range. The AtomPositionMap is used to calculate the length and fill in missing information, such as for whole chains ('A:'). Supports the special chain name '_' for single-chain structures. If residues are specified outside of the range given in the map, attempts to decrease the input range to valid values. In extreme cases where this process fails fails to find any valid indices, returns null. For a function which more conservatively represents the input range, without chain inference and error fixes, use {@link ResidueRange#parse(String)}. @param s A string of the form chain_start-end. For example: <code>A.5-100</code>. @return The unique ResidueRange corresponding to {@code s}.
[ "Parses", "a", "residue", "range", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/ResidueRangeAndLength.java#L96-L128
31,461
biojava/biojava
biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java
Jronn.convertProteinSequencetoFasta
public static FastaSequence convertProteinSequencetoFasta(ProteinSequence sequence){ StringBuffer buf = new StringBuffer(); for (AminoAcidCompound compound : sequence) { String c = compound.getShortName(); if (! SequenceUtil.NON_AA.matcher(c).find()) { buf.append(c); } else { buf.append("X"); } } return new FastaSequence(sequence.getAccession().getID(),buf.toString()); }
java
public static FastaSequence convertProteinSequencetoFasta(ProteinSequence sequence){ StringBuffer buf = new StringBuffer(); for (AminoAcidCompound compound : sequence) { String c = compound.getShortName(); if (! SequenceUtil.NON_AA.matcher(c).find()) { buf.append(c); } else { buf.append("X"); } } return new FastaSequence(sequence.getAccession().getID(),buf.toString()); }
[ "public", "static", "FastaSequence", "convertProteinSequencetoFasta", "(", "ProteinSequence", "sequence", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "AminoAcidCompound", "compound", ":", "sequence", ")", "{", "String", ...
Utility method to convert a BioJava ProteinSequence object to the FastaSequence object used internally in JRonn. @param sequence @return
[ "Utility", "method", "to", "convert", "a", "BioJava", "ProteinSequence", "object", "to", "the", "FastaSequence", "object", "used", "internally", "in", "JRonn", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java#L159-L173
31,462
biojava/biojava
biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java
Jronn.getDisorder
public static Range[] getDisorder(FastaSequence sequence) { float[] scores = getDisorderScores(sequence); return scoresToRanges(scores, RonnConstraint.DEFAULT_RANGE_PROBABILITY_THRESHOLD); }
java
public static Range[] getDisorder(FastaSequence sequence) { float[] scores = getDisorderScores(sequence); return scoresToRanges(scores, RonnConstraint.DEFAULT_RANGE_PROBABILITY_THRESHOLD); }
[ "public", "static", "Range", "[", "]", "getDisorder", "(", "FastaSequence", "sequence", ")", "{", "float", "[", "]", "scores", "=", "getDisorderScores", "(", "sequence", ")", ";", "return", "scoresToRanges", "(", "scores", ",", "RonnConstraint", ".", "DEFAULT_...
Calculates the disordered regions of the sequence. More formally, the regions for which the probability of disorder is greater then 0.50. @param sequence an instance of FastaSequence object, holding the name and the sequence. @return the array of ranges if there are any residues predicted to have the probability of disorder greater then 0.5, null otherwise.
[ "Calculates", "the", "disordered", "regions", "of", "the", "sequence", ".", "More", "formally", "the", "regions", "for", "which", "the", "probability", "of", "disorder", "is", "greater", "then", "0", ".", "50", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java#L200-L203
31,463
biojava/biojava
biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java
Jronn.scoresToRanges
public static Range[] scoresToRanges(float[] scores, float probability) { assert scores!=null && scores.length>0; assert probability>0 && probability<1; int count=0; int regionLen=0; List<Range> ranges = new ArrayList<Range>(); for(float score: scores) { count++; // Round to 2 decimal points before comparison score = (float) (Math.round(score*100.0)/100.0); if(score>probability) { regionLen++; } else { if(regionLen>0) { ranges.add(new Range(count-regionLen, count-1,score)); } regionLen=0; } } // In case of the range to boundary runs to the very end of the sequence if(regionLen>1) { ranges.add(new Range(count-regionLen+1, count,scores[scores.length-1])); } return ranges.toArray(new Range[ranges.size()]); }
java
public static Range[] scoresToRanges(float[] scores, float probability) { assert scores!=null && scores.length>0; assert probability>0 && probability<1; int count=0; int regionLen=0; List<Range> ranges = new ArrayList<Range>(); for(float score: scores) { count++; // Round to 2 decimal points before comparison score = (float) (Math.round(score*100.0)/100.0); if(score>probability) { regionLen++; } else { if(regionLen>0) { ranges.add(new Range(count-regionLen, count-1,score)); } regionLen=0; } } // In case of the range to boundary runs to the very end of the sequence if(regionLen>1) { ranges.add(new Range(count-regionLen+1, count,scores[scores.length-1])); } return ranges.toArray(new Range[ranges.size()]); }
[ "public", "static", "Range", "[", "]", "scoresToRanges", "(", "float", "[", "]", "scores", ",", "float", "probability", ")", "{", "assert", "scores", "!=", "null", "&&", "scores", ".", "length", ">", "0", ";", "assert", "probability", ">", "0", "&&", "...
Convert raw scores to ranges. Gives ranges for given probability of disorder value @param scores the raw probability of disorder scores for each residue in the sequence. @param probability the cut off threshold. Include all residues with the probability of disorder greater then this value @return the array of ranges if there are any residues predicted to have the probability of disorder greater then {@code probability}, null otherwise.
[ "Convert", "raw", "scores", "to", "ranges", ".", "Gives", "ranges", "for", "given", "probability", "of", "disorder", "value" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java#L212-L238
31,464
biojava/biojava
biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java
Jronn.getDisorderScores
public static Map<FastaSequence,float[]> getDisorderScores(List<FastaSequence> sequences) { Map<FastaSequence,float[]> results = new TreeMap<FastaSequence, float[]>(); for(FastaSequence fsequence : sequences) { results.put(fsequence, predictSerial(fsequence)); } return results; }
java
public static Map<FastaSequence,float[]> getDisorderScores(List<FastaSequence> sequences) { Map<FastaSequence,float[]> results = new TreeMap<FastaSequence, float[]>(); for(FastaSequence fsequence : sequences) { results.put(fsequence, predictSerial(fsequence)); } return results; }
[ "public", "static", "Map", "<", "FastaSequence", ",", "float", "[", "]", ">", "getDisorderScores", "(", "List", "<", "FastaSequence", ">", "sequences", ")", "{", "Map", "<", "FastaSequence", ",", "float", "[", "]", ">", "results", "=", "new", "TreeMap", ...
Calculates the probability of disorder scores for each residue in the sequence for many sequences in the input. @param sequences the list of the FastaSequence objects @return the Map with key->FastaSequence, value->probability of disorder for each residue @see #getDisorder(FastaSequence)
[ "Calculates", "the", "probability", "of", "disorder", "scores", "for", "each", "residue", "in", "the", "sequence", "for", "many", "sequences", "in", "the", "input", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java#L248-L254
31,465
biojava/biojava
biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java
Jronn.getDisorder
public static Map<FastaSequence,Range[]> getDisorder(List<FastaSequence> sequences) { Map<FastaSequence,Range[]> disorderRanges = new TreeMap<FastaSequence,Range[]>(); for(FastaSequence fs: sequences) { disorderRanges.put(fs, getDisorder(fs)); } return disorderRanges; }
java
public static Map<FastaSequence,Range[]> getDisorder(List<FastaSequence> sequences) { Map<FastaSequence,Range[]> disorderRanges = new TreeMap<FastaSequence,Range[]>(); for(FastaSequence fs: sequences) { disorderRanges.put(fs, getDisorder(fs)); } return disorderRanges; }
[ "public", "static", "Map", "<", "FastaSequence", ",", "Range", "[", "]", ">", "getDisorder", "(", "List", "<", "FastaSequence", ">", "sequences", ")", "{", "Map", "<", "FastaSequence", ",", "Range", "[", "]", ">", "disorderRanges", "=", "new", "TreeMap", ...
Calculates the disordered regions of the sequence for many sequences in the input. @param sequences sequences the list of the FastaSequence objects @return @see #getDisorder(FastaSequence)
[ "Calculates", "the", "disordered", "regions", "of", "the", "sequence", "for", "many", "sequences", "in", "the", "input", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java#L263-L269
31,466
biojava/biojava
biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java
Jronn.getDisorder
public static Map<FastaSequence,Range[]> getDisorder(String fastaFile) throws FileNotFoundException, IOException { final List<FastaSequence> sequences = SequenceUtil.readFasta(new FileInputStream(fastaFile)); return getDisorder(sequences); }
java
public static Map<FastaSequence,Range[]> getDisorder(String fastaFile) throws FileNotFoundException, IOException { final List<FastaSequence> sequences = SequenceUtil.readFasta(new FileInputStream(fastaFile)); return getDisorder(sequences); }
[ "public", "static", "Map", "<", "FastaSequence", ",", "Range", "[", "]", ">", "getDisorder", "(", "String", "fastaFile", ")", "throws", "FileNotFoundException", ",", "IOException", "{", "final", "List", "<", "FastaSequence", ">", "sequences", "=", "SequenceUtil"...
Calculates the disordered regions of the protein sequence. @param fastaFile input file name containing the sequence in FASTA @return the Map with key->FastaSequence, value->the list of disordered regions for each sequence @throws FileNotFoundException if the input file cannot be found @throws IOException of the system cannot access or read from the input file @see #getDisorder(FastaSequence) @see #Jronn.Range
[ "Calculates", "the", "disordered", "regions", "of", "the", "protein", "sequence", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-protein-disorder/src/main/java/org/biojava/nbio/ronn/Jronn.java#L280-L283
31,467
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/CAConverter.java
CAConverter.getRepresentativeAtomsOnly
public static List<Chain> getRepresentativeAtomsOnly(List<Chain> chains){ List<Chain> newChains = new ArrayList<Chain>(); for (Chain chain : chains){ Chain newChain = getRepresentativeAtomsOnly(chain); newChains.add(newChain); } return newChains; }
java
public static List<Chain> getRepresentativeAtomsOnly(List<Chain> chains){ List<Chain> newChains = new ArrayList<Chain>(); for (Chain chain : chains){ Chain newChain = getRepresentativeAtomsOnly(chain); newChains.add(newChain); } return newChains; }
[ "public", "static", "List", "<", "Chain", ">", "getRepresentativeAtomsOnly", "(", "List", "<", "Chain", ">", "chains", ")", "{", "List", "<", "Chain", ">", "newChains", "=", "new", "ArrayList", "<", "Chain", ">", "(", ")", ";", "for", "(", "Chain", "ch...
Convert a List of chain objects to another List of chains, containing Representative atoms only. @param chains list of chains @return a list of chains @since Biojava 4.1.0
[ "Convert", "a", "List", "of", "chain", "objects", "to", "another", "List", "of", "chains", "containing", "Representative", "atoms", "only", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/CAConverter.java#L44-L53
31,468
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/CAConverter.java
CAConverter.getRepresentativeAtomsOnly
public static Chain getRepresentativeAtomsOnly(Chain chain){ Chain newChain = new ChainImpl(); newChain.setId(chain.getId()); newChain.setName(chain.getName()); newChain.setEntityInfo(chain.getEntityInfo()); newChain.setSwissprotId(chain.getSwissprotId()); List<Group> groups = chain.getAtomGroups(); grouploop: for (Group g: groups){ List<Atom> atoms = g.getAtoms(); if ( ! (g instanceof AminoAcid)) continue; for (Atom a : atoms){ if ( a.getName().equals(StructureTools.CA_ATOM_NAME) && a.getElement()==Element.C){ // we got a CA atom in this group! AminoAcid n = new AminoAcidImpl(); n.setPDBName(g.getPDBName()); n.setResidueNumber(g.getResidueNumber()); n.addAtom(a); newChain.addGroup(n); continue grouploop; } } } return newChain; }
java
public static Chain getRepresentativeAtomsOnly(Chain chain){ Chain newChain = new ChainImpl(); newChain.setId(chain.getId()); newChain.setName(chain.getName()); newChain.setEntityInfo(chain.getEntityInfo()); newChain.setSwissprotId(chain.getSwissprotId()); List<Group> groups = chain.getAtomGroups(); grouploop: for (Group g: groups){ List<Atom> atoms = g.getAtoms(); if ( ! (g instanceof AminoAcid)) continue; for (Atom a : atoms){ if ( a.getName().equals(StructureTools.CA_ATOM_NAME) && a.getElement()==Element.C){ // we got a CA atom in this group! AminoAcid n = new AminoAcidImpl(); n.setPDBName(g.getPDBName()); n.setResidueNumber(g.getResidueNumber()); n.addAtom(a); newChain.addGroup(n); continue grouploop; } } } return newChain; }
[ "public", "static", "Chain", "getRepresentativeAtomsOnly", "(", "Chain", "chain", ")", "{", "Chain", "newChain", "=", "new", "ChainImpl", "(", ")", ";", "newChain", ".", "setId", "(", "chain", ".", "getId", "(", ")", ")", ";", "newChain", ".", "setName", ...
Convert a Chain to a new Chain containing C-alpha atoms only. @param chain to convert @return a new chain containing Amino acids with C-alpha only. @since Biojava 4.1.0
[ "Convert", "a", "Chain", "to", "a", "new", "Chain", "containing", "C", "-", "alpha", "atoms", "only", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/CAConverter.java#L62-L95
31,469
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/GradientMapper.java
GradientMapper.getGradientMapper
public static GradientMapper getGradientMapper(int gradientType, double min, double max) { GradientMapper gm; switch( gradientType ) { case BLACK_WHITE_GRADIENT: gm = new GradientMapper(Color.BLACK, Color.WHITE); gm.put(min, Color.BLACK); gm.put(max, Color.WHITE); return gm; case WHITE_BLACK_GRADIENT: gm = new GradientMapper(Color.WHITE, Color.BLACK); gm.put(min, Color.WHITE); gm.put(max, Color.BLACK); return gm; case RED_BLUE_GRADIENT: gm = new GradientMapper(Color.RED, Color.BLUE); gm.put(min, Color.RED); gm.put(max, Color.BLUE); return gm; case RAINBOW_GRADIENT: { //Set up interpolation in HSV colorspace ColorSpace hsv = HSVColorSpace.getHSVColorSpace(); LinearColorInterpolator interp = new LinearColorInterpolator(hsv); interp.setInterpolationDirection(0, InterpolationDirection.UPPER); Color hsvLow = new Color(hsv,new float[] {0f, 1f, 1f},1f); Color hsvHigh = new Color(hsv,new float[] {1f, 1f, 1f},1f); gm = new GradientMapper(hsvLow, hsvHigh, hsv); gm.put(min, hsvLow); gm.put(max, hsvHigh); gm.setInterpolator(interp); return gm; } case RAINBOW_INTENSITY_GRADIENT: { //Set up interpolation in HSV colorspace ColorSpace hsv = HSVColorSpace.getHSVColorSpace(); LinearColorInterpolator interp = new LinearColorInterpolator(hsv); interp.setInterpolationDirection(0, InterpolationDirection.LOWER); Color hsvLow = new Color(hsv,new float[] {1f, 1f, 1f},1f); Color hsvHigh = new Color(hsv,new float[] {0f, 1f, 0f},1f); gm = new GradientMapper(hsvLow, hsvHigh, hsv); gm.put(min, hsvLow); gm.put(max, hsvHigh); gm.setInterpolator(interp); return gm; } default: throw new IllegalArgumentException("Unsupported gradient "+gradientType); } }
java
public static GradientMapper getGradientMapper(int gradientType, double min, double max) { GradientMapper gm; switch( gradientType ) { case BLACK_WHITE_GRADIENT: gm = new GradientMapper(Color.BLACK, Color.WHITE); gm.put(min, Color.BLACK); gm.put(max, Color.WHITE); return gm; case WHITE_BLACK_GRADIENT: gm = new GradientMapper(Color.WHITE, Color.BLACK); gm.put(min, Color.WHITE); gm.put(max, Color.BLACK); return gm; case RED_BLUE_GRADIENT: gm = new GradientMapper(Color.RED, Color.BLUE); gm.put(min, Color.RED); gm.put(max, Color.BLUE); return gm; case RAINBOW_GRADIENT: { //Set up interpolation in HSV colorspace ColorSpace hsv = HSVColorSpace.getHSVColorSpace(); LinearColorInterpolator interp = new LinearColorInterpolator(hsv); interp.setInterpolationDirection(0, InterpolationDirection.UPPER); Color hsvLow = new Color(hsv,new float[] {0f, 1f, 1f},1f); Color hsvHigh = new Color(hsv,new float[] {1f, 1f, 1f},1f); gm = new GradientMapper(hsvLow, hsvHigh, hsv); gm.put(min, hsvLow); gm.put(max, hsvHigh); gm.setInterpolator(interp); return gm; } case RAINBOW_INTENSITY_GRADIENT: { //Set up interpolation in HSV colorspace ColorSpace hsv = HSVColorSpace.getHSVColorSpace(); LinearColorInterpolator interp = new LinearColorInterpolator(hsv); interp.setInterpolationDirection(0, InterpolationDirection.LOWER); Color hsvLow = new Color(hsv,new float[] {1f, 1f, 1f},1f); Color hsvHigh = new Color(hsv,new float[] {0f, 1f, 0f},1f); gm = new GradientMapper(hsvLow, hsvHigh, hsv); gm.put(min, hsvLow); gm.put(max, hsvHigh); gm.setInterpolator(interp); return gm; } default: throw new IllegalArgumentException("Unsupported gradient "+gradientType); } }
[ "public", "static", "GradientMapper", "getGradientMapper", "(", "int", "gradientType", ",", "double", "min", ",", "double", "max", ")", "{", "GradientMapper", "gm", ";", "switch", "(", "gradientType", ")", "{", "case", "BLACK_WHITE_GRADIENT", ":", "gm", "=", "...
Constructs a gradientMapper to draw one of the pre-defined gradients For example, GradientMapper.getGradientMapper(GradientMapper.RAINBOW_GRADIENT, 0, 10) @param gradientType One of the gradient types, eg GradientMapper.BLACK_WHITE_GRADIENT @param min Start of the gradient @param max End of the gradient @return
[ "Constructs", "a", "gradientMapper", "to", "draw", "one", "of", "the", "pre", "-", "defined", "gradients" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/GradientMapper.java#L81-L132
31,470
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/GradientMapper.java
GradientMapper.clear
@Override public void clear() { Color neg = mapping.get(Double.NEGATIVE_INFINITY); Color pos = mapping.get(Double.POSITIVE_INFINITY); mapping.clear(); mapping.put(Double.NEGATIVE_INFINITY, neg); mapping.put(Double.POSITIVE_INFINITY, pos); }
java
@Override public void clear() { Color neg = mapping.get(Double.NEGATIVE_INFINITY); Color pos = mapping.get(Double.POSITIVE_INFINITY); mapping.clear(); mapping.put(Double.NEGATIVE_INFINITY, neg); mapping.put(Double.POSITIVE_INFINITY, pos); }
[ "@", "Override", "public", "void", "clear", "(", ")", "{", "Color", "neg", "=", "mapping", ".", "get", "(", "Double", ".", "NEGATIVE_INFINITY", ")", ";", "Color", "pos", "=", "mapping", ".", "get", "(", "Double", ".", "POSITIVE_INFINITY", ")", ";", "ma...
Clears all finite endpoints @see java.util.Map#clear()
[ "Clears", "all", "finite", "endpoints" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/GradientMapper.java#L168-L175
31,471
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/GradientMapper.java
GradientMapper.put
@Override public Color put(Double position, Color color) { if( position == null ) { throw new NullPointerException("Null endpoint position"); } if( color == null ){ throw new NullPointerException("Null colors are not allowed."); } return mapping.put(position, color); }
java
@Override public Color put(Double position, Color color) { if( position == null ) { throw new NullPointerException("Null endpoint position"); } if( color == null ){ throw new NullPointerException("Null colors are not allowed."); } return mapping.put(position, color); }
[ "@", "Override", "public", "Color", "put", "(", "Double", "position", ",", "Color", "color", ")", "{", "if", "(", "position", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Null endpoint position\"", ")", ";", "}", "if", "(", "colo...
Adds a gradient endpoint at the specified position. @param position The endpoint position. May be Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY for endpoints. @param color @return @see java.util.Map#put(java.lang.Object, java.lang.Object)
[ "Adds", "a", "gradient", "endpoint", "at", "the", "specified", "position", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/color/GradientMapper.java#L234-L243
31,472
biojava/biojava
biojava-ontology/src/main/java/org/biojava/nbio/ontology/io/OboParser.java
OboParser.parseOBO
public Ontology parseOBO( BufferedReader oboFile, String ontoName, String ontoDescription ) throws ParseException, IOException { try { OntologyFactory factory = OntoTools.getDefaultFactory(); Ontology ontology = factory.createOntology(ontoName, ontoDescription); OboFileParser parser = new OboFileParser(); OboFileEventListener handler = new OboFileHandler(ontology); parser.addOboFileEventListener(handler); parser.parseOBO(oboFile); return ontology; } catch (AlreadyExistsException ex) { throw new RuntimeException( "Duplication in ontology"); } catch (OntologyException ex) { throw new RuntimeException(ex); } }
java
public Ontology parseOBO( BufferedReader oboFile, String ontoName, String ontoDescription ) throws ParseException, IOException { try { OntologyFactory factory = OntoTools.getDefaultFactory(); Ontology ontology = factory.createOntology(ontoName, ontoDescription); OboFileParser parser = new OboFileParser(); OboFileEventListener handler = new OboFileHandler(ontology); parser.addOboFileEventListener(handler); parser.parseOBO(oboFile); return ontology; } catch (AlreadyExistsException ex) { throw new RuntimeException( "Duplication in ontology"); } catch (OntologyException ex) { throw new RuntimeException(ex); } }
[ "public", "Ontology", "parseOBO", "(", "BufferedReader", "oboFile", ",", "String", "ontoName", ",", "String", "ontoDescription", ")", "throws", "ParseException", ",", "IOException", "{", "try", "{", "OntologyFactory", "factory", "=", "OntoTools", ".", "getDefaultFac...
Parse a OBO file and return its content as a BioJava Ontology object @param oboFile the file to be parsed @param ontoName @param ontoDescription @return the ontology represented as a BioJava ontology file @throws ParseException @throws IOException
[ "Parse", "a", "OBO", "file", "and", "return", "its", "content", "as", "a", "BioJava", "Ontology", "object" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-ontology/src/main/java/org/biojava/nbio/ontology/io/OboParser.java#L76-L103
31,473
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/align/multiple/util/MultipleAlignmentDisplay.java
MultipleAlignmentDisplay.getRotatedAtoms
public static List<Atom[]> getRotatedAtoms(MultipleAlignment multAln) throws StructureException { int size = multAln.size(); List<Atom[]> atomArrays = multAln.getAtomArrays(); for (int i = 0; i < size; i++) { if (atomArrays.get(i).length < 1) throw new StructureException( "Length of atoms arrays is too short! Size: " + atomArrays.get(i).length); } List<Atom[]> rotatedAtoms = new ArrayList<Atom[]>(); // TODO implement independent BlockSet superposition of the structure List<Matrix4d> transf = multAln.getBlockSet(0).getTransformations(); if (transf == null) { logger.error("Alignment Transformations are not calculated. " + "Superimposing to first structure as reference."); multAln = multAln.clone(); MultipleSuperimposer imposer = new ReferenceSuperimposer(); imposer.superimpose(multAln); transf = multAln.getBlockSet(0).getTransformations(); assert (transf != null); } // Rotate the atom coordinates of all the structures for (int i = 0; i < size; i++) { // TODO handle BlockSet-level transformations // make sure this method has the same behavior as the other display. // -SB 2015-06 // Assume all atoms are from the same structure Structure displayS = atomArrays.get(i)[0].getGroup().getChain() .getStructure().clone(); // Get all the atoms and include ligands and hetatoms Atom[] rotCA = StructureTools.getRepresentativeAtomArray(displayS); List<Group> hetatms = StructureTools.getUnalignedGroups(rotCA); int index = rotCA.length; rotCA = Arrays.copyOf(rotCA, rotCA.length + hetatms.size()); for (Group g : hetatms) { rotCA[index] = g.getAtom(0); index++; } // Transform the structure to ensure a full rotation in the display Calc.transform(displayS, transf.get(i)); rotatedAtoms.add(rotCA); } return rotatedAtoms; }
java
public static List<Atom[]> getRotatedAtoms(MultipleAlignment multAln) throws StructureException { int size = multAln.size(); List<Atom[]> atomArrays = multAln.getAtomArrays(); for (int i = 0; i < size; i++) { if (atomArrays.get(i).length < 1) throw new StructureException( "Length of atoms arrays is too short! Size: " + atomArrays.get(i).length); } List<Atom[]> rotatedAtoms = new ArrayList<Atom[]>(); // TODO implement independent BlockSet superposition of the structure List<Matrix4d> transf = multAln.getBlockSet(0).getTransformations(); if (transf == null) { logger.error("Alignment Transformations are not calculated. " + "Superimposing to first structure as reference."); multAln = multAln.clone(); MultipleSuperimposer imposer = new ReferenceSuperimposer(); imposer.superimpose(multAln); transf = multAln.getBlockSet(0).getTransformations(); assert (transf != null); } // Rotate the atom coordinates of all the structures for (int i = 0; i < size; i++) { // TODO handle BlockSet-level transformations // make sure this method has the same behavior as the other display. // -SB 2015-06 // Assume all atoms are from the same structure Structure displayS = atomArrays.get(i)[0].getGroup().getChain() .getStructure().clone(); // Get all the atoms and include ligands and hetatoms Atom[] rotCA = StructureTools.getRepresentativeAtomArray(displayS); List<Group> hetatms = StructureTools.getUnalignedGroups(rotCA); int index = rotCA.length; rotCA = Arrays.copyOf(rotCA, rotCA.length + hetatms.size()); for (Group g : hetatms) { rotCA[index] = g.getAtom(0); index++; } // Transform the structure to ensure a full rotation in the display Calc.transform(displayS, transf.get(i)); rotatedAtoms.add(rotCA); } return rotatedAtoms; }
[ "public", "static", "List", "<", "Atom", "[", "]", ">", "getRotatedAtoms", "(", "MultipleAlignment", "multAln", ")", "throws", "StructureException", "{", "int", "size", "=", "multAln", ".", "size", "(", ")", ";", "List", "<", "Atom", "[", "]", ">", "atom...
New structures are downloaded if they were not cached in the alignment and they are entirely transformed here with the superposition information in the Multiple Alignment. @param multAln @return list of transformed AtomArrays @throws StructureException
[ "New", "structures", "are", "downloaded", "if", "they", "were", "not", "cached", "in", "the", "alignment", "and", "they", "are", "entirely", "transformed", "here", "with", "the", "superposition", "information", "in", "the", "Multiple", "Alignment", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/multiple/util/MultipleAlignmentDisplay.java#L59-L115
31,474
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/io/BondMaker.java
BondMaker.formLinkRecordBond
public void formLinkRecordBond(LinkRecord linkRecord) { // only work with atoms that aren't alternate locations if (linkRecord.getAltLoc1().equals(" ") || linkRecord.getAltLoc2().equals(" ")) return; try { Map<Integer, Atom> a = getAtomFromRecord(linkRecord.getName1(), linkRecord.getAltLoc1(), linkRecord.getResName1(), linkRecord.getChainID1(), linkRecord.getResSeq1(), linkRecord.getiCode1()); Map<Integer, Atom> b = getAtomFromRecord(linkRecord.getName2(), linkRecord.getAltLoc2(), linkRecord.getResName2(), linkRecord.getChainID2(), linkRecord.getResSeq2(), linkRecord.getiCode2()); for(int i=0; i<structure.nrModels(); i++){ if(a.containsKey(i) && b.containsKey(i)){ // TODO determine what the actual bond order of this bond is; for // now, we're assuming they're single bonds if(!a.get(i).equals(b.get(i))){ new BondImpl(a.get(i), b.get(i), 1); } } } }catch (StructureException e) { // Note, in Calpha only mode the link atoms may not be present. if (! params.isParseCAOnly()) { logger.warn("Could not find atoms specified in LINK record: {}",linkRecord.toString()); } else { logger.debug("Could not find atoms specified in LINK record while parsing in parseCAonly mode."); } } }
java
public void formLinkRecordBond(LinkRecord linkRecord) { // only work with atoms that aren't alternate locations if (linkRecord.getAltLoc1().equals(" ") || linkRecord.getAltLoc2().equals(" ")) return; try { Map<Integer, Atom> a = getAtomFromRecord(linkRecord.getName1(), linkRecord.getAltLoc1(), linkRecord.getResName1(), linkRecord.getChainID1(), linkRecord.getResSeq1(), linkRecord.getiCode1()); Map<Integer, Atom> b = getAtomFromRecord(linkRecord.getName2(), linkRecord.getAltLoc2(), linkRecord.getResName2(), linkRecord.getChainID2(), linkRecord.getResSeq2(), linkRecord.getiCode2()); for(int i=0; i<structure.nrModels(); i++){ if(a.containsKey(i) && b.containsKey(i)){ // TODO determine what the actual bond order of this bond is; for // now, we're assuming they're single bonds if(!a.get(i).equals(b.get(i))){ new BondImpl(a.get(i), b.get(i), 1); } } } }catch (StructureException e) { // Note, in Calpha only mode the link atoms may not be present. if (! params.isParseCAOnly()) { logger.warn("Could not find atoms specified in LINK record: {}",linkRecord.toString()); } else { logger.debug("Could not find atoms specified in LINK record while parsing in parseCAonly mode."); } } }
[ "public", "void", "formLinkRecordBond", "(", "LinkRecord", "linkRecord", ")", "{", "// only work with atoms that aren't alternate locations", "if", "(", "linkRecord", ".", "getAltLoc1", "(", ")", ".", "equals", "(", "\" \"", ")", "||", "linkRecord", ".", "getAltLoc2",...
Creates bond objects from a LinkRecord as parsed from a PDB file @param linkRecord
[ "Creates", "bond", "objects", "from", "a", "LinkRecord", "as", "parsed", "from", "a", "PDB", "file" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/io/BondMaker.java#L311-L346
31,475
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationGroup.java
RotationGroup.setEAxis
private void setEAxis() { Rotation e = rotations.get(0); Rotation h = rotations.get(principalAxisIndex); e.setAxisAngle(new AxisAngle4d(h.getAxisAngle())); e.getAxisAngle().angle = 0.0; e.setFold(h.getFold()); }
java
private void setEAxis() { Rotation e = rotations.get(0); Rotation h = rotations.get(principalAxisIndex); e.setAxisAngle(new AxisAngle4d(h.getAxisAngle())); e.getAxisAngle().angle = 0.0; e.setFold(h.getFold()); }
[ "private", "void", "setEAxis", "(", ")", "{", "Rotation", "e", "=", "rotations", ".", "get", "(", "0", ")", ";", "Rotation", "h", "=", "rotations", ".", "get", "(", "principalAxisIndex", ")", ";", "e", ".", "setAxisAngle", "(", "new", "AxisAngle4d", "(...
Add E operation to the highest order rotation axis. By definition E belongs to the highest order axis.
[ "Add", "E", "operation", "to", "the", "highest", "order", "rotation", "axis", ".", "By", "definition", "E", "belongs", "to", "the", "highest", "order", "axis", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/RotationGroup.java#L249-L255
31,476
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/ScaleableMatrixPanel.java
ScaleableMatrixPanel.main
public static void main(String[] args){ PDBFileReader pdbr = new PDBFileReader(); pdbr.setPath("/tmp/"); //String pdb1 = "1crl"; //String pdb2 = "1ede"; String pdb1 = "1buz"; String pdb2 = "1ali"; //String pdb1 = "5pti"; //String pdb2 = "5pti"; // NO NEED TO DO CHANGE ANYTHING BELOW HERE... StructurePairAligner sc = new StructurePairAligner(); StrucAligParameters params = new StrucAligParameters(); params.setMaxIter(1); sc.setParams(params); // step1 : read molecules try { Structure s1 = pdbr.getStructureById(pdb1); Structure s2 = pdbr.getStructureById(pdb2); System.out.println("aligning " + pdb1 + " vs. " + pdb2); System.out.println(s1); System.out.println(); System.out.println(s2); // step 2 : do the calculations sc.align(s1,s2); ScaleableMatrixPanel smp = new ScaleableMatrixPanel(); JFrame frame = new JFrame(); frame.addWindowListener(new WindowAdapter(){ @Override public void windowClosing(WindowEvent e){ JFrame f = (JFrame) e.getSource(); f.setVisible(false); f.dispose(); } }); smp.setMatrix(sc.getDistMat()); smp.setFragmentPairs(sc.getFragmentPairs()); smp.setAlternativeAligs(sc.getAlignments()); for (int i = 0; i < sc.getAlignments().length; i++) { AlternativeAlignment aa =sc.getAlignments()[i]; System.out.println(aa); } frame.getContentPane().add(smp); frame.pack(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
java
public static void main(String[] args){ PDBFileReader pdbr = new PDBFileReader(); pdbr.setPath("/tmp/"); //String pdb1 = "1crl"; //String pdb2 = "1ede"; String pdb1 = "1buz"; String pdb2 = "1ali"; //String pdb1 = "5pti"; //String pdb2 = "5pti"; // NO NEED TO DO CHANGE ANYTHING BELOW HERE... StructurePairAligner sc = new StructurePairAligner(); StrucAligParameters params = new StrucAligParameters(); params.setMaxIter(1); sc.setParams(params); // step1 : read molecules try { Structure s1 = pdbr.getStructureById(pdb1); Structure s2 = pdbr.getStructureById(pdb2); System.out.println("aligning " + pdb1 + " vs. " + pdb2); System.out.println(s1); System.out.println(); System.out.println(s2); // step 2 : do the calculations sc.align(s1,s2); ScaleableMatrixPanel smp = new ScaleableMatrixPanel(); JFrame frame = new JFrame(); frame.addWindowListener(new WindowAdapter(){ @Override public void windowClosing(WindowEvent e){ JFrame f = (JFrame) e.getSource(); f.setVisible(false); f.dispose(); } }); smp.setMatrix(sc.getDistMat()); smp.setFragmentPairs(sc.getFragmentPairs()); smp.setAlternativeAligs(sc.getAlignments()); for (int i = 0; i < sc.getAlignments().length; i++) { AlternativeAlignment aa =sc.getAlignments()[i]; System.out.println(aa); } frame.getContentPane().add(smp); frame.pack(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "{", "PDBFileReader", "pdbr", "=", "new", "PDBFileReader", "(", ")", ";", "pdbr", ".", "setPath", "(", "\"/tmp/\"", ")", ";", "//String pdb1 = \"1crl\";", "//String pdb2 = \"1ede\";", "S...
Number of minor ticks per unit scaled
[ "Number", "of", "minor", "ticks", "per", "unit", "scaled" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/ScaleableMatrixPanel.java#L76-L144
31,477
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java
GenbankSequenceParser.readSection
private List<String[]> readSection(BufferedReader bufferedReader) { List<String[]> section = new ArrayList<String[]>(); String line = ""; String currKey = null; StringBuffer currVal = new StringBuffer(); boolean done = false; int linecount = 0; try { while (!done) { bufferedReader.mark(320); line = bufferedReader.readLine(); String firstSecKey = section.isEmpty() ? "" : section.get(0)[0]; if (line != null && line.matches("\\p{Space}*")) { // regular expression \p{Space}* will match line // having only white space characters continue; } if (line == null || (!line.startsWith(" ") && linecount++ > 0 && (!firstSecKey .equals(START_SEQUENCE_TAG) || line .startsWith(END_SEQUENCE_TAG)))) { // dump out last part of section section.add(new String[]{currKey, currVal.toString()}); bufferedReader.reset(); done = true; } else { Matcher m = sectp.matcher(line); if (m.matches()) { // new key if (currKey != null) { section.add(new String[]{currKey, currVal.toString()}); } // key = group(2) or group(4) or group(6) - whichever is // not null currKey = m.group(2) == null ? (m.group(4) == null ? m .group(6) : m.group(4)) : m.group(2); currVal = new StringBuffer(); // val = group(3) if group(2) not null, group(5) if // group(4) not null, "" otherwise, trimmed currVal.append((m.group(2) == null ? (m.group(4) == null ? "" : m.group(5)) : m.group(3)).trim()); } else { // concatted line or SEQ START/END line? if (line.startsWith(START_SEQUENCE_TAG) || line.startsWith(END_SEQUENCE_TAG)) { currKey = line; } else { currVal.append("\n"); // newline in between lines - // can be removed later currVal.append(currKey.charAt(0) == '/' ? line .substring(21) : line.substring(12)); } } } } } catch (IOException e) { throw new ParserException(e.getMessage()); } catch (RuntimeException e) { throw new ParserException(e.getMessage()); } return section; }
java
private List<String[]> readSection(BufferedReader bufferedReader) { List<String[]> section = new ArrayList<String[]>(); String line = ""; String currKey = null; StringBuffer currVal = new StringBuffer(); boolean done = false; int linecount = 0; try { while (!done) { bufferedReader.mark(320); line = bufferedReader.readLine(); String firstSecKey = section.isEmpty() ? "" : section.get(0)[0]; if (line != null && line.matches("\\p{Space}*")) { // regular expression \p{Space}* will match line // having only white space characters continue; } if (line == null || (!line.startsWith(" ") && linecount++ > 0 && (!firstSecKey .equals(START_SEQUENCE_TAG) || line .startsWith(END_SEQUENCE_TAG)))) { // dump out last part of section section.add(new String[]{currKey, currVal.toString()}); bufferedReader.reset(); done = true; } else { Matcher m = sectp.matcher(line); if (m.matches()) { // new key if (currKey != null) { section.add(new String[]{currKey, currVal.toString()}); } // key = group(2) or group(4) or group(6) - whichever is // not null currKey = m.group(2) == null ? (m.group(4) == null ? m .group(6) : m.group(4)) : m.group(2); currVal = new StringBuffer(); // val = group(3) if group(2) not null, group(5) if // group(4) not null, "" otherwise, trimmed currVal.append((m.group(2) == null ? (m.group(4) == null ? "" : m.group(5)) : m.group(3)).trim()); } else { // concatted line or SEQ START/END line? if (line.startsWith(START_SEQUENCE_TAG) || line.startsWith(END_SEQUENCE_TAG)) { currKey = line; } else { currVal.append("\n"); // newline in between lines - // can be removed later currVal.append(currKey.charAt(0) == '/' ? line .substring(21) : line.substring(12)); } } } } } catch (IOException e) { throw new ParserException(e.getMessage()); } catch (RuntimeException e) { throw new ParserException(e.getMessage()); } return section; }
[ "private", "List", "<", "String", "[", "]", ">", "readSection", "(", "BufferedReader", "bufferedReader", ")", "{", "List", "<", "String", "[", "]", ">", "section", "=", "new", "ArrayList", "<", "String", "[", "]", ">", "(", ")", ";", "String", "line", ...
key->value tuples
[ "key", "-", ">", "value", "tuples" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java#L328-L394
31,478
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/location/InsdcParser.java
InsdcParser.parse
public Location parse(String locationString) throws ParserException { featureGlobalStart = Integer.MAX_VALUE; featureGlobalEnd = 1; Location l; List<Location> ll = parseLocationString(locationString, 1); if (ll.size() == 1) { l = ll.get(0); } else { l = new SimpleLocation( featureGlobalStart, featureGlobalEnd, Strand.UNDEFINED, ll); } return l; }
java
public Location parse(String locationString) throws ParserException { featureGlobalStart = Integer.MAX_VALUE; featureGlobalEnd = 1; Location l; List<Location> ll = parseLocationString(locationString, 1); if (ll.size() == 1) { l = ll.get(0); } else { l = new SimpleLocation( featureGlobalStart, featureGlobalEnd, Strand.UNDEFINED, ll); } return l; }
[ "public", "Location", "parse", "(", "String", "locationString", ")", "throws", "ParserException", "{", "featureGlobalStart", "=", "Integer", ".", "MAX_VALUE", ";", "featureGlobalEnd", "=", "1", ";", "Location", "l", ";", "List", "<", "Location", ">", "ll", "="...
Main method for parsing a location from a String instance @param locationString Represents a logical location @return The parsed location @throws ParserException thrown in the event of any error during parsing
[ "Main", "method", "for", "parsing", "a", "location", "from", "a", "String", "instance" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/location/InsdcParser.java#L138-L155
31,479
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/cluster/Subunit.java
Subunit.getProteinSequenceString
public String getProteinSequenceString() { if (sequence != null) return sequence.toString(); StringBuilder builder = new StringBuilder(); for (Atom a : reprAtoms) // This method preferred over getChemComp.getOneLetterCode because // it returns always X for Unknown residues builder.append(StructureTools.get1LetterCode(a.getGroup() .getPDBName())); return builder.toString(); }
java
public String getProteinSequenceString() { if (sequence != null) return sequence.toString(); StringBuilder builder = new StringBuilder(); for (Atom a : reprAtoms) // This method preferred over getChemComp.getOneLetterCode because // it returns always X for Unknown residues builder.append(StructureTools.get1LetterCode(a.getGroup() .getPDBName())); return builder.toString(); }
[ "public", "String", "getProteinSequenceString", "(", ")", "{", "if", "(", "sequence", "!=", "null", ")", "return", "sequence", ".", "toString", "(", ")", ";", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Atom", "a", ...
Get the protein sequence of the Subunit as String. @return protein sequence String
[ "Get", "the", "protein", "sequence", "of", "the", "Subunit", "as", "String", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/cluster/Subunit.java#L108-L121
31,480
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/storage/JoiningSequenceReader.java
JoiningSequenceReader.linearSearch
private int linearSearch(int position) { int[] minSeqIndex = getMinSequenceIndex(); int[] maxSeqIndex = getMaxSequenceIndex(); int length = minSeqIndex.length; for (int i = 0; i < length; i++) { if (position >= minSeqIndex[i] && position <= maxSeqIndex[i]) { return i; } } throw new IndexOutOfBoundsException("Given position " + position + " does not map into this Sequence"); }
java
private int linearSearch(int position) { int[] minSeqIndex = getMinSequenceIndex(); int[] maxSeqIndex = getMaxSequenceIndex(); int length = minSeqIndex.length; for (int i = 0; i < length; i++) { if (position >= minSeqIndex[i] && position <= maxSeqIndex[i]) { return i; } } throw new IndexOutOfBoundsException("Given position " + position + " does not map into this Sequence"); }
[ "private", "int", "linearSearch", "(", "int", "position", ")", "{", "int", "[", "]", "minSeqIndex", "=", "getMinSequenceIndex", "(", ")", ";", "int", "[", "]", "maxSeqIndex", "=", "getMaxSequenceIndex", "(", ")", ";", "int", "length", "=", "minSeqIndex", "...
Scans through the sequence index arrays in linear time. Not the best performance but easier to code
[ "Scans", "through", "the", "sequence", "index", "arrays", "in", "linear", "time", ".", "Not", "the", "best", "performance", "but", "easier", "to", "code" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/storage/JoiningSequenceReader.java#L174-L184
31,481
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/storage/JoiningSequenceReader.java
JoiningSequenceReader.binarySearch
private int binarySearch(int position) { int[] minSeqIndex = getMinSequenceIndex(); int[] maxSeqIndex = getMaxSequenceIndex(); int low = 0; int high = minSeqIndex.length - 1; while (low <= high) { //Go to the mid point in the array int mid = (low + high) >>> 1; //Get the max position represented by this Sequence int midMinPosition = minSeqIndex[mid]; int midMaxPosition = maxSeqIndex[mid]; //if current position is greater than the current bounds then //increase search space if (midMinPosition < position && midMaxPosition < position) { low = mid + 1; } //if current position is less than current bounds then decrease //search space else if (midMinPosition > position && midMaxPosition > position) { high = mid - 1; } else { return mid; } } throw new IndexOutOfBoundsException("Given position " + position + " does not map into this Sequence"); }
java
private int binarySearch(int position) { int[] minSeqIndex = getMinSequenceIndex(); int[] maxSeqIndex = getMaxSequenceIndex(); int low = 0; int high = minSeqIndex.length - 1; while (low <= high) { //Go to the mid point in the array int mid = (low + high) >>> 1; //Get the max position represented by this Sequence int midMinPosition = minSeqIndex[mid]; int midMaxPosition = maxSeqIndex[mid]; //if current position is greater than the current bounds then //increase search space if (midMinPosition < position && midMaxPosition < position) { low = mid + 1; } //if current position is less than current bounds then decrease //search space else if (midMinPosition > position && midMaxPosition > position) { high = mid - 1; } else { return mid; } } throw new IndexOutOfBoundsException("Given position " + position + " does not map into this Sequence"); }
[ "private", "int", "binarySearch", "(", "int", "position", ")", "{", "int", "[", "]", "minSeqIndex", "=", "getMinSequenceIndex", "(", ")", ";", "int", "[", "]", "maxSeqIndex", "=", "getMaxSequenceIndex", "(", ")", ";", "int", "low", "=", "0", ";", "int", ...
Scans through the sequence index arrays using binary search
[ "Scans", "through", "the", "sequence", "index", "arrays", "using", "binary", "search" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/storage/JoiningSequenceReader.java#L189-L216
31,482
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/storage/JoiningSequenceReader.java
JoiningSequenceReader.iterator
@Override public Iterator<C> iterator() { final List<Sequence<C>> localSequences = sequences; return new Iterator<C>() { private Iterator<C> currentSequenceIterator = null; private int currentPosition = 0; @Override public boolean hasNext() { //If the current iterator is null then see if the Sequences object has anything if (currentSequenceIterator == null) { return !localSequences.isEmpty(); } //See if we had any compounds boolean hasNext = currentSequenceIterator.hasNext(); if (!hasNext) { hasNext = currentPosition < sequences.size(); } return hasNext; } @Override public C next() { if (currentSequenceIterator == null) { if (localSequences.isEmpty()) { throw new NoSuchElementException("No sequences to iterate over; make sure you call hasNext() before next()"); } currentSequenceIterator = localSequences.get(currentPosition).iterator(); currentPosition++; } if (!currentSequenceIterator.hasNext()) { currentSequenceIterator = localSequences.get(currentPosition).iterator(); currentPosition++; } return currentSequenceIterator.next(); } @Override public void remove() throws UnsupportedOperationException { throw new UnsupportedOperationException("Cannot remove from this Sequence"); } }; }
java
@Override public Iterator<C> iterator() { final List<Sequence<C>> localSequences = sequences; return new Iterator<C>() { private Iterator<C> currentSequenceIterator = null; private int currentPosition = 0; @Override public boolean hasNext() { //If the current iterator is null then see if the Sequences object has anything if (currentSequenceIterator == null) { return !localSequences.isEmpty(); } //See if we had any compounds boolean hasNext = currentSequenceIterator.hasNext(); if (!hasNext) { hasNext = currentPosition < sequences.size(); } return hasNext; } @Override public C next() { if (currentSequenceIterator == null) { if (localSequences.isEmpty()) { throw new NoSuchElementException("No sequences to iterate over; make sure you call hasNext() before next()"); } currentSequenceIterator = localSequences.get(currentPosition).iterator(); currentPosition++; } if (!currentSequenceIterator.hasNext()) { currentSequenceIterator = localSequences.get(currentPosition).iterator(); currentPosition++; } return currentSequenceIterator.next(); } @Override public void remove() throws UnsupportedOperationException { throw new UnsupportedOperationException("Cannot remove from this Sequence"); } }; }
[ "@", "Override", "public", "Iterator", "<", "C", ">", "iterator", "(", ")", "{", "final", "List", "<", "Sequence", "<", "C", ">", ">", "localSequences", "=", "sequences", ";", "return", "new", "Iterator", "<", "C", ">", "(", ")", "{", "private", "Ite...
Iterator implementation which attempts to move through the 2D structure attempting to skip onto the next sequence as & when it is asked to
[ "Iterator", "implementation", "which", "attempts", "to", "move", "through", "the", "2D", "structure", "attempting", "to", "skip", "onto", "the", "next", "sequence", "as", "&", "when", "it", "is", "asked", "to" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/storage/JoiningSequenceReader.java#L223-L270
31,483
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/scop/ScopFactory.java
ScopFactory.getSCOP
public static ScopDatabase getSCOP(String version, boolean forceLocalData){ if( version == null ) { version = defaultVersion; } ScopDatabase scop = versionedScopDBs.get(version); if ( forceLocalData) { // Use a local installation if( scop == null || !(scop instanceof LocalScopDatabase) ) { logger.info("Creating new {}, version {}", BerkeleyScopInstallation.class.getSimpleName(), version); BerkeleyScopInstallation berkeley = new BerkeleyScopInstallation(); berkeley.setScopVersion(version); versionedScopDBs.put(version,berkeley); return berkeley; } return scop; } else { // Use a remote installation if( scop == null ) { logger.info("Creating new {}, version {}", RemoteScopInstallation.class.getSimpleName(), version); scop = new RemoteScopInstallation(); scop.setScopVersion(version); versionedScopDBs.put(version,scop); } return scop; } }
java
public static ScopDatabase getSCOP(String version, boolean forceLocalData){ if( version == null ) { version = defaultVersion; } ScopDatabase scop = versionedScopDBs.get(version); if ( forceLocalData) { // Use a local installation if( scop == null || !(scop instanceof LocalScopDatabase) ) { logger.info("Creating new {}, version {}", BerkeleyScopInstallation.class.getSimpleName(), version); BerkeleyScopInstallation berkeley = new BerkeleyScopInstallation(); berkeley.setScopVersion(version); versionedScopDBs.put(version,berkeley); return berkeley; } return scop; } else { // Use a remote installation if( scop == null ) { logger.info("Creating new {}, version {}", RemoteScopInstallation.class.getSimpleName(), version); scop = new RemoteScopInstallation(); scop.setScopVersion(version); versionedScopDBs.put(version,scop); } return scop; } }
[ "public", "static", "ScopDatabase", "getSCOP", "(", "String", "version", ",", "boolean", "forceLocalData", ")", "{", "if", "(", "version", "==", "null", ")", "{", "version", "=", "defaultVersion", ";", "}", "ScopDatabase", "scop", "=", "versionedScopDBs", ".",...
Gets an instance of the specified scop version. <p> The particular implementation returned is influenced by the <tt>forceLocalData</tt> parameter. When false, the instance returned will generally be a {@link RemoteScopInstallation}, although this may be influenced by previous calls to this class. When true, the result is guaranteed to implement {@link LocalScopDatabase} (generally a {@link BerkeleyScopInstallation}). <p> Note that @param version A version number, such as {@link #VERSION_1_75A} @param forceLocalData Whether to use a local installation or a remote installation @return an
[ "Gets", "an", "instance", "of", "the", "specified", "scop", "version", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/scop/ScopFactory.java#L136-L161
31,484
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/scop/ScopFactory.java
ScopFactory.setScopDatabase
public static void setScopDatabase(String version, boolean forceLocalData) { logger.debug("ScopFactory: Setting ScopDatabase to version: {}, forced local: {}", version, forceLocalData); getSCOP(version,forceLocalData); defaultVersion = version; }
java
public static void setScopDatabase(String version, boolean forceLocalData) { logger.debug("ScopFactory: Setting ScopDatabase to version: {}, forced local: {}", version, forceLocalData); getSCOP(version,forceLocalData); defaultVersion = version; }
[ "public", "static", "void", "setScopDatabase", "(", "String", "version", ",", "boolean", "forceLocalData", ")", "{", "logger", ".", "debug", "(", "\"ScopFactory: Setting ScopDatabase to version: {}, forced local: {}\"", ",", "version", ",", "forceLocalData", ")", ";", "...
Set the default scop version @param version A version number, such as {@link #VERSION_1_75A} @param forceLocalData Whether to use a local installation or a remote installation
[ "Set", "the", "default", "scop", "version" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/scop/ScopFactory.java#L178-L182
31,485
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/scop/ScopFactory.java
ScopFactory.setScopDatabase
public static void setScopDatabase(ScopDatabase scop){ logger.debug("ScopFactory: Setting ScopDatabase to type: {}", scop.getClass().getName()); defaultVersion = scop.getScopVersion(); versionedScopDBs.put(defaultVersion,scop); }
java
public static void setScopDatabase(ScopDatabase scop){ logger.debug("ScopFactory: Setting ScopDatabase to type: {}", scop.getClass().getName()); defaultVersion = scop.getScopVersion(); versionedScopDBs.put(defaultVersion,scop); }
[ "public", "static", "void", "setScopDatabase", "(", "ScopDatabase", "scop", ")", "{", "logger", ".", "debug", "(", "\"ScopFactory: Setting ScopDatabase to type: {}\"", ",", "scop", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "defaultVersion", ...
Set the default scop version and instance @param scop
[ "Set", "the", "default", "scop", "version", "and", "instance" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/scop/ScopFactory.java#L188-L192
31,486
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/SequenceDisplay.java
SequenceDisplay.setStructure1
public void setStructure1(Structure structure){ this.structure1 = structure; if ( structure != null) { setAtoms(structure1,panel1); label1.setText(structure.getPDBCode()); label1.repaint(); } }
java
public void setStructure1(Structure structure){ this.structure1 = structure; if ( structure != null) { setAtoms(structure1,panel1); label1.setText(structure.getPDBCode()); label1.repaint(); } }
[ "public", "void", "setStructure1", "(", "Structure", "structure", ")", "{", "this", ".", "structure1", "=", "structure", ";", "if", "(", "structure", "!=", "null", ")", "{", "setAtoms", "(", "structure1", ",", "panel1", ")", ";", "label1", ".", "setText", ...
has been called with setting the atoms directly
[ "has", "been", "called", "with", "setting", "the", "atoms", "directly" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/SequenceDisplay.java#L373-L382
31,487
biojava/biojava
biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/SequenceDisplay.java
SequenceDisplay.calcScale
public void calcScale(int zoomFactor){ float s = getScaleForZoom(zoomFactor); scale = s; //logger.info("calc scale zoom:"+zoomFactor+ " s: " + s); panel1.setScale(s); panel2.setScale(s); panel1.repaint(); panel2.repaint(); //return scale; }
java
public void calcScale(int zoomFactor){ float s = getScaleForZoom(zoomFactor); scale = s; //logger.info("calc scale zoom:"+zoomFactor+ " s: " + s); panel1.setScale(s); panel2.setScale(s); panel1.repaint(); panel2.repaint(); //return scale; }
[ "public", "void", "calcScale", "(", "int", "zoomFactor", ")", "{", "float", "s", "=", "getScaleForZoom", "(", "zoomFactor", ")", ";", "scale", "=", "s", ";", "//logger.info(\"calc scale zoom:\"+zoomFactor+ \" s: \" + s);", "panel1", ".", "setScale", "(", "s", ")",...
a value of 100 means that the whole sequence should be displayed in the current visible window a factor of 1 means that one amino acid shoud be drawn as big as possible @param zoomFactor - a value between 1 and 100
[ "a", "value", "of", "100", "means", "that", "the", "whole", "sequence", "should", "be", "displayed", "in", "the", "current", "visible", "window", "a", "factor", "of", "1", "means", "that", "one", "amino", "acid", "shoud", "be", "drawn", "as", "big", "as"...
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/SequenceDisplay.java#L505-L518
31,488
biojava/biojava
biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java
FastqBuilder.withSequence
public FastqBuilder withSequence(final String sequence) { if (sequence == null) { throw new IllegalArgumentException("sequence must not be null"); } if (this.sequence == null) { this.sequence = new StringBuilder(sequence.length()); } this.sequence.replace(0, this.sequence.length(), sequence); return this; }
java
public FastqBuilder withSequence(final String sequence) { if (sequence == null) { throw new IllegalArgumentException("sequence must not be null"); } if (this.sequence == null) { this.sequence = new StringBuilder(sequence.length()); } this.sequence.replace(0, this.sequence.length(), sequence); return this; }
[ "public", "FastqBuilder", "withSequence", "(", "final", "String", "sequence", ")", "{", "if", "(", "sequence", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"sequence must not be null\"", ")", ";", "}", "if", "(", "this", ".", "seq...
Return this FASTQ formatted sequence builder configured with the specified sequence. @param sequence sequence for this FASTQ formatted sequence builder, must not be null @return this FASTQ formatted sequence builder configured with the specified sequence
[ "Return", "this", "FASTQ", "formatted", "sequence", "builder", "configured", "with", "the", "specified", "sequence", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java#L87-L99
31,489
biojava/biojava
biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java
FastqBuilder.appendSequence
public FastqBuilder appendSequence(final String sequence) { if (sequence == null) { throw new IllegalArgumentException("sequence must not be null"); } if (this.sequence == null) { this.sequence = new StringBuilder(sequence.length()); } this.sequence.append(sequence); return this; }
java
public FastqBuilder appendSequence(final String sequence) { if (sequence == null) { throw new IllegalArgumentException("sequence must not be null"); } if (this.sequence == null) { this.sequence = new StringBuilder(sequence.length()); } this.sequence.append(sequence); return this; }
[ "public", "FastqBuilder", "appendSequence", "(", "final", "String", "sequence", ")", "{", "if", "(", "sequence", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"sequence must not be null\"", ")", ";", "}", "if", "(", "this", ".", "s...
Return this FASTQ formatted sequence builder configured with the specified sequence appended to its current sequence. @param sequence sequence to append to the sequence for this FASTQ formatted sequence builder, must not be null @return this FASTQ formatted sequence builder configured with the specified sequence appended to its current sequence
[ "Return", "this", "FASTQ", "formatted", "sequence", "builder", "configured", "with", "the", "specified", "sequence", "appended", "to", "its", "current", "sequence", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java#L109-L121
31,490
biojava/biojava
biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java
FastqBuilder.withQuality
public FastqBuilder withQuality(final String quality) { if (quality == null) { throw new IllegalArgumentException("quality must not be null"); } if (this.quality == null) { this.quality = new StringBuilder(quality.length()); } this.quality.replace(0, this.quality.length(), quality); return this; }
java
public FastqBuilder withQuality(final String quality) { if (quality == null) { throw new IllegalArgumentException("quality must not be null"); } if (this.quality == null) { this.quality = new StringBuilder(quality.length()); } this.quality.replace(0, this.quality.length(), quality); return this; }
[ "public", "FastqBuilder", "withQuality", "(", "final", "String", "quality", ")", "{", "if", "(", "quality", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"quality must not be null\"", ")", ";", "}", "if", "(", "this", ".", "quality...
Return this FASTQ formatted sequence builder configured with the specified quality scores. @param quality quality scores for this FASTQ formatted sequence builder, must not be null @return this FASTQ formatted sequence builder configured with the specified quality scores
[ "Return", "this", "FASTQ", "formatted", "sequence", "builder", "configured", "with", "the", "specified", "quality", "scores", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java#L129-L141
31,491
biojava/biojava
biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java
FastqBuilder.appendQuality
public FastqBuilder appendQuality(final String quality) { if (quality == null) { throw new IllegalArgumentException("quality must not be null"); } if (this.quality == null) { this.quality = new StringBuilder(quality.length()); } this.quality.append(quality); return this; }
java
public FastqBuilder appendQuality(final String quality) { if (quality == null) { throw new IllegalArgumentException("quality must not be null"); } if (this.quality == null) { this.quality = new StringBuilder(quality.length()); } this.quality.append(quality); return this; }
[ "public", "FastqBuilder", "appendQuality", "(", "final", "String", "quality", ")", "{", "if", "(", "quality", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"quality must not be null\"", ")", ";", "}", "if", "(", "this", ".", "quali...
Return this FASTQ formatted sequence builder configured with the specified quality scores appended to its current quality scores. @param quality quality scores to append to the quality scores for this FASTQ formatted sequence builder, must not be null @return this FASTQ formatted sequence builder configured with the specified quality scores appended to its current quality scores
[ "Return", "this", "FASTQ", "formatted", "sequence", "builder", "configured", "with", "the", "specified", "quality", "scores", "appended", "to", "its", "current", "quality", "scores", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java#L152-L164
31,492
biojava/biojava
biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java
FastqBuilder.sequenceAndQualityLengthsMatch
public boolean sequenceAndQualityLengthsMatch() { if (sequence == null && quality == null) { return true; } if ((sequence != null && quality == null) || (sequence == null && quality != null)) { return false; } return sequence.length() == quality.length(); }
java
public boolean sequenceAndQualityLengthsMatch() { if (sequence == null && quality == null) { return true; } if ((sequence != null && quality == null) || (sequence == null && quality != null)) { return false; } return sequence.length() == quality.length(); }
[ "public", "boolean", "sequenceAndQualityLengthsMatch", "(", ")", "{", "if", "(", "sequence", "==", "null", "&&", "quality", "==", "null", ")", "{", "return", "true", ";", "}", "if", "(", "(", "sequence", "!=", "null", "&&", "quality", "==", "null", ")", ...
Return true if the sequence and quality scores for this FASTQ formatted sequence builder are equal in length. @return true if the sequence and quality scores for this FASTQ formatted sequence builder are equal in length
[ "Return", "true", "if", "the", "sequence", "and", "quality", "scores", "for", "this", "FASTQ", "formatted", "sequence", "builder", "are", "equal", "in", "length", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java#L171-L182
31,493
biojava/biojava
biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java
FastqBuilder.build
public Fastq build() { if (description == null) { throw new IllegalStateException("description must not be null"); } if (sequence == null) { throw new IllegalStateException("sequence must not be null"); } if (quality == null) { throw new IllegalStateException("quality must not be null"); } if (!sequenceAndQualityLengthsMatch()) { throw new IllegalStateException("sequence and quality scores must be the same length"); } Fastq fastq = new Fastq(description, sequence.toString(), quality.toString(), variant); return fastq; }
java
public Fastq build() { if (description == null) { throw new IllegalStateException("description must not be null"); } if (sequence == null) { throw new IllegalStateException("sequence must not be null"); } if (quality == null) { throw new IllegalStateException("quality must not be null"); } if (!sequenceAndQualityLengthsMatch()) { throw new IllegalStateException("sequence and quality scores must be the same length"); } Fastq fastq = new Fastq(description, sequence.toString(), quality.toString(), variant); return fastq; }
[ "public", "Fastq", "build", "(", ")", "{", "if", "(", "description", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"description must not be null\"", ")", ";", "}", "if", "(", "sequence", "==", "null", ")", "{", "throw", "new", "Il...
Build and return a new FASTQ formatted sequence configured from the properties of this builder. @return a new FASTQ formatted sequence configured from the properties of this builder @throws IllegalStateException if the configuration of this builder results in an illegal state
[ "Build", "and", "return", "a", "new", "FASTQ", "formatted", "sequence", "configured", "from", "the", "properties", "of", "this", "builder", "." ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-genome/src/main/java/org/biojava/nbio/genome/io/fastq/FastqBuilder.java#L206-L226
31,494
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/FCAlignHelper.java
FCAlignHelper.doAlign
private void doAlign(){ int i, j; double s, e, c, d, wa; double[] CC = new double[N+1]; //note N + 1 double[] DD = new double[N+1]; double maxs = -100; char trace_e, trace_d; //forward-phase CC[0] = 0; for(j = 1; j <= N; j ++) { CC[j] = 0; DD[j] = -g; } //local-alignment, no terminal penalty for(i = 1; i <= M; i ++) { CC[0] = c = s = 0; e = -g; for(j = 1; j <= N; j ++) { trace_e = 'e'; if ((c = c - m) > (e = e - h)) { e = c; trace_e = 'E'; }//insertion trace_d = 'd'; if ((c = CC[j] - m) > (d = DD[j] - h)) { d = c; trace_d = 'D'; }//deletion //ie CC[j]==CC[i-1][j] DD[j]==DD[i-1][j] wa = sij[i - 1][j - 1]; //note i - 1, j - 1 c = s + wa; //s==CC[i-1][j-1] trace[i][j] = 's'; if (e > c) { c = e; trace[i][j] = trace_e; } if (d > c) { c = d; trace[i][j] = trace_d; } etrace[i][j] = trace_e; dtrace[i][j] = trace_d; s = CC[j]; //important for next replace CC[j] = c; //CC[i][j] DD[j] = d; //DD[i][j] if(c < 0) { CC[j] = 0; DD[j] = -g; c = 0; e = -g; trace[i][j] = '0'; } //local-N if(c > maxs) { E1 = i; E2 = j; maxs = c; } //local-C } } alignScore = maxs; //printf("alignment score %f\n", alignScore); //trace-back if(trace[E1][E2] != 's') { throw new RuntimeException("FCAlignHelper encoutered Exception: Not ending with substitution"); } //Trace(maxs, E1, E2); trace('s', E1, E2); //printf("B1 %d B2 %d, E1 %d E2 %d\n", B1, B2, E1, E2); //check-alignment checkAlign(); }
java
private void doAlign(){ int i, j; double s, e, c, d, wa; double[] CC = new double[N+1]; //note N + 1 double[] DD = new double[N+1]; double maxs = -100; char trace_e, trace_d; //forward-phase CC[0] = 0; for(j = 1; j <= N; j ++) { CC[j] = 0; DD[j] = -g; } //local-alignment, no terminal penalty for(i = 1; i <= M; i ++) { CC[0] = c = s = 0; e = -g; for(j = 1; j <= N; j ++) { trace_e = 'e'; if ((c = c - m) > (e = e - h)) { e = c; trace_e = 'E'; }//insertion trace_d = 'd'; if ((c = CC[j] - m) > (d = DD[j] - h)) { d = c; trace_d = 'D'; }//deletion //ie CC[j]==CC[i-1][j] DD[j]==DD[i-1][j] wa = sij[i - 1][j - 1]; //note i - 1, j - 1 c = s + wa; //s==CC[i-1][j-1] trace[i][j] = 's'; if (e > c) { c = e; trace[i][j] = trace_e; } if (d > c) { c = d; trace[i][j] = trace_d; } etrace[i][j] = trace_e; dtrace[i][j] = trace_d; s = CC[j]; //important for next replace CC[j] = c; //CC[i][j] DD[j] = d; //DD[i][j] if(c < 0) { CC[j] = 0; DD[j] = -g; c = 0; e = -g; trace[i][j] = '0'; } //local-N if(c > maxs) { E1 = i; E2 = j; maxs = c; } //local-C } } alignScore = maxs; //printf("alignment score %f\n", alignScore); //trace-back if(trace[E1][E2] != 's') { throw new RuntimeException("FCAlignHelper encoutered Exception: Not ending with substitution"); } //Trace(maxs, E1, E2); trace('s', E1, E2); //printf("B1 %d B2 %d, E1 %d E2 %d\n", B1, B2, E1, E2); //check-alignment checkAlign(); }
[ "private", "void", "doAlign", "(", ")", "{", "int", "i", ",", "j", ";", "double", "s", ",", "e", ",", "c", ",", "d", ",", "wa", ";", "double", "[", "]", "CC", "=", "new", "double", "[", "N", "+", "1", "]", ";", "//note N + 1", "double", "[", ...
local-model
[ "local", "-", "model" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/FCAlignHelper.java#L108-L184
31,495
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/FCAlignHelper.java
FCAlignHelper.trace
private void trace(char mod, int i, int j) { if(mod == '0' || i <= 0 || j <= 0) { B1 = i + 1; B2 = j + 1; } if(mod == 's') { trace(trace[i - 1][j - 1], i - 1, j - 1); rep(); } else if(mod == 'D') { trace(trace[i - 1][j], i - 1, j); del(1); } else if(mod == 'd') { trace(dtrace[i - 1][j], i - 1, j); del(1); } else if(mod == 'E') { trace(trace[i][j - 1], i, j - 1); ins(1); } else if(mod == 'e') { trace(etrace[i][j - 1], i, j - 1); ins(1); } }
java
private void trace(char mod, int i, int j) { if(mod == '0' || i <= 0 || j <= 0) { B1 = i + 1; B2 = j + 1; } if(mod == 's') { trace(trace[i - 1][j - 1], i - 1, j - 1); rep(); } else if(mod == 'D') { trace(trace[i - 1][j], i - 1, j); del(1); } else if(mod == 'd') { trace(dtrace[i - 1][j], i - 1, j); del(1); } else if(mod == 'E') { trace(trace[i][j - 1], i, j - 1); ins(1); } else if(mod == 'e') { trace(etrace[i][j - 1], i, j - 1); ins(1); } }
[ "private", "void", "trace", "(", "char", "mod", ",", "int", "i", ",", "int", "j", ")", "{", "if", "(", "mod", "==", "'", "'", "||", "i", "<=", "0", "||", "j", "<=", "0", ")", "{", "B1", "=", "i", "+", "1", ";", "B2", "=", "j", "+", "1",...
trace-back, recorded in sapp, wrong method!
[ "trace", "-", "back", "recorded", "in", "sapp", "wrong", "method!" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/FCAlignHelper.java#L191-L217
31,496
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/FCAlignHelper.java
FCAlignHelper.checkScore
private double checkScore() { int i, j, op, s; double sco; sco = 0; op = 0; s = 0; i = B1; j = B2; while (i <= E1 && j <= E2) { op = sapp0[s ++]; if (op == 0) { sco += sij[i - 1][j - 1]; //if (debug) //System.err.println(String.format("%d-%d %f\n", i - 1, j - 1, sij[i - 1][j - 1])); i ++; j ++; } else if (op > 0) { sco -= g+op*h; j = j+op; } else { sco -= g-op*h; i = i-op; } } return(sco); }
java
private double checkScore() { int i, j, op, s; double sco; sco = 0; op = 0; s = 0; i = B1; j = B2; while (i <= E1 && j <= E2) { op = sapp0[s ++]; if (op == 0) { sco += sij[i - 1][j - 1]; //if (debug) //System.err.println(String.format("%d-%d %f\n", i - 1, j - 1, sij[i - 1][j - 1])); i ++; j ++; } else if (op > 0) { sco -= g+op*h; j = j+op; } else { sco -= g-op*h; i = i-op; } } return(sco); }
[ "private", "double", "checkScore", "(", ")", "{", "int", "i", ",", "j", ",", "op", ",", "s", ";", "double", "sco", ";", "sco", "=", "0", ";", "op", "=", "0", ";", "s", "=", "0", ";", "i", "=", "B1", ";", "j", "=", "B2", ";", "while", "(",...
checkscore - return the score of the alignment stored in sapp
[ "checkscore", "-", "return", "the", "score", "of", "the", "alignment", "stored", "in", "sapp" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/align/fatcat/calc/FCAlignHelper.java#L266-L296
31,497
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/StructureIO.java
StructureIO.guessFiletype
public static StructureFiletype guessFiletype(String filename) { String lower = filename.toLowerCase(); for(StructureFiletype type : StructureFiletype.values()) { for(String ext : type.getExtensions()) { if(lower.endsWith(ext.toLowerCase())) { return type; } } } return StructureFiletype.UNKNOWN; }
java
public static StructureFiletype guessFiletype(String filename) { String lower = filename.toLowerCase(); for(StructureFiletype type : StructureFiletype.values()) { for(String ext : type.getExtensions()) { if(lower.endsWith(ext.toLowerCase())) { return type; } } } return StructureFiletype.UNKNOWN; }
[ "public", "static", "StructureFiletype", "guessFiletype", "(", "String", "filename", ")", "{", "String", "lower", "=", "filename", ".", "toLowerCase", "(", ")", ";", "for", "(", "StructureFiletype", "type", ":", "StructureFiletype", ".", "values", "(", ")", ")...
Attempts to guess the type of a structure file based on the extension @param filename @return
[ "Attempts", "to", "guess", "the", "type", "of", "a", "structure", "file", "based", "on", "the", "extension" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/StructureIO.java#L309-L319
31,498
biojava/biojava
biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/embl/EmblReference.java
EmblReference.copyEmblReference
public EmblReference copyEmblReference(EmblReference emblReference) { EmblReference copy = new EmblReference(); copy.setReferenceAuthor(emblReference.getReferenceAuthor()); copy.setReferenceComment(emblReference.getReferenceComment()); copy.setReferenceCrossReference(emblReference.getReferenceCrossReference()); copy.setReferenceGroup(emblReference.getReferenceGroup()); copy.setReferenceLocation(emblReference.getReferenceLocation()); copy.setReferenceNumber(emblReference.getReferenceNumber()); copy.setReferencePosition(emblReference.getReferencePosition()); copy.setReferenceTitle(emblReference.getReferenceTitle()); return copy; }
java
public EmblReference copyEmblReference(EmblReference emblReference) { EmblReference copy = new EmblReference(); copy.setReferenceAuthor(emblReference.getReferenceAuthor()); copy.setReferenceComment(emblReference.getReferenceComment()); copy.setReferenceCrossReference(emblReference.getReferenceCrossReference()); copy.setReferenceGroup(emblReference.getReferenceGroup()); copy.setReferenceLocation(emblReference.getReferenceLocation()); copy.setReferenceNumber(emblReference.getReferenceNumber()); copy.setReferencePosition(emblReference.getReferencePosition()); copy.setReferenceTitle(emblReference.getReferenceTitle()); return copy; }
[ "public", "EmblReference", "copyEmblReference", "(", "EmblReference", "emblReference", ")", "{", "EmblReference", "copy", "=", "new", "EmblReference", "(", ")", ";", "copy", ".", "setReferenceAuthor", "(", "emblReference", ".", "getReferenceAuthor", "(", ")", ")", ...
return copy of EmblReference @param emblReference @return EmblReference
[ "return", "copy", "of", "EmblReference" ]
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/embl/EmblReference.java#L170-L181
31,499
biojava/biojava
biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucState.java
SecStrucState.addBridge
public boolean addBridge(BetaBridge bridge) { if (bridge1 == null) { bridge1 = bridge; return true; } else if (bridge1.equals(bridge)) { return true; } else if (bridge2 == null) { bridge2 = bridge; return true; } else if (bridge2.equals(bridge)) { return true; } else { //no space left, cannot add the bridge logger.info("Residue forms more than 2 beta Bridges, " + "DSSP output might differ in Bridges column."); return false; } }
java
public boolean addBridge(BetaBridge bridge) { if (bridge1 == null) { bridge1 = bridge; return true; } else if (bridge1.equals(bridge)) { return true; } else if (bridge2 == null) { bridge2 = bridge; return true; } else if (bridge2.equals(bridge)) { return true; } else { //no space left, cannot add the bridge logger.info("Residue forms more than 2 beta Bridges, " + "DSSP output might differ in Bridges column."); return false; } }
[ "public", "boolean", "addBridge", "(", "BetaBridge", "bridge", ")", "{", "if", "(", "bridge1", "==", "null", ")", "{", "bridge1", "=", "bridge", ";", "return", "true", ";", "}", "else", "if", "(", "bridge1", ".", "equals", "(", "bridge", ")", ")", "{...
Adds a Bridge to the residue. Each residue can only store two bridges. If the residue contains already two Bridges, the Bridge will not be added and the method returns false. @param bridge @return false if the Bridge was not added, true otherwise
[ "Adds", "a", "Bridge", "to", "the", "residue", ".", "Each", "residue", "can", "only", "store", "two", "bridges", ".", "If", "the", "residue", "contains", "already", "two", "Bridges", "the", "Bridge", "will", "not", "be", "added", "and", "the", "method", ...
a1c71a8e3d40cc32104b1d387a3d3b560b43356e
https://github.com/biojava/biojava/blob/a1c71a8e3d40cc32104b1d387a3d3b560b43356e/biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucState.java#L201-L217