예제 #1
0
 def MGFFileReader_DigitalParts(contents):
     index = []  # indes is a local list that record place of MZ & intensity
     MZAndIntensityContents = []
     TempData = []
     for i in range(0, len(contents) - 1):
         rule0 = re.findall(r'^\D*',
                            contents[i])  #Match character beginning
         rule1 = re.findall(
             r'^-*([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)',
             contents[i + 1])  #Matching Floating Points beginning
         rule2 = re.findall(r'^-*[1-9]\d*',
                            contents[i + 1])  #match integer  beginning
         if (rule0 != [] and rule1 != []) or (rule0 != [] and rule2 != []):
             index.append(i + 1)
     #print(index[0:120])
     '''extrat continuous range of local list'''
     beginAndEndLocal = list(AID.ContinuousDigitalRange(index))
     begin = beginAndEndLocal[0]
     end = beginAndEndLocal[1]
     '''extract MZ & intensity informations from all contents list based on local list'''
     for j in range(0, len(begin)):
         TempData = contents[begin[j]:end[j] + 1]
         MZAndIntensityContents.append(TempData)
     #print(MZAndIntensityContents)
     '''preprocessing MZ * intensity informations extracted.'''
     tempData1 = []
     MZAndIntensityContentsList = []
     for k in range(0, len(MZAndIntensityContents)):
         for v in range(0, len(MZAndIntensityContents[k])):
             tempData1.append(MZAndIntensityContents[k][v].split("\n")[0])
         MZAndIntensityContentsList.append(tempData1)
         tempData1 = []  # clean
     #print(MZAndIntensityContentsList[0:200])
     return MZAndIntensityContentsList  #data format:[['104.3094 85.0', '107.8294 114.0', '110.0711 2221.7'...],['108.0543 154.1', '110.0710 1591.2'...]...]
예제 #2
0
    def MGFFileReader_CharactersParts(contents):
        ZContents = []
        TempData = []
        index = []
        for i in range(0, len(contents) - 1):
            rule0 = re.findall(r'^\D*',
                               contents[i])  #Match character beginning
            #rule1 = re.findall(r'^-*([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)',contents[i+1])#Matching Floating Points beginning
            rule2 = re.findall(r'^([1-9])',
                               contents[i + 1])  #match integer  beginning
            if rule0 != [] and rule2 == []:
                index.append(i)
        #print(index[0:30])
        beginAndEndLocal = list(AID.ContinuousDigitalRange2(index))
        #print(beginAndEndLocal)
        begin = beginAndEndLocal[0]
        end = beginAndEndLocal[1]
        '''extract informations begin with "Z" from all contents list based on local list'''
        for j in range(0, len(begin)):
            TempData = contents[begin[j]:end[j] + 1]
            ZContents.append(TempData)
        #print(MZAndIntensityContents)
        '''preprocessing informations extracted.'''
        tempData1 = []
        CharactersContentsList = []
        for k in range(0, len(ZContents)):
            for v in range(0, len(ZContents[k])):
                tempData1.append(ZContents[k][v].split("\n")[0])
            CharactersContentsList.append(tempData1)
            tempData1 = []  # clean

        #print(CharactersContentsList)
        '''At the end of list,usually,is a character:['END IONS'] Originated from split mgf.This part not mapping a digital part,must be remove'''
        #print(CharactersContentsList)
        for t in range(0, len(CharactersContentsList)):
            if len(CharactersContentsList[t]
                   ) == 1 and CharactersContentsList[t][0] == 'END IONS':
                CharactersContentsList.pop(t)
            elif len(
                    CharactersContentsList[t]
            ) == 2 and CharactersContentsList[t][
                    0] == 'END IONS' and CharactersContentsList[t][1] == '':
                CharactersContentsList.pop(t)
            elif len(
                    CharactersContentsList[t]) == 3 and CharactersContentsList[
                        t][0] == 'END IONS' and CharactersContentsList[t][
                            1] == '' and CharactersContentsList[t][2] == '':
                CharactersContentsList.pop(t)
            elif len(
                    CharactersContentsList[t]
            ) == 4 and CharactersContentsList[t][
                    0] == 'END IONS' and CharactersContentsList[t][
                        1] == '' and CharactersContentsList[t][
                            2] == '' and CharactersContentsList[t][3] == '':
                CharactersContentsList.pop(t)
            else:
                pass
        return CharactersContentsList
        '''
예제 #3
0
        'author': 'J. R. R. Tolkien',
        'qty': 10,
        'how much is': 43.50
    }, {
        'title': 'Harry Potter',
        'author': 'J. K. Roling',
        'qty': 10,
        'how much is': 31.70
    }, {
        'title': 'Game of Thrones',
        'author': 'A. M. M. Martin',
        'qty': 10,
        'how much is': 53.80
    }]

    bookStoresInfo = [(AID(name='Cultura'), bookslist_Cultura),
                      (AID(name='Saraiva'), booksList_Saraiva)]

    order = {
        'title': 'The Lord of the Rings',
        'author': 'J. R. R. Tolkien',
        'qty': 5
    }

    #set_ams('localhost', 8000)

    agents = []
    #saraiva = BookstoreAgent(AID(name='[email protected]:2002'), booksList_Saraiva)
    saraiva = BookstoreAgent(AID(name='Saraiva'), booksList_Saraiva)
    saraiva.set_ams()
    agents.append(saraiva)
예제 #4
0
파일: script_5.py 프로젝트: Brunovf1/pade-1
from time import sleep



class Teste(Agent):
	def __init__(self, aid):
		Agent.__init__(self, aid)
		
	def on_start
on_start(self):
		Agent.on_start
on_start(self)
		display_message(self.aid.name, "Hello World")
		if 'Bob' in self.aid.name:
			message = ACLMessage(ACLMessage.INFORM)
			message.add_receiver(AID('Alice'))
			message.set_content('Hello Alice!')
			self.send(message)
	
	def react(self, message):
		Agent.react(self, message)
		display_message(self.aid.name, message.get_message())

if __name__ == '__main__':
	set_ams('localhost', 8000)
	
	agente = Teste(AID('Alice'))
	agente.set_ams('localhost', 8000)
	agente.start()
	
	agente = Teste(AID('Bob'))
예제 #5
0
파일: script_3.py 프로젝트: Brunovf1/pade-1
		self.addBehaviour(behaviour_1)
	
	def on_start
on_start(self):
		Agent.on_start
on_start(self)

class Agent_Participant(Agent):
	def __init__(self, aid):
		Agent.__init__(self, aid)
		behaviour_1 = RequestParticipant(self)
		self.addBehaviour(behaviour_1)
		
	def on_start
on_start(self):
		Agent.on_start
on_start(self)

if __name__ == '__main__':
	
	set_ams(8000)
	
	agent_participant_1 = Agent_Participant(AID('agent_participant_1'))
	agent_participant_1.set_ams('localhost', 8000)
	agent_participant_1.start()
	
	agent_initiator = Agent_Initiator(AID('agent_initiator'))
	agent_initiator.set_ams('localhost', 8000)
	agent_initiator.start()
	
	start_loop()
예제 #6
0
        
        display_message(self.agent.aid.name, 'Proposal Rejected')

class BookstoreAgent(Agent):
    
    def __init__(self, aid, booksList):
        Agent.__init__(self, aid)
        
        self.booksList = booksList
        
        behav_ = BookstoreAgentBehaviour(self)
        self.addBehaviour(behav_)

if __name__ == '__main__':
    
    bookslist_Nobel = [{'title' : 'The Lord of the Rings', 'author' : 'J. R. R. Tolkien', 'qty' : 10, 'how much is' : 63.50},
                         {'title' : 'Harry Potter', 'author' : 'J. K. Roling', 'qty' : 10, 'how much is' : 35.70},
                         {'title' : 'Game of Thrones', 'author' : 'A. M. M. Martin', 'qty' : 10, 'how much is' : 33.80}
                         ]
    
    bookStoresInfo = [(AID(name='[email protected]:2001'), bookslist_Nobel)]
    
    order = {'title' : 'The Lord of the Rings', 'author' : 'J. R. R. Tolkien', 'qty' : 5}
    
    agents = []
    
    nobel = BookstoreAgent(AID(name='Nobel'), bookslist_Nobel)
    nobel.set_ams('192.168.0.101', 8000)
    agents.append(nobel)
    
    start_loop(agents)
예제 #7
0
        'author': 'J. R. R. Tolkien',
        'qtd': 10,
        'how much is': 63.50
    }, {
        'title': 'Harry Potter',
        'author': 'J. K. Roling',
        'qtd': 10,
        'how much is': 35.70
    }, {
        'title': 'Game of Thrones',
        'author': 'A. M. M. Martin',
        'qtd': 10,
        'how much is': 33.80
    }]

    bookStoresInfo = [(AID(name='Cultura'), bookslist_Cultura),
                      (AID(name='Saraiva'), booksList_Saraiva),
                      (AID(name='Nobel'), bookslist_Nobel)]

    pedido = {
        'title': 'The Lord of the Rings',
        'author': 'J. R. R. Tolkien',
        'qtd': 5
    }

    set_ams('localhost', 8000)

    agents = []
    saraiva = AgenteLivraria(AID(name='Saraiva'), booksList_Saraiva)
    agents.append(saraiva)
예제 #8
0
        self.bookStores = bookStores
        self.pedido = pedido

        cfp_message = ACLMessage(ACLMessage.CFP)
        cfp_message.set_protocol(ACLMessage.FIPA_CONTRACT_NET_PROTOCOL)
        for i in self.bookStores:
            cfp_message.add_receiver(i)
        cfp_message.set_content(dumps(self.pedido))

        comportamento = ComportamentoAgenteConsumidor(self, cfp_message)
        self.addBehaviour(comportamento)


if __name__ == '__main__':

    agents = []
    pedido = {
        'title': 'The Lord of the Rings',
        'author': 'J. R. R. Tolkien',
        'qtd': 5
    }

    #consumidor = AgenteConsumidor(AID('[email protected]:2004'), ['Saraiva', 'Cultura', 'Nobel'], pedido)
    consumidor = AgenteConsumidor(AID('Lucas'),
                                  ['Saraiva', 'Cultura', 'Nobel'], pedido)

    consumidor.set_ams()
    agents.append(consumidor)

    start_loop(agents)
예제 #9
0
 booksList_Saraiva = [{'title' : 'The Lord of the Rings', 'author' : 'J. R. R. Tolkien', 'qty' : 10, 'how much is' : 53.50},
                      {'title' : 'Harry Potter', 'author' : 'J. K. Roling', 'qty' : 10, 'how much is' : 33.70},
                      {'title' : 'Game of Thrones', 'author' : 'A. M. M. Martin', 'qty' : 10,'how much is' : 23.80}
                      ]
 
 bookslist_Cultura = [{'title' : 'The Lord of the Rings', 'author' : 'J. R. R. Tolkien', 'qty' : 10, 'how much is' : 43.50},
                      {'title' : 'Harry Potter', 'author' : 'J. K. Roling', 'qty' : 10, 'how much is' : 31.70},
                      {'title' : 'Game of Thrones', 'author' : 'A. M. M. Martin', 'qty' : 10, 'how much is' : 53.80}
                      ]
 
 bookslist_Nobel = [{'title' : 'The Lord of the Rings', 'author' : 'J. R. R. Tolkien', 'qty' : 10, 'how much is' : 63.50},
                      {'title' : 'Harry Potter', 'author' : 'J. K. Roling', 'qty' : 10, 'how much is' : 35.70},
                      {'title' : 'Game of Thrones', 'author' : 'A. M. M. Martin', 'qty' : 10, 'how much is' : 33.80}
                      ]
 
 bookStoresInfo = [(AID(name='Saraiva'), booksList_Saraiva),
                   (AID(name='Cultura'), bookslist_Cultura),
                   (AID(name='Nobel'), bookslist_Nobel)]
 
 set_ams('localhost', 8000)
 
 for bookStore in bookStoresInfo:
     agent = BookStore(bookStore[0], bookStore[1])
     agent.set_ams('localhost', 8000)
     agent.start()
 
 consumidor = Consumer(AID('Lucas'), ['Saraiva', 'Cultura', 'Nobel'])
 consumidor.set_ams('localhost', 8000)
 consumidor.start()
 
 start_loop()
예제 #10
0
        'author': 'J. R. R. Tolkien',
        'qtd': 10,
        'how much is': 43.50
    }, {
        'title': 'Harry Potter',
        'author': 'J. K. Roling',
        'qtd': 10,
        'how much is': 31.70
    }, {
        'title': 'Game of Thrones',
        'author': 'A. M. M. Martin',
        'qtd': 10,
        'how much is': 53.80
    }]

    bookStoresInfo = [(AID(name='Cultura'), bookslist_Cultura),
                      (AID(name='Saraiva'), booksList_Saraiva)]

    pedido = {
        'title': 'The Lord of the Rings',
        'author': 'J. R. R. Tolkien',
        'qtd': 5
    }

    #set_ams('localhost', 8000)

    agents = []
    #saraiva = AgenteLivraria(AID(name='[email protected]:2002'), booksList_Saraiva)
    saraiva = AgenteLivraria(AID(name='Saraiva'), booksList_Saraiva)
    saraiva.set_ams()
    agents.append(saraiva)
예제 #11
0
파일: script_4.py 프로젝트: tbfreitas/Pade
        message.add_receiver('participant_agent_2')
        behaviour = InitiatorProtocol(self, message)
        self.addBehaviour(behaviour)


class ParticipantAgent(Agent):
    def __init__(self, aid, power_values):
        Agent.__init__(self, aid)
        behaviour = ParticipantProtocol(self, power_values)
        self.addBehaviour(behaviour)


if __name__ == '__main__':

    set_ams('localhost', 8000)

    agent_participant_1 = ParticipantAgent(AID('participant_agent_1'),
                                           {'value': 100.0})
    agent_participant_1.set_ams('localhost', 8000)
    agent_participant_1.start()

    agent_participant_2 = ParticipantAgent(AID('participant_agent_2'),
                                           {'value': 200.0})
    agent_participant_2.set_ams('localhost', 8000)
    agent_participant_2.start()

    agent_initiator = InitiatorAgent(AID('initiator_agent'))
    agent_initiator.set_ams('localhost', 8000)
    agent_initiator.start()

    start_loop()
예제 #12
0
 booksList_Saraiva = [{'title' : 'The Lord of the Rings', 'author' : 'J. R. R. Tolkien', 'qty' : 10, 'how much is' : 53.50},
                      {'title' : 'Harry Potter', 'author' : 'J. K. Roling', 'qty' : 10, 'how much is' : 33.70},
                      {'title' : 'Game of Thrones', 'author' : 'A. M. M. Martin', 'qty' : 10,'how much is' : 23.80}
                      ]
 
 bookslist_Cultura = [{'title' : 'The Lord of the Rings', 'author' : 'J. R. R. Tolkien', 'qty' : 10, 'how much is' : 43.50},
                      {'title' : 'Harry Potter', 'author' : 'J. K. Roling', 'qty' : 10, 'how much is' : 31.70},
                      {'title' : 'Game of Thrones', 'author' : 'A. M. M. Martin', 'qty' : 10, 'how much is' : 53.80}
                      ]
 
 bookslist_Nobel = [{'title' : 'The Lord of the Rings', 'author' : 'J. R. R. Tolkien', 'qty' : 10, 'how much is' : 63.50},
                      {'title' : 'Harry Potter', 'author' : 'J. K. Roling', 'qty' : 10, 'how much is' : 35.70},
                      {'title' : 'Game of Thrones', 'author' : 'A. M. M. Martin', 'qty' : 10, 'how much is' : 33.80}
                      ]
 
 bookStoresInfo = [(AID(name='Cultura'), bookslist_Cultura),
                   (AID(name='Saraiva'), booksList_Saraiva),
                   (AID(name='Nobel'), bookslist_Nobel)]
 
 order = {'title' : 'The Lord of the Rings', 'author' : 'J. R. R. Tolkien', 'qty' : 5}
 
 set_ams('localhost', 8000)
 
 agents = []
 saraiva = BookstoreAgent(AID(name='Saraiva'), booksList_Saraiva)
 agents.append(saraiva)
 
 cultura = BookstoreAgent(AID(name='Cultura'), bookslist_Cultura)
 agents.append(cultura)
 
 nobel = BookstoreAgent(AID(name='Nobel'), bookslist_Nobel)
예제 #13
0
        self.bookStores = bookStores
        self.order = order

        cfp_message = ACLMessage(ACLMessage.CFP)
        cfp_message.set_protocol(ACLMessage.FIPA_CONTRACT_NET_PROTOCOL)
        for i in self.bookStores:
            cfp_message.add_receiver(i)
        cfp_message.set_content(dumps(self.order))

        behav_ = ConsumerAgentBehaviour(self, cfp_message)
        self.addBehaviour(behav_)


if __name__ == '__main__':

    agents = []
    order = {
        'title': 'The Lord of the Rings',
        'author': 'J. R. R. Tolkien',
        'qty': 5
    }

    #consumidor = ConsumerAgent(AID('[email protected]:2004'), ['Saraiva', 'Cultura', 'Nobel'], order)
    consumidor = ConsumerAgent(AID('Lucas'), ['Saraiva', 'Cultura', 'Nobel'],
                               order)

    consumidor.set_ams()
    agents.append(consumidor)

    start_loop(agents)
예제 #14
0
            message.set_content('Ola Agente!')
            self.send(message)
            display_message(self.aid.name, 'Enviando mensagem...')

    def react(self, message):
        Agent.react(self, message)
        display_message(self.aid.name, 'Uma mensagem recebida')

        if 'agente_teste_participante' in self.aid.name:
            resposta = message.create_reply()
            resposta.set_content('Ola tambem agente!')
            self.send(resposta)


if __name__ == '__main__':

    set_ams('localhost', 8000)

    agente_teste_iniciante = Teste(AID('agente_teste_iniciante'))

    agente_teste_participante = Teste(AID('agente_teste_participante'))

    agentes = list()

    print id(agente_teste_iniciante)
    print id(agente_teste_participante)

    agentes.append(agente_teste_participante)
    agentes.append(agente_teste_iniciante)

    start_loop(agentes)
예제 #15
0
            message.set_content('Hello Agent!')
            self.send(message)
            display_message(self.aid.name, 'Sending Message...')

    def react(self, message):
        Agent.react(self, message)
        display_message(self.aid.name, 'One message received')

        if 'test_agent_participant' in self.aid.name:
            resposta = message.create_reply()
            resposta.set_content('Hello to you too, Agent!')
            self.send(resposta)


if __name__ == '__main__':

    set_ams('localhost', 8000)

    test_agent_initiator = Teste(AID('test_agent_initiator'))

    test_agent_participant = Teste(AID('test_agent_participant'))

    agents = list()

    print id(test_agent_initiator)
    print id(test_agent_participant)

    agents.append(test_agent_participant)
    agents.append(test_agent_initiator)

    start_loop(agents)