Skip to content

Instantly share code, notes, and snippets.

@kouichi-c-nakamura
Last active September 27, 2017 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kouichi-c-nakamura/7fddbe1003fea885310487ccf1048f0f to your computer and use it in GitHub Desktop.
Save kouichi-c-nakamura/7fddbe1003fea885310487ccf1048f0f to your computer and use it in GitHub Desktop.
JSON commas are placed
{
"translatorID": "1ed36c21-de68-4ba4-a27f-d724ce258db4",
"label": "Society for Neuroscience Abstract",
"creator": "Kouchi C. Nakamura",
"target": "^https?://www\\.abstractsonline\\.com/pp8/#!/\\d+/presentation/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gc",
"lastUpdated": "2017-09-27 12:13:11"
}
// ^https?://www\.abstractsonline\.com/pp8/#!/\d+/(presentation|presentations|sessions|participants)/
function detectWeb(doc, url) {
if (url.search(/\/presentation\/\d+/) != -1) {
return 'conferencePaper';
} else if (url.search(/(presentations|session|participant)\/[^\\]+\/\d+/) != -1) {
return 'multiple';
}
}
function doWeb(doc, url) {
if (detectWeb(doc,url) == 'conferencePaper') {
var id = [];
id[0] = url.match(/\d+$/)[0];
var baseurl = url.replace(/\d+$/,"");
scrape(id,baseurl);
} else if (detectWeb(doc,url) == 'multiple') {
//TODO does not work properly becuase the page HTML is dynamically generated and
// ZU.processDocuments() cannot obtain the actual page content from URL.
var items = {};
var bodyTitle = ZU.xpath(doc,'//h4[@class="name"]//span[@class="bodyTitle"]');
for (var i = 0; i < bodyTitle.length; i++) {
var item = new Zotero.Item("conferencePaper");
item.title = bodyTitle[i].innerText.replace(/^\d+\.\d+\.\s/,"");
item.id = ZU.xpath(doc,'//h4[@class="name"]/@data-id')[i].value;
items[item.id] = item.title;
}
Zotero.debug(items);
Zotero.selectItems(items, function(selectedItems){
if(!selectedItems) return true;
var abstractIDs = [];
for (var i in selectedItems) {
abstractIDs.push(i);
//ZU.processDocuments(i, scrape);
}
var baseurl = url.replace(/presentations.+$|sessions.+$|participants.+$/,"presntation/");
Zotero.debug(baseurl);
scrape(abstractIDs,baseurl);
});
}
}
function scrape(ids,baseurl){
Zotero.debug(ids);
for (k = 0; k < ids.length; k++) {
var newurl = baseurl + ids[k];
Zotero.debug(newurl);
ZU.HTTP.processDocuments(newurl, function (doc) {
// NOTE doGet() html does not contain the actual contents,
// object is HTTPreqest object, use processDocuments
//
// Zotero.debug(doc); //object HTMLDocument
// Zotero.debug(doc.URL);
var item = new Zotero.Item("conferencePaper");
// pages, title
var color_primary = ZU.xpath(doc,'//h1[@class="color-primary"]');
//TODO when multiple doc does not contain the contents
// Zotero.debug(color_primary);
//TODO does not work for mulitiple
// var m1 = color_primary[0].innerHTML.match(/^\s*(\d+\.\d+)\n\s*\/\s(\w+\d+)\n\s*\-\s/);
// 282.18/B8, 1, 3.02
var m1 = color_primary[0].innerHTML.match(
/^\s*\n\s*(\d+)(\.(\d+))?\n(\s*\/\s(\w+\d+)\n)?\s*-\s/);
Zotero.debug('Hey');
Zotero.debug(m1);
if (m1 != null ) {
if (m1[3] != undefined) {
if (m1[5] != undefined) {
item.pages = m1[1] + "." + m1[3] + "/" + m1[5];
} else {
item.pages = m1[1] + "." + m1[3];
}
} else {
item.pages = m1[1];
}
item.title = color_primary[0].innerHTML.replace(
/^\s*\n\s*\d+(\.\d+)?\n(\s*\/\s\w+\d+\n)?\s*-\s/,"");
} else {
// SPC01, SOC01, SAT02, PDW01
var m2 = color_primary[0].innerHTML.match(/^[\s\n]*([\w\d]+)\n.+\s*-\s/);
Zotero.debug(m2);
item.pages = m2[1];
var m3 = color_primary[0].innerHTML.match(/\n\s+-\s(.+)\t+<br>\t/);
if (m3 != null) {
item.title = m3[1];
} else {
item.title = "";
}
Zotero.debug(m3[1]); // null
item.title = m3[1];
}
Zotero.debug(item.pages);
Zotero.debug(item.title);
// extra
var well =ZU.xpath(doc,'//div[@class="well well-small"]');
//Zotero.debug(well[0].innerHTML);
var mst = well[0].innerHTML.match(/<dt>Session Type<\/dt>[.\n\s]*<dd>(.+)<\/dd>/);
if (mst == null) {
mst = "";
}
//Zotero.debug(mst);
var session = ZU.xpath(doc,'//h2[@class="session"]/a');
item.extra = "Session: " + session[0].innerText
+ "; " + "Session Type: " + mst[1];
//attachments
//TODO does not work
// item.attachments = [{
// url: doc.URL,
// title: "Print page",
// mimeType: "text/html",
// snapshot: true
//}];
// creators
var creatorbox = ZU.xpath(doc,'//div[@class="span7"]/dl/dd[1]');
var indexsemicolon = creatorbox[0].innerText.search(/;/);
var creatorstr = creatorbox[0].innerText.substr(0,indexsemicolon);
//Zotero.debug(creatorstr);
creatorstr = creatorstr.replace(/\*/g,"");
creatorstr = creatorstr.replace(/\d,(?=\d)/g,"");
creatorstr = creatorstr.replace(/\d,/g,";");
creatorstr = creatorstr.replace(/\d$/,"");
var creatorarr = creatorstr.split(/;/);
//Zotero.debug(creatorarr);
for (var i = 0; i < creatorarr.length; i++) {
var creator = ZU.cleanAuthor(creatorarr[i],"author");
var lastNameBits = creator.lastName.split(/-/);
Zotero.debug(lastNameBits);
for (var j = 0; j< lastNameBits.length ; j++){
lastNameBits[j] = lastNameBits[j].substr(0,1)
+ lastNameBits[j].substr(1).toLowerCase();
}
creator.lastName = lastNameBits.join('-');
item.creators.push(creator);
}
// date
var spandate = ZU.xpath(doc,'//span[@class="session-date"]');
item.date = spandate[0].innerHTML.match(/\w+\s\d+,\s\d+/)[0];
if (ZU.xpath(doc,'//div[@class="span7"]/dl/dd[3]').length != 0) {
item.abstractNote = ZU.xpath(doc,'//div[@class="span7"]/dl/dd[3]')[0].innerHTML;
}
item.publicationTitle = "Society for Neuroscience Abstract";
item.url = doc.URL;
item.conferenceName = "Society for Neuroscience";
item.language = 'eng';
item.complete();
});
}
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://www.abstractsonline.com/pp8/#!/4376/presentation/30154",
"items": [
{
"itemType": "conferencePaper",
"creators": [
{
"firstName": "L.-L.",
"lastName": "Pai",
"creatorType": "author"
},
{
"firstName": "D.",
"lastName": "Vogt",
"creatorType": "author"
},
{
"firstName": "A. C.",
"lastName": "Perez",
"creatorType": "author"
},
{
"firstName": "M.",
"lastName": "Wimer",
"creatorType": "author"
},
{
"firstName": "G.",
"lastName": "Mckinsey",
"creatorType": "author"
},
{
"firstName": "J. S.",
"lastName": "Hu",
"creatorType": "author"
},
{
"firstName": "M.",
"lastName": "Sandberg",
"creatorType": "author"
},
{
"firstName": "R.",
"lastName": "Pla",
"creatorType": "author"
},
{
"firstName": "L. V.",
"lastName": "Goodrich",
"creatorType": "author",
},
{
"firstName": "J. T.",
"lastName": "Paz",
"creatorType": "author"
},
{
"firstName": "J. L.",
"lastName": "Rubenstein",
"creatorType": "author"
}
],
"notes": [],
"tags": [],
"seeAlso": [],
"attachments": [],
"pages": "282.18/B8",
"title": "Mafb and c-Maf control the balanced neurogenesis of MGE-derived PV<sup>+</sup> and SST<sup>+</sup> GABAergic cortical interneurons",
"extra": "Session: Session 282 - Fate Specification and Generation of Neuronal Diversity; Session Type: Poster",
"date": "November 13, 2017",
"abstractNote": "GABAergic cortical interneurons (CINs), primarily generated by medial and caudal ganglionic eminences (MGE &amp; CGE), control circuit excitability by acting as a breaking system in the brain. CIN malfunctions are implicated in neuropsychiatric diseases including autism spectrum disorder, schizophrenia and epilepsy. Understanding CIN generation and maturation are crucial in order to better understand interneuronopathy-related brain diseases.<br>MGE-derived CINs are composed of two broad subgroups: parvalbumin- (PV; late-born) and somatostatin- (SST; early-born) expressing. While MGE interneuron progenitor fate is initially determined by the Nkx2.1 and Lhx6 transcription factors (TFs), factors regulating the control over CIN fate and generation are still being uncovered. Here, we characterized two TFs, Mafb and c-Maf, which are genetically downstream of Nkx2.1, Lhx6 and Dlx, as critical for generating the correct balance of early and late born MGE CIN progenitors.<br>Combined deletion of Mafb and c-Maf from MGE progenitors resulted in ~70% reduction of MGE-derived CINs at P35, with preferential loss of the PV subgroup. Surviving CINs reside in deeper cortical layers and are more likely to be early-born SST interneurons. At embryonic ages, EdU birthdating experiments showed no change of MGE CIN progenitor numbers with deletion of Mafb and c-Maf but an increase of precocious neurogenesis. Notably, we also found a robust increase of SST CINs in the neocortex of these mutants. Together, these results suggest Mafb and c-Maf control the balance of neurogenesis in late progenitors of the MGE, and these early disruptions cause a shift in the balance of PV<sup>+</sup> and SST<sup>+</sup> CINs.",
"publicationTitle": "Society for Neuroscience Abstract",
"url": "http://www.abstractsonline.com/pp8/#!/4376/presentation/30154",
"conferenceName": "Society for Neuroscience",
"language": "eng",
"libraryCatalog": "Society for Neuroscience Abstract",
"accessDate": "CURRENT_TIMESTAMP",
"proceedingsTitle": "Society for Neuroscience Abstract"
}
]
},
{
"type": "web",
"url": "http://www.abstractsonline.com/pp8/#!/4376/presentation/1247",
"items": [
{
"itemType": "conferencePaper",
"creators": [
{
"firstName": "S.",
"lastName": "Mukherjee",
"creatorType": "author"
}
],
"notes": [],
"tags": [],
"seeAlso": [],
"attachments": [],
"pages": "1",
"title": "DIALOGUES BETWEEN NEUROSCIENCE AND SOCIETY",
"extra": "Session: Session 1 - DIALOGUES BETWEEN NEUROSCIENCE AND SOCIETY; Session Type: Lecture",
"date": "November 11, 2017",
"abstractNote": "Mukherjee, a physician and researcher, wrote the Pulitzer Prize-winning book <i>The Emperor of All Maladies: A Biography of Cancer</i>, which explores the disease that has plagued humans for thousands of years. His new book, <i>The Gene: An Intimate History</i>, examines the quest to decipher how human heredity combines with life experiences to control our lives. In this lecture, Dr. Mukherjee will engage in a conversation with SfN President Eric Nestler about the excitement and importance of communicating the promise of scientific inquiry to the public.",
"publicationTitle": "Society for Neuroscience Abstract",
"url": "http://www.abstractsonline.com/pp8/#!/4376/presentation/1247",
"conferenceName": "Society for Neuroscience",
"language": "eng",
"libraryCatalog": "Society for Neuroscience Abstract",
"accessDate": "CURRENT_TIMESTAMP",
"proceedingsTitle": "Society for Neuroscience Abstract"
}
]
}
]
/** END TEST CASES **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment