franciscoadasme / mm Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
The type restriction on the method ParameterSet#<<(Array(DihedralType))
should be changed to Enumerable(DihedralType)
, otherwise Array::View(DihedralType)
(returned by ParameterSet#dihedrals
) doesn't work. This will require to transform the argument to an array via #to_a
before adding it to the internal array of dihedrals.
In the promp.cr
module, the prompt_matching_param
requiere two changes. To erase the puts
at the end of the function and to change the return_type
from Array(DihedralType)
to Array::View(DihedralType)
those are the changes:
module MM
{% for type in %w(bond angle dihedral improper).map(&.id) %}
{% return_type = type == "dihedral" ? Array::View(DihedralType) : "#{type.camelcase}Type".id %}
def self.prompt_matching_param(
params : ParameterSet,
conn : Chem::{{type.camelcase}}
) : {{return_type}}?
printf "Missing %s between %s [%s]\n",
conn.class.name.split("::").last.underscore.split('_').first,
conn.atoms.join(", "),
conn.atoms.join('-', &.type),
matching_params = params.fuzzy_search(conn)
case matching_params.size
when 0
puts "No matching paramater found"
prompt_exit
when 1
param = matching_params[0]
param = param[0] unless param.is_a?(MM::ParameterType)
puts "Found match #{param.typenames.join('-')}"
matching_params[0]
else
prompt_match(matching_params)
end
#puts
end
{% end %}
end
Right now, it's cumbersome to find and add missing parameters due to the type system, for instance, the following example doesn't compile due to type mismatch for typenames:
conns = params.detect_missing(topology)
conns.each do |conn|
if params = MM.prompt_matching_param(params, conn)
params << param.copy_with(typenames: conn.atoms.map(&.type.not_nil!))
end
end
One solution to circumvent the compiler check is to enumerate all valid possibilities via a case statement:
conns = params.detect_missing(topology)
conns.each do |conn|
case {param = MM.prompt_matching_param(params, conn), conn}
when {MM::BondType, Chem::Bond}
params << param.copy_with(typenames: conn.atoms.map(&.type.not_nil!))
when {MM::AngleType, Chem::Angle}
params << param.copy_with(typenames: conn.atoms.map(&.type.not_nil!))
when {Enumerable(MM::DihedralType), Chem::Dihedral}
params << param.map(&.copy_with(typenames: conn.atoms.map(&.type.not_nil!)))
when {MM::ImproperType, Chem::Improper}
params << param.copy_with(typenames: conn.atoms.map(&.type.not_nil!))
end
end
There should be a easier alternative to do the above.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.