samedi 7 février 2015

randomly remove portions of a sequence to create shorter sequence

I am new to programming and would appreciate your help!


I have a file with ~20K sequences with the following format:



>sequence_1
MAADTPGKPSASPMAGAPASASRTPDKPRSAAEHRKSSKPVMEKRRRARINESLAQLKTLILDALRKESSRHSKLEKADILEMTVRHLRSLRRVQVTAALSADPAVLGKYRAGFHECLAEVNRFLAGCEGVPADVRSRLLGHLAACLRQLGPSRRPASLSPAAPAEAPAPEVYAGRPLLPSLGGPFPLLAPPLLPGLTRALPAAPRAGPQGPGGPWRPWLR

>sequence_2
MGWDLTVKMLAGNEFQVSLSSSMSVSELKAQITQKIGVHAFQQRLAVHPSGVALQDRVPLASQGLGPGSTVLLVVDKCDEPLSILVRNNKGRSSTYEVRLTQTVAHLKQQVSGLEGVQDDLFWLTFEGKPLEDQLPLGEYGLKPLSTVFMNLRLRGGGTEPGGRS


I want to create random fragments of these sequences of lengths ~ 50-100 characters. I need to keep the original order intact (so I am not randomizing the characters).


Examples of sequences I could make from >sequence_1 would be:



MAADTPGKPSASPMAGAPASASRTPDKPRSAAEHRKSSKPVMEKRRRARINESLAQLKTLILDALR


or



MTVRHLRSLRRVQVTAALSADPAVLGKYRAGFHECLAEVNRFLAGCEGVPADVRSRLLGHLAACLRQLGPSRRPASLSPAAPAEAPAPEVYAGRPLLPSLGGPFPLLAPPLLPGLTRALPAAPRAGPQGPGGPW


The best analogy I can think of is randomly cutting these sequences into smaller lengths. I'm really unsure how to even go about this, or if it is possible with a script. I'd also appreciate any explanation for responses so I can learn.





Aucun commentaire:

Enregistrer un commentaire