How to retrieve superclass (subClassOf) identifiers (not labels) from OBO ontology using ROBOT? - ontology

I am currently running the ROBOT snippet
robot export --input data/cl.owl \
--header "ID|LABEL|IAO_0000115|hasDbXref|subClassOf" \
--export results/cl.csv
To retrieve entries from the Cell Ontology. Currently it retrieves something like:
CL:0000036,epithelial fate stem cell,,,single fate stem cell
Where "single fate stem cell" is the parent. Is there any way to retrieve the CL identifier instead of the label?

See the documentation on rendering cell values in the ROBOT documentation:
http://robot.obolibrary.org/export.html#rendering-cell-values
Specifically, you can affix [ID] onto the column descriptor, i.e. SubClass Of [ID]
So the command would look like this:
robot export --input data/cl.owl \
--header "ID|LABEL|IAO_0000115|hasDbXref|subClassOf [ID]" \
--export results/cl.csv
Which will give the desired result.

Related

Google Ads Get Campaign ads spends based on date and all states of USA

I have many campaigns and I want to summarize the spends by all the states (USA states) and based on from and to dates.
I went through the https://developers.google.com/google-ads/api/docs/reporting/overview but I dont see any point that can determine the spends based on states.
Which endpoint I need to use in Google Ads API: In the FB I am using https://graph.facebook.com/v13.0/act_2264578877108750/insights?access_token=<ACCESS_TOKEN>&fields=spend&breakdowns=region%2Ccountry&level=ad&time_range=%7B%27since%27%3A%272022-05-15%27%2C%27until%27%3A%272022-05-15%27%7D&limit=100&after=OTkZD
Any help is really appreciated.
Reporting in the Ads API works by defining a query in GAQL that describes the data you want to obtain. For your use case, a possible query would look something like this:
SELECT
campaign.name,
segments.geo_target_state,
metrics.cost_micros
FROM geographic_view
WHERE
geographic_view.location_type = LOCATION_OF_PRESENCE
AND segments.date BETWEEN 20220101 AND 20220430
This will return rows for every combination of campaign name and state with the respective spend, while the WHERE clause makes sure that the use actually was in that state when the click happened—as opposed to somebody being interested in it.
Note that segments.geo_target_state will be returned as an ID, you can find the reference data here. Additionally, metrics.cost_micros will be returned in millionth of the base currency of the accounts, i.e. you'll need to multiply the value by 1'000'000.
About which endpoint to use: REST isn't recommended by Google (you should rather be using gRPC via a client library), but this here should work:
curl "https://googleads.googleapis.com/v10/customers/${CUSTOMER_ID}/googleAds:searchStream" \
--header "Content-Type: application/json" \
--header "developer-token: ${DEVELOPER_TOKEN}" \
--header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
--header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
--data '{
"query": "
SELECT
campaign.name,
segments.geo_target_state,
metrics.cost_micros
FROM geographic_view
WHERE
geographic_view.location_type = LOCATION_OF_PRESENCE
AND segments.date BETWEEN 20220101 AND 20220430
"
}'

Is there a way to set Parameters in Cypher?

I have a LOAD_CSV cypher script that creates and sets properties for nodes and edges.
I want to add a parameter at run time (i.e. when I do cat mycypher.cql | cypher-shell -u xxxx -p xxx) so that a key property gets set on nodes -- like so:
LOAD CSV WITH HEADERS FROM $MY_CSV AS row
MERGE (a:abcLabel {abcId: toInteger(row.abc_id), extraProp: $EXTRA_PROPERTY})
ON CREATE SET
abc.name = row.abc_name
MERGE (b:bcdLabel {bcdId: toInteger(row.bcd_id), extraProp: $EXTRA_PROPERTY})
ON CREATE SET
etc ....
Now, know that I can't use shell-like params, but is there a way to set $EXTRA_PROPERTY and $MY_FILE so that I can rerun the cql against a separate data set and ensure that a subsequent MATCH (:abcProperty {extraLabel: "xyz"}) will return nodes that were given the "xyz" property?
In principle this would be completely automated and templated so I will never do a manual load.
TIA
Upcoming version 1.2 of cypher-shell will support the command line option --param, which would allow you to specify Cypher parameters.
Here is the merged pull request.

How to limit Jenkins API response to last n build IDs

http://xxx/api/xml?&tree=builds[number,description,result,id,actions[parameters[name,value]]]
Above API returns all the build IDs. Is there a way to limit results to get last 5 build IDS?
The tree query parameter allows you to explicitly specify and retrieve only the information you are looking for, by using an XPath-ish path expression. The value should be a list of property names to include, with sub-properties inside square braces. Try tree=jobs[name],views[name,jobs[name]] to see just a list of jobs (only giving the name) and views (giving the name and jobs they contain). Note: for array-type properties (such as jobs in this example), the name must be given in the original plural, not in the singular as the element would appear in XML (). This will be more natural for e.g. json?tree=jobs[name] anyway: the JSON writer does not do plural-to-singular mangling because arrays are represented explicitly.
For array-type properties, a range specifier is supported. For example, tree=jobs[name]{0,10} would retrieve the name of the first 10 jobs. The range specifier has the following variants:
{M,N}: From the M-th element (inclusive) to the N-th element (exclusive).
{M,}: From the M-th element (inclusive) to the end.
{,N}: From the first element (inclusive) to the N-th element (exclusive). The same as {0,N}.
{N}: Just retrieve the N-th element. The same as {N,N+1}.
Another way to retrieve more data is to use the depth=N query parameter . This retrieves all the data up to the specified depth. Compare depth=0 and depth=1 and see what the difference is for yourself. Also note that data created by a smaller depth value is always a subset of the data created by a bigger depth value.
Because of the size of the data, the depth parameter should really be only used to explore what data Jenkins can return. Once you identify the data you want to retrieve, you can then come up with the tree parameter to exactly specify the data you need.
I'm on version 1.509.4. which doesn't support range specifier.
Source: http://ci.citizensnpcs.co/api/
You can create an xml object with the build numbers via xpath and parse it yourself with via different means.
http://xxx/api/xml?xpath=//build/number&wrapper=meep
Creates an xml that looks like:
<meep>
<number>n</number>
<number>n+1</number>
...
<number>m</number>
</meep>
And will be populated with the build numbers n through m that are currently in jenkins for the specified job in the url. You can substitute anything for the word "meep", that will become the wrapper object for the newly created xml object.
How are you collecting/manipulating the api xml output once you get it? Because there is a solution here for How do I select the last N elements with XPath?. I tried using some of these xpath manipulations but I couldn't get it to work when playing with the url in my browser; it might work if you are doing something else.
When I get the xml object, I happen to manipulate it via shell scripts.
#!/bin/sh
# NOTE: To get the url to work with curl, you need a valid jenkins user and api token
# Put all build numbers in a variable called build_ids
build_ids="$(curl -sL --user ${_jenkins_api_user}:${_jenkins_api_token} \
"${_jenkins_url}/job/${_job_name}/api/xml?xpath=//build/number&wrapper=meep" \
| sed -e 's/<[^>]*>/ /g' | sed -e 's/ / /g')"
# Print the last 5 items with awk
echo "${build_ids}" | awk '{n = 5; for (--n; n >= 0; n--){ printf "%s\t",$(NF-n)} print ""}';
Once you have your xml object you can essentially parse it however you want.
NOTE: I am running Jenkins ver. 2.46.1
Looking at the doco at the raw .../api/ endpoint (on Jenkins 2.60.3) it says
For array-type properties, a range specifier is supported. For
example, tree=jobs[name]{0,10} would retrieve the name of the first 10
jobs. The range specifier has the following variants:
{M,N}: From the M-th element (inclusive) to the N-th element (exclusive).
{M,}: From the M-th element (inclusive) to the end.
{,N}: From the first element (inclusive) to the N-th element (exclusive). The same as {0,N}.
{N}: Just retrieve the N-th element. The same as {N,N+1}.
For the OP's case, you'd append {,5} to the end of the URL to get the first 5 results:
http://xxx/api/xml?&tree=builds[number,description,result,id,actions[parameters[name,value]]]{,5}

Importing relationships result in error message "Mixing specified and unspecified group belongings in a single import isn't supported

I'm trying to import ~10 million rows to my neo4j database. I'm able to import the nodes with the labels and it takes less than 5 seconds. However, when I'm trying to import the relationships it's failing.
Users.csv header
id,"first_name","last_name","email","phone1","phone2","password",is_locked,"created_at","updated_at"
Roles.csv header
"id","tenure_start","tenure_end"
user_roles.csv header
:START_ID(User),:END_ID(Role)
This is the command I'm using to import:
bin/neo4j-import --into data/databases/graph.db --multiline-fields=true \
--nodes:User import/users.csv \
--nodes:Role import/roles.csv \
--relationships:HAS_ROLE import/user_roles.csv
As Bruno and Tom pointed out. The structure must be
users.csv
id:ID(User-ID),"first_name","last_name","email","phone1","phone2","password",is_locked,"created_at","updated_at"
roles.csv
id:ID(Role-ID),"tenure_start","tenure_end"
user_roles.csv
:START_ID(User-ID),:END_ID(Role-ID)

How to search a pattern like pattern using grep only?

I am searching list of names with pattern "japconfig".There are many files inside one directory. Those files contain names like ixdf_japconfig_FZ.txt,
ixdf_japconfig_AB.txt, ixdf_japconfig_RK.txt, ixdf_japconfig_DK.txt, ixdf_japconfig_LY.txt. But I don't know what are the names present after japconfig word. I need to list down all such names. Also my files contain ixdf_dbconfig.txt, but I don't want to print ixdf_dbconfig.txt in the output.
Each of my file contains one ixdf_japconfig_*.txt and ixdf_dbconfig.txt where * can be FZ,AB,RK,DK,LY. I can achieve my desired result by using grep and then awk to cut the columns.But I don't want to use AWK or other command. I want to achive using grep only.
I need to print below names.
ixdf_japconfig_FZ.txt
ixdf_japconfig_AB.txt
ixdf_japconfig_RK.txt
ixdf_japconfig_DK.txt
ixdf_japconfig_LY.txt
I don't want to print ixdf_dbconfig.txt.
When I tried using "grep -oh "ixdf_japconfig.*.txt" *.dat" command, I am getting below output.
ixdf_japconfig_FZ.txt ixdf_dbconfig.txt
ixdf_japconfig_AB.txt ixdf_dbconfig.txt
ixdf_japconfig_RK.txt ixdf_dbconfig.txt
ixdf_japconfig_DK.txt ixdf_dbconfig.txt
ixdf_japconfig_LY.txt ixdf_dbconfig.txt
where first column is my desired column. But I don't want to print second column. How can I change my code to print only first column?
grep -oh ixdf_japconfig_...txt *.dat
(Your .*. was matching most of the line.)

Resources