Esempio n. 1
0
def init_db():
    db.create_all()
    if not Structure.query.get(2004):
        asset_safety = Structure(
            id=2004,
            name='Asset Safety',
            system_id=None,
            corporation_id=None,
        )
        db.session.add(asset_safety)
        db.session.commit()
Esempio n. 2
0
    def parse_ct(self, ct_filepath, transcript_id, experiment_config):

        structure = None

        n_structs = 0
        with open(ct_filepath) as ct_file:
            for line in ct_file:
                # if it's an energy line, we're looking at a brand new structure

                # the .ct format is a bit annoying because it's not tab delimited.
                # instead it's delimited by variable numbers of spaces.

                # calling split() with no parameter makes it split on any length 
                # of whitespace - i.e. so that each element is 1 word
                # from_pos = bits[0]

                bits = line.strip().split()

                if len(bits) != 6: # brand new structure

                    # save existing structure to DB
                    if structure != None:
                        db_session.add(structure)

                    # Parse the energy out using regex
                    search = re.search('ENERGY = (-[0-9\.]+)', line)

                    if search == None:
                        # No energy data - for some reason this happens for some structures.
                        # If this happens, just ignore the entire ct file by returning
                        return

                    energy = search.group(1)

                    # Create the new structure object, we'll commit it later...
                    structure = Structure(
                        structure_prediction_run_id=experiment_config["structure_prediction_run_id"],
                        transcript_id=transcript_id,
                        energy=energy
                    )

                    # insert the experiment into the DB. can now access ID
                    db_session.commit() 
                    n_structs += 1

                else:
                    to_pos = bits[4]
                    structure.add_value(to_pos)

        db_session.add(structure)
        db_session.commit() # insert remaining data into DB
        print ("["+str(n_structs)+"] structures added")
Esempio n. 3
0
    def setUp(self):
        self.stiffness = 10.0
        self.original_length = 0.9
        self.spacing = 1.0
        self.mass = 1.0

        #set up the structure
        self.structure = Structure("001")
        for i in range(10):
            self.structure.addNode(
                MassedNode2d("%s" % str(i + 1), (self.spacing * i), 0.0,
                             self.mass))
        for i in range(9):
            self.structure.addElement(
                Spring2d("%s" % str(i + 1), self.structure.n[i],
                         self.structure.n[i + 1], self.stiffness,
                         self.original_length))
        self.structure.n[0].cx = True
        self.structure.n[0].cy = True
        self.structure.n[9].cx = True
        self.structure.n[9].cy = True
Esempio n. 4
0
 def setUp(self):
     self.structure=Structure('001')