Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed support for optimade, poscar and some cifs; error styles #23

Merged
merged 7 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions matinfio/cell/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ namespace $ {
}

/** 3x3 matrix to crystalline cell parameters */
export function $mpds_cifplayer_matinfio_cell_params_from_matrix( matrix: number[] ) {
const norms: number[] = []
export function $mpds_cifplayer_matinfio_cell_params_from_matrix( matrix: number[][] ) {
const norms: number[] = matrix.map( vec => math.norm( vec ) )
const angles = []
matrix.forEach( function( vec ) {
norms.push( math.norm( vec ) )
} )
let j = -1
let k = -2
for( let i = 0; i < 3; i++ ) {
Expand Down
9 changes: 7 additions & 2 deletions matinfio/cif/cif.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ namespace $ {
}
continue

} else if( fingerprt.startsWith( '_symmetry_space_group_name_h-m' ) || fingerprt.startsWith( '_space_group.patterson_name_h-m' ) ) {
} else if(
fingerprt.startsWith( '_symmetry_space_group_name_h-m' )
|| fingerprt.startsWith( '_space_group.patterson_name_h-m' )
|| fingerprt.startsWith( '_space_group_name_h-m_alt' )
) {
loop_active = false
cur_structure.sg_name = lines[ i ].trim().substr( 31 ).replace( /"/g, '' ).replace( /'/g, '' )
const match = cur_line.match( /"(.*)"|'(.*)'/ )
cur_structure.sg_name = match?.[1] || match?.[2]
continue

} else if( fingerprt.startsWith( '_space_group.it_number' ) || fingerprt.startsWith( '_space_group_it_number' ) || fingerprt.startsWith( '_symmetry_int_tables_number' ) ) {
Expand Down
10 changes: 10 additions & 0 deletions matinfio/player/player.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ namespace $ {

} else {
cell_matrix = crystal.cell_matrix // for POSCAR and OPTIMADE

const params = $mpds_cifplayer_matinfio_cell_params_from_matrix( cell_matrix! )
descr = {
'a': params[0],
'b': params[1],
'c': params[2],
'alpha': params[3],
'beta': params[4],
'gamma': params[5],
}
}

if( !crystal.atoms.length ) this.$mpds_cifplayer_matinfio_log.warning( "Note: no atomic coordinates supplied" )
Expand Down
8 changes: 4 additions & 4 deletions matinfio/spacegroup/spacegroup.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace $ {
super()
}

@ $mol_mem_key
static by_name_and_num( name: string, num: number ) {
const spacegroup = $mpds_cifplayer_matinfio_spacegroup.by_num( num )
?? $mpds_cifplayer_matinfio_spacegroup.by_name( name )
static by_name_or_num( name: string, num: number ) {
const spacegroup = num
? $mpds_cifplayer_matinfio_spacegroup.by_num( num )
: name ? $mpds_cifplayer_matinfio_spacegroup.by_name( name ) : null
return spacegroup ? spacegroup : $mpds_cifplayer_matinfio_spacegroup.unknown()
}

Expand Down
7 changes: 7 additions & 0 deletions player/player.view.css
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут лучше бы просто перехватывать ошибки и рисовать кастомное сообщение.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[mpds_cifplayer_player][mol_view_error]:not([mol_view_error="Promise"]) {
color: var(--mol_theme_text);
background-image: none;
padding-top: 6rem;
align-items: flex-start;
justify-content: center;
}
4 changes: 2 additions & 2 deletions player/player.view.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace $.$$ {

@ $mol_mem
render(): void {
super.render()
this.structure_3d_data() //for bubbling errors into view
super.render()
}

@ $mol_mem
Expand Down Expand Up @@ -153,7 +153,7 @@ namespace $.$$ {
spacegroup() {
const { sg_name, ng_name } = this.structure_3d_data()

return $mpds_cifplayer_matinfio_spacegroup.by_name_and_num( sg_name, ng_name )
return $mpds_cifplayer_matinfio_spacegroup.by_name_or_num( sg_name, ng_name )
}

@ $mol_mem
Expand Down
Loading