Ejemplo n.º 1
0
static void domainsPrint(struct section *section, 
	struct sqlConnection *conn, char *geneId)
/* Print out protein domains. */
{
char *db = sqlGetDatabase(conn);
struct slName *el, *list;
list = spExtDbAcc1List(spConn, swissProtAcc, "Interpro");
if (list != NULL)
    {
    char query[256], **row, **row2;
    struct sqlResult *sr, *sr2;
    hPrintf("<B>InterPro Domains: </B> ");
    hPrintf("<A HREF=\"http://www.ebi.ac.uk/interpro/protein/%s\" TARGET=_blank>",
    	swissProtAcc);
    hPrintf("Graphical view of domain structure</A><BR>");
    sqlSafef(query, sizeof(query),
    	"select extAcc1,extAcc2 from extDbRef,extDb"
	" where extDbRef.acc = '%s'"
	" and extDb.val = 'Interpro' and extDb.id = extDbRef.extDb"
	, swissProtAcc);
    sr = sqlGetResult(spConn, query);
    while ((row = sqlNextRow(sr)) != NULL)
        {
	//hPrintf("<A HREF=\"http://www.ebi.ac.uk/interpro/entry/%s\" TARGET=_blank>", row[0]);
	//hPrintf("%s</A> - %s<BR>\n", row[0], row[1]);
        char interPro[256];
        char *pdb = hPdbFromGdb(db);
        safef(interPro, 128, "%s.interProXref", pdb);
        if (hTableExists(db, interPro))
                {
                sqlSafef(query, sizeof(query),
                        "select description from %s where accession = '%s' and interProId = '%s'",
                        interPro, swissProtAcc, row[0]);
                sr2 = sqlGetResult(conn, query);
                if ((row2 = sqlNextRow(sr2)) != NULL)
                    {
                    hPrintf("<A HREF=\"http://www.ebi.ac.uk/interpro/entry/%s\" TARGET=_blank>", row[0]);
                    hPrintf("%s</A> - %s <BR>\n", row[0], row2[0]);
                    }
                sqlFreeResult(&sr2);
                }
            else
                {
                hPrintf("<A HREF=\"http://www.ebi.ac.uk/interpro/entry/%s\" TARGET=_blank>", row[0]);
                hPrintf("%s</A> - %s<BR>\n", row[0], row[1]);
                }
	}
    hPrintf("<BR>\n");
    slFreeList(&list);
    }
if (kgVersion == KG_III)
    {
    /* Do Pfam domains here. */
    list = getPfamDomainList(conn, geneId);
    if (list != NULL)
    	{
    	hPrintf("<B>Pfam Domains:</B><BR>");
    	for (el = list; el != NULL; el = el->next)
	    {
	    char query[256];
	    char *description;
	    sqlSafef(query, sizeof(query), 
	          "select description from pfamDesc where pfamAC='%s'", el->name);
	    description = sqlQuickString(conn, query);
	    if (description == NULL)
	    	description = cloneString("n/a");
	    hPrintf("<A HREF=\"http://pfam.xfam.org/family?acc=%s\" TARGET=_blank>", 
	    	    el->name);
	    hPrintf("%s</A> - %s<BR>\n", el->name, description);
	    freez(&description);
	    }
        slFreeList(&list);
        hPrintf("<BR>\n");
	}
    
    /* Do SCOP domains here */
    list = getDomainList(conn, geneId,  "Scop");
    if (list != NULL)
    	{
    	hPrintf("<B>SCOP Domains:</B><BR>");
    	for (el = list; el != NULL; el = el->next)
	    {
	    char query[256];
	    char *description;
	    sqlSafef(query, sizeof(query), 
	          "select description from scopDesc where acc='%s'", el->name);
	    description = sqlQuickString(conn, query);
	    if (description == NULL)
	    	description = cloneString("n/a");
	    hPrintf("<A HREF=\"http://scop.berkeley.edu/sunid=%s\" TARGET=_blank>", 
	    	    el->name);
	    hPrintf("%s</A> - %s<BR>\n", el->name, description);
	    freez(&description);
	    }
        slFreeList(&list);
        hPrintf("<BR>\n");
	}
    }
else
    {
    list = spExtDbAcc1List(spConn, swissProtAcc, "Pfam");
    if (list != NULL)
    	{
    	char *pfamDescSql = genomeSetting("pfamDescSql");
    	hPrintf("<B>Pfam Domains:</B><BR>");
    	for (el = list; el != NULL; el = el->next)
	    {
	    char query[256];
	    char *description;
	    sqlSafef(query, sizeof(query), pfamDescSql, el->name);
	    description = sqlQuickString(conn, query);
	    if (description == NULL)
	    	description = cloneString("n/a");
	    hPrintf("<A HREF=\"http://pfam.xfam.org/family?acc=%s\" TARGET=_blank>",
	    	        el->name);
	    hPrintf("%s</A> - %s<BR>\n", el->name, description);
	    freez(&description);
	    }
    	slFreeList(&list);
    	hPrintf("<BR>\n");
    	}
    }

list = spExtDbAcc1List(spConn, swissProtAcc, "PDB");
if (list != NULL)
    {
    struct sqlConnection *conn2 = sqlConnect(db);
    char query[256], **row;
    struct sqlResult *sr;
    int column = 0, maxColumn=3, rowCount=0;
    hPrintf("<B>Protein Data Bank (PDB) 3-D Structure</B><BR>");
    sqlSafef(query, sizeof(query),
    	"select extAcc1,extAcc2 from extDbRef,extDb"
	" where extDbRef.acc = '%s'"
	" and extDb.val = 'PDB' and extDb.id = extDbRef.extDb"
	, swissProtAcc);
    sr = sqlGetResult(spConn, query);
    hPrintf("<TABLE><TR>\n");
    while ((row = sqlNextRow(sr)) != NULL)
        {
	if (++column > maxColumn)
	    {
	    hPrintf("</TR><TR>");
	    column = 1;
	    if (rowCount == 0)
	        {
		hPrintf("<TD ALIGN=CENTER COLSPAN=4><I>To conserve bandwidth, only the images from the first %d structures are shown.</I>", maxColumn);
		hPrintf("</TR><TR>");
		}
	    ++rowCount;
	    }
	hPrintf("<TD>");
	hPrintf("<A HREF=\"http://www.rcsb.org/pdb/cgi/explore.cgi?pdbId=%s\" TARGET=_blank>", row[0]);
	if (rowCount < 1)
	    hPrintf("<IMG SRC=\"http://www.rcsb.org/pdb/images/%s_asym_r_250.jpg\"><BR>", row[0]);
        hPrintf("%s</A> - %s ", row[0], row[1]);
        // include links LS-SNP and to launch viewer in PDB chimera
        struct tempName chimerax;
        lsSnpPdbChimeraSnpAnn(conn, row[0], NULL, &chimerax);
        hPrintf(" <A HREF=\"%s\">Chimera</A>", chimerax.forHtml);
        if (lsSnpPdbHasPdb(conn2, row[0]))
            hPrintf(" <A HREF=\"%s\" TARGET=_blank>LS-SNP</A>", lsSnpPdbGetUrlPdbSnp(row[0], NULL));
	hPrintf("</TD>\n");
	}
    hPrintf("</TR></TABLE>\n");
    hPrintf("<A href=\"../goldenPath/help/chimera.html\" TARGET=_blank>Chimera help</A>\n");
    hPrintf("<BR><BR>\n");
    slFreeList(&list);
    sqlDisconnect(&conn2);
    }

/* Do modBase link. */
    {
    hPrintf("<B>ModBase Predicted Comparative 3D Structure on ");
    modBaseAnchor(swissProtAcc);
    hPrintf("%s", swissProtAcc);
    hPrintf("</A></B><BR>\n");

    hPrintf("<TABLE><TR>");
    hPrintf("<TD>");
    modBaseAnchor(swissProtAcc);
    hPrintf("\n<IMG SRC=\"https://modbase.compbio.ucsf.edu/modbase-cgi/image/modbase.jpg?database_id=%s\"></A></TD>", swissProtAcc);
    hPrintf("<TD>");
    modBaseAnchor(swissProtAcc);
    hPrintf("\n<IMG SRC=\"https://modbase.compbio.ucsf.edu/modbase-cgi/image/modbase.jpg?database_id=%s&axis=x&degree=90\"></A></TD>", swissProtAcc);
    hPrintf("<TD>");
    modBaseAnchor(swissProtAcc);
    hPrintf("\n<IMG SRC=\"https://modbase.compbio.ucsf.edu/modbase-cgi/image/modbase.jpg?database_id=%s&axis=y&degree=90\"></A></TD>", swissProtAcc);
    hPrintf("</TR><TR>\n");
    hPrintf("<TD ALIGN=CENTER>Front</TD>");
    hPrintf("<TD ALIGN=CENTER>Top</TD>");
    hPrintf("<TD ALIGN=CENTER>Side</TD>");
    hPrintf("</TR></TABLE>\n");
    hPrintf("<I>The pictures above may be empty if there is no "
            "ModBase structure for the protein.  The ModBase structure "
	    "frequently covers just a fragment of the protein.  You may "
	    "be asked to log onto ModBase the first time you click on the "
	    "pictures. It is simplest after logging in to just click on "
	    "the picture again to get to the specific info on that model.</I>");
    }
}
Ejemplo n.º 2
0
	void GeomData::mappingNodesIds(pMesh theMesh){
		int ndom = getNumDomains();
		const int* domainList = getDomainList();
		std::map<int,int> mapIDtoIndex, mapBdryIDtoIndex, mapIDtoIndex_global;
		std::set<int> setID, setBdryID;
		int i, j, k, id, id0, id1;
		pEntity node, edge, face, tetra;

		i = 0;
		// set a sequential numbering for each vertex ID: from 0 to n-1, where n is the number of vertices
		VIter vit = M_vertexIter(theMesh);
		while ( (node=VIter_next(vit))){
			mapIDtoIndex_global[EN_id(node)] = i++;
		}
		VIter_delete(vit);

		pEntity v1,v2,v3;
		bool extElem = true;// PERFORME ONLY ONCE

		// STEP1: get all vertices ID from domain "dom" and its boundary.
		// All IDs are stored into setID and setBdryID set containers.
		for (k=0; k<ndom; k++){
			int dom = domainList[k];

			if (dim==2){
				FIter fit = M_faceIter(theMesh);
				while ( (face=FIter_next(fit) )){
					int faceflag = getFaceFlag(face);
					if (faceflag==domainList[k]){
						for(i=0; i<3; i++){
							setID.insert( EN_id(face->get(0,i)) );				// nodes domain
						}
						for(i=0; i<3; i++){
							if (getVertexFlag(face->get(0,i))!=faceflag){
								setBdryID.insert(EN_id(face->get(0,i)));		// boundary nodes
							}
						}
					}
				}
				FIter_delete(fit);
			}
			else{
				RIter rit = M_regionIter(theMesh);
				while ( (tetra = RIter_next(rit) )){
					int tetraflag = getTetraFlag(tetra);
					if (tetraflag==domainList[k]){
						for(i=0; i<4; i++){
							setID.insert( EN_id(tetra->get(0,i)) );				// nodes domain
						}
						for(i=0; i<4; i++){
							if (getVertexFlag(tetra->get(0,i))!=tetraflag){
								setBdryID.insert(EN_id(tetra->get(0,i)));		// boundary nodes
							}
						}
					}
				}
				RIter_delete(rit);
			}

			// get external boundary edges/faces only: It's for saturation gradient calculation
			if (extElem){
				i = 0;
				if (dim==2){
					EIter eit = M_edgeIter(theMesh);
					while ( (edge=EIter_next(eit)) ){
						/* ONLY EXTERNAL EDGES */
						if (E_numFaces(edge)==1){
							v1 = edge->get(0,0);
							v2 = edge->get(0,1);
							external_bdry_elem[0].setValue(i,0,mapIDtoIndex_global[EN_id(v1)]);
							external_bdry_elem[0].setValue(i,1,mapIDtoIndex_global[EN_id(v2)]);
							external_bdry_elem[0].setValue(i,2,GEN_tag(v1->getClassification()));
							external_bdry_elem[0].setValue(i,3,GEN_tag(v2->getClassification()));
							i++;
						}
					}
					EIter_delete(eit);
				}
				else{
					FIter fit = M_faceIter(theMesh);
					while ( (face = FIter_next(fit)) ){
						/* ONLY EXTERNAL FACES */
						if ( F_numRegions(face)==1 ){
							v1 = face->get(0,0);
							v2 = face->get(0,1);
							v3 = face->get(0,2);
							external_bdry_elem[0].setValue(i,0,mapIDtoIndex_global[EN_id(v1)]);
							external_bdry_elem[0].setValue(i,1,mapIDtoIndex_global[EN_id(v2)]);
							external_bdry_elem[0].setValue(i,2,mapIDtoIndex_global[EN_id(v3)]);
							external_bdry_elem[0].setValue(i,3,GEN_tag(v1->getClassification()));
							external_bdry_elem[0].setValue(i,4,GEN_tag(v2->getClassification()));
							external_bdry_elem[0].setValue(i,5,GEN_tag(v3->getClassification()));
							i++;
						}
					}
					FIter_delete(fit);
				}
				extElem = false;
			}

			// STEP2: map IDs from step1 like this:
			//		id0 = 0;
			//		id1 = 1;
			//		id2 = 2;
			//		...
			//		idn = n;

			if (setID.size() > this->getNumNodesPerDomain(k)){
				char msg[256]; sprintf(msg,"NUmber of elements collected [%d] is greater than the max [%d]",(int)setID.size(),this->getNumNodesPerDomain(k));
				throw Exception(__LINE__,__FILE__,msg);
			}

			// domain
			i = 0;
			pVertex node;
			for (std::set<int>::iterator iter=setID.begin(); iter!= setID.end(); iter++){
				int id = *iter;			// vertex ID
				mapIDtoIndex[id] = i;	// gives a sequential numbering (0,1,2,...) for all vertices ID for domain k
				ID[k].setValue(i,id);
				node = theMesh->getVertex(id);
				volume[k].setValue(i,getVolume(node,dom) );
				nodes[k].setValue(i,mapIDtoIndex_global[id]);
				i++;
			}
			setID.clear();

			// boundary
			i = 0;
			for (std::set<int>::iterator iter=setBdryID.begin(); iter!= setBdryID.end(); iter++){
				int id = *iter;					// boundary vertex ID
				mapBdryIDtoIndex[id] = i;		// gives a sequential numbering (0,1,2,...) for all boundary vertices ID for domain k
				ID_bdry[k].setValue(i,id);
				node = theMesh->getVertex(id);
				volume_bdry[k].setValue(i,getVolume(node,dom) );
				i++;
			}
			setBdryID.clear();

			// STEP3: use mapped ID to initialize edge struct, where:
			//		edge_id0 = index_mapped
			//		edge_id1 = index_mapped

			// ALL EDGES
			i = 0;
			EIter eit = M_edgeIter(theMesh);
			while ( (edge=EIter_next(eit)) ){
				if ( edgeBelongToDomain(edge,domainList[k]) ){
					v1 = edge->get(0,0);
					v2 = edge->get(0,1);
					id0 = EN_id( v1 );
					id1 = EN_id( v2 );
					edges[k].setValue(i,0,mapIDtoIndex[id0]);					// index number for vertex ID for domain k
					edges[k].setValue(i,1,mapIDtoIndex[id1]); 					// index number for vertex ID for domain k
					edges[k].setValue(i,2,mapIDtoIndex_global[id0]);			// global index number for vertex ID
					edges[k].setValue(i,3,mapIDtoIndex_global[id1]);			// global index number for vertex ID
					edges[k].setValue(i,4,GEN_tag(v1->getClassification()));
					edges[k].setValue(i,5,GEN_tag(v2->getClassification()));
					i++;
				}
			}

			if (!i){
				throw Exception(__LINE__,__FILE__,"Any edge detected!");
			}

			i = 0;
			bool bdryElem_detected = false;
			if (dim==2){
				// BOUNDARY EDGES PER DOMAIN
				eit = M_edgeIter(theMesh);
				while ( (edge=EIter_next(eit)) ){
					if ( edgeBelongToDomain(edge,domainList[k]) ){
						if (belongsToBoundary(edge)){
							bdryElem_detected = true;
							for (j=0;j<2;j++){
								id = EN_id( edge->get(0,j) );
								edges_bdry[k].setValue(i,j,mapBdryIDtoIndex[id]);		// index number for boundary vertex ID for domain k
								edges_bdry[k].setValue(i,j+2,mapIDtoIndex[id]); 		// index number for vertex ID for domain k
								edges_bdry[k].setValue(i,j+4,mapIDtoIndex_global[id]);	// global index number for vertex ID
							}
							i++;
						}
					}
				}
			}
			else{
				// BOUNDARY FACES PER DOMAIN
				FIter fit = M_faceIter(theMesh);
				while ( (face = FIter_next(fit)) ){
					if ( faceBelongToDomain(face,domainList[k]) ){
						if ( belongsToBoundary(face) ){
							bdryElem_detected = true;
							for (j=0;j<3;j++){
								id = EN_id( face->get(0,j) );
								faces_bdry[k].setValue(i,j,mapBdryIDtoIndex[id]);		// index number for boundary vertex ID for domain k
								faces_bdry[k].setValue(i,j+3,mapIDtoIndex[id]);			// index number for vertex ID for domain k
								faces_bdry[k].setValue(i,j+6,mapIDtoIndex_global[id]);	// global index number for vertex ID
							}
							i++;
						}
					}
				}
				FIter_delete(fit);
				if (!bdryElem_detected){
					throw Exception(__LINE__,__FILE__,"Any boundary element detected! You must use Physical command in .geo Gmsh to define them.");
				}
			}
			mapBdryIDtoIndex.clear();
			mapIDtoIndex.clear();
		}
		mapIDtoIndex_global.clear();
	}
Ejemplo n.º 3
0
static std::error_code loadTrigger(ExecState& exec, const JSObject& ruleObject, Trigger& trigger)
{
    VM& vm = exec.vm();
    auto scope = DECLARE_THROW_SCOPE(vm);

    const JSValue triggerObject = ruleObject.get(&exec, Identifier::fromString(&exec, "trigger"));
    if (!triggerObject || scope.exception() || !triggerObject.isObject())
        return ContentExtensionError::JSONInvalidTrigger;
    
    const JSValue urlFilterObject = triggerObject.get(&exec, Identifier::fromString(&exec, "url-filter"));
    if (!urlFilterObject || scope.exception() || !urlFilterObject.isString())
        return ContentExtensionError::JSONInvalidURLFilterInTrigger;

    String urlFilter = urlFilterObject.toWTFString(&exec);
    if (urlFilter.isEmpty())
        return ContentExtensionError::JSONInvalidURLFilterInTrigger;

    trigger.urlFilter = urlFilter;

    const JSValue urlFilterCaseValue = triggerObject.get(&exec, Identifier::fromString(&exec, "url-filter-is-case-sensitive"));
    if (urlFilterCaseValue && !scope.exception() && urlFilterCaseValue.isBoolean())
        trigger.urlFilterIsCaseSensitive = urlFilterCaseValue.toBoolean(&exec);

    const JSValue resourceTypeValue = triggerObject.get(&exec, Identifier::fromString(&exec, "resource-type"));
    if (!scope.exception() && resourceTypeValue.isObject()) {
        auto typeFlagsError = getTypeFlags(exec, resourceTypeValue, trigger.flags, readResourceType);
        if (typeFlagsError)
            return typeFlagsError;
    } else if (!resourceTypeValue.isUndefined())
        return ContentExtensionError::JSONInvalidTriggerFlagsArray;

    const JSValue loadTypeValue = triggerObject.get(&exec, Identifier::fromString(&exec, "load-type"));
    if (!scope.exception() && loadTypeValue.isObject()) {
        auto typeFlagsError = getTypeFlags(exec, loadTypeValue, trigger.flags, readLoadType);
        if (typeFlagsError)
            return typeFlagsError;
    } else if (!loadTypeValue.isUndefined())
        return ContentExtensionError::JSONInvalidTriggerFlagsArray;

    const JSValue ifDomain = triggerObject.get(&exec, Identifier::fromString(&exec, "if-domain"));
    if (!scope.exception() && ifDomain.isObject()) {
        auto ifDomainError = getDomainList(exec, asObject(ifDomain), trigger.domains);
        if (ifDomainError)
            return ifDomainError;
        if (trigger.domains.isEmpty())
            return ContentExtensionError::JSONInvalidDomainList;
        ASSERT(trigger.domainCondition == Trigger::DomainCondition::None);
        trigger.domainCondition = Trigger::DomainCondition::IfDomain;
    } else if (!ifDomain.isUndefined())
        return ContentExtensionError::JSONInvalidDomainList;
    
    const JSValue unlessDomain = triggerObject.get(&exec, Identifier::fromString(&exec, "unless-domain"));
    if (!scope.exception() && unlessDomain.isObject()) {
        if (trigger.domainCondition != Trigger::DomainCondition::None)
            return ContentExtensionError::JSONUnlessAndIfDomain;
        auto unlessDomainError = getDomainList(exec, asObject(unlessDomain), trigger.domains);
        if (unlessDomainError)
            return unlessDomainError;
        if (trigger.domains.isEmpty())
            return ContentExtensionError::JSONInvalidDomainList;
        trigger.domainCondition = Trigger::DomainCondition::UnlessDomain;
    } else if (!unlessDomain.isUndefined())
        return ContentExtensionError::JSONInvalidDomainList;

    return { };
}