Name resolver of galaxies parsing the output using a python tool
Created: 2011-09-21 18:07:25
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 have to write this string in a file using the local service "Write_text_file" in order to provide with a input file to the python tool. The python tool parse the text and extract the coordinates (ra and dec param) of the galaxy
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (0)
Titles (1)
Name resolver of galaxies parsing the output using a python tool |
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:
target=cig+1
service=NED(nedwww.ipac.caltech.edu)
coordsys=ICRS
ra=0.77358
dec=-1.91381
time(ms)=0
We have to write this string in a file using the local service "Write_text_file" in order to provide with a input file to the python tool. The python tool parse the text and extract the coordinates (ra and dec param) of the galaxy |
Dependencies (0)
Processors (13)
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 |
Tool |
externaltool |
|
Write_Text_File |
localworker |
Script
BufferedWriter out;
if (encoding == void) {
out = new BufferedWriter(new FileWriter(outputFile));
}
else {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), encoding));
}
out.write(filecontents);
out.flush();
out.close();
outputFile = filecontents;
|
encoding_value_1 |
stringconstant |
Valueutf-8 |
outputFile_value |
stringconstant |
Valuefiletmp.txt |
Outputs (2)
Name |
Description |
listRA_DEC |
|
test2 |
|
Datalinks (14)
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 |
Write_Text_File:outputFile |
Tool:filetmp |
encoding_value_1:value |
Write_Text_File:encoding |
REST_Service:responseBody |
Write_Text_File:filecontents |
outputFile_value:value |
Write_Text_File:outputFile |
Tool:STDOUT |
listRA_DEC |
REST_Service:responseBody |
test2 |
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 (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment