Skip to content

Commit

Permalink
small changes and bugfixes (portal shows only cdms-data)
Browse files Browse the repository at this point in the history
Former-commit-id: 99f7400
  • Loading branch information
cpe committed Oct 17, 2014
1 parent 70a1b8d commit 4beeec4
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ doc*/build/*
*.json
*.dat
*.log
*.save
mysqldatabase/*
settings.py
76 changes: 56 additions & 20 deletions nodes/VamdcSpeciesDB/node/update_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@

## return charge + num_protons

def get_node_list():
"""
Returns a list of all nodes which are stored in the speciesdatabase
"""
nodes = VamdcMemberDatabases.objects.all()

return nodes

def get_node(nodename):
"""
Returns a node instance of the node specified by the short_name
Expand Down Expand Up @@ -87,8 +95,8 @@ def get_species(nodename):
query = q.Query()
request = r.Request()


query_string = "SELECT SPECIES"
query_string = "SELECT SPECIES"
query_string = "SELECT SPECIES WHERE ((InchiKey!='UGFAIRIUMAVXCW'))"
request.setnode(node)
request.setquery(query_string)

Expand Down Expand Up @@ -200,7 +208,10 @@ def process_species(nodename, checkonly = False):
# Insert names for the specie
# The element ChemicalName cannot be repeated in current XSAMS versions. A list
# of names has to be separated by ', ' therefore.
names = molecule.ChemicalName.split(', ')
try:
names = molecule.ChemicalName.split(', ')
except AttributeError:
names = []
for name in names:
insert_species_name(id, name, checkonly = checkonly)

Expand Down Expand Up @@ -265,22 +276,25 @@ def insert_molecule(molecule, member_db_id = 0, checkonly = False):
print "DETERMINED Formula: %s" % molecule.StoichiometricFormula

try:
if molecular_weight != int(molecule.MolecularWeight):
print "MISMATCH mass: %d does not match %d" % (molecular_weight, int(molecule.MolecularWeight))
if molecular_weight != int(float(molecule.MolecularWeight)):
print "MISMATCH mass: %d does not match %d" % (molecular_weight, int(float(molecule.MolecularWeight)))
except AttributeError:
print "DETERMINED mass: %d" % molecular_weight

if checkonly == False:
specie = VamdcSpecies()

type_2 = VamdcSpeciesTypes.objects.get(id = 2)
member_database = VamdcMemberDatabases.objects.get(id = member_db_id)

specie.id = inchikey
specie.inchi = inchi
specie.inchikey = inchikey
specie.inchikey_duplicate_counter = 1
specie.stoichiometric_formula = stoichiometricformula
specie.species_type = 2
specie.species_type = type_2
specie.created = datetime.now()
specie.member_database = member_db_id
specie.member_database = member_database
specie.mass_number = molecular_weight
specie.charge = charge

Expand Down Expand Up @@ -328,6 +342,9 @@ def insert_atom(atom, member_db_id = 0, checkonly = False):
elif len(ids) > 1:
return None

print "Insert Atom: %s" % atom.InChIKey
print ids

try:
inchi = atom.InChI
except:
Expand All @@ -350,20 +367,26 @@ def insert_atom(atom, member_db_id = 0, checkonly = False):
if massnumber != int(atom.MassNumber):
print "MISMATCH mass: %d does not match %d" % (massnumber, int(atom.MassNumber))
except AttributeError:
atom.MassNumber = massnumber
print "DETERMINED mass: %d" % massnumber

if checkonly == False:
type_1 = VamdcSpeciesTypes.objects.get(id = 1)
member_database = VamdcMemberDatabases.objects.get(id = member_db_id)
specie = VamdcSpecies()

specie.id = atom.InChIKey
specie.inchi = atom.InChI
if atom.InChI[:6] == 'InChI=':
specie.inchi = atom.InChI
else:
specie.inchi = 'InChI='+atom.InChI
specie.inchikey = atom.InChIKey
specie.inchikey_duplicate_counter = 1
specie.stoichiometric_formula = stoichiometricformula
specie.species_type = 2
specie.species_type = type_1
specie.created = datetime.now()
specie.member_database = member_db_id
specie.mass_number = atom.massnumber
specie.member_database = member_database
specie.mass_number = atom.MassNumber
specie.charge = charge

# charge = m.Charge
Expand Down Expand Up @@ -401,11 +424,13 @@ def insert_structural_formula(id, formula, checkonly = False):
search_priority = 1

if checkonly == False:
specie = VamdcSpecies.objects.get(id = id)
m_type_1 = VamdcMarkupTypes.objects.get(id = 1)
structformula = VamdcSpeciesStructFormulae()
structformula.species = id
structformula.species = specie
structformula.formula = formula
# Currently only pure text markup-type can be retrieved via XSAMS
structformula.markup_type = 1
structformula.markup_type = m_type_1
structformula.search_priority = search_priority
structformula.created = datetime.now()

Expand All @@ -421,23 +446,26 @@ def insert_species_name(id, name, checkonly = False):
# Check if it is already in the species-database
names = VamdcSpeciesNames.objects.filter(species = id, name = name)

m_type_1 = VamdcMarkupTypes.objects.get(id = 1)

# Insert name into the species-database if not found
if len(names) == 0:

# determine the search-priority. There is no automatic way to determine it, so new entries
# will be added with the highest priority
search_priorities = VamdcSpeciesNames.objects.filter(species = id).values_list("search_priority", flat = True)
if len(search_priorities)>0:
search_priority = max(search_priorities)
search_priority = max(search_priorities)+1
else:
search_priority = 1

if checkonly == False:
specie = VamdcSpecies.objects.get(id = id)
speciesname = VamdcSpeciesNames()
speciesname.species = id
speciesname.species = specie
speciesname.name = name
# Currently only pure text markup-type can be retrieved via XSAMS
speciesname.markup_type = 1
speciesname.markup_type = m_type_1
speciesname.search_priority = search_priority
speciesname.created = datetime.now()

Expand All @@ -449,17 +477,25 @@ def insert_member_db_speciesid(id, member_db_id, speciesid, checkonly = False):
"""
Inserts the Species-ID available at a specific database node into
the species-database.
id = VamdcSpeciesID (Inchikey)
member_db_id = id of the database node
speciesid = id of the specie in the database node
checkonly = Boolean (False if the data is inserted in the database, otherwise it is only printed)
"""
# Check if it is already in the species-database
dbidentifier = VamdcMemberDatabaseIdentifiers.objects.filter(species = id, member_database = member_db_id, database_species_id = speciesid)

# Insert database-species-id into the species-database if not found
print "%20s %2d %20s" % (id, member_db_id, speciesid)
# Insert database-species-id into the species-database if not found
if len(dbidentifier) == 0:

if checkonly == False:
specie = VamdcSpecies.objects.get(id = id)
member_database = VamdcMemberDatabases.objects.get(id = member_db_id)

dbidentifier = VamdcMemberDatabaseIdentifiers()
dbidentifier.species = id
dbidentifier.member_database = member_db_id
dbidentifier.species = specie
dbidentifier.member_database = member_database
dbidentifier.database_species_id = speciesid

dbidentifier.save()
Expand Down
4 changes: 2 additions & 2 deletions nodes/cdms/node/queryfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def setupResults(sql):

# this header info is used in xsams-header-info (html-request)
headerinfo={\
'Truncated':"100", # CDMS will not truncate data (at least for now)
'Truncated':"0", # CDMS will not truncate data (at least for now)
'count-sources':nsources,
'count-species':nspecies,
'count-molecules':nmolecules,
Expand Down Expand Up @@ -437,7 +437,7 @@ def returnResults(tap, LIMIT=None):
# use tap.parsedSQL.columns instead of tap.requestables
# because only the selected columns should be returned and no additional ones
col = tap.parsedSQL.columns #.asList()
transs = RadiativeTransitions.objects.filter(q,specie__archiveflag=0,dataset__archiveflag=0,energylower__gt=0)
transs = RadiativeTransitions.objects.filter(q,specie__archiveflag=0,dataset__archiveflag=0) #,energylower__gt=0)
ntrans = transs.count()

if LIMIT is not None and ntrans > LIMIT:
Expand Down
20 changes: 8 additions & 12 deletions nodes/cdms/templates/cdmsportal/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,22 @@

<div style="margin: 20px 0 -10px 0;padding:15px;text-align:center;font-size:13px;background:#fff;-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);">

<ul>
<ul>
<li>
Support
<a href="mailto:[email protected]">endres(At)ph1(Dot)uni-koeln(Dot)de</a>
</li>
<li>
<a href="http://www.ph1.uni-koeln.de/~hspm" target="_top">Dr. Holger S. P. M&uuml;ller </a>
<a href="mailto:[email protected]">hspm(At)ph1(Dot)uni-koeln(Dot)de</a>
</li>
<li>
<a href="http://www.ph1.uni-koeln.de/~stutzki" target="_top">Prof. Dr. J&uuml;rgen Stutzki</a>
<a href="mailto:[email protected]">stutzki(At)ph1(Dot)uni-koeln(Dot)de</a>
</li>
<li>
<a href="http://www.ph1.uni-koeln.de/~schlemmer" target="_top">Prof. Dr. Stephan Schlemmer</a>
<a href="mailto:[email protected]">schlemmer(At)ph1(Dot)uni-koeln(Dot)de</a>
</li>
<li>Prof. Dr. Thomas Giesen
<a href="mailto:[email protected]">giesen(At)ph1(Dot)uni-koeln(Dot)de</a>
<li>Dr. Christian Endres
<a href="mailto:[email protected]">endres(At)ph1(Dot)uni-koeln(Dot)de</a>
</li>
</ul>

</div>
</div>
</div>

{% endblock %}
{% endblock %}
4 changes: 3 additions & 1 deletion nodes/cdms/templates/cdmsportal/queryForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ <h6 class="vlist"> REFINEMENTS </h6>
<INPUT TYPE="HIDDEN" NAME="col_speciesid" id="col_speciesid" VALUE="">

<div class="type-button float_right radexsubmit">
<INPUT id="button1" TYPE="button" NAME="T_SEARCH" onclick='$("#control").hide();ajaxQuery("ajaxQuery","http://cdms.ph1.uni-koeln.de/cdms/tap/sync?REQUEST=doQuery&LANG=VSS2&FORMAT=XSAMS&QUERY=SELECT+ALL+WHERE+%28+InchiKey+=+%27UGFAIRIUMAVXCW-UHFFFAOYSA-N%27+%29&ORDERBY=frequency","http://cdms.ph1.uni-koeln.de/cdms/tap/");$("#result").show();docShowSubpage("queryresult");' VALUE="QUERY" >
<INPUT id="button2" TYPE="button" NAME="T_SEARCH" onclick='ajaxDownload("ajaxQuery","http://cdms.ph1.uni-koeln.de/cdms/tap/sync?REQUEST=doQuery&LANG=VSS2&FORMAT=XSAMS&QUERY=SELECT+ALL+WHERE+%28+InchiKey+=+%27UGFAIRIUMAVXCW-UHFFFAOYSA-N%27+%29&ORDERBY=frequency","http://cdms.ph1.uni-koeln.de/cdms/tap/");' VALUE="Download" >

<INPUT id="button1" TYPE="button" NAME="T_SEARCH" onclick='$("#control").hide();ajaxQuery("ajaxQuery","http://cdms.ph1.uni-koeln.de/cdms/tap/sync?REQUEST=doQuery&LANG=VSS2&FORMAT=XSAMS&QUERY=SELECT+ALL+WHERE+%28+InchiKey+=+%27UGFAIRIUMAVXCW-UHFFFAOYSA-N%27+%29&ORDERBY=frequency","http://cdms.ph1.uni-koeln.de/cdms/tap/");$("#result").show();docShowSubpage("queryresult");' VALUE="QUERY" >
</div>
</fieldset>

Expand Down
2 changes: 1 addition & 1 deletion nodes/cdms/templates/cdmsportal/selectSpeciesAjax.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h6 class="vlist"> FILTER SPECIES LIST</h6>
isotopologs = [{% for inchikey in inchikey_list %}'{{inchikey}}',{% endfor %}]
molecules = [{% for molecule in stoichio_list %}'{{molecule}}',{% endfor %}]
$(document).ready(function() {
ajaxGetSpeciesList(-5);
ajaxGetSpeciesList(5);
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion nodes/jpl/node/queryfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def setupResults(sql):

# this header info is used in xsams-header-info (html-request)
headerinfo={\
'Truncated':"100", # CDMS will not truncate data (at least for now)
'Truncated':"0", # CDMS will not truncate data (at least for now)
'count-sources':nsources,
'count-species':nspecies,
'count-molecules':nmolecules,
Expand Down

0 comments on commit 4beeec4

Please sign in to comment.