Name resolver of galaxies parsing the output using local services
Created: 2011-09-21 17:59:49
Last updated: 2011-09-21 18:03:58
This workflow ask for text file using "Select_file" local services. This file is read by the "read_text_file", using "utf-8" as encoding. The result of "read_text_file" is splitted in lines by "split_string_into_string_list_by_regular_expression" and each of this lines is the input for the Rest_servise. The REST service search for each line (each line contains one name of one galaxy) some information about that galaxy. The string is like:
target=cig+1
service=NED(nedwww.ipac.caltech.edu)
coordsys=ICRS
ra=0.77358
dec=-1.91381
time(ms)=0
We convert this string into list of string using "split_string_into_string_list_by_regular_expression"
We need extract the coordinates of the galaxy: the RA and DEC parameters, so we have to use two times the local services "filter_list_of_string_extracting_match_to_a_regex". One of them with the regex= "ra=(.*)" and the other one with the regex="dec=(.*)". The result of this both filters is a list of list, so we have to use "merge_string_list_to_a_string" to get a list.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
|  |
Titles (1)
|  |
Name resolver of galaxies parsing the output using local services |
Descriptions (1)
|  |
This workflow ask for text file using "Select_file" local services. This file is read by the "read_text_file", using "utf-8" as encoding. The result of "read_text_file" is splitted in lines by "split_string_into_string_list_by_regular_expression" and each of this lines is the input for the Rest_servise. The REST service search for each line (each line contains one name of one galaxy) some information about that galaxy. The string is like:
We convert this string into list of string using "split_string_into_string_list_by_regular_expression"
We need extract the coordinates of the galaxy: the RA and DEC parameters, so we have to use two times the local services "filter_list_of_string_extracting_match_to_a_regex". One of them with the regex= "ra=(.*)" and the other one with the regex="dec=(.*)". The result of this both filters is a list of list, so we have to use "merge_string_list_to_a_string" to get a list.
|
Dependencies (0)
|  |
Inputs (0)
|  |
Processors (19)
|  |
Name |
Type |
Description |
Read_Text_File |
localworker |
ScriptBufferedReader getReader (String fileUrl, String encoding) throws IOException {
InputStreamReader reader;
try {
if (encoding == null) {
reader = new FileReader(fileUrl);
} else {
reader = new InputStreamReader(new FileInputStream(fileUrl),encoding);
}
}
catch (FileNotFoundException e) {
// try a real URL instead
URL url = new URL(fileUrl);
if (encoding == null) {
reader = new InputStreamReader (url.openStream());
} else {
reader = new InputStreamReader (url.openStream(), encoding);
}
}
return new BufferedReader(reader);
}
StringBuffer sb = new StringBuffer(4000);
if (encoding == void) {
encoding = null;
}
BufferedReader in = getReader(fileurl, encoding);
String str;
String lineEnding = System.getProperty("line.separator");
while ((str = in.readLine()) != null) {
sb.append(str);
sb.append(lineEnding);
}
in.close();
filecontents = sb.toString();
|
encoding_value |
stringconstant |
Valueutf-8 |
Select_File |
localworker |
Scriptimport java.awt.CardLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.filechooser.FileFilter;
class FileExtFilter extends FileFilter {
public FileExtFilter(String ext, String label, boolean includeDir) {
this.ext = ext;
this.label = label;
this.includeDir = includeDir;
}
public String getDescription() {
return this.label;
}
public boolean accept(File file) {
if (file.isDirectory() && includeDir) {
return true;
} else {
return file.getName().endsWith(this.ext);
}
}
String ext, label;
boolean includeDir;
}
if (title == void) {
title = null;
}
if ((fileExtensions == void) || (fileExtensions == null)) {
fileExtensions = "";
}
if ((fileExtLabels == void) || (fileExtLabels == null)) {
fileExtLabels = "";
}
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle(title);
String[] fileTypeList = fileExtensions.split(",");
String[] filterLabelList = fileExtLabels.split(",");
if (fileTypeList != null && filterLabelList != null && fileTypeList.length != filterLabelList.length) {
throw new RuntimeException("The list of extensions and file filter labels must be the same length");
}
// create the file filters
for (int i = 0; i < fileTypeList.length; i++) {
FileExtFilter filter = new FileExtFilter(fileTypeList[i], filterLabelList[i], true);
chooser.setFileFilter(filter);
}
chooser.showOpenDialog(null);
File file = chooser.getSelectedFile();
selectedFile = file.getAbsolutePath();
|
fileExtensions_value |
stringconstant |
Valuetxt |
fileExtLabels_value |
stringconstant |
ValueTXT |
title_value |
stringconstant |
ValueChoose a file |
REST_Service |
rest |
|
Split_string_into_string_list_by_regular_expression |
localworker |
ScriptList split = new ArrayList();
if (!string.equals("")) {
String regexString = ",";
if (regex != void) {
regexString = regex;
}
String[] result = string.split(regexString);
for (int i = 0; i < result.length; i++) {
split.add(result[i]);
}
}
|
regex_value |
stringconstant |
Value\n |
Split_string_into_string_list_by_regular_expression_2 |
localworker |
ScriptList split = new ArrayList();
if (!string.equals("")) {
String regexString = ",";
if (regex != void) {
regexString = regex;
}
String[] result = string.split(regexString);
for (int i = 0; i < result.length; i++) {
split.add(result[i]);
}
}
|
Filter_list_of_strings_extracting_match_to_a_regex |
localworker |
Scriptimport java.util.regex.*;
filteredlist = new ArrayList();
Pattern thePat = Pattern.compile(regex);
int theGroup = Integer.parseInt(group);
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
Matcher matcher = thePat.matcher(item);
if (matcher.find()) {
filteredlist.add(matcher.group(theGroup));
}
}
|
group_value |
stringconstant |
Value1 |
regex_value_1 |
stringconstant |
Valuera=(.*) |
Filter_list_of_strings_extracting_match_to_a_regex_2 |
localworker |
Scriptimport java.util.regex.*;
filteredlist = new ArrayList();
Pattern thePat = Pattern.compile(regex);
int theGroup = Integer.parseInt(group);
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
Matcher matcher = thePat.matcher(item);
if (matcher.find()) {
filteredlist.add(matcher.group(theGroup));
}
}
|
regex_value_2 |
stringconstant |
Valuedec=(.*) |
group_value_1 |
stringconstant |
Value1 |
Merge_String_List_to_a_String |
localworker |
ScriptString seperatorString = "\n";
if (seperator != void) {
seperatorString = seperator;
}
StringBuffer sb = new StringBuffer();
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
sb.append(item);
if (i.hasNext()) {
sb.append(seperatorString);
}
}
concatenated = sb.toString();
|
seperator_value |
stringconstant |
Value |
Merge_String_List_to_a_String_2 |
localworker |
ScriptString seperatorString = "\n";
if (seperator != void) {
seperatorString = seperator;
}
StringBuffer sb = new StringBuffer();
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
sb.append(item);
if (i.hasNext()) {
sb.append(seperatorString);
}
}
concatenated = sb.toString();
|
Beanshells (0)
|  |
Outputs (3)
|  |
Name |
Description |
test |
|
DEC |
|
RA |
|
Datalinks (23)
|  |
Source |
Sink |
encoding_value:value |
Read_Text_File:encoding |
Select_File:selectedFile |
Read_Text_File:fileurl |
fileExtensions_value:value |
Select_File:fileExtensions |
fileExtLabels_value:value |
Select_File:fileExtLabels |
title_value:value |
Select_File:title |
Split_string_into_string_list_by_regular_expression:split |
REST_Service:object_name |
Read_Text_File:filecontents |
Split_string_into_string_list_by_regular_expression:string |
regex_value:value |
Split_string_into_string_list_by_regular_expression:regex |
REST_Service:responseBody |
Split_string_into_string_list_by_regular_expression_2:string |
regex_value:value |
Split_string_into_string_list_by_regular_expression_2:regex |
Split_string_into_string_list_by_regular_expression_2:split |
Filter_list_of_strings_extracting_match_to_a_regex:stringlist |
group_value:value |
Filter_list_of_strings_extracting_match_to_a_regex:group |
regex_value_1:value |
Filter_list_of_strings_extracting_match_to_a_regex:regex |
Split_string_into_string_list_by_regular_expression_2:split |
Filter_list_of_strings_extracting_match_to_a_regex_2:stringlist |
regex_value_2:value |
Filter_list_of_strings_extracting_match_to_a_regex_2:regex |
group_value_1:value |
Filter_list_of_strings_extracting_match_to_a_regex_2:group |
Filter_list_of_strings_extracting_match_to_a_regex:filteredlist |
Merge_String_List_to_a_String:stringlist |
seperator_value:value |
Merge_String_List_to_a_String:seperator |
Filter_list_of_strings_extracting_match_to_a_regex_2:filteredlist |
Merge_String_List_to_a_String_2:stringlist |
seperator_value:value |
Merge_String_List_to_a_String_2:seperator |
REST_Service:responseBody |
test |
Merge_String_List_to_a_String_2:concatenated |
DEC |
Merge_String_List_to_a_String:concatenated |
RA |
Coordinations (0)
|  |
Uploader
License
All versions of this Workflow are
licensed under:
BSD License
Version 1
(of 1)
Credits (0)
(People/Groups)
None
Attributions (0)
(Workflows/Files)
None
Shared with Groups (0)
None
Featured In Packs (1)
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Citations (0)Version History
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
No comments yet
Log in to make a comment